cmmanager/cmmgr/Framework/Src/cmpbasesettingsdlg.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:  base class for connection method plugin dialogs
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 
       
    21 // System
       
    22 #include <cmmanager.rsg>
       
    23 #include <aknnavide.h>
       
    24 #include <StringLoader.h>
       
    25 #include <akntitle.h>
       
    26 #include <aknradiobuttonsettingpage.h>
       
    27 #include <data_caging_path_literals.hrh>
       
    28 #include <akntextsettingpage.h>
       
    29 #include <aknpasswordsettingpage.h>
       
    30 #include <in_sock.h>
       
    31 #include <aknmfnesettingpage.h>
       
    32 #include <AknQueryDialog.h>
       
    33 #include <featmgr.h>
       
    34 
       
    35 #include <hlplch.h>
       
    36 
       
    37 // User
       
    38 #include <mcmdexec.h>
       
    39 #include <cmpbasesettingsdlg.h>
       
    40 #include <cmmanager.h>
       
    41 #include <cmpluginbaseeng.h>
       
    42 #include "cmmanagerimpl.h"
       
    43 #include "cmmanager.hrh"
       
    44 #include <cmcommonui.h>
       
    45 #include <cmcommonconstants.h>
       
    46 #include <cmpsettingsconsts.h>
       
    47 #include "cmpluginmultilinedialog.h"
       
    48 #include "cmlogger.h"
       
    49 #include "ccmdexec.h"
       
    50 
       
    51 using namespace CMManager;
       
    52 
       
    53 // Maximum speed mapping
       
    54 struct TIPv6DNSMapping
       
    55     {
       
    56     TInt iResId;
       
    57     TInt iSettingValue;
       
    58     };
       
    59 
       
    60 // Mapping for IPv6 DNS types
       
    61 const TIPv6DNSMapping KTIPv6DNSItems[] =
       
    62     {
       
    63     { R_QTN_SET_DNS_SERVERS_AUTOMATIC, EIPv6Unspecified },
       
    64     { R_QTN_SET_IP_WELL_KNOWN,         EIPv6WellKnown },
       
    65     { R_QTN_SET_IP_USER_DEFINED,       EIPv6UserDefined },
       
    66     { 0, 0 }
       
    67     };
       
    68     
       
    69 const TUint32 KMaxInt32Length = 10;
       
    70 
       
    71 // ================= MEMBER FUNCTIONS =======================================
       
    72 
       
    73 // --------------------------------------------------------------------------
       
    74 // CmPluginBaseSettingsDlg::ConstructAndRunLD
       
    75 // Constructs the dialog and runs it.
       
    76 // --------------------------------------------------------------------------
       
    77 //
       
    78 EXPORT_C TInt CmPluginBaseSettingsDlg::ConstructAndRunLD( )
       
    79     {
       
    80     CleanupStack::PushL( this );
       
    81     FeatureManager::InitializeLibL();
       
    82     iHelp = FeatureManager::FeatureSupported( KFeatureIdHelp ); 
       
    83     FeatureManager::UnInitializeLib();
       
    84     ConstructL( R_PLUGIN_BASE_MENUBAR );
       
    85     PrepareLC( R_PLUGIN_BASE_DIALOG );
       
    86     CleanupStack::Pop( this );
       
    87     iSettingIndex = new ( ELeave ) CArrayFixFlat<TUint>( 4 );
       
    88 
       
    89     if (!iHasSettingChanged)
       
    90 	    {
       
    91         iHasSettingChanged = ETrue;
       
    92         }
       
    93 
       
    94     return RunLD();
       
    95     }
       
    96     
       
    97     
       
    98 // --------------------------------------------------------------------------
       
    99 // CmPluginBaseSettingsDlg::CmPluginBaseSettingsDlg()
       
   100 // --------------------------------------------------------------------------
       
   101 //
       
   102 EXPORT_C  CmPluginBaseSettingsDlg::CmPluginBaseSettingsDlg( 
       
   103                                           CCmPluginBaseEng& aCmPluginBase ) :
       
   104         iCmPluginBaseEng( aCmPluginBase ),
       
   105         iExitReason( KDialogUserBack ),
       
   106         iResourceReader( *CCoeEnv::Static() ),
       
   107         iIsPossibleToSaveSetting( ETrue ),
       
   108         iHasSettingChanged( EFalse )
       
   109     {
       
   110     }
       
   111    
       
   112 // --------------------------------------------------------------------------
       
   113 // CmPluginBaseSettingsDlg::~CApSelectorDialog
       
   114 // --------------------------------------------------------------------------
       
   115 //
       
   116 EXPORT_C CmPluginBaseSettingsDlg::~CmPluginBaseSettingsDlg()
       
   117     {
       
   118     // iModel is deleted by the ListBox because LB owns the model...
       
   119     // of course only after we passed ownership...
       
   120     if ( iNaviDecorator )
       
   121         {
       
   122         delete iNaviDecorator;
       
   123         }
       
   124     if ( iTitlePane )
       
   125         {
       
   126         // set old text back, if we have it...
       
   127         if ( iOldTitleText )
       
   128             {
       
   129             TRAP_IGNORE( iTitlePane->SetTextL( *iOldTitleText ) );
       
   130             delete iOldTitleText;
       
   131             }
       
   132         }       
       
   133     if ( iSettingIndex )
       
   134         {
       
   135         delete iSettingIndex;
       
   136         }
       
   137     iResourceReader.Close();        
       
   138 
       
   139     delete iCmdExec;
       
   140     iCmdExec = NULL;
       
   141     }
       
   142 
       
   143 // --------------------------------------------------------------------------
       
   144 // CmPluginBaseSettingsDlg::PreLayoutDynInitL();
       
   145 // called by framework before dialog is shown
       
   146 // --------------------------------------------------------------------------
       
   147 //
       
   148 EXPORT_C void CmPluginBaseSettingsDlg::PreLayoutDynInitL()
       
   149     {
       
   150     iListbox = STATIC_CAST( CAknSettingStyleListBox*, 
       
   151                                            Control( KPluginBaseListboxId ) );
       
   152     iListbox->CreateScrollBarFrameL( ETrue );
       
   153     iListbox->ScrollBarFrame()->SetScrollBarVisibilityL
       
   154                     ( CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto );
       
   155     iListbox->SetListBoxObserver( this );
       
   156 
       
   157     HandleListboxDataChangeL();
       
   158     iListbox->HandleItemAdditionL();
       
   159     InitTextsL();
       
   160     }
       
   161 
       
   162 // --------------------------------------------------------------------------
       
   163 // CmPluginBaseSettingsDlg::UpdateListBoxContentL
       
   164 // --------------------------------------------------------------------------
       
   165 //
       
   166 EXPORT_C void CmPluginBaseSettingsDlg::UpdateListBoxContentL()
       
   167     {        
       
   168     // Must save listbox indexes because content will be deleted
       
   169     TInt lastListBoxPos = iListbox->CurrentItemIndex();
       
   170     TInt lastListBoxTopPos = iListbox->TopItemIndex();
       
   171 
       
   172     // deleting listbox content
       
   173     MDesCArray* itemList = iListbox->Model()->ItemTextArray();
       
   174     CDesCArray* itemArray = (CDesCArray*)itemList;
       
   175     
       
   176     while ( itemArray->Count() )
       
   177         {
       
   178         itemArray->Delete( 0 );
       
   179         }
       
   180     while ( iSettingIndex->Count() )
       
   181         {
       
   182         iSettingIndex->Delete( 0 );
       
   183         }
       
   184 
       
   185     // CONNECTION NAME
       
   186     AppendSettingTextsL( *itemArray, ECmName );
       
   187 
       
   188     // BEARER SPECIFIC SETTINGS
       
   189     UpdateListBoxContentBearerSpecificL( *itemArray );
       
   190 
       
   191     //-----------------------------------------------------------------------
       
   192     // Handle content changes
       
   193     iListbox->Reset();
       
   194     iListbox->HandleItemAdditionL();
       
   195     
       
   196     // Listbox might not have index
       
   197     if ( lastListBoxPos != -1 )
       
   198         {
       
   199         iListbox->SetCurrentItemIndex( lastListBoxPos );
       
   200         iListbox->SetTopItemIndex( lastListBoxTopPos );
       
   201         }
       
   202     iListbox->DrawNow();
       
   203     }
       
   204 
       
   205 // --------------------------------------------------------------------------
       
   206 // CmPluginBaseSettingsDlg::AppendSettingTextsL
       
   207 // --------------------------------------------------------------------------
       
   208 //
       
   209 EXPORT_C void CmPluginBaseSettingsDlg::AppendSettingTextsL( 
       
   210                                                     CDesCArray& aItemArray,
       
   211                                                     const TInt aSettingItemId,
       
   212                                                     const TInt aValueResId )
       
   213     {
       
   214     HBufC* value = StringLoader::LoadLC( aValueResId );
       
   215 
       
   216     AppendSettingTextsL( aItemArray, aSettingItemId, value );
       
   217     
       
   218     CleanupStack::PopAndDestroy( value );
       
   219     }
       
   220     
       
   221 // --------------------------------------------------------------------------
       
   222 // CmPluginBaseSettingsDlg::AppendSettingTextsL
       
   223 // --------------------------------------------------------------------------
       
   224 //
       
   225 EXPORT_C void CmPluginBaseSettingsDlg::AppendSettingTextsL( 
       
   226                                             CDesCArray& aItemArray,
       
   227                                             const TInt aSettingItemId,
       
   228                                             const HBufC* aValueString )
       
   229     {
       
   230     const TCmAttribConvTable* convItem = 
       
   231                         iCmPluginBaseEng.ConvTableItem( aSettingItemId );
       
   232     HBufC* value = NULL;
       
   233     
       
   234     if ( aValueString )
       
   235         {
       
   236         value = (HBufC*)aValueString;
       
   237         }
       
   238     else
       
   239         {
       
   240         if ( convItem->iAttribFlags & EConvNumber )
       
   241             {
       
   242             TUint32 num = iCmPluginBaseEng.GetIntAttributeL( aSettingItemId );
       
   243             
       
   244             if( !num && convItem->iDefSettingResId )
       
   245                 {
       
   246                 value = StringLoader::LoadL( convItem->iDefSettingResId );
       
   247                 }
       
   248             else
       
   249                 {
       
   250                 value = HBufC::NewL( KMaxInt32Length );
       
   251                 value->Des().AppendNum( num );
       
   252 
       
   253                 TPtr number( value->Des() );
       
   254                 AknTextUtils::LanguageSpecificNumberConversion( number );
       
   255                 }
       
   256             }
       
   257         else
       
   258             {
       
   259             if( convItem->iAttribFlags & EConv8Bits )
       
   260                 // make 16bits copy of this 8bits buffer
       
   261                 {
       
   262                 HBufC8* value8 = iCmPluginBaseEng.GetString8AttributeL( aSettingItemId );
       
   263                 CleanupStack::PushL( value8 );
       
   264                 value = HBufC::NewL( value8->Length() );
       
   265                 value->Des().Copy( *value8 );
       
   266                 CleanupStack::PopAndDestroy( value8 );
       
   267                 }
       
   268             else
       
   269                 {   
       
   270                 value = iCmPluginBaseEng.GetStringAttributeL( aSettingItemId );
       
   271                 }
       
   272                 
       
   273             if ( convItem->iDefSettingResId )
       
   274                 // We have default value in resource.
       
   275                 // Check if we have use it, instead of current value.
       
   276                 {
       
   277                 if ( convItem->iAttribFlags & EConvIPv4 )
       
   278                     // This is an IPv4 text attribute
       
   279                     {
       
   280                     if ( IsUnspecifiedIPv4Address( *value ) )
       
   281                         // Use default value from resource instead of
       
   282                         // displaying unspecified IP address
       
   283                         {
       
   284                         delete value; value = NULL;
       
   285                         }
       
   286                     }
       
   287                 else if ( convItem->iAttribFlags & EConvIPv6 )
       
   288                     // This is an IPv4 text attribute
       
   289                     {
       
   290                     }
       
   291                 else if( convItem->iAttribFlags & EConvPassword )
       
   292                     // In case of password, we can show only the resource 
       
   293                     // string.
       
   294                     {
       
   295                     delete value; value = NULL;
       
   296                     }
       
   297                 else if ( *value == KNullDesC && convItem->iDefSettingResId )
       
   298                     // empty string, but it has a default value in resource
       
   299                     // Use the resource value.
       
   300                     {
       
   301                     delete value; value = NULL;
       
   302                     }
       
   303                     
       
   304                 if ( !value )
       
   305                     // use default value from resource.
       
   306                     {
       
   307                     value = StringLoader::LoadL( convItem->iDefSettingResId );
       
   308                     }
       
   309                 }
       
   310             }
       
   311 
       
   312         CleanupStack::PushL( value );
       
   313         }
       
   314 
       
   315     HBufC* title = StringLoader::LoadLC( convItem->iTitleId );
       
   316 
       
   317     _LIT( KSettingListFormat, "\t%S\t\t%S" );
       
   318     HBufC* itemTextBuf = HBufC::NewLC( KSettingListFormat().Length() + 
       
   319                                        title->Length() +
       
   320                                        value->Length() + 
       
   321                                        KTxtCompulsory().Length() );
       
   322                                        
       
   323     TPtr itemText = itemTextBuf->Des();
       
   324 
       
   325     itemText.Format( KSettingListFormat, title, value ); 
       
   326     
       
   327     // indicator for compulsory settings
       
   328     if ( convItem->iAttribFlags & EConvCompulsory )
       
   329         {
       
   330         itemText.Append( KTxtCompulsory );        
       
   331         }
       
   332         
       
   333     aItemArray.AppendL( itemText );
       
   334     CleanupStack::PopAndDestroy( 2, title ); // itemTextBuf, title
       
   335 
       
   336     if ( !aValueString )
       
   337         {
       
   338         CleanupStack::PopAndDestroy( (HBufC*)value );
       
   339         }
       
   340         
       
   341     iSettingIndex->AppendL( aSettingItemId );
       
   342     }
       
   343 
       
   344 // --------------------------------------------------------------------------
       
   345 // CmPluginBaseSettingsDlg::AppendSettingTextsL
       
   346 // --------------------------------------------------------------------------
       
   347 //
       
   348 
       
   349 EXPORT_C void CmPluginBaseSettingsDlg::AppendSettingTextsL(   
       
   350                                               CDesCArray& aItemArray,
       
   351                                               const TInt aSettingItemId,
       
   352                                               const TInt aTitleResId,
       
   353                                               const TInt aValueResId,
       
   354                                               const TBool aCompulsory ) const
       
   355     {
       
   356     HBufC* value = NULL;
       
   357     if ( aValueResId )
       
   358         {
       
   359         value = StringLoader::LoadLC( aValueResId );
       
   360         }
       
   361     else
       
   362         {   
       
   363         value = KNullDesC().AllocL();
       
   364         CleanupStack::PushL( value );
       
   365         }        
       
   366     TPtr ptrValue = value->Des();
       
   367     
       
   368     AppendSettingTextsL( aItemArray, aSettingItemId, 
       
   369                                         aTitleResId, ptrValue, aCompulsory );
       
   370     
       
   371     CleanupStack::PopAndDestroy( value );
       
   372     }
       
   373     
       
   374 // --------------------------------------------------------------------------
       
   375 // CmPluginBaseSettingsDlg::AppendSettingTextsL
       
   376 // --------------------------------------------------------------------------
       
   377 //
       
   378 EXPORT_C void CmPluginBaseSettingsDlg::AppendSettingTextsL(   
       
   379                                               CDesCArray& aItemArray,
       
   380                                               const TInt aSettingItemId,
       
   381                                               const TInt aTitleResId,
       
   382                                               const TDesC& aValueString,
       
   383                                               const TBool aCompulsory ) const
       
   384     {
       
   385     // Title
       
   386     HBufC* title = StringLoader::LoadLC( aTitleResId );
       
   387 
       
   388     _LIT( KSettingListFormat, "\t%S\t\t%S" );
       
   389     HBufC* itemTextBuf = HBufC::NewLC( KSettingListFormat().Length() + 
       
   390                                        title->Length() +
       
   391                                        aValueString.Length() + 
       
   392                                        KTxtCompulsory().Length() );
       
   393                                        
       
   394     TPtr itemText = itemTextBuf->Des();
       
   395 
       
   396     itemText.Format( KSettingListFormat, title, &aValueString ); 
       
   397     
       
   398     // indicator for compulsory settings
       
   399     if ( aCompulsory )
       
   400         {
       
   401         itemText.Append( KTxtCompulsory );        
       
   402         }
       
   403         
       
   404     aItemArray.AppendL( itemText );
       
   405     CleanupStack::PopAndDestroy( 2, title ); // itemTextBuf, title
       
   406     iSettingIndex->AppendL( aSettingItemId );
       
   407     }
       
   408 
       
   409 // --------------------------------------------------------------------------
       
   410 // CmPluginBaseSettingsDlg::DynInitMenuPaneL
       
   411 // --------------------------------------------------------------------------
       
   412 //
       
   413 EXPORT_C void CmPluginBaseSettingsDlg::DynInitMenuPaneL( 
       
   414                                                TInt aResourceId,
       
   415                                                CEikMenuPane* aMenuPane  )
       
   416     {
       
   417     CAknDialog::DynInitMenuPaneL( aResourceId, aMenuPane );
       
   418         
       
   419     if ( aResourceId == R_PLUGIN_BASE_MENU )
       
   420         {
       
   421     	if (!iHelp)
       
   422             {
       
   423             aMenuPane->DeleteMenuItem( EAknCmdHelp );		    
       
   424             }
       
   425         TInt currentItem = iSettingIndex->At( iListbox->CurrentItemIndex() );
       
   426         if ( currentItem == ECmBearerSettingName )
       
   427             {
       
   428             
       
   429             aMenuPane->SetItemDimmed( EPluginBaseCmdChange, ETrue );
       
   430             }
       
   431         }
       
   432     }
       
   433     
       
   434 // --------------------------------------------------------------------------
       
   435 // CmPluginBaseSettingsDlg::ProcessCommandL
       
   436 // --------------------------------------------------------------------------
       
   437 //
       
   438 EXPORT_C void CmPluginBaseSettingsDlg::ProcessCommandL( TInt aCommandId )
       
   439     {
       
   440     if ( MenuShowing() )
       
   441         {
       
   442         HideMenu();
       
   443         }
       
   444 
       
   445     switch ( aCommandId )
       
   446         {
       
   447         case EAknSoftkeyOptions:
       
   448             {
       
   449             DisplayMenuL();
       
   450             break;
       
   451             }
       
   452         case EPluginBaseCmdExit:
       
   453             {
       
   454             iExitReason = KDialogUserExit;
       
   455             if( iIsPossibleToSaveSetting && iHasSettingChanged )
       
   456             {
       
   457                 iCmPluginBaseEng.UpdateL();
       
   458                 iHasSettingChanged = EFalse;
       
   459             }
       
   460 
       
   461             TryExitL( iExitReason );
       
   462             break;
       
   463             }
       
   464         case EAknSoftkeyOk:
       
   465         case EAknSoftkeyChange:
       
   466             {
       
   467             // Function CheckSpaceBelowCriticalLevelL may User::Leave with KLeaveWithoutAlert
       
   468             // if no space available to save changes. The User::Leave message will be caught
       
   469             // by iCmdExec. So,it is not caught here.
       
   470             iCmPluginBaseEng.CheckSpaceBelowCriticalLevelL();
       
   471 
       
   472             ShowPopupSettingPageL( 
       
   473                     iSettingIndex->At( iListbox->CurrentItemIndex() ), 
       
   474                                         aCommandId );
       
   475 
       
   476             break;            
       
   477             }
       
   478         case EAknCmdHelp:
       
   479             {
       
   480             // Help context (the default value) has been set so this value is used.
       
   481             HlpLauncher::LaunchHelpApplicationL( iEikonEnv->WsSession(),
       
   482                                 iEikonEnv->EikAppUi()->AppHelpContextL() );
       
   483             }
       
   484             break;
       
   485         default:
       
   486             {
       
   487             break;
       
   488             }
       
   489         }
       
   490     }
       
   491 
       
   492 // --------------------------------------------------------------------------
       
   493 // CmPluginBaseSettingsDlg::InitTextsL
       
   494 // called before the dialog is shown
       
   495 // to initialize localized textual data
       
   496 // --------------------------------------------------------------------------
       
   497 //
       
   498 EXPORT_C void CmPluginBaseSettingsDlg::InitTextsL()
       
   499     {
       
   500     // set pane text if neccessary...
       
   501     // pane text needed if not pop-up...
       
   502     if ( iEikonEnv )
       
   503         {
       
   504         iStatusPane = iEikonEnv->AppUiFactory()->StatusPane();
       
   505         iTitlePane = ( CAknTitlePane* )iStatusPane->ControlL(
       
   506                                 TUid::Uid( EEikStatusPaneUidTitle ) );
       
   507 
       
   508         iOldTitleText = iTitlePane->Text()->AllocL();
       
   509         HBufC* pdConnName = iCmPluginBaseEng.GetStringAttributeL( ECmName );
       
   510         CleanupStack::PushL( pdConnName ); // 1
       
   511                 
       
   512         if ( pdConnName )
       
   513             {
       
   514             iTitlePane->SetTextL( *pdConnName );
       
   515             }
       
   516         else
       
   517             {
       
   518             iTitlePane->SetTextL( KNullDesC );
       
   519             }        
       
   520         CleanupStack::PopAndDestroy( pdConnName ); // 0
       
   521 
       
   522 
       
   523         iNaviPane = ( CAknNavigationControlContainer* )iStatusPane->ControlL(
       
   524                                         TUid::Uid( EEikStatusPaneUidNavi ) );
       
   525         iNaviDecorator = iNaviPane->CreateNavigationLabelL( KNullDesC );
       
   526         iNaviPane->PushL( *iNaviDecorator );
       
   527         }
       
   528     }
       
   529 
       
   530 // --------------------------------------------------------------------------
       
   531 // CmPluginBaseSettingsDlg::OkToExitL
       
   532 // Good to know : EAknSoftkeyCancel is never called, because
       
   533 // EEikDialogFlagNotifyEsc flag is not set in the resource.
       
   534 // --------------------------------------------------------------------------
       
   535 //
       
   536 EXPORT_C TBool CmPluginBaseSettingsDlg::OkToExitL( TInt aButtonId )
       
   537     {
       
   538     // Translate the button presses into commands for the appui & current
       
   539     // view to handle
       
   540     TBool retval( EFalse );
       
   541     
       
   542     switch ( aButtonId )
       
   543         {
       
   544         case EAknSoftkeyOk:
       
   545         case EAknSoftkeyChange:
       
   546             {
       
   547             ProcessCommandL( aButtonId );
       
   548             break;
       
   549             }        
       
   550         case EAknSoftkeyBack:
       
   551         case EAknSoftkeyExit:
       
   552         case KDialogUserExit:
       
   553             {
       
   554             
       
   555             if ( iIsPossibleToSaveSetting && iHasSettingChanged )
       
   556             {
       
   557                 iCmPluginBaseEng.UpdateL();
       
   558                 iHasSettingChanged = EFalse;
       
   559             }
       
   560             retval = ETrue;
       
   561             break;
       
   562             }
       
   563         case EAknSoftkeyOptions:
       
   564             {
       
   565             DisplayMenuL();
       
   566             break;
       
   567             }
       
   568         default:
       
   569             {
       
   570             retval = ETrue;
       
   571             break;
       
   572             }
       
   573         }
       
   574 
       
   575     return retval;
       
   576     }
       
   577 
       
   578 // --------------------------------------------------------------------------
       
   579 // CmPluginBaseSettingsDlg::HandleListBoxEventL
       
   580 // --------------------------------------------------------------------------
       
   581 //
       
   582 EXPORT_C void CmPluginBaseSettingsDlg::HandleListBoxEventL( 
       
   583                         CEikListBox* /*aListBox*/, TListBoxEvent aEventType )
       
   584     {
       
   585     switch ( aEventType )
       
   586         {
       
   587         case EEventEnterKeyPressed:
       
   588         case EEventItemSingleClicked:
       
   589             {
       
   590             if ( !iProcessing )
       
   591                 {
       
   592                 delete iCmdExec;
       
   593                 iCmdExec = NULL;
       
   594                 iCmdExec = new (ELeave) CCmdExec(*this);
       
   595                 iCmdExec->Execute();
       
   596                 }
       
   597             break;
       
   598             }
       
   599         case EEventEditingStarted:
       
   600             {
       
   601             break;
       
   602             }
       
   603         case EEventEditingStopped:
       
   604             {
       
   605             break;
       
   606             }
       
   607         default:
       
   608             {
       
   609             break;
       
   610 //            User::Leave( KErrNotSupported );
       
   611             }
       
   612         }
       
   613     }
       
   614 
       
   615 // ---------------------------------------------------------------------------
       
   616 // CmPluginBaseSettingsDlg::OfferKeyEventL
       
   617 // ---------------------------------------------------------------------------
       
   618 //
       
   619 EXPORT_C TKeyResponse CmPluginBaseSettingsDlg::OfferKeyEventL( const TKeyEvent& aKeyEvent, 
       
   620                                        TEventCode aType )    
       
   621     {
       
   622     return iListbox->OfferKeyEventL( aKeyEvent, aType );       
       
   623     }
       
   624 
       
   625 //---------------------------------------------------------------------------
       
   626 // CmPluginBaseSettingsDlg::LoadResourceL
       
   627 //---------------------------------------------------------------------------
       
   628 //
       
   629 EXPORT_C TInt CmPluginBaseSettingsDlg::LoadResourceL ( 
       
   630                                                 const TDesC& aResFileName )
       
   631     {
       
   632     TInt err( KErrNone );
       
   633     // Add resource file.
       
   634     TParse* fp = new ( ELeave ) TParse();
       
   635     err = fp->Set( aResFileName, 
       
   636                         &KDC_RESOURCE_FILES_DIR, 
       
   637                         NULL ); 
       
   638     if ( err )
       
   639         {
       
   640         User::Leave( err );
       
   641         }   
       
   642 
       
   643     TFileName resourceFileNameBuf = fp->FullName();
       
   644     delete fp;
       
   645 
       
   646     iResourceReader.OpenL( resourceFileNameBuf );
       
   647     return err;
       
   648     }
       
   649 
       
   650 //---------------------------------------------------------------------------
       
   651 // CmPluginBaseSettingsDlg::HandleListboxDataChangeL
       
   652 // called before the dialog is shown to initialize listbox data
       
   653 //---------------------------------------------------------------------------
       
   654 //
       
   655 EXPORT_C void CmPluginBaseSettingsDlg::HandleListboxDataChangeL()
       
   656     {
       
   657     UpdateListBoxContentL();
       
   658     iListbox->HandleItemAdditionL();
       
   659     }
       
   660 
       
   661 //---------------------------------------------------------------------------
       
   662 // CmPluginBaseSettingsDlg::ShowPopupSettingPageL
       
   663 //---------------------------------------------------------------------------
       
   664 //
       
   665 EXPORT_C TBool CmPluginBaseSettingsDlg::ShowPopupSettingPageL( 
       
   666                                            TUint32 aAttribute, TInt /*aCommandId*/ )
       
   667     {
       
   668     TBool retval( EFalse );
       
   669     
       
   670     switch ( aAttribute )
       
   671         {
       
   672         case ECmBearerSettingName:
       
   673             {
       
   674             TCmCommonUi::ShowNoteL ( R_PLUGIN_BASE_INFO_BEARER_NOT_EDITABLE,
       
   675                                                   TCmCommonUi::ECmInfoNote );
       
   676             break;
       
   677             }
       
   678         case ECmName:
       
   679         default:
       
   680             {
       
   681             retval = ShowPopupTextSettingPageL( aAttribute );
       
   682             break;
       
   683             }
       
   684         }
       
   685     return retval;
       
   686     }
       
   687     
       
   688 //---------------------------------------------------------------------------
       
   689 // CmPluginBaseSettingsDlg::SelectItem
       
   690 //---------------------------------------------------------------------------
       
   691 //
       
   692 EXPORT_C void CmPluginBaseSettingsDlg::SelectItem( TInt aItemIndex )
       
   693     {
       
   694     iListbox->ScrollToMakeItemVisible( aItemIndex );
       
   695     iListbox->SetCurrentItemIndexAndDraw( aItemIndex );
       
   696     }
       
   697     
       
   698 //---------------------------------------------------------------------------
       
   699 // CmPluginBaseSettingsDlg::StringAttributeWithDefaultL
       
   700 //---------------------------------------------------------------------------
       
   701 //
       
   702 EXPORT_C HBufC* CmPluginBaseSettingsDlg::StringAttributeWithDefaultL( 
       
   703                                         TUint32 aAttribute, TUint32 aDefRes )
       
   704     {
       
   705     HBufC* value = iCmPluginBaseEng.GetStringAttributeL( aAttribute );
       
   706     if ( *value == KNullDesC )
       
   707         {
       
   708         delete value;
       
   709         value = NULL;
       
   710         value = StringLoader::LoadL( aDefRes );
       
   711         }
       
   712 
       
   713     return value;
       
   714     }
       
   715    
       
   716 // --------------------------------------------------------------------------
       
   717 // CmPluginBaseSettingsDlg::GetHelpContext
       
   718 // --------------------------------------------------------------------------
       
   719 //
       
   720 EXPORT_C void CmPluginBaseSettingsDlg::GetHelpContext( TCoeHelpContext& aContext ) const
       
   721     {
       
   722     aContext.iMajor = KHelpUidPlugin;
       
   723     aContext.iContext = iHelpContext;
       
   724     }
       
   725 
       
   726 // --------------------------------------------------------------------------
       
   727 // CmPluginBaseSettingsDlg::ShowPopupIpSettingPageL
       
   728 // --------------------------------------------------------------------------
       
   729 //
       
   730 EXPORT_C TBool CmPluginBaseSettingsDlg::ShowPopupIpSettingPageL( 
       
   731                                                             TUint32 aAttribute,
       
   732                                                             TUint32 aTitleId )
       
   733     
       
   734     {
       
   735     TBool retval = EFalse;
       
   736     const TCmAttribConvTable* convItem = 
       
   737                         iCmPluginBaseEng.ConvTableItem( aAttribute );
       
   738     
       
   739     HBufC* servName = HBufC::NewLC( convItem->iMaxLength );
       
   740     TPtr ptrServName ( servName->Des() );
       
   741      
       
   742     HBufC* orig = iCmPluginBaseEng.GetStringAttributeL( aAttribute );    
       
   743     CleanupStack::PushL( orig );
       
   744     ptrServName.Copy( *orig );
       
   745     
       
   746     TInetAddr addr;
       
   747     addr.Input( ptrServName );
       
   748     
       
   749     TInt resId = EditorId( convItem->iEditorResId, R_TEXT_SETTING_PAGE_IP );
       
   750     
       
   751     CAknIpFieldSettingPage* dlg = 
       
   752                     new ( ELeave ) CAknIpFieldSettingPage( 
       
   753                                        resId, 
       
   754                                        addr );
       
   755 
       
   756     CleanupStack::PushL( dlg );
       
   757     SetTitleL( dlg, convItem->iTitleId, aTitleId );
       
   758     CleanupStack::Pop( dlg );
       
   759 
       
   760     if ( dlg->ExecuteLD( CAknSettingPage::EUpdateWhenAccepted ) )
       
   761         {
       
   762         addr.Output( ptrServName );
       
   763         
       
   764         if ( orig->Des().CompareF( ptrServName ) )
       
   765             // User modified IP address
       
   766             {
       
   767             iCmPluginBaseEng.SetStringAttributeL( aAttribute, ptrServName );
       
   768             retval = ETrue;  
       
   769             UpdateListBoxContentL();                                                                                     
       
   770             }
       
   771         }
       
   772 
       
   773     CleanupStack::PopAndDestroy( 2, servName ); // orig, servName
       
   774     return retval;
       
   775     }
       
   776     
       
   777 // --------------------------------------------------------------------------
       
   778 // CmPluginBaseSettingsDlg::ShowRadioButtonSettingPageL
       
   779 // --------------------------------------------------------------------------
       
   780 //
       
   781 EXPORT_C TInt CmPluginBaseSettingsDlg::ShowRadioButtonSettingPageL( 
       
   782                                                 const TUint32* aResIds, 
       
   783                                                 TInt& aCurrentItem,
       
   784                                                 TUint32 aTitleId )
       
   785     {
       
   786     CDesCArrayFlat* items = 
       
   787                    new ( ELeave ) CDesCArrayFlat( KCmArraySmallGranularity );
       
   788             
       
   789     CleanupStack::PushL( items );
       
   790     TInt count( 0 );       
       
   791     for( ; aResIds[count]; ++count )
       
   792         {
       
   793         HBufC* item = StringLoader::LoadLC( aResIds[count] );
       
   794         items->AppendL( *item );
       
   795         }
       
   796         
       
   797     TUint32 resId = EditorId( 0, R_RADIO_BUTTON_SETTING_PAGE_OK_CANCEL );
       
   798     CAknRadioButtonSettingPage* dlg = 
       
   799                             new ( ELeave ) CAknRadioButtonSettingPage(
       
   800                                     resId,
       
   801                                     aCurrentItem, 
       
   802                                     items );
       
   803     CleanupStack::PushL( dlg );
       
   804     SetTitleL( dlg, 0, aTitleId );
       
   805     CleanupStack::Pop( dlg );
       
   806 
       
   807     TBool retVal = dlg->ExecuteLD( CAknSettingPage::EUpdateWhenChanged );    
       
   808     
       
   809     CleanupStack::PopAndDestroy( count );   // selection items
       
   810     CleanupStack::PopAndDestroy( items );
       
   811     
       
   812     return retVal;
       
   813     }
       
   814     
       
   815 // --------------------------------------------------------------------------
       
   816 // CmPluginBaseSettingsDlg::ShowRadioButtonSettingPageL
       
   817 // --------------------------------------------------------------------------
       
   818 //
       
   819 EXPORT_C TInt CmPluginBaseSettingsDlg::ShowRadioButtonSettingPageL( 
       
   820                                                 CDesCArrayFlat& aItems, 
       
   821                                                 TInt& aCurrentItem,
       
   822                                                 TUint32 aTitleId )
       
   823     {
       
   824     TUint32 resId = EditorId( 0, R_RADIO_BUTTON_SETTING_PAGE_OK_CANCEL );
       
   825     CAknRadioButtonSettingPage* dlg = 
       
   826                             new ( ELeave ) CAknRadioButtonSettingPage(
       
   827                                     resId,
       
   828                                     aCurrentItem, 
       
   829                                     &aItems );
       
   830     CleanupStack::PushL( dlg );
       
   831     SetTitleL( dlg, 0, aTitleId );
       
   832     CleanupStack::Pop( dlg );
       
   833 
       
   834     TBool retVal = dlg->ExecuteLD( CAknSettingPage::EUpdateWhenChanged );    
       
   835 
       
   836     return retVal;
       
   837     }
       
   838     
       
   839 //---------------------------------------------------------------------------
       
   840 // CmPluginBaseSettingsDlg::ShowPopupTextSettingPageL
       
   841 //---------------------------------------------------------------------------
       
   842 //
       
   843 EXPORT_C TBool CmPluginBaseSettingsDlg::ShowPopupTextSettingPageL( 
       
   844                                                             TUint32 aAttribute,
       
   845                                                             TUint32 aTitleId )
       
   846     {    
       
   847     TBool retval( EFalse );
       
   848     const TCmAttribConvTable* convItem = 
       
   849                         iCmPluginBaseEng.ConvTableItem( aAttribute );
       
   850     
       
   851     HBufC* textToChange = HBufC::NewLC( convItem->iMaxLength );
       
   852     TPtr ptrTextToChange( textToChange->Des() );
       
   853 
       
   854     HBufC* value = HBufC::NewLC( convItem->iMaxLength );
       
   855     if ( convItem->iAttribFlags & EConv8Bits )
       
   856         // convert 8bits attribute to 16bits
       
   857         {
       
   858         HBufC8* stringFromCm = 
       
   859                 iCmPluginBaseEng.GetString8AttributeL( aAttribute );
       
   860         value->Des().Copy( *stringFromCm );
       
   861 
       
   862         delete stringFromCm; stringFromCm = NULL;
       
   863         }
       
   864     else
       
   865         {
       
   866         HBufC* stringFromCm = 
       
   867                 iCmPluginBaseEng.GetStringAttributeL( aAttribute );
       
   868         value->Des().Copy( *stringFromCm );
       
   869 
       
   870         delete stringFromCm; stringFromCm = NULL;
       
   871         }
       
   872         
       
   873     if( *value == KNullDesC && convItem->iDefValueResId )
       
   874         // empty string is replaced with the default value from resource
       
   875         {
       
   876         HBufC* stringFromCm = StringLoader::LoadL( convItem->iDefValueResId );
       
   877                 
       
   878         value->Des().Copy( *stringFromCm );
       
   879 
       
   880         delete stringFromCm; stringFromCm = NULL;
       
   881         }
       
   882    
       
   883     TPtr ptrValue( value->Des() );
       
   884     ptrTextToChange.Copy( ptrValue );
       
   885     
       
   886     TInt textSettingPageFlags( EAknSettingPageNoOrdinalDisplayed );
       
   887     
       
   888     if ( !(convItem->iAttribFlags & EConvNoZeroLength) )
       
   889         {
       
   890         textSettingPageFlags = CAknTextSettingPage::EZeroLengthAllowed;
       
   891         }
       
   892 
       
   893     TUint32 resId = EditorId( convItem->iEditorResId, 0 );
       
   894 
       
   895     CAknTextSettingPage* dlg = new ( ELeave ) CAknTextSettingPage( 
       
   896                                     resId, 
       
   897                                     ptrTextToChange, 
       
   898                                     textSettingPageFlags );
       
   899 
       
   900     CleanupStack::PushL( dlg );
       
   901     SetTitleL( dlg, convItem->iTitleId, aTitleId );
       
   902     CleanupStack::Pop( dlg );
       
   903 
       
   904     if ( dlg->ExecuteLD( CAknSettingPage::EUpdateWhenAccepted ) )
       
   905         {
       
   906         if ( aAttribute == ECmName )
       
   907             {
       
   908             iTitlePane->SetTextL( ptrTextToChange );                                                                          
       
   909             }
       
   910         if ( ptrTextToChange.Compare( ptrValue ) )
       
   911             // user modified the value
       
   912             {
       
   913             if ( convItem->iAttribFlags & EConv8Bits )
       
   914                 // convert back from 16bits to 8bits
       
   915                 {
       
   916                 HBufC8* stringTo = HBufC8::NewLC( ptrTextToChange.Length() );
       
   917                 
       
   918                 stringTo->Des().Copy( ptrTextToChange );
       
   919                 iCmPluginBaseEng.SetString8AttributeL( aAttribute, *stringTo );
       
   920                                                                    
       
   921                 CleanupStack::PopAndDestroy( stringTo );
       
   922                 }
       
   923             else
       
   924                 {
       
   925                 if( aAttribute == ECmName )
       
   926                     {
       
   927                     SetUniqueNameL( ptrTextToChange );
       
   928                     }
       
   929                 else
       
   930                     {
       
   931                     iCmPluginBaseEng.SetStringAttributeL( aAttribute, 
       
   932                                                       ptrTextToChange );
       
   933                     }    
       
   934                 }
       
   935                 
       
   936             retval = ETrue;
       
   937             UpdateListBoxContentL();
       
   938             }
       
   939         }
       
   940 
       
   941     CleanupStack::PopAndDestroy( 2, textToChange );
       
   942     return retval;
       
   943     }
       
   944 
       
   945 
       
   946 void CmPluginBaseSettingsDlg::SetUniqueNameL( TPtr aPtrTextToChange )
       
   947     {
       
   948      // Saves the recent naming method and set it to "Not accept"
       
   949     TUint32 savedNM = iCmPluginBaseEng.GetIntAttributeL( ECmNamingMethod );
       
   950     iCmPluginBaseEng.SetIntAttributeL( ECmNamingMethod, ENamingNotAccept );
       
   951 
       
   952     // Tries to save the nem name. If it is not unique
       
   953     // then ret == KErrArgument
       
   954     TRAPD( err, iCmPluginBaseEng.SetStringAttributeL( ECmName, aPtrTextToChange ) );
       
   955 
       
   956     if( KErrArgument == err )
       
   957         {
       
   958         // Opens a info note
       
   959         HBufC* noteLine = StringLoader::LoadLC(
       
   960                     R_CMMANAGERUI_INFO_DEST_ALREADY_IN_USE, aPtrTextToChange );
       
   961 
       
   962         TCmCommonUi::ShowNoteL( *noteLine, TCmCommonUi::ECmInfoNote );
       
   963 
       
   964         CleanupStack::PopAndDestroy( noteLine );
       
   965         }
       
   966 
       
   967     // Sets back the original naming method
       
   968     iCmPluginBaseEng.SetIntAttributeL( ECmNamingMethod, savedNM );
       
   969     }
       
   970 
       
   971 
       
   972 
       
   973 //---------------------------------------------------------------------------
       
   974 // CmPluginBaseSettingsDlg::ShowPopupPasswordSettingPageL
       
   975 //---------------------------------------------------------------------------
       
   976 //
       
   977 EXPORT_C TBool CmPluginBaseSettingsDlg::ShowPopupPasswordSettingPageL( 
       
   978                                                         TUint32 aAttribute,
       
   979                                                         TUint32 aTitleId )
       
   980     {
       
   981     TBool retVal( EFalse );
       
   982 
       
   983     const TCmAttribConvTable* convItem = 
       
   984                         iCmPluginBaseEng.ConvTableItem( aAttribute );
       
   985     HBufC* newPassword = HBufC::NewLC( KCmMaxPasswordLength );
       
   986     TPtr16 ptrNewPassword = newPassword->Des();
       
   987     
       
   988     HBufC* oldPassword = NULL;
       
   989     oldPassword = iCmPluginBaseEng.GetStringAttributeL( aAttribute );
       
   990     CleanupStack::PushL( oldPassword );   
       
   991     
       
   992     TUint32 resId = EditorId( convItem->iEditorResId, 
       
   993                               R_TEXT_SETTING_PAGE_PASSWD );
       
   994     CAknAlphaPasswordSettingPage* dlg = 
       
   995                     new ( ELeave ) CAknAlphaPasswordSettingPage(
       
   996                                             resId,
       
   997                                             ptrNewPassword,
       
   998                                             *oldPassword );
       
   999     CleanupStack::PushL( dlg );
       
  1000     SetTitleL( dlg, convItem->iTitleId, aTitleId );
       
  1001     CleanupStack::Pop( dlg );
       
  1002 
       
  1003     if ( dlg->ExecuteLD( CAknSettingPage::EUpdateWhenChanged ) )
       
  1004         {
       
  1005         iCmPluginBaseEng.SetStringAttributeL( aAttribute, newPassword->Des() );
       
  1006         UpdateListBoxContentL();
       
  1007 
       
  1008         retVal = ETrue;
       
  1009         }
       
  1010     CleanupStack::PopAndDestroy( 2, newPassword );
       
  1011     
       
  1012     return retVal;
       
  1013     }
       
  1014 
       
  1015 //---------------------------------------------------------------------------
       
  1016 // CmPluginBaseSettingsDlg::ShowNumSettingPageL
       
  1017 //---------------------------------------------------------------------------
       
  1018 //
       
  1019 EXPORT_C TBool CmPluginBaseSettingsDlg::ShowPopupPortNumSettingPageL( 
       
  1020                                     TUint32 aAttribute, TUint32 aTitleId )
       
  1021     {
       
  1022     TBool retVal( EFalse );
       
  1023     const TCmAttribConvTable* convItem = 
       
  1024                         iCmPluginBaseEng.ConvTableItem( aAttribute );
       
  1025 
       
  1026     TInt value( 0 );
       
  1027     value = iCmPluginBaseEng.GetIntAttributeL( aAttribute );
       
  1028 
       
  1029     TInt origVal = value;
       
  1030     
       
  1031     HBufC* buf = HBufC::NewLC( convItem->iMaxLength );
       
  1032     TPtr ptr( buf->Des() );
       
  1033     
       
  1034     ptr.Num( value );
       
  1035     
       
  1036     TInt flags = EAknSettingPageNoOrdinalDisplayed;
       
  1037     
       
  1038     if ( !(convItem->iAttribFlags & EConvNoZeroLength) )
       
  1039         {
       
  1040         flags |= CAknTextSettingPage::EZeroLengthAllowed;
       
  1041         }
       
  1042     
       
  1043     TUint32 resId = EditorId( convItem->iEditorResId, 
       
  1044                               R_PORT_NUMBER_SETTING_PAGE );
       
  1045     CAknTextSettingPage* dlg = new ( ELeave ) CAknTextSettingPage( 
       
  1046                                     resId,
       
  1047                                     ptr, 
       
  1048                                     flags );
       
  1049 
       
  1050     CleanupStack::PushL( dlg );
       
  1051     SetTitleL( dlg, convItem->iTitleId, aTitleId );
       
  1052     CleanupStack::Pop( dlg );
       
  1053 
       
  1054     if ( dlg->ExecuteLD( CAknSettingPage::EUpdateWhenAccepted ) )
       
  1055         {
       
  1056         TLex lex ( buf->Des() );
       
  1057 
       
  1058         // An empty string should be treated as default        
       
  1059         if ( buf->Des() == KNullDesC )
       
  1060             {
       
  1061             value = 0;
       
  1062             }
       
  1063         else
       
  1064             {
       
  1065             lex.Val( value );
       
  1066             }
       
  1067         if ( value != origVal )
       
  1068             {
       
  1069             iCmPluginBaseEng.SetIntAttributeL( aAttribute, value );
       
  1070             retVal = ETrue;
       
  1071             UpdateListBoxContentL();
       
  1072             }
       
  1073         }
       
  1074         
       
  1075     CleanupStack::PopAndDestroy( buf );
       
  1076     return retVal;
       
  1077     }
       
  1078 
       
  1079 //---------------------------------------------------------------------------
       
  1080 // CmPluginBaseSettingsDlg::ShowPopupIPv4DNSEditorL
       
  1081 //---------------------------------------------------------------------------
       
  1082 //
       
  1083 EXPORT_C TBool CmPluginBaseSettingsDlg::ShowPopupIPv4DNSEditorL(
       
  1084                                             TUint32 aDNSUsageAttribute,
       
  1085                                             TUint32 aDNS1ServAttribute,
       
  1086                                             TUint32 aDNS2ServAttribute,
       
  1087                                             TUint32 aTitleId )
       
  1088     {
       
  1089     // In default the return value is 'Automatic'
       
  1090     TBool retVal( EFalse );
       
  1091     // In default DNS setting is automatic.
       
  1092     const TCmAttribConvTable* convItem = 
       
  1093                         iCmPluginBaseEng.ConvTableItem( aDNSUsageAttribute );
       
  1094 
       
  1095     HBufC* primServ = iCmPluginBaseEng.GetStringAttributeL( aDNS1ServAttribute );
       
  1096     CleanupStack::PushL( primServ );
       
  1097     HBufC* secServ = iCmPluginBaseEng.GetStringAttributeL( aDNS2ServAttribute );
       
  1098     CleanupStack::PushL( secServ );
       
  1099     
       
  1100     TBuf<KIpAddressWidth> newPrim;
       
  1101     TBuf<KIpAddressWidth> newSec;
       
  1102     
       
  1103     newPrim.Copy( *primServ );
       
  1104     newSec.Copy( *secServ );
       
  1105     
       
  1106     TInetAddr dns1Addr;
       
  1107     TInetAddr dns2Addr;
       
  1108     
       
  1109     dns1Addr.Input( newPrim );
       
  1110     dns2Addr.Input( newSec );
       
  1111     
       
  1112     CAknMultiLineIpQueryDialog* dlg = 
       
  1113             CAknMultiLineIpQueryDialog::NewL( dns1Addr, 
       
  1114                                               dns2Addr );
       
  1115     
       
  1116     CleanupStack::PushL( dlg );
       
  1117 
       
  1118     TUint32 editorId = EditorId( convItem->iEditorResId, R_DNSIP4_QUERY );
       
  1119     dlg->PrepareLC( editorId );
       
  1120 
       
  1121     TUint32 titleId = TitleId( convItem->iTitleId, aTitleId );
       
  1122     if ( titleId )
       
  1123         {
       
  1124         dlg->SetTitleL( titleId );
       
  1125         }
       
  1126         
       
  1127     CleanupStack::Pop( dlg );
       
  1128     
       
  1129     if ( dlg->RunLD() )
       
  1130         {
       
  1131         dns1Addr.Output( newPrim );
       
  1132         dns2Addr.Output( newSec );
       
  1133         
       
  1134         if ( newPrim.CompareF( *primServ ) ||
       
  1135              newSec.CompareF( *secServ ) )
       
  1136             // User modified the DNS setting
       
  1137             {
       
  1138             iCmPluginBaseEng.SetDNSServerAddressL( 
       
  1139                                 aDNS1ServAttribute,
       
  1140                                 newPrim,
       
  1141                                 aDNS2ServAttribute, 
       
  1142                                 newSec,
       
  1143                                 aDNSUsageAttribute,
       
  1144                                 EFalse );
       
  1145                 
       
  1146             UpdateListBoxContentL();
       
  1147             
       
  1148             retVal = ETrue;
       
  1149             }
       
  1150         }
       
  1151     
       
  1152     CleanupStack::PopAndDestroy( 2, primServ );
       
  1153     
       
  1154     return retVal;
       
  1155     }
       
  1156 
       
  1157 //---------------------------------------------------------------------------
       
  1158 // CmPluginBaseSettingsDlg::ShowPopupIPv6DNSEditorL
       
  1159 //---------------------------------------------------------------------------
       
  1160 //
       
  1161 EXPORT_C TInt CmPluginBaseSettingsDlg::ShowPopupIPv6DNSEditorL(
       
  1162                                             const TUint32* aSelectionItems,
       
  1163                                             TUint32 aDNSUsageAttribute,
       
  1164                                             TUint32 aDNS1ServAttribute,
       
  1165                                             TUint32 aDNS2ServAttribute )
       
  1166     {
       
  1167     TBool update( EFalse );
       
  1168     TInt selected = GetIPv6DNSTypeL( aDNS1ServAttribute, aDNS2ServAttribute );
       
  1169     
       
  1170     // convert the current setting value to the selection index
       
  1171     TInt resId = KTIPv6DNSItems[selected].iResId;    
       
  1172     TInt i = 0;
       
  1173     while ( aSelectionItems[i] )
       
  1174         {
       
  1175         if ( resId == aSelectionItems[i] )
       
  1176             {
       
  1177             selected = i;
       
  1178             break;
       
  1179             }
       
  1180         i++;
       
  1181         }
       
  1182     
       
  1183     if ( ShowRadioButtonSettingPageL( aSelectionItems, 
       
  1184                                       selected, 
       
  1185                                       R_QTN_SET_DNS_SERVERS_IP ) )
       
  1186         {
       
  1187         // convert the selection to the setting value
       
  1188         resId = aSelectionItems[selected];
       
  1189         TInt j = 0;
       
  1190         
       
  1191         while ( KTIPv6DNSItems[j].iResId )
       
  1192             {
       
  1193             if ( resId == KTIPv6DNSItems[j].iResId )
       
  1194                 {
       
  1195                 selected = KTIPv6DNSItems[j].iSettingValue;
       
  1196                 break;
       
  1197                 }
       
  1198             j++;
       
  1199             }
       
  1200         
       
  1201         switch ( selected )
       
  1202             {
       
  1203             case EIPv6WellKnown: 
       
  1204                 {
       
  1205                 iCmPluginBaseEng.SetStringAttributeL( 
       
  1206                         aDNS1ServAttribute, KKnownIp6NameServer1 );
       
  1207                 iCmPluginBaseEng.SetStringAttributeL( 
       
  1208                         aDNS2ServAttribute, KKnownIp6NameServer2 );
       
  1209                         
       
  1210                 iCmPluginBaseEng.SetBoolAttributeL( 
       
  1211                         aDNSUsageAttribute, EFalse );
       
  1212                         
       
  1213                 update = ETrue;
       
  1214                 }
       
  1215                 break;
       
  1216 
       
  1217             case EIPv6Unspecified: 
       
  1218                 {
       
  1219                 iCmPluginBaseEng.SetStringAttributeL( 
       
  1220                         aDNS1ServAttribute, KDynamicIpv6Address );
       
  1221                 iCmPluginBaseEng.SetStringAttributeL( 
       
  1222                         aDNS2ServAttribute, KDynamicIpv6Address );               
       
  1223                 iCmPluginBaseEng.SetBoolAttributeL( 
       
  1224                         aDNSUsageAttribute, ETrue );
       
  1225                         
       
  1226                 update = ETrue;
       
  1227                 }
       
  1228                 break;
       
  1229 
       
  1230             case EIPv6UserDefined:                 
       
  1231                 {
       
  1232                 TInt err1;
       
  1233                 TInt err2;
       
  1234                 TBool cancelled(EFalse);
       
  1235                 do
       
  1236                     {
       
  1237                     // These has to be reset to KErrNone in case of
       
  1238                     // inputting an invalid address (DLAN-7FJD68). 
       
  1239                     err1 = KErrNone;
       
  1240                     err2 = KErrNone;
       
  1241              
       
  1242                     HBufC* dns1 = HBufC::NewLC( KMaxIPv6NameServerLength );
       
  1243                     HBufC* dns2 = HBufC::NewLC( KMaxIPv6NameServerLength );
       
  1244                     
       
  1245                     TPtr dns1ptr( dns1->Des() );
       
  1246                     TPtr dns2ptr( dns2->Des() );
       
  1247                     
       
  1248                     HBufC* temp = iCmPluginBaseEng.GetStringAttributeL(
       
  1249                                                 aDNS1ServAttribute );
       
  1250                     dns1ptr.Copy( *temp );
       
  1251                     delete temp; temp = NULL;
       
  1252                     
       
  1253                     temp = iCmPluginBaseEng.GetStringAttributeL( 
       
  1254                                                 aDNS2ServAttribute );
       
  1255                     dns2ptr.Copy( *temp );
       
  1256                     delete temp; temp = NULL;
       
  1257 
       
  1258                     // KDynamicIpv6Address is offered instead of empty string 
       
  1259                     if ( dns1ptr.Length() == 0 )
       
  1260                         { 
       
  1261                         dns1ptr = KDynamicIpv6Address;
       
  1262                         }
       
  1263                     if ( dns2ptr.Length() == 0 )
       
  1264                         { 
       
  1265                         dns2ptr = KDynamicIpv6Address;
       
  1266                         }
       
  1267 
       
  1268                         
       
  1269                     if ( ( dns1ptr.Compare( KKnownIp6NameServer1 ) == 0 ) && 
       
  1270                          ( dns2ptr.Compare( KKnownIp6NameServer2 ) == 0 ) )
       
  1271                         { // special value, well-known
       
  1272                         // in this case 'dynamic' string must be offered so 
       
  1273                         // temp data must be changed to 'dynamic'
       
  1274                         dns1ptr = KDynamicIpv6Address;
       
  1275                         dns2ptr = KDynamicIpv6Address;
       
  1276                         }
       
  1277 
       
  1278                     CCmPluginMultiLineDialog* ipquery = 
       
  1279                         CCmPluginMultiLineDialog::NewL( dns1ptr, 
       
  1280                                                         dns2ptr );
       
  1281 
       
  1282                     if ( ipquery->ExecuteLD( R_DNSIP6_QUERY ) )
       
  1283                         {
       
  1284                         TInetAddr dns1Addr;
       
  1285                         TInetAddr dns2Addr;
       
  1286 
       
  1287                         if ( dns1ptr.Compare( KNullDesC ) )
       
  1288                             {
       
  1289                             err1 = dns1Addr.Input( dns1ptr );
       
  1290                             }
       
  1291                         if ( dns2ptr.Compare( KNullDesC ) )
       
  1292                             {
       
  1293                             err2 = dns2Addr.Input( dns2ptr );
       
  1294                             }
       
  1295                         if ( err1 || err2 )
       
  1296                             {
       
  1297                             TCmCommonUi::ShowNoteL
       
  1298                                 ( R_QTN_SET_INFO_INVALID_IP,
       
  1299                                 TCmCommonUi::ECmErrorNote );
       
  1300                             }
       
  1301                         else
       
  1302                             {
       
  1303                             iCmPluginBaseEng.SetDNSServerAddressL( 
       
  1304                                                 aDNS1ServAttribute,
       
  1305                                                 dns1ptr,
       
  1306                                                 aDNS2ServAttribute, 
       
  1307                                                 dns2ptr,
       
  1308                                                 aDNSUsageAttribute,
       
  1309                                                 ETrue );
       
  1310 
       
  1311                             update = ETrue;
       
  1312                             }
       
  1313                         }
       
  1314                     else
       
  1315                         {
       
  1316                         cancelled = ETrue;
       
  1317                         }
       
  1318                     CleanupStack::PopAndDestroy( dns2 );
       
  1319                     CleanupStack::PopAndDestroy( dns1 );                            
       
  1320                     } while ( (err1 || err2) && (!cancelled) );
       
  1321                 break;
       
  1322                 }
       
  1323             default:
       
  1324                 {
       
  1325                 User::Leave( KErrNotSupported );
       
  1326                 }
       
  1327             }
       
  1328         }
       
  1329 
       
  1330     if( update )
       
  1331         {
       
  1332         UpdateListBoxContentL();
       
  1333         }
       
  1334                 
       
  1335     return selected;
       
  1336     }
       
  1337 
       
  1338 //---------------------------------------------------------------------------
       
  1339 // CmPluginBaseSettingsDlg::TitleId
       
  1340 //---------------------------------------------------------------------------
       
  1341 //
       
  1342 TUint32 CmPluginBaseSettingsDlg::TitleId( TUint32 aConvTitleId,
       
  1343                                           TUint32 aTitleId ) const
       
  1344     {
       
  1345     TUint32 titleId( 0 );
       
  1346     if ( aTitleId )
       
  1347         {
       
  1348         titleId = aTitleId;
       
  1349         }
       
  1350     else if ( !titleId )
       
  1351         {
       
  1352         titleId = aConvTitleId;
       
  1353         }
       
  1354         
       
  1355     return titleId;
       
  1356     }
       
  1357     
       
  1358 //---------------------------------------------------------------------------
       
  1359 // CmPluginBaseSettingsDlg::SetTitleL
       
  1360 //---------------------------------------------------------------------------
       
  1361 //
       
  1362 void CmPluginBaseSettingsDlg::SetTitleL( CAknSettingPage* aDlg,
       
  1363                                          TUint32 aConvTitleId,
       
  1364                                          TUint32 aTitleId ) const
       
  1365     {
       
  1366     TUint32 titleId( TitleId( aConvTitleId, aTitleId ) );
       
  1367         
       
  1368     if ( titleId )
       
  1369         {
       
  1370         HBufC* title = StringLoader::LoadLC( titleId );
       
  1371         aDlg->SetSettingTextL( *title );
       
  1372         CleanupStack::PopAndDestroy( title );
       
  1373         }
       
  1374     }
       
  1375     
       
  1376 //---------------------------------------------------------------------------
       
  1377 // CmPluginBaseSettingsDlg::EditorId
       
  1378 //---------------------------------------------------------------------------
       
  1379 //
       
  1380 TUint32 CmPluginBaseSettingsDlg::EditorId( TUint32 aConvEditorId,
       
  1381                                            TUint32 aEditorId ) const
       
  1382     {
       
  1383     TUint32 resId( 0 );
       
  1384     if ( aConvEditorId )
       
  1385         {
       
  1386         resId = aConvEditorId;
       
  1387         }
       
  1388     if ( !resId )
       
  1389         {
       
  1390         resId = aEditorId;
       
  1391         }
       
  1392 
       
  1393     return resId;
       
  1394     }
       
  1395     
       
  1396 // --------------------------------------------------------------------------
       
  1397 // CmPluginBaseSettingsDlg::GetIPv6DNSTypeL
       
  1398 // --------------------------------------------------------------------------
       
  1399 //
       
  1400 EXPORT_C TInt CmPluginBaseSettingsDlg::GetIPv6DNSTypeL( 
       
  1401                                                 TUint32 aDNS1ServAttribute,
       
  1402                                                 TUint32 aDNS2ServAttribute )
       
  1403     {
       
  1404     TIPv6Types retval( EIPv6UserDefined );
       
  1405 
       
  1406     HBufC* priServ = NULL;
       
  1407     priServ = iCmPluginBaseEng.GetStringAttributeL( aDNS1ServAttribute );
       
  1408     CleanupStack::PushL( priServ );
       
  1409     TPtr16 ptr1( priServ->Des() );
       
  1410        
       
  1411     HBufC* secServ = NULL;
       
  1412     secServ = iCmPluginBaseEng.GetStringAttributeL( aDNS2ServAttribute );
       
  1413     CleanupStack::PushL( secServ );
       
  1414     TPtr16 ptr2( secServ->Des() );
       
  1415     
       
  1416     // net type 6: if IspIPv6NameServ <> 0.0.0.0 
       
  1417     // => User defined OR well-known
       
  1418     
       
  1419     if ( ( !ptr1.Compare( KKnownIp6NameServer1 ) )
       
  1420         && ( !ptr2.Compare( KKnownIp6NameServer2 ) ) )
       
  1421         { // special value, well-known
       
  1422         retval = EIPv6WellKnown;
       
  1423         }
       
  1424     else
       
  1425         { 
       
  1426         // dynamic, if 0:0:...
       
  1427         // OR EMPTY text...
       
  1428         if ( ( ( !ptr1.Compare( KDynamicIpv6Address ) )
       
  1429                || ( !ptr1.Compare( KNullDesC ) ) )
       
  1430            &&( ( !ptr2.Compare( KDynamicIpv6Address ) ) 
       
  1431                ||( !ptr2.Compare( KDynamicIpv6Address ) ) ) )
       
  1432             { // dynamic, 0:0:...
       
  1433             retval = EIPv6Unspecified;
       
  1434             }
       
  1435         else
       
  1436             { // other value, user defined
       
  1437             retval = EIPv6UserDefined;
       
  1438             }
       
  1439         }
       
  1440 
       
  1441     CleanupStack::PopAndDestroy( 2, priServ );
       
  1442 
       
  1443     return retval;
       
  1444     }
       
  1445     
       
  1446 // --------------------------------------------------------------------------
       
  1447 // CmPluginBaseSettingsDlg::HandleResourceChange
       
  1448 // --------------------------------------------------------------------------
       
  1449 //
       
  1450 
       
  1451 EXPORT_C void CmPluginBaseSettingsDlg::HandleResourceChange( TInt aType )
       
  1452     {
       
  1453     CCoeControl::HandleResourceChange( aType ); 
       
  1454 
       
  1455     CAknDialog::HandleResourceChange(aType);
       
  1456 
       
  1457     if( aType == KEikDynamicLayoutVariantSwitch )
       
  1458         {
       
  1459         DrawNow(); 
       
  1460         }
       
  1461     }
       
  1462 
       
  1463 // --------------------------------------------------------------------------
       
  1464 // CmPluginBaseSettingsDlg::Execute
       
  1465 // --------------------------------------------------------------------------
       
  1466 //
       
  1467 EXPORT_C void CmPluginBaseSettingsDlg::Execute()
       
  1468     {
       
  1469     iProcessing = ETrue;
       
  1470     
       
  1471     TRAPD( err, ProcessCommandL( EAknSoftkeyChange ) );
       
  1472     if ( err )
       
  1473         {
       
  1474         HandleLeaveError( err );
       
  1475         }
       
  1476     iProcessing = EFalse;
       
  1477     }
       
  1478 
       
  1479 // --------------------------------------------------------------------------
       
  1480 // CmPluginBaseSettingsDlg::HandleLeaveError
       
  1481 // --------------------------------------------------------------------------
       
  1482 //
       
  1483 EXPORT_C void CmPluginBaseSettingsDlg::HandleLeaveError( TInt aError )
       
  1484 {
       
  1485     switch( aError )
       
  1486     {
       
  1487         case KLeaveWithoutAlert:
       
  1488         case KErrNoMemory:
       
  1489             // Indicate no memory to save setting changes
       
  1490             iIsPossibleToSaveSetting = EFalse;
       
  1491 
       
  1492             if (iProcessing)
       
  1493             {
       
  1494                 // Release processing protection so that the next processing can be done
       
  1495                 iProcessing = EFalse;
       
  1496             }
       
  1497             break;
       
  1498         default:
       
  1499             // More leave errors may be handled if necessary
       
  1500             // Now other leave errors are ignored here
       
  1501             break;
       
  1502     }
       
  1503 }