cmmanager/cmmgr/Plugins/cmpluginwlan/src/cmpwlansettingsdlgipv6.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 Ipv6 settings dialog
       
    15 *
       
    16 */
       
    17 
       
    18 #include <StringLoader.h>
       
    19 #include <akntitle.h>
       
    20 #include <aknnavide.h>
       
    21 #include <cmcommonui.h>
       
    22 #include <cmwlanui.rsg>
       
    23 #include <cmmanager.rsg>
       
    24 #include <csxhelp/cp.hlp.hrh>
       
    25 
       
    26 #include <cmpluginwlandef.h>
       
    27 #include "cmpluginwlan.h"
       
    28 #include "cmpwlansettingsdlgipv6.h"
       
    29 #include "cmwlancommonconstants.h"
       
    30 #include "cmpluginmenucommands.hrh"
       
    31 #include "cmpluginmultilinedialog.h"
       
    32 #include <cmcommonconstants.h>
       
    33 #include <cmpsettingsconsts.h>
       
    34 #include "cmmanagerimpl.h"
       
    35 
       
    36 using namespace CMManager;
       
    37 
       
    38 const TUint32 KIPv6SelectionItems[] = 
       
    39     {
       
    40     R_QTN_SET_DNS_SERVERS_AUTOMATIC,
       
    41     R_QTN_SET_IP_WELL_KNOWN,
       
    42     R_QTN_SET_IP_USER_DEFINED,
       
    43     0
       
    44     };
       
    45     
       
    46 // ================= MEMBER FUNCTIONS =======================================
       
    47 
       
    48 // --------------------------------------------------------------------------
       
    49 // CmPluginWlanSettingsDlgIpv6::NewL
       
    50 // Two-phase dconstructor, second phase is ConstructAndRunLD
       
    51 // --------------------------------------------------------------------------
       
    52 //
       
    53 CmPluginWlanSettingsDlgIpv6* CmPluginWlanSettingsDlgIpv6::NewL( 
       
    54                                             CCmPluginBaseEng& aCmPluginBase )
       
    55 	{
       
    56 	CmPluginWlanSettingsDlgIpv6* self = 
       
    57 	            new (ELeave) CmPluginWlanSettingsDlgIpv6( aCmPluginBase );
       
    58 	return self;
       
    59 	}
       
    60 	
       
    61 // --------------------------------------------------------------------------
       
    62 // CmPluginWlanSettingsDlgIpv6::CmPluginWlanSettingsDlgIpv6
       
    63 // --------------------------------------------------------------------------
       
    64 //
       
    65 CmPluginWlanSettingsDlgIpv6::CmPluginWlanSettingsDlgIpv6( 
       
    66                                          CCmPluginBaseEng& aCmPluginBase ):
       
    67     CmPluginBaseSettingsDlgIp( aCmPluginBase ) ,
       
    68     iParent( NULL )
       
    69     {
       
    70     iHelpContext = KSET_HLP_AP_WLAN_AS_IPV6;
       
    71     }
       
    72     
       
    73 // --------------------------------------------------------------------------
       
    74 // CmPluginWlanSettingsDlgIpv6::~CmPluginWlanSettingsDlgIpv6
       
    75 // --------------------------------------------------------------------------
       
    76 //
       
    77 CmPluginWlanSettingsDlgIpv6::~CmPluginWlanSettingsDlgIpv6()
       
    78     {
       
    79     }
       
    80 
       
    81 // --------------------------------------------------------------------------
       
    82 // CmPluginWlanSettingsDlgIpv6::ConstructAndRunLD
       
    83 // --------------------------------------------------------------------------
       
    84 //
       
    85 TInt CmPluginWlanSettingsDlgIpv6::ConstructAndRunLD()
       
    86     {
       
    87     CCmManagerImpl& cmMgr = iCmPluginBaseEng.CmMgr();
       
    88     cmMgr.WatcherRegisterL( this );
       
    89     
       
    90     return CmPluginBaseSettingsDlgIp::ConstructAndRunLD();
       
    91     }
       
    92 
       
    93 // --------------------------------------------------------------------------
       
    94 // CmPluginWlanSettingsDlgIpv6::UpdateListBoxContentBearerSpecificL
       
    95 // --------------------------------------------------------------------------
       
    96 //
       
    97 void CmPluginWlanSettingsDlgIpv6::UpdateListBoxContentBearerSpecificL( 
       
    98                                                     CDesCArray& aItemArray )
       
    99     {
       
   100     TInt value( 0 );
       
   101     
       
   102     // DNS SERVERS IP ADDRESS
       
   103     switch ( GetIPv6DNSTypeL( EWlanIp6NameServer1,
       
   104                               EWlanIp6NameServer2 ) )
       
   105         {
       
   106         case EIpv6DNSDynamic:
       
   107             {
       
   108             value = R_QTN_SET_DNS_SERVERS_AUTOMATIC;
       
   109             break;
       
   110             }
       
   111         case EIpv6DNSWellKnown:
       
   112             {
       
   113             value = R_QTN_SET_IP_WELL_KNOWN;
       
   114             break;
       
   115             }
       
   116         case EIpv6DNSUserDefined:
       
   117             {
       
   118             value = R_QTN_SET_IP_USER_DEFINED;
       
   119             break;
       
   120             }
       
   121         default:
       
   122             {
       
   123             User::Leave( KErrNotSupported );
       
   124             break;
       
   125             }
       
   126         }
       
   127     AppendSettingTextsL( aItemArray,
       
   128                          EWlanIp6DNSAddrFromServer,
       
   129                          value );
       
   130     }    
       
   131 
       
   132 //---------------------------------------------------------------------------
       
   133 // CmPluginWlanSettingsDlgIpv6::ShowPopupSettingPageL
       
   134 //---------------------------------------------------------------------------
       
   135 //
       
   136 TBool CmPluginWlanSettingsDlgIpv6::ShowPopupSettingPageL( TUint32 aAttribute, 
       
   137                                                           TInt aCommandId )
       
   138     {    
       
   139     TBool retval = EFalse;
       
   140     switch ( aAttribute )
       
   141         {
       
   142         case EWlanIp6DNSAddrFromServer:        
       
   143             {
       
   144             ShowPopupIPv6DNSEditorL( KIPv6SelectionItems, 
       
   145                                      EWlanIp6DNSAddrFromServer,
       
   146                                      EWlanIp6NameServer1,
       
   147                                      EWlanIp6NameServer2 );
       
   148             break;
       
   149             }
       
   150         default:
       
   151             {
       
   152             CmPluginBaseSettingsDlgIp::ShowPopupSettingPageL( aAttribute, 
       
   153                                                                aCommandId );
       
   154             break;            
       
   155             }
       
   156         }
       
   157     return retval;
       
   158     }
       
   159     
       
   160 //---------------------------------------------------------------------------
       
   161 // CmPluginWlanSettingsDlgIpv6::InitTextsL
       
   162 // called before the dialog is shown to initialize localized textual data
       
   163 //---------------------------------------------------------------------------
       
   164 //
       
   165 void CmPluginWlanSettingsDlgIpv6::InitTextsL()
       
   166     {
       
   167     // set pane text if neccessary...
       
   168     // pane text needed if not pop-up...
       
   169     if ( iEikonEnv )
       
   170         {
       
   171         iStatusPane = iEikonEnv->AppUiFactory()->StatusPane();
       
   172         iTitlePane = ( CAknTitlePane* )iStatusPane->ControlL(
       
   173                                 TUid::Uid( EEikStatusPaneUidTitle ) );
       
   174 
       
   175         iOldTitleText = iTitlePane->Text()->AllocL();
       
   176         HBufC* title = StringLoader::LoadLC ( R_QTN_SET_IPV6_SETTINGS );
       
   177         iTitlePane->SetTextL( *title ) ;
       
   178         CleanupStack::PopAndDestroy(title);                         
       
   179         iNaviPane = ( CAknNavigationControlContainer* ) 
       
   180                         iStatusPane->ControlL( 
       
   181                                 TUid::Uid( EEikStatusPaneUidNavi ) );
       
   182         iNaviDecorator = iNaviPane->CreateNavigationLabelL( KNullDesC );
       
   183         iNaviPane->PushL( *iNaviDecorator );
       
   184         }
       
   185     }    
       
   186     
       
   187 // --------------------------------------------------------------------------
       
   188 // CmPluginWlanSettingsDlgIpv6::ProcessCommandL
       
   189 // --------------------------------------------------------------------------
       
   190 //
       
   191 void CmPluginWlanSettingsDlgIpv6:: ProcessCommandL( TInt aCommandId )
       
   192     {
       
   193     if ( MenuShowing() )
       
   194         {
       
   195         HideMenu();
       
   196         }
       
   197 
       
   198     switch ( aCommandId )
       
   199         {
       
   200         case EPluginBaseCmdExit:
       
   201             {
       
   202             iExitReason = KDialogUserExit;
       
   203             }
       
   204         // fall-through intended here
       
   205         case EAknSoftkeyBack:
       
   206             {
       
   207             CCmManagerImpl& cmMgr = iCmPluginBaseEng.CmMgr();
       
   208             cmMgr.WatcherUnRegister();
       
   209             
       
   210             TryExitL( iExitReason );
       
   211             break;
       
   212             }           
       
   213         case EAknSoftkeyOk:
       
   214         case EPluginBaseCmdChange:
       
   215             {
       
   216             TInt attrib = iSettingIndex->At( iListbox->CurrentItemIndex() );
       
   217             ShowPopupSettingPageL( attrib, aCommandId);
       
   218             break;
       
   219             }
       
   220         default:
       
   221             {
       
   222             CmPluginBaseSettingsDlgIp::ProcessCommandL( aCommandId );
       
   223             break;            
       
   224             }
       
   225         }
       
   226     }
       
   227 
       
   228 // --------------------------------------------------------------------------
       
   229 // CmPluginWlanSettingsDlgIpv6::OkToExitL
       
   230 // --------------------------------------------------------------------------
       
   231 //
       
   232 TBool CmPluginWlanSettingsDlgIpv6::OkToExitL( TInt aButtonId )
       
   233     {
       
   234     TBool retval( EFalse );
       
   235     
       
   236     switch ( aButtonId )
       
   237         {
       
   238         case EAknSoftkeyBack:
       
   239         case EAknSoftkeyExit:
       
   240         case KDialogUserExit:
       
   241             {
       
   242             CCmManagerImpl& cmMgr = iCmPluginBaseEng.CmMgr();
       
   243             cmMgr.WatcherUnRegister();
       
   244             } // Continue to call base setting dialog view
       
   245         default:
       
   246             {
       
   247             retval = CmPluginBaseSettingsDlgIp::OkToExitL( aButtonId );
       
   248             break;
       
   249             }
       
   250         }
       
   251     return retval;
       
   252     }
       
   253 
       
   254 // --------------------------------------------------------------------------
       
   255 // CmPluginWlanSettingsDlgIpv6::RegisterParentView
       
   256 // --------------------------------------------------------------------------
       
   257 //
       
   258 void CmPluginWlanSettingsDlgIpv6::RegisterParentView( CCmParentViewNotifier* aParent )
       
   259     {
       
   260     iParent = aParent;
       
   261     }
       
   262 
       
   263 // --------------------------------------------------------------------------
       
   264 // CmPluginWlanSettingsDlgIpv6::CommsDatChangesL
       
   265 // --------------------------------------------------------------------------
       
   266 //
       
   267 void CmPluginWlanSettingsDlgIpv6::CommsDatChangesL()
       
   268     {
       
   269     CCmManagerImpl& cmMgr = iCmPluginBaseEng.CmMgr();
       
   270     CCmDestinationImpl* parentDest = iCmPluginBaseEng.ParentDestination();
       
   271     
       
   272     if ( parentDest )
       
   273         {
       
   274         if( !cmMgr.DestinationStillExistedL( parentDest ) )
       
   275             {
       
   276             if( iParent )
       
   277                 {
       
   278                 iParent->NotifyParentView( KCmNotifiedDestinationDisappear );
       
   279                 }
       
   280             
       
   281             // cmMgr.WatcherUnRegister();
       
   282             // If parent destination is deleted by somebody then the dialog must exit back to main view
       
   283             iExitReason = KDialogUserExit; // cmMgr.WatcherUnRegister will be done in function OkToExitL in this case
       
   284             TryExitL( iExitReason );
       
   285                 
       
   286             cmMgr.RemoveDestFromPool( parentDest );
       
   287             delete parentDest;
       
   288             return;
       
   289             }
       
   290             
       
   291         if( !cmMgr.IsIapStillInDestL( parentDest, iCmPluginBaseEng ) )
       
   292             {
       
   293             if( iParent )
       
   294                 {
       
   295                 iParent->NotifyParentView( KCmNotifiedIapIsNotInThisDestination );
       
   296                 }
       
   297             
       
   298             cmMgr.WatcherUnRegister();
       
   299             // In this case, the dialog can go back to the parent view
       
   300             TryExitL( iExitReason );
       
   301             
       
   302             cmMgr.RemoveDestFromPool( parentDest );
       
   303             delete parentDest;
       
   304             return;
       
   305             }
       
   306         
       
   307         // We may have to notify parent view to go back to its parent view even though this Iap is still in CommsDat
       
   308         // for cmMgr ( = iCmPluginBaseEng.CmMgr() ) can not be accessed any more
       
   309         // after this call when some Iap is deleted.
       
   310         if( iParent )
       
   311             {
       
   312             iParent->NotifyParentView( KCmNotifiedIapDisappear );
       
   313             }
       
   314         cmMgr.WatcherUnRegister();
       
   315         TryExitL( iExitReason );
       
   316         
       
   317         cmMgr.RemoveDestFromPool( parentDest );
       
   318         delete parentDest;
       
   319         }
       
   320     else
       
   321         {
       
   322         if( !cmMgr.IapStillExistedL( iCmPluginBaseEng ) )
       
   323             {
       
   324             if( iParent )
       
   325                 {
       
   326                 iParent->NotifyParentView( KCmNotifiedIapDisappear );
       
   327                 }
       
   328             
       
   329             cmMgr.WatcherUnRegister();
       
   330             // In this case, the dialog can go back to the parent view
       
   331             TryExitL( iExitReason );
       
   332             return;
       
   333             }
       
   334         
       
   335         // We may have to notify parent view to go back to its parent view even though this Iap is still in CommsDat
       
   336         // for cmMgr ( = iCmPluginBaseEng.CmMgr() ) can not be accessed any more
       
   337         // after this call when some Iap is deleted.
       
   338         if( iParent )
       
   339             {
       
   340             iParent->NotifyParentView( KCmNotifiedIapDisappear );
       
   341             }
       
   342         cmMgr.WatcherUnRegister();
       
   343         TryExitL( iExitReason );
       
   344         }
       
   345     }