mobilemessaging/unieditor/application/src/UniSendingSettingsDialog.cpp
changeset 0 72b543305e3a
equal deleted inserted replaced
-1:000000000000 0:72b543305e3a
       
     1 /*
       
     2 * Copyright (c) 2006,2007 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:   Provides Uni Sending Settings Dialog methods.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include <barsread.h>
       
    22 //#include <mtclreg.h>
       
    23 
       
    24 #include <eiktxlbx.h>
       
    25 #include <aknnavi.h>
       
    26 #include <akntitle.h>
       
    27 #include <aknsettingpage.h>
       
    28 #include <aknradiobuttonsettingpage.h>
       
    29 #include <aknnotewrappers.h> 
       
    30 
       
    31 #include <StringLoader.h>
       
    32 
       
    33 #include <centralrepository.h>    // link against centralrepository.lib
       
    34 #include <messaginginternalcrkeys.h> // for Central Repository keys
       
    35 
       
    36 #include <mmsconst.h>
       
    37 
       
    38 // Features
       
    39 #include <featmgr.h>    
       
    40 #include <bldvariant.hrh>
       
    41 #include <messagingvariant.hrh>
       
    42 #include <csxhelp/unif.hlp.hrh>
       
    43 #include <hlplch.h>   // For HlpLauncher
       
    44 
       
    45 #include <UniEditor.rsg>
       
    46 #include "UniEditorApp.hrh"
       
    47 #include "UniSendingSettingsDialog.h"
       
    48 
       
    49 // CONSTANTS
       
    50 const TUid  KUniEditorAppId = { 0x102072D8 };
       
    51 
       
    52 // ---------------------------------------------------------
       
    53 // CUniSendingSettingsDialog
       
    54 // C++ constructor
       
    55 // ---------------------------------------------------------
       
    56 //
       
    57 CUniSendingSettingsDialog::CUniSendingSettingsDialog( TInt aSettingsFlags,
       
    58                                                       TUniSendingSettings& aSendingSettings,
       
    59                                                       TUniExitCode& aExitCode,
       
    60                                                       CAknTitlePane& aTitlePane ) :
       
    61     iTitlePane( aTitlePane ),
       
    62     iExitCode( aExitCode ),
       
    63     iSendingSettings( aSendingSettings ),
       
    64     iSettingsFlags( aSettingsFlags )
       
    65     {
       
    66     iExitCode = EUniExternalInterrupt; // reference -> cannot be initialized above
       
    67     }
       
    68 
       
    69 // ---------------------------------------------------------
       
    70 // ~CUniSendingSettingsDialog()
       
    71 // Destructor
       
    72 // ---------------------------------------------------------
       
    73 //
       
    74 CUniSendingSettingsDialog::~CUniSendingSettingsDialog()
       
    75     {
       
    76     delete iPreviousTitleText;
       
    77 
       
    78     // remove default navi pane
       
    79     if ( iNaviPane && 
       
    80          iSettingsDialogFlags & EDefaultNaviPane )
       
    81         {
       
    82         // if "EDefaultNaviPane" flag is set
       
    83         // iNaviPane != 0
       
    84         iNaviPane->Pop();
       
    85         }
       
    86     
       
    87     if ( iItems->MdcaCount() == 1 )
       
    88         {
       
    89 		/*
       
    90          * If MpMessagingHideMessageTypeId is set, then we must delete
       
    91          * iMuiuSettingsItemArray corresponding to message type array.
       
    92          * Message type array gets deleted from this dialog during
       
    93          * PreLayoutDynInitL, therefore array contained by 
       
    94          * message type array requires a clean-up here
       
    95          */
       
    96         if ( iSettingsFlags & EUniSettingsHideMessageTypeOption )
       
    97             {
       
    98             delete iMessageTypeSettings.iMuiuSettingsItemArray;
       
    99             }
       
   100         else
       
   101             {
       
   102             delete iCharacterSettings.iMuiuSettingsItemArray;
       
   103             }
       
   104         }
       
   105     
       
   106     // For lint
       
   107     iNaviPane = NULL;
       
   108     iItems = NULL;
       
   109     iListbox = NULL;
       
   110     }
       
   111 
       
   112 // ---------------------------------------------------------
       
   113 // CUniSendingSettingsDialog::ProcessCommandL
       
   114 // Processes menu item commands
       
   115 // ---------------------------------------------------------
       
   116 //
       
   117 void CUniSendingSettingsDialog::ProcessCommandL( TInt aCommandId ) 
       
   118     {
       
   119     CAknDialog::ProcessCommandL( aCommandId );
       
   120 
       
   121     switch ( aCommandId )
       
   122         {
       
   123         case EChangeItem:
       
   124             {
       
   125             HandleEditRequestL( iListbox->CurrentItemIndex(), EFalse );
       
   126             break;
       
   127             }
       
   128         case EAknCmdHelp:
       
   129             {
       
   130             LaunchHelpL();
       
   131             break;
       
   132             }
       
   133         case EExitItem:
       
   134             {
       
   135             ExitDialogL();
       
   136             break;
       
   137             }
       
   138         default:
       
   139             {
       
   140             break;
       
   141             }
       
   142         }
       
   143     }
       
   144 
       
   145 // ---------------------------------------------------------
       
   146 // CUniSendingSettingsDialog::ExitDialogL
       
   147 // ---------------------------------------------------------
       
   148 //
       
   149 void CUniSendingSettingsDialog::ExitDialogL()
       
   150     {
       
   151     // signal Editor of Exit
       
   152     iSendingSettings.iDialogExited = ETrue;
       
   153 
       
   154     iExitCode = EUniExit;
       
   155     TryExitL( EAknSoftkeyExit );
       
   156     }
       
   157         
       
   158 // ---------------------------------------------------------
       
   159 // CUniSendingSettingsDialog::OkToExitL
       
   160 // ---------------------------------------------------------
       
   161 //
       
   162 TBool CUniSendingSettingsDialog::OkToExitL( TInt aKeyCode )
       
   163     {
       
   164     switch ( aKeyCode )
       
   165         {
       
   166         case EUniCmdSettingsChange:
       
   167             { 
       
   168             // As all the softkey buttons come only to this function, MSK needs to handled here
       
   169             HandleEditRequestL( iListbox->CurrentItemIndex(), ETrue );
       
   170             return EFalse;
       
   171             }
       
   172         case EAknSoftkeyCancel:
       
   173         case EAknSoftkeyBack:
       
   174             {
       
   175             // If exit wanted during back operation
       
   176             iSettingsDialogFlags &= ~EExitSelected;
       
   177             ClosingDialogL();
       
   178             
       
   179             if( iSettingsDialogFlags & ESwitchToExit )
       
   180                 {
       
   181                 iExitCode = EUniExit;
       
   182                 }
       
   183             else//normal back
       
   184                 {
       
   185                 iExitCode = EUniBack;
       
   186                 }
       
   187                     
       
   188             return ETrue;
       
   189             }
       
   190         default :
       
   191             {
       
   192             return CAknDialog::OkToExitL( aKeyCode );
       
   193             }
       
   194         }
       
   195     }
       
   196 
       
   197 // ---------------------------------------------------------
       
   198 // CUniSendingSettingsDialog::PreLayoutDynInitL
       
   199 // Creates a listbox for the settings.
       
   200 // Values are read from the resource file.
       
   201 // ---------------------------------------------------------
       
   202 //
       
   203 void CUniSendingSettingsDialog::PreLayoutDynInitL()
       
   204     {
       
   205     // Get supported features from feature manager.
       
   206     FeatureManager::InitializeLibL();
       
   207     if ( FeatureManager::FeatureSupported( KFeatureIdHelp ) )
       
   208         {
       
   209         iSettingsDialogFlags |= EHelpFeatureSupported;
       
   210         }
       
   211     FeatureManager::UnInitializeLib();
       
   212 
       
   213     SetTitleTextL();
       
   214 
       
   215     // Get listbox pointer
       
   216     iListbox = static_cast<CEikTextListBox*>( Control( EDlgSettingListBox ) );
       
   217     iListbox->SetListBoxObserver( this );
       
   218     
       
   219     // Sets correct size for the listbox    
       
   220     iListbox->SetRect( iAvkonAppUi->ClientRect() );
       
   221     
       
   222     // Read&store the current values to listbox items.
       
   223     TInt itemsResId = R_UNI_SENDINGSETTINGS_ITEMS;
       
   224     
       
   225     iItems = CMuiuSettingsArray::NewL( itemsResId );
       
   226     
       
   227     iCharacterSettings = iItems->At( EUniSendingSettingsCharSupport );
       
   228     /*
       
   229      * If MpMessagingHideMessageTypeId is set, we need to
       
   230      * delete the settings from message type array.
       
   231      * We will need to manually clean up the items contained
       
   232      * by message type array in the destructor since we are deleting
       
   233      * message type array here */
       
   234     iMessageTypeSettings = iItems->At( EUniSendingSettingsMessageType );
       
   235     if ( iSettingsFlags & EUniSettingsHideMessageTypeOption )
       
   236         {
       
   237         iItems->Delete( EUniSendingSettingsMessageType );
       
   238         }
       
   239     
       
   240     if( ( iSettingsFlags & EUniSettingsContentNeedsMms &&
       
   241           !( iSettingsFlags & EUniSettingsPermanentSms ) ) ||
       
   242         iSettingsFlags & EUniSettingsPermanentMms || 
       
   243         iSettingsFlags & EUniSettingsHideCharSet ||
       
   244         iSendingSettings.iMessageType == TUniSendingSettings::EUniMessageTypeMultimedia )
       
   245         {
       
   246         // CharSupport is not shown when we are dealing with MMS messages
       
   247         // or when the charSet is locked
       
   248         iItems->Delete( EUniSendingSettingsCharSupport );
       
   249         }
       
   250     
       
   251     GetSendingSettingsValues();
       
   252 
       
   253     // scroll bars
       
   254     iListbox->CreateScrollBarFrameL( ETrue );
       
   255     iListbox->ScrollBarFrame()->SetScrollBarVisibilityL( CEikScrollBarFrame::EOff, 
       
   256                                                          CEikScrollBarFrame::EAuto );
       
   257 
       
   258     // replace navi pane with empty one.
       
   259     iNaviPane = static_cast<CAknNavigationControlContainer*>
       
   260         ( iEikonEnv->AppUiFactory()->StatusPane()->ControlL( TUid::Uid(EEikStatusPaneUidNavi) ) );
       
   261         
       
   262     iNaviPane->PushDefaultL();
       
   263     iSettingsDialogFlags |= EDefaultNaviPane;
       
   264 
       
   265     CTextListBoxModel* model = iListbox->Model();
       
   266     model->SetItemTextArray( iItems );
       
   267     model->SetOwnershipType( ELbmOwnsItemArray );
       
   268     UpdateMskL();
       
   269     }
       
   270 
       
   271 // ---------------------------------------------------------
       
   272 // CUniSendingSettingsDialog::ClosingDialogL
       
   273 // ---------------------------------------------------------
       
   274 //
       
   275 TBool CUniSendingSettingsDialog::ClosingDialogL()
       
   276     {
       
   277     // Replace title with old title text
       
   278     if ( !( iSettingsDialogFlags & EGoingToExit ) )
       
   279         {
       
   280         iTitlePane.SetTextL( *iPreviousTitleText );
       
   281         }
       
   282     return EFalse;
       
   283     }
       
   284 
       
   285 // ---------------------------------------------------------
       
   286 // CUniSendingSettingsDialog::GetSendingSettingsValues
       
   287 // Gets the values for the uni message settings and puts them in
       
   288 // to the listbox. Text strings are from loc files.
       
   289 // ---------------------------------------------------------
       
   290 //
       
   291 void CUniSendingSettingsDialog::GetSendingSettingsValues()
       
   292     {
       
   293     TInt index = 0;
       
   294     /*
       
   295      * Set up the Message Type item only if the 
       
   296      * MpMessagingHideMessageTypeId feature flag is not set
       
   297      * Note: This is the default/existing case */
       
   298     if ( ! ( iSettingsFlags & EUniSettingsHideMessageTypeOption ) )
       
   299         {
       
   300         TInt currentItem = iSendingSettings.iMessageType;
       
   301         
       
   302         SetArrayItem( index, currentItem );
       
   303         }
       
   304     if( !( ( iSettingsFlags &  EUniSettingsContentNeedsMms &&
       
   305              !( iSettingsFlags & EUniSettingsPermanentSms ) ) || 
       
   306             ( iSettingsFlags & EUniSettingsPermanentMms ) ||
       
   307             ( iSettingsFlags & EUniSettingsHideCharSet ) ||
       
   308               iSendingSettings.iMessageType == TUniSendingSettings::EUniMessageTypeMultimedia ) )
       
   309         { 
       
   310         // Show CharSupport when not in MMS mode
       
   311         /*
       
   312          * Change the index only if we are also displaying
       
   313          * Message Type.
       
   314          */
       
   315         if ( ! ( iSettingsFlags & EUniSettingsHideMessageTypeOption ) )
       
   316             {
       
   317             index = EUniSendingSettingsCharSupport;
       
   318             }
       
   319 
       
   320         switch ( iSendingSettings.iCharSupport )
       
   321             {
       
   322             case TUniSendingSettings::EUniCharSupportFull:
       
   323                 {
       
   324                 SetArrayItem( index, EUniSettingsCharSupportFull );
       
   325                 break;
       
   326                 }
       
   327             case TUniSendingSettings::EUniCharSupportReduced:
       
   328             default:
       
   329                 {
       
   330                 SetArrayItem( index, EUniSettingsCharSupportReduced );
       
   331                 break;
       
   332                 }
       
   333             }
       
   334         }
       
   335     }
       
   336 
       
   337 // ---------------------------------------------------------
       
   338 // CUniSendingSettingsDialog::SetArrayItem
       
   339 // Updates indexed item of listbox
       
   340 // ---------------------------------------------------------
       
   341 //
       
   342 void CUniSendingSettingsDialog::SetArrayItem( TInt aIndex, TInt aCurrentNumber )
       
   343     {
       
   344     /*
       
   345      * Instead of using hardcoded number to do bounds checking
       
   346      * use the number of items in the array
       
   347      */
       
   348     if( aIndex < 0 || aIndex >= iItems->MdcaCount() )
       
   349         { // Item is invisible so just return
       
   350         return;
       
   351         }
       
   352         
       
   353     iItems->At( aIndex ).iUserText.Copy(
       
   354         ( *iItems->At( aIndex ).iMuiuSettingsItemArray )[aCurrentNumber]);
       
   355     ( *iItems )[aIndex].iCurrentNumber = aCurrentNumber;
       
   356     }
       
   357 
       
   358 // ---------------------------------------------------------
       
   359 // CUniSendingSettingsDialog::SetArrayItem
       
   360 // Updates indexed item of listbox - user text formatted by the caller
       
   361 // ---------------------------------------------------------
       
   362 //
       
   363 void CUniSendingSettingsDialog::SetArrayItem( TInt aIndex, 
       
   364                                               TInt aCurrentNumber, 
       
   365                                               const TDesC& aUserText)
       
   366     {
       
   367     if( aIndex < 0 )
       
   368         {
       
   369         return;
       
   370         }
       
   371         
       
   372     iItems->At( aIndex ).iUserText.Copy( aUserText );
       
   373     ( *iItems )[aIndex].iCurrentNumber = aCurrentNumber;
       
   374     }
       
   375 
       
   376 // ---------------------------------------------------------
       
   377 // CUniSendingSettingsDialog::HandleListBoxEventL
       
   378 // Handles listbox event
       
   379 // ---------------------------------------------------------
       
   380 //
       
   381 void CUniSendingSettingsDialog::HandleListBoxEventL( CEikListBox* /* aListBox */, 
       
   382                                                      TListBoxEvent aEventType )
       
   383     {
       
   384     switch ( aEventType )
       
   385         {
       
   386         case EEventEnterKeyPressed:
       
   387         case EEventItemSingleClicked:
       
   388             {
       
   389             HandleEditRequestL( iListbox->CurrentItemIndex(), ETrue );
       
   390             break;
       
   391             }
       
   392         default:
       
   393             {
       
   394             break;
       
   395             }
       
   396         }
       
   397     }
       
   398 
       
   399 // ---------------------------------------------------------
       
   400 // CUniSendingSettingsDialog::DynInitMenuPaneL
       
   401 // ---------------------------------------------------------
       
   402 //
       
   403 void CUniSendingSettingsDialog::DynInitMenuPaneL( TInt aMenuId, 
       
   404                                                   CEikMenuPane* aMenuPane )
       
   405     {
       
   406     switch ( aMenuId )
       
   407         {
       
   408         case R_UNI_SENDINGSETTINGS_DIALOG_MENUPANE:
       
   409             {
       
   410             aMenuPane->SetItemDimmed( EAknCmdHelp, !( iSettingsDialogFlags & EHelpFeatureSupported ) );
       
   411             break;
       
   412             }
       
   413         default:
       
   414             {
       
   415             break;
       
   416             }
       
   417         };
       
   418     }
       
   419 
       
   420 // ---------------------------------------------------------
       
   421 // CUniSendingSettingsDialog::OfferKeyEventL
       
   422 // Handles listbox event
       
   423 // ---------------------------------------------------------
       
   424 //
       
   425 TKeyResponse CUniSendingSettingsDialog::OfferKeyEventL( const TKeyEvent& aKeyEvent, 
       
   426                                                         TEventCode aType )
       
   427     {
       
   428     TKeyResponse ret = CAknDialog::OfferKeyEventL( aKeyEvent, aType );
       
   429 
       
   430     if( aType == EEventKeyUp )
       
   431         {
       
   432         UpdateMskL();
       
   433         }
       
   434 
       
   435     if ( iSettingsDialogFlags & EShouldExit ) 
       
   436         {
       
   437         iExitCode = EUniExit;
       
   438         TryExitL( EAknSoftkeyCancel );
       
   439         }
       
   440 
       
   441     return ret;
       
   442     }
       
   443 
       
   444 // ---------------------------------------------------------
       
   445 // CUniSendingSettingsDialog::HandleEditRequestL
       
   446 // Handles editing of a selected setting
       
   447 // ---------------------------------------------------------
       
   448 //
       
   449 void CUniSendingSettingsDialog::HandleEditRequestL( TInt aIndex, TBool aEnterPressed )
       
   450     {
       
   451     /*
       
   452      * Instead of switching on hard coded index values and
       
   453      * calling methods based on index values, we now call
       
   454      * the function based on the item itself.
       
   455      * Search the settings array to find the index of 
       
   456      * Message Type and Character Support, and call
       
   457      * the appropriate method.
       
   458      */
       
   459     TKeyArrayFix actNumKey( 0, ECmpTInt );
       
   460     TInt characterIndex = -1;
       
   461     TInt messagetypeIndex = -1;
       
   462     
       
   463     iItems->Find( iCharacterSettings, actNumKey, characterIndex );
       
   464     iItems->Find( iMessageTypeSettings, actNumKey, messagetypeIndex );
       
   465     
       
   466     if( messagetypeIndex == aIndex )
       
   467         {
       
   468         EditMessageTypeL();
       
   469         }
       
   470     else if( characterIndex == aIndex )
       
   471         {
       
   472         EditCharacterSupportL( aEnterPressed );
       
   473         }
       
   474         
       
   475     iListbox->DrawItem( aIndex );
       
   476     }
       
   477 
       
   478 // ---------------------------------------------------------
       
   479 // CUniSendingSettingsDialog::EditMessageTypeL
       
   480 // ---------------------------------------------------------
       
   481 //
       
   482 void CUniSendingSettingsDialog::EditMessageTypeL()
       
   483     {
       
   484     TResourceReader reader;
       
   485     iEikonEnv->CreateResourceReaderLC( reader, R_UNI_SETTING_MESSAGE_TYPE_LIST );
       
   486     
       
   487     CDesCArrayFlat* items = new ( ELeave ) CDesCArrayFlat( KSettingsGranularity );
       
   488     CleanupStack::PushL( items );
       
   489     
       
   490     CArrayFixFlat<TInt>* itemIds = new ( ELeave ) CArrayFixFlat<TInt>( KSettingsGranularity );
       
   491     CleanupStack::PushL( itemIds );
       
   492     
       
   493     // Get the labels from resources
       
   494     const TInt count = reader.ReadInt16();
       
   495     
       
   496     for ( TInt loop = 0; loop < count; loop++ )
       
   497         {
       
   498         HBufC* label = reader.ReadHBufCL();
       
   499         
       
   500         TBool addLabel( ETrue );
       
   501         switch( loop )
       
   502             {
       
   503             case EUniSettingsMessageTypeAutomatic:
       
   504                 {
       
   505                 if ( iSettingsFlags & EUniSettingsPermanentSms ||
       
   506                      iSettingsFlags & EUniSettingsPermanentMms )
       
   507                     {
       
   508                     // Delete automatic if it's permanent SMS or MMS
       
   509                     addLabel = EFalse;
       
   510                     }
       
   511                 break;
       
   512                 }
       
   513             case EUniSettingsMessageTypeText:
       
   514                 {
       
   515                 if ( ( iSettingsFlags & EUniSettingsContentNeedsMms &&
       
   516                        !( iSettingsFlags & EUniSettingsPermanentSms ) ) ||
       
   517                      iSettingsFlags & EUniSettingsPermanentMms )
       
   518                     {
       
   519                     // Delete text if it's permanent MMS or content is MMS and
       
   520                     // we are not on permanently locked SMS mode.
       
   521                     addLabel = EFalse;
       
   522                     }
       
   523                 break;
       
   524                 }
       
   525             case EUniSettingsMessageTypeMultimedia:
       
   526                 {
       
   527                 if ( iSettingsFlags & EUniSettingsPermanentSms )
       
   528                     {
       
   529                     // Delete multimedia if it's permanent SMS
       
   530                     addLabel = EFalse;
       
   531                     }
       
   532                 break;
       
   533                 }
       
   534             case EUniSettingsMessageTypeFax:
       
   535             case EUniSettingsMessageTypePaging:
       
   536                 {
       
   537                 if ( ( iSettingsFlags & EUniSettingsContentNeedsMms &&
       
   538                        !( iSettingsFlags & EUniSettingsPermanentSms ) ) ||
       
   539                      iSettingsFlags & EUniSettingsPermanentMms ||
       
   540                      iSettingsFlags & EUniSettingsCSPBitsOn )
       
   541                     {
       
   542                     // Delete fax/paging if it's permanent MMS or content is MMS
       
   543                     // or CSP bits deny conversion
       
   544                     addLabel = EFalse;
       
   545                     }
       
   546                 break;
       
   547                 }
       
   548             default:
       
   549                 {
       
   550                 break;
       
   551                 }
       
   552             }
       
   553         
       
   554         if ( addLabel )
       
   555             {
       
   556             TPtr pLabel = label->Des();
       
   557             AknTextUtils::DisplayTextLanguageSpecificNumberConversion( pLabel );
       
   558             
       
   559             CleanupStack::PushL( label );
       
   560             items->AppendL( pLabel );
       
   561             CleanupStack::PopAndDestroy( label );           
       
   562             
       
   563             itemIds->AppendL( loop );
       
   564             }
       
   565         else
       
   566             {
       
   567             delete label;
       
   568             }
       
   569         }
       
   570     
       
   571     // Map the stored message type to current item index.
       
   572     TInt currentItem = 0;
       
   573     TBool matchFound( EFalse );
       
   574     const TBool hideMessageType = iSettingsFlags & EUniSettingsHideMessageTypeOption;
       
   575     while( !matchFound )
       
   576         {
       
   577         if ( currentItem == itemIds->Count() )
       
   578             {
       
   579             currentItem = 0;
       
   580             matchFound = ETrue;
       
   581             }
       
   582         else if ( hideMessageType && itemIds->At( currentItem ) == iSendingSettings.iCharSupport )
       
   583             {
       
   584             matchFound = ETrue;
       
   585             }
       
   586         else if ( !hideMessageType && itemIds->At( currentItem ) == iSendingSettings.iMessageType )
       
   587             {
       
   588             matchFound = ETrue;
       
   589             }
       
   590         else
       
   591             {
       
   592             currentItem++;
       
   593             }
       
   594         }
       
   595 
       
   596     if ( ExecuteSettingsPageDialogL( items, 
       
   597                                      currentItem, 
       
   598                                      iItems->At( EUniSendingSettingsMessageType ).iLabelText ) )
       
   599         {
       
   600         switch ( itemIds->At( currentItem ) )
       
   601             {
       
   602             case EUniSettingsMessageTypeAutomatic:
       
   603                 {
       
   604                 SetMessageTypeL( TUniSendingSettings::EUniMessageTypeAutomatic );
       
   605                 break;
       
   606                 }
       
   607             case EUniSettingsMessageTypeText:
       
   608                 {
       
   609                 SetMessageTypeL( TUniSendingSettings::EUniMessageTypeText );
       
   610                 break;
       
   611                 }
       
   612             case EUniSettingsMessageTypeMultimedia:
       
   613                 {
       
   614                 SetMessageTypeL( TUniSendingSettings::EUniMessageTypeMultimedia );
       
   615                 break;
       
   616                 }
       
   617             case EUniSettingsMessageTypeFax:
       
   618                 {
       
   619                 SetMessageTypeL( TUniSendingSettings::EUniMessageTypeFax );
       
   620                 break;
       
   621                 }
       
   622             case EUniSettingsMessageTypePaging:
       
   623                 {
       
   624                 SetMessageTypeL( TUniSendingSettings::EUniMessageTypePaging );
       
   625                 break;
       
   626                 }
       
   627             default:
       
   628                 {
       
   629                 break;
       
   630                 }
       
   631             }
       
   632         
       
   633         SetArrayItem( 0, itemIds->At( currentItem ) );
       
   634         CEikFormattedCellListBox* settingListBox =
       
   635             static_cast<CEikFormattedCellListBox*>( Control( EDlgSettingListBox ) );
       
   636                     
       
   637         if ( iSendingSettings.iMessageType == TUniSendingSettings::EUniMessageTypeMultimedia ||
       
   638              ( iSendingSettings.iMessageType == TUniSendingSettings::EUniMessageTypeAutomatic && 
       
   639                iSettingsFlags & EUniSettingsContentNeedsMms ) )
       
   640             {
       
   641             if ( iItems->MdcaCount() == 2 )
       
   642                 {
       
   643                 iItems->Delete( EUniSendingSettingsCharSupport );
       
   644                 settingListBox->HandleItemRemovalL();
       
   645                 }
       
   646             }
       
   647         else
       
   648             {
       
   649             if ( iItems->MdcaCount() == 1 &&
       
   650                  !( iSettingsFlags & EUniSettingsHideCharSet ) )
       
   651                 {
       
   652                 iItems->InsertL( EUniSendingSettingsCharSupport, iCharacterSettings );
       
   653                 settingListBox->HandleItemAdditionL();
       
   654                 
       
   655                 SetArrayItem( EUniSendingSettingsCharSupport, iSendingSettings.iCharSupport );
       
   656                 }
       
   657             }
       
   658             
       
   659         settingListBox->DrawNow();
       
   660         }
       
   661     
       
   662     CleanupStack::PopAndDestroy( 3 ); // itemIds, items & reader 
       
   663     }
       
   664     
       
   665 // ---------------------------------------------------------
       
   666 // CUniSendingSettingsDialog::SetMessageTypeL
       
   667 // ---------------------------------------------------------
       
   668 //
       
   669 void CUniSendingSettingsDialog::SetMessageTypeL( TInt aMessageType )
       
   670     {
       
   671     iSendingSettings.iMessageType = (TUniSendingSettings::TUniMessageType)aMessageType;
       
   672     }
       
   673     
       
   674 // ---------------------------------------------------------
       
   675 // CUniSendingSettingsDialog::EditCharacterSupportL
       
   676 // ---------------------------------------------------------
       
   677 //
       
   678 void CUniSendingSettingsDialog::EditCharacterSupportL( TBool aEnterPressed )
       
   679     {
       
   680     TInt currentItem = iSendingSettings.iCharSupport;
       
   681     TBool isOk = EFalse;
       
   682 
       
   683     if ( aEnterPressed )
       
   684         {
       
   685         currentItem ^= 1;
       
   686         }
       
   687     else
       
   688         {
       
   689         TResourceReader reader;
       
   690         iEikonEnv->CreateResourceReaderLC( reader, R_UNI_SETTING_CHARACTER_SUPPORT_LIST );
       
   691         
       
   692         CDesCArrayFlat* items = new ( ELeave ) CDesCArrayFlat( KSettingsGranularity );
       
   693         CleanupStack::PushL( items );
       
   694         
       
   695         // Get the labels from resources
       
   696         const TInt count = reader.ReadInt16();
       
   697 
       
   698         for ( TInt loop = 0; loop < count; loop++ )
       
   699             {
       
   700             HBufC* label = reader.ReadHBufCL();
       
   701             TPtr pLabel = label->Des();
       
   702             
       
   703             AknTextUtils::DisplayTextLanguageSpecificNumberConversion( pLabel );
       
   704             
       
   705             CleanupStack::PushL( label );
       
   706             items->AppendL( pLabel );
       
   707             CleanupStack::PopAndDestroy( label );           
       
   708             }
       
   709         
       
   710         /*
       
   711          * Instead of using hard coded index value, use the current
       
   712          * index value
       
   713          */ 
       
   714         isOk = ExecuteSettingsPageDialogL( items, 
       
   715                                            currentItem, 
       
   716                                            iItems->At( iListbox->CurrentItemIndex() ).iLabelText );
       
   717         
       
   718         CleanupStack::PopAndDestroy( 2 ); //items & reader 
       
   719         }
       
   720 
       
   721     if( isOk || aEnterPressed )
       
   722         {
       
   723         switch ( currentItem )
       
   724             {
       
   725             case EUniSettingsCharSupportFull:
       
   726                 {
       
   727                 SetCharacterSupportL( TUniSendingSettings::EUniCharSupportFull );
       
   728                 break;
       
   729                 }
       
   730             case EUniSettingsCharSupportReduced:
       
   731             default:
       
   732                 {
       
   733                 SetCharacterSupportL( TUniSendingSettings::EUniCharSupportReduced );
       
   734                 break;
       
   735                 }
       
   736             }
       
   737         /*
       
   738          * Instead of using hardcoded value for index, use
       
   739          * the last index of the array
       
   740          */
       
   741         SetArrayItem( iItems->MdcaCount()-1, currentItem );
       
   742         CEikFormattedCellListBox* settingListBox =
       
   743             static_cast<CEikFormattedCellListBox*>( Control( EDlgSettingListBox ) );
       
   744         settingListBox->DrawNow();
       
   745         }
       
   746     }
       
   747     
       
   748 // ---------------------------------------------------------
       
   749 // CUniSendingSettingsDialog::SetCharacterSupportL
       
   750 // ---------------------------------------------------------
       
   751 //
       
   752 void CUniSendingSettingsDialog::SetCharacterSupportL( TInt aCharSetSupport )
       
   753     {
       
   754     iSendingSettings.iCharSupport = (TUniSendingSettings::TUniCharSupport)aCharSetSupport;    
       
   755     }
       
   756     
       
   757 // ---------------------------------------------------------
       
   758 // CUniSendingSettingsDialog::SetTitleTextL
       
   759 // Makes the status pane
       
   760 // ---------------------------------------------------------
       
   761 //
       
   762 void CUniSendingSettingsDialog::SetTitleTextL()
       
   763     {   
       
   764     //save old title
       
   765     iPreviousTitleText = iTitlePane.Text()->Alloc();
       
   766         
       
   767     // set new title
       
   768     HBufC* text = StringLoader::LoadLC( R_UNI_SETTINGS_TITLE_TEXT );
       
   769 
       
   770     iTitlePane.SetTextL( *text );
       
   771     CleanupStack::PopAndDestroy(); // text
       
   772     }
       
   773 
       
   774 // ---------------------------------------------------------
       
   775 // CUniSendingSettingsDialog::LaunchHelpL
       
   776 // launch help using context
       
   777 // ---------------------------------------------------------
       
   778 //
       
   779 void CUniSendingSettingsDialog::LaunchHelpL()
       
   780     {
       
   781     if ( iSettingsDialogFlags & EHelpFeatureSupported )
       
   782         {
       
   783         CCoeAppUi* editorAppUi = static_cast<CCoeAppUi*>( ControlEnv()->AppUi() );
       
   784       
       
   785         CArrayFix<TCoeHelpContext>* helpContext = editorAppUi->AppHelpContextL();   
       
   786         HlpLauncher::LaunchHelpApplicationL( iEikonEnv->WsSession(), helpContext );
       
   787         }
       
   788     }
       
   789 
       
   790 // ---------------------------------------------------------
       
   791 // CUniSendingSettingsDialog::GetHelpContext
       
   792 // returns helpcontext as aContext
       
   793 // ---------------------------------------------------------
       
   794 //
       
   795 void CUniSendingSettingsDialog::GetHelpContext( TCoeHelpContext& aContext ) const
       
   796     {
       
   797     if ( iSettingsDialogFlags & EHelpFeatureSupported )
       
   798         {
       
   799         aContext.iMajor = KUniEditorAppId; 
       
   800         aContext.iContext = KUNIFIED_HLP_SENDING_OPTIONS;
       
   801         }
       
   802     }
       
   803 
       
   804 // ---------------------------------------------------------
       
   805 // CUniSendingSettingsDialog::ShowInformationNoteL
       
   806 // ---------------------------------------------------------
       
   807 //
       
   808 void CUniSendingSettingsDialog::ShowInformationNoteL( TInt aResourceId )
       
   809     {
       
   810     CAknInformationNote* note = new ( ELeave ) CAknInformationNote( ETrue );
       
   811     HBufC* string = StringLoader::LoadLC( aResourceId );
       
   812     note->ExecuteLD( *string );
       
   813     CleanupStack::PopAndDestroy(); //string
       
   814     }
       
   815 
       
   816 // ---------------------------------------------------------
       
   817 // CUniSendingSettingsDialog::UpdateMskL
       
   818 // ---------------------------------------------------------
       
   819 //
       
   820 void CUniSendingSettingsDialog::UpdateMskL()
       
   821     {
       
   822     // Leaving this function here in case there might be different MSKs in future
       
   823     TInt resId = R_UNI_MSK_SETTINGS_BUTTON_CHANGE;    
       
   824     CEikButtonGroupContainer& cba = ButtonGroupContainer();
       
   825     const TInt KMskPosition = 3;
       
   826     cba.SetCommandL( KMskPosition, resId );
       
   827     cba.DrawDeferred();
       
   828     }
       
   829 
       
   830 // ---------------------------------------------------------
       
   831 // CUniSendingSettingsDialog::ExecuteSettingsPageDialogL
       
   832 // ---------------------------------------------------------
       
   833 //
       
   834 TBool CUniSendingSettingsDialog::ExecuteSettingsPageDialogL( CDesCArrayFlat* aItems, 
       
   835                                                              TInt& aCurrentItem,
       
   836                                                              const TDesC& aLabelText )
       
   837     {
       
   838     CAknRadioButtonSettingPage* dlg = new ( ELeave ) CAknRadioButtonSettingPage( R_UNI_SETTING_PAGE, 
       
   839                                                                                  aCurrentItem, 
       
   840                                                                                  aItems );
       
   841     CleanupStack::PushL( dlg );
       
   842     
       
   843     dlg->SetSettingTextL( aLabelText );
       
   844     
       
   845     CleanupStack::Pop( dlg );
       
   846     
       
   847     return dlg->ExecuteLD( CAknSettingPage::EUpdateWhenChanged );
       
   848     }
       
   849 
       
   850 //  End of File