mobilemessaging/mmsui/settingssrc/MmsSettingsDialog.cpp
changeset 0 72b543305e3a
equal deleted inserted replaced
-1:000000000000 0:72b543305e3a
       
     1 /*
       
     2 * Copyright (c) 2002-2004 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:  
       
    15 *       Provides MMS Settings Dialog methods.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 // INCLUDE FILES
       
    22 #include <barsread.h>
       
    23 #include <mtclreg.h>
       
    24 
       
    25 #include <eiktxlbx.h>
       
    26 #include <aknnavi.h>
       
    27 #include <akntitle.h>
       
    28 #include <aknsettingpage.h>
       
    29 #include <aknradiobuttonsettingpage.h>
       
    30 #include <aknnotewrappers.h> 
       
    31 
       
    32 #include <mmssettings.h> // MMS Engine settings
       
    33 
       
    34 #include <MmsSettings.rsg>
       
    35 #include <mmssettingsdefs.h>    // image size definitions
       
    36 
       
    37 #include <ApSettingsHandlerUI.h>
       
    38 #include <ApSettingsHandlerCommons.h>
       
    39 #include <ApEngineConsts.h>
       
    40 #include <ApUtils.h>
       
    41 #include <ApDataHandler.h>
       
    42 #include <ApAccessPointItem.h>
       
    43 #include <ApSelect.h> //CApSelect
       
    44 
       
    45 #include <muiusettingsarray.h>
       
    46 #include <StringLoader.h>
       
    47 
       
    48 #include <centralrepository.h>    // link against centralrepository.lib
       
    49 #include <messaginginternalcrkeys.h> // for Central Repository keys
       
    50 
       
    51 #include <mmsclient.h>
       
    52 #include <mmsconst.h>
       
    53 
       
    54 // Features
       
    55 #include <featmgr.h>    
       
    56 #include <bldvariant.hrh>
       
    57 #include <messagingvariant.hrh>
       
    58 #include <csxhelp/mce.hlp.hrh>
       
    59 #include <hlplch.h>   // For HlpLauncher
       
    60 
       
    61 #include "unieditorfeatures.h"  // EUniFeaturePriority
       
    62 
       
    63 #include "MmsMtmConst.h" 
       
    64 
       
    65 #include "MmsApSelect.h"
       
    66 #include "MmsSettingsDialog.h"
       
    67 #include "MmsSettingsPanic.h"
       
    68 #include "MmsSettings.hrh"
       
    69 
       
    70 // CONSTANTS
       
    71 
       
    72 const TUid KUidMce = {0x100058C5};
       
    73 
       
    74 // Possible values for mms validity period in seconds
       
    75 const TInt32 KMmsValidityPeriod1h = 3600;
       
    76 const TInt32 KMmsValidityPeriod6h = 21600;
       
    77 const TInt32 KMmsValidityPeriod24h = 86400;
       
    78 const TInt32 KMmsValidityPeriod3Days = 259200;
       
    79 const TInt32 KMmsValidityPeriodWeek = 604800;
       
    80 const TInt32 KMmsValidityPeriodMax = 0;
       
    81 
       
    82 
       
    83 // ---------------------------------------------------------
       
    84 // CMmsSettingsDialog
       
    85 // C++ constructor
       
    86 // ---------------------------------------------------------
       
    87 //
       
    88 CMmsSettingsDialog::CMmsSettingsDialog(
       
    89     //CMmsClientMtm *aClientMtm,
       
    90     CMmsSettings* aMmsSettings,
       
    91     TMmsExitCode& aExitCode ) :
       
    92     //iMmsClient( aClientMtm ),
       
    93     iMmsSettings( aMmsSettings ),
       
    94     iExitCode( aExitCode ),
       
    95     iSettingsFlags( 0 )
       
    96     {
       
    97     iExitCode = EMmsExternalInterrupt; // reference -> cannot be initialized above
       
    98     }
       
    99 
       
   100 
       
   101 // ---------------------------------------------------------
       
   102 // ~CMmsSettingsDialog()
       
   103 // Destructor
       
   104 // ---------------------------------------------------------
       
   105 //
       
   106 CMmsSettingsDialog::~CMmsSettingsDialog()
       
   107     {
       
   108     delete iPreviousTitleText;
       
   109     delete iCommsDb;
       
   110 
       
   111     // remove default navi pane
       
   112     if (    iSettingsFlags & EDefaultNaviPane )
       
   113         {
       
   114         if ( iNaviPane )
       
   115             {                    
       
   116             // if "EDefaultNaviPane" flag is set
       
   117             // iNaviPane != 0
       
   118             iNaviPane->Pop(NULL);
       
   119             }
       
   120         }
       
   121 
       
   122     // For lint
       
   123     iNaviPane = NULL;
       
   124     iItems = NULL;
       
   125     //iMmsClient = NULL;
       
   126     iMmsSettings = NULL;
       
   127     iTitlePane = NULL;
       
   128     iListbox = NULL;
       
   129     }
       
   130 
       
   131 
       
   132 // ---------------------------------------------------------
       
   133 // CMmsSettingsDialog::ProcessCommandL
       
   134 //
       
   135 // Processes menu item commands
       
   136 // ---------------------------------------------------------
       
   137 //
       
   138 void CMmsSettingsDialog::ProcessCommandL( TInt aCommandId ) 
       
   139     {
       
   140     CAknDialog::ProcessCommandL( aCommandId );
       
   141 
       
   142     switch ( aCommandId )
       
   143         {
       
   144         case EChangeItem:
       
   145             HandleEditRequestL( iListbox->CurrentItemIndex(), EFalse );
       
   146             break;
       
   147 
       
   148         case EAknCmdHelp:
       
   149             {
       
   150             LaunchHelpL();                
       
   151             }
       
   152             break;
       
   153 
       
   154         case EExitItem:            
       
   155             ExitDialogL();
       
   156             break;
       
   157         default:
       
   158             break;
       
   159         }
       
   160     }
       
   161 
       
   162 
       
   163 // ---------------------------------------------------------
       
   164 // CMmsSettingsDialog::ExitDialogL()
       
   165 //
       
   166 // ---------------------------------------------------------
       
   167 //
       
   168 void CMmsSettingsDialog::ExitDialogL()
       
   169     {
       
   170     iExitCode = EMmsExit;
       
   171     TryExitL( EAknSoftkeyCancel );
       
   172     }
       
   173         
       
   174 
       
   175 // ---------------------------------------------------------
       
   176 // DynInitMenuPaneL(TInt aMenuId, CEikMenuPane* aMenuPane)
       
   177 //  Initializes items on the menu
       
   178 // ---------------------------------------------------------
       
   179 //
       
   180 void CMmsSettingsDialog::DynInitMenuPaneL(
       
   181     TInt aMenuId, 
       
   182     CEikMenuPane* aMenuPane)
       
   183     {
       
   184     if (    aMenuPane
       
   185         &&  aMenuId == R_SETTINGSDIALOG_MENUPANE )
       
   186         {
       
   187         // Set help menu-item visibility according featureManager
       
   188         if ( ! ( iSettingsFlags & EHelpFeatureSupported ) )
       
   189             {
       
   190             aMenuPane->SetItemDimmed( EAknCmdHelp, ETrue );
       
   191             }
       
   192         }
       
   193     }
       
   194 
       
   195     
       
   196 // ---------------------------------------------------------
       
   197 // CMmsSettingsDialog::OkToExitL
       
   198 //
       
   199 // ---------------------------------------------------------
       
   200 //
       
   201 TBool CMmsSettingsDialog::OkToExitL( TInt aKeyCode )
       
   202     {
       
   203     switch ( aKeyCode )
       
   204         {
       
   205         case EChangeItem:
       
   206             HandleEditRequestL( iListbox->CurrentItemIndex(), ETrue );
       
   207             return EFalse;
       
   208            
       
   209         case EAknSoftkeyCancel:
       
   210             {
       
   211             iSettingsFlags |= EExitSelected;
       
   212             iSettingsFlags |= EGoingToExit;
       
   213             if ( ClosingDialogL() )
       
   214                 {
       
   215                 iExitCode = EMmsExit;
       
   216                 }
       
   217             else
       
   218                 {
       
   219                 iExitCode = EMmsExitWithSave;
       
   220                 }
       
   221 
       
   222             return ETrue;
       
   223             }
       
   224         case EAknSoftkeyBack:
       
   225             {
       
   226             iSettingsFlags &= ~EExitSelected;
       
   227             ClosingDialogL();
       
   228 
       
   229             //if exit wanted during back operation
       
   230             if( iSettingsFlags & ESwitchToExit )
       
   231                 {
       
   232                 iExitCode = EMmsExit;
       
   233                 }
       
   234             else//normal back
       
   235                 {
       
   236                 iExitCode = EMmsBack;
       
   237                 }
       
   238 
       
   239             // Replace title with old title text
       
   240             if ( iPreviousTitleText  )
       
   241                 {
       
   242                 iTitlePane->SetTextL( *iPreviousTitleText );
       
   243                 }
       
   244             return ETrue;
       
   245             }
       
   246         default :
       
   247             return CAknDialog::OkToExitL( aKeyCode );
       
   248         }
       
   249    
       
   250     }
       
   251 
       
   252 
       
   253 // ---------------------------------------------------------
       
   254 // CMmsSettingsDialog::CheckAndCorrectAccessPointL()
       
   255 //
       
   256 // Checks the access point as a part of closing dialog
       
   257 // (back / exit). AP must exist.
       
   258 // ---------------------------------------------------------
       
   259 //
       
   260 TBool CMmsSettingsDialog::CheckAndCorrectAccessPointL()
       
   261     {
       
   262     TInt32 ap = iMmsSettings->AccessPoint( 0 );
       
   263 
       
   264     CApUtils* apUtils = CApUtils::NewLC(*iCommsDb);
       
   265     
       
   266     // Access point is compulsory
       
   267     TBool closingWithErrors = EFalse;   // ETrue if user wants to close down even with errors
       
   268     while ( !ApExistsL( apUtils, ap ) )
       
   269         {
       
   270         // Do not save if exit with errors
       
   271         if ( iSettingsFlags & EExitSelected )
       
   272             {
       
   273             closingWithErrors = ETrue;
       
   274             }
       
   275         else
       
   276             {
       
   277             closingWithErrors = ShowExitAnywayQueryL();
       
   278             }
       
   279 
       
   280         if ( closingWithErrors )
       
   281             {
       
   282             break;
       
   283             }
       
   284         //if user selects exit in ap dialog, we will exit.
       
   285         if ( EditAccessPointL() )
       
   286             {
       
   287             //when we return, this tells that we are exiting.
       
   288             iSettingsFlags |= ESwitchToExit;
       
   289             break;
       
   290             }
       
   291         ap = iMmsSettings->AccessPoint( 0 );
       
   292         }
       
   293     CleanupStack::PopAndDestroy(); // apUtils
       
   294     return closingWithErrors;
       
   295     }
       
   296 
       
   297 
       
   298 // ---------------------------------------------------------
       
   299 // CMmsSettingsDialog::ShowExitAnywayQueryL() const
       
   300 //
       
   301 // ---------------------------------------------------------
       
   302 //
       
   303 TBool CMmsSettingsDialog::ShowExitAnywayQueryL() const
       
   304     {
       
   305     CAknQueryDialog* confirmQuery = CAknQueryDialog::NewL();
       
   306     return ( confirmQuery->ExecuteLD( R_MMSUI_QUERY_EXIT_ANYWAY ) );
       
   307     }
       
   308 
       
   309 
       
   310 // ---------------------------------------------------------
       
   311 // CMmsSettingsDialog::ApExistsL(CApUtils* aUtils, TUint32 aAP) const
       
   312 // Checks whether or not given AP exists
       
   313 //
       
   314 // ---------------------------------------------------------
       
   315 //
       
   316 TBool CMmsSettingsDialog::ApExistsL( CApUtils* aUtils, TInt32 aAP ) const
       
   317     {
       
   318     if ( aAP == KErrNotFound )
       
   319         {
       
   320         return EFalse;
       
   321         }
       
   322     TBool exists = EFalse;
       
   323     TRAPD( error, ( exists = aUtils->WapApExistsL( aAP ) ) );
       
   324     if ( exists )
       
   325         {
       
   326         return ETrue;
       
   327         }
       
   328     // we are only handling "not found" leave
       
   329     if ( error != KErrNotFound )
       
   330         {
       
   331         User::LeaveIfError( error );
       
   332         }
       
   333     return EFalse;
       
   334     }
       
   335 
       
   336 
       
   337 // ---------------------------------------------------------
       
   338 // CMmsSettingsDialog::PreLayoutDynInitL()
       
   339 //
       
   340 // Creates a listbox for the settings.
       
   341 // Values are read from the resource file.
       
   342 //
       
   343 // ---------------------------------------------------------
       
   344 //
       
   345 void CMmsSettingsDialog::PreLayoutDynInitL()
       
   346     {
       
   347 
       
   348     // Get supported features from feature manager.
       
   349     FeatureManager::InitializeLibL();
       
   350     if ( FeatureManager::FeatureSupported( KFeatureIdHelp ) )
       
   351         {
       
   352         iSettingsFlags |= EHelpFeatureSupported;
       
   353         }
       
   354     FeatureManager::UnInitializeLib();
       
   355 
       
   356     TInt featureBitmask = 0;
       
   357     CRepository* repository = CRepository::NewL( KCRUidMmsui );
       
   358     repository->Get( KMmsuiCsdEnabled, featureBitmask );
       
   359     if ( featureBitmask )
       
   360         {
       
   361         iSettingsFlags |= ECSDEnabled;
       
   362         }
       
   363     delete repository;
       
   364     repository = NULL;
       
   365     featureBitmask = 0;
       
   366 
       
   367     repository = CRepository::NewL( KCRUidMuiuVariation );
       
   368     repository->Get( KMuiuMmsFeatures, featureBitmask );
       
   369     delete repository;
       
   370     repository = NULL;
       
   371     if ( featureBitmask & KMmsFeatureIdUserCreationMode )
       
   372         {
       
   373         iSettingsFlags |= ECreationModeChangeEnabled;
       
   374         }
       
   375     if ( featureBitmask & KMmsFeatureIdHideReceivingOff )
       
   376         {
       
   377         iSettingsFlags |= EReceivingOffDisabled;
       
   378         }
       
   379     if ( featureBitmask & KMmsFeatureIdHideManualFetchMode )
       
   380         {
       
   381         iSettingsFlags |= EReceivingAlwaysManualDisabled;
       
   382         }
       
   383     if ( featureBitmask & KMmsFeatureIdHideAutomaticAtHome )
       
   384         {
       
   385         iSettingsFlags |= EReceivingAutomaticHomeDisabled;
       
   386         }
       
   387 
       
   388     SetTitleTextL();
       
   389 
       
   390     iCommsDb = CCommsDatabase::NewL( EDatabaseTypeIAP );
       
   391 
       
   392     // Get listbox pointer
       
   393     iListbox = static_cast<CEikTextListBox*>( Control( EDlgSettingListBox ) );
       
   394     iListbox->SetListBoxObserver( this );
       
   395     
       
   396 
       
   397     // Sets correct size for the listbox    
       
   398     iListbox->SetRect( iAvkonAppUi->ClientRect() );
       
   399     
       
   400     iItems = CMuiuSettingsArray::NewL( R_MMS_SERVICE_SETTINGS_LIST );
       
   401     GetServiceSettingsValuesL();
       
   402 
       
   403     // scroll bars
       
   404     iListbox->CreateScrollBarFrameL( ETrue );
       
   405     iListbox->ScrollBarFrame()->SetScrollBarVisibilityL( 
       
   406         CEikScrollBarFrame::EOff, 
       
   407         CEikScrollBarFrame::EAuto
       
   408         );
       
   409 
       
   410     // replace navi pane with empty one.
       
   411     iNaviPane = static_cast<CAknNavigationControlContainer*>
       
   412         ( iEikonEnv->AppUiFactory()->StatusPane()->ControlL(
       
   413             TUid::Uid(EEikStatusPaneUidNavi) ) );
       
   414     iNaviPane->PushDefaultL();
       
   415     iSettingsFlags |= EDefaultNaviPane;
       
   416 
       
   417     CTextListBoxModel* model = iListbox->Model();
       
   418     model->SetItemTextArray( iItems );
       
   419     }
       
   420 
       
   421 
       
   422 // ---------------------------------------------------------
       
   423 // CMmsSettingsDialog::ClosingDialogL
       
   424 //
       
   425 // ---------------------------------------------------------
       
   426 //
       
   427 TBool CMmsSettingsDialog::ClosingDialogL()
       
   428     {
       
   429     //if user selects exit or outside exit occurs, no ap checks are made.
       
   430     return CheckAndCorrectAccessPointL();
       
   431     }
       
   432 
       
   433 // ---------------------------------------------------------
       
   434 // CMmsSettingsDialog::GetServiceSettingsValuesL
       
   435 // Gets the values for the mms service settings and puts them in
       
   436 // to the listbox. Text strings are from loc files.
       
   437 //
       
   438 // ---------------------------------------------------------
       
   439 //
       
   440 void CMmsSettingsDialog::GetServiceSettingsValuesL()
       
   441     {
       
   442     // Access point
       
   443     TInt32 ap = iMmsSettings->AccessPoint( 0 );
       
   444     TBuf<KCommsDbSvrMaxFieldLength> apName;
       
   445 
       
   446     GetNameForApL( ap, apName );
       
   447     SetArrayItem( EMmsSettingsAccessPoint, static_cast<TInt>( ap ), apName );
       
   448 
       
   449     TInt fetchHome = iMmsSettings->ReceivingModeHome();
       
   450     TInt fetchRoam = iMmsSettings->ReceivingModeForeign();
       
   451 
       
   452     // if default value is not acceptable, choose next by keeping costs low
       
   453     if ( fetchHome == EMmsReceivingAutomatic &&
       
   454         fetchRoam == EMmsReceivingAutomatic )
       
   455         {
       
   456         SetArrayItem( EMmsSettingsReceivingMode,
       
   457                       EMmsSettingsReceivingAutomaticAlways );
       
   458         }
       
   459     else if ( fetchHome == EMmsReceivingManual &&
       
   460             fetchRoam == EMmsReceivingManual )
       
   461         {
       
   462         if ( ! ( iSettingsFlags & EReceivingAlwaysManualDisabled ) )
       
   463             {
       
   464             SetArrayItem(   EMmsSettingsReceivingMode,
       
   465                             EMmsSettingsReceivingManualAlways );
       
   466             }
       
   467         else
       
   468             {
       
   469             if ( ! ( iSettingsFlags & EReceivingAutomaticHomeDisabled ) )
       
   470                 {    
       
   471                 SetArrayItem(   EMmsSettingsReceivingMode,
       
   472                                 EMmsSettingsReceivingAutomaticHome );
       
   473                 }
       
   474             else if ( ! ( iSettingsFlags & EReceivingOffDisabled ) )
       
   475                 {
       
   476                 SetArrayItem(   EMmsSettingsReceivingMode,
       
   477                                 EMmsSettingsReceivingDisabledAlways );
       
   478                 }
       
   479             else
       
   480                 {
       
   481                 SetArrayItem( EMmsSettingsReceivingMode,
       
   482                               EMmsSettingsReceivingAutomaticAlways );
       
   483                 }
       
   484             }
       
   485         }
       
   486     else if ( fetchHome == EMmsReceivingReject &&
       
   487         fetchRoam == EMmsReceivingReject )
       
   488         {
       
   489         if ( ! ( iSettingsFlags & EReceivingOffDisabled ) )
       
   490             {
       
   491             SetArrayItem( EMmsSettingsReceivingMode,
       
   492               EMmsSettingsReceivingDisabledAlways );
       
   493             }
       
   494         else
       
   495             {
       
   496             if ( ! ( iSettingsFlags & EReceivingAlwaysManualDisabled ) )
       
   497                 {
       
   498                 SetArrayItem(   EMmsSettingsReceivingMode,
       
   499                                 EMmsSettingsReceivingManualAlways );
       
   500                 }
       
   501             else if ( ! ( iSettingsFlags & EReceivingAutomaticHomeDisabled ) )
       
   502                 {    
       
   503                 SetArrayItem(   EMmsSettingsReceivingMode,
       
   504                                 EMmsSettingsReceivingAutomaticHome );
       
   505                 }
       
   506             else
       
   507                 {
       
   508                 SetArrayItem( EMmsSettingsReceivingMode,
       
   509                               EMmsSettingsReceivingAutomaticAlways );
       
   510                 }
       
   511             }
       
   512         }
       
   513     else
       
   514         {
       
   515         // Should always be automatic@home & manaul@roam
       
   516         if ( ! ( iSettingsFlags & EReceivingAutomaticHomeDisabled ) )
       
   517             {    
       
   518             SetArrayItem(   EMmsSettingsReceivingMode,
       
   519                             EMmsSettingsReceivingAutomaticHome );
       
   520             }
       
   521         else
       
   522             {
       
   523             if ( ! ( iSettingsFlags & EReceivingAlwaysManualDisabled ) )
       
   524                 {
       
   525                 SetArrayItem(   EMmsSettingsReceivingMode,
       
   526                                 EMmsSettingsReceivingManualAlways );
       
   527                 }
       
   528             else if ( ! ( iSettingsFlags & EReceivingOffDisabled ) )
       
   529                 {
       
   530                 SetArrayItem(   EMmsSettingsReceivingMode,
       
   531                                 EMmsSettingsReceivingDisabledAlways );
       
   532                 }
       
   533             else
       
   534                 {
       
   535                 SetArrayItem( EMmsSettingsReceivingMode,
       
   536                               EMmsSettingsReceivingAutomaticAlways );
       
   537                 }
       
   538             }
       
   539         }
       
   540 
       
   541     // Receiving anonymous messages
       
   542     if ( iMmsSettings->AcceptAnonymousMessages() )    
       
   543         {
       
   544         SetArrayItem( EMmsSettingsReceivingAnonymous, EMmsSettingsYes );
       
   545         }
       
   546     else
       
   547         {
       
   548         SetArrayItem( EMmsSettingsReceivingAnonymous, EMmsSettingsNo );
       
   549         }
       
   550 
       
   551     
       
   552     // Receiving ads
       
   553     if ( iMmsSettings->AcceptAdvertisementMessages() )
       
   554         {
       
   555         SetArrayItem( EMmsSettingsReceivingAds, EMmsSettingsYes );
       
   556         }
       
   557     else
       
   558         {
       
   559         SetArrayItem( EMmsSettingsReceivingAds, EMmsSettingsNo );
       
   560         }
       
   561 
       
   562     // Receive report
       
   563     TBool deliveryReport = ( iMmsSettings->DeliveryReportWanted() == EMmsYes );
       
   564     if ( deliveryReport && iMmsSettings->ReadReplyReportWanted() == EMmsYes  )
       
   565         {
       
   566         SetArrayItem( EMmsSettingsReceiveReport, EMmsSettingsReceiveReportBoth );
       
   567         }
       
   568     else if ( deliveryReport )
       
   569         {
       
   570         SetArrayItem( EMmsSettingsReceiveReport, EMmsSettingsReceiveReportDelivery );
       
   571         }
       
   572     else // read report only is not supported 
       
   573         {
       
   574         SetArrayItem( EMmsSettingsReceiveReport, EMmsSettingsReceiveReportNone );
       
   575         }
       
   576 
       
   577     // Delivery report sending allowed and read report sending has both their own
       
   578     // attribute. Writing the value takes care that both have same value.
       
   579     // Read here only delivery report sending allowed attribute.
       
   580     if ( iMmsSettings->DeliveryReportSendingAllowed() == EMmsDeliveryReportAllowedYes )
       
   581         {
       
   582         SetArrayItem( EMmsSettingsDenyDeliveryReport, EMmsSettingsNo );
       
   583         }
       
   584     else
       
   585         {
       
   586         SetArrayItem( EMmsSettingsDenyDeliveryReport, EMmsSettingsYes );
       
   587         }
       
   588 
       
   589     // Validity period
       
   590     switch ( iMmsSettings->ExpiryInterval() )
       
   591         {
       
   592         case KMmsValidityPeriod1h:
       
   593             SetArrayItem( EMmsSettingsValidityPeriod, EMmsSettingsValidityPeriod1h );
       
   594             break;
       
   595         case KMmsValidityPeriod6h:
       
   596             SetArrayItem( EMmsSettingsValidityPeriod, EMmsSettingsValidityPeriod6h );
       
   597             break;
       
   598         case KMmsValidityPeriod24h:
       
   599             SetArrayItem( EMmsSettingsValidityPeriod, EMmsSettingsValidityPeriod24h );
       
   600             break;
       
   601         case KMmsValidityPeriod3Days:
       
   602             SetArrayItem( EMmsSettingsValidityPeriod, EMmsSettingsValidityPeriod3d );
       
   603             break;
       
   604         case KMmsValidityPeriodWeek:
       
   605             SetArrayItem( EMmsSettingsValidityPeriod, EMmsSettingsValidityPeriodWeek );
       
   606             break;
       
   607         case KMmsValidityPeriodMax:
       
   608         default: // default to max
       
   609             SetArrayItem( EMmsSettingsValidityPeriod, EMmsSettingsValidityPeriodMaximum );
       
   610             break;
       
   611         }
       
   612 
       
   613     // Image size
       
   614     TInt32 imageWidth = iMmsSettings->ImageWidth();
       
   615     TInt32 imageHeight = iMmsSettings->ImageHeight();
       
   616 
       
   617     if ( imageWidth == KMmsUniImageLargeWidth && imageHeight == KMmsUniImageLargeHeight )
       
   618         {
       
   619         SetArrayItem( EMmsSettingsImageSize, EMmsSettingsImageLarge );
       
   620         }
       
   621     else
       
   622         {
       
   623         SetArrayItem( EMmsSettingsImageSize, EMmsSettingsImageSmall );
       
   624         }
       
   625 
       
   626     SetArrayItem( EMmsSettingsCreationMode, GetCreationMode() );
       
   627 
       
   628     }
       
   629 
       
   630 
       
   631 // ---------------------------------------------------------
       
   632 // CMmsSettingsDialog::SetArrayItem(TInt aIndex, TInt aCurrentNumber)
       
   633 // Updates indexed item of listbox
       
   634 //
       
   635 // ---------------------------------------------------------
       
   636 //
       
   637 void CMmsSettingsDialog::SetArrayItem( TInt aIndex, TInt aCurrentNumber )
       
   638     {
       
   639     iItems->At( aIndex ).iUserText.Copy(
       
   640         ( *iItems->At( aIndex ).iMuiuSettingsItemArray )[aCurrentNumber]);
       
   641     ( *iItems )[aIndex].iCurrentNumber = aCurrentNumber;
       
   642     }
       
   643 
       
   644 
       
   645 // ---------------------------------------------------------
       
   646 // CMmsSettingsDialog::SetArrayItem(TInt aIndex, TInt aCurrentNumber, const TDesC& aUserText)
       
   647 // Updates indexed item of listbox - user text formatted by the caller
       
   648 //
       
   649 // ---------------------------------------------------------
       
   650 //
       
   651 void CMmsSettingsDialog::SetArrayItem(TInt aIndex, TInt aCurrentNumber, const TDesC& aUserText)
       
   652     {
       
   653     iItems->At( aIndex ).iUserText.Copy( aUserText );
       
   654     ( *iItems )[aIndex].iCurrentNumber = aCurrentNumber;
       
   655     }
       
   656 
       
   657 
       
   658 // ---------------------------------------------------------
       
   659 // CMmsSettingsDialog::HandleListBoxEventL(CEikListBox* aListBox, TListBoxEvent aEventType)
       
   660 // Handles listbox event
       
   661 //
       
   662 // ---------------------------------------------------------
       
   663 //
       
   664 void CMmsSettingsDialog::HandleListBoxEventL( CEikListBox* /* aListBox */, 
       
   665                                              TListBoxEvent aEventType )
       
   666     {
       
   667     switch ( aEventType )
       
   668         {
       
   669         case EEventEnterKeyPressed:
       
   670         case EEventItemSingleClicked:
       
   671             HandleEditRequestL( iListbox->CurrentItemIndex(), ETrue );
       
   672             break;
       
   673         default:
       
   674             break;
       
   675         }
       
   676 
       
   677     }
       
   678 
       
   679 
       
   680 // ---------------------------------------------------------
       
   681 // CMmsSettingsDialog::HandleListBoxEventL(CEikListBox* aListBox, TListBoxEvent aEventType)
       
   682 // Handles listbox event
       
   683 //
       
   684 // ---------------------------------------------------------
       
   685 //
       
   686 TKeyResponse CMmsSettingsDialog::OfferKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType )
       
   687     {
       
   688     TBool isDestructed( EFalse );
       
   689     if (    aType ==EEventKey
       
   690         &&  aKeyEvent.iCode == EKeyEscape )
       
   691         {
       
   692         isDestructed = ETrue;
       
   693         }
       
   694     
       
   695     TKeyResponse ret = CAknDialog::OfferKeyEventL( aKeyEvent, aType );
       
   696 
       
   697     if (    !isDestructed
       
   698         &&  iSettingsFlags & EShouldExit ) 
       
   699         {
       
   700         iExitCode = EMmsExit;
       
   701         TryExitL( EAknSoftkeyCancel );
       
   702         }
       
   703 
       
   704     return ret;
       
   705     }
       
   706 
       
   707 // ---------------------------------------------------------
       
   708 // CMmsSettingsDialog::HandleEditRequestL(TInt aIndex, TBool aEnterPressed)
       
   709 // Handles editing of a selected setting
       
   710 //
       
   711 // ---------------------------------------------------------
       
   712 //
       
   713 void CMmsSettingsDialog::HandleEditRequestL( TInt aIndex, TBool aEnterPressed )
       
   714     {
       
   715     switch ( aIndex )
       
   716         {
       
   717         case EMmsSettingsAccessPoint:
       
   718             if ( EditAccessPointL() )
       
   719                 {
       
   720                 // Cannot exit directly here - we are in the middle of HandleListBoxEvent
       
   721                 // Real exit is activated in OfferKeyEventL()
       
   722                 iSettingsFlags |= EShouldExit;
       
   723                 iExitCode = EMmsExit;
       
   724                 }
       
   725             break;
       
   726         case EMmsSettingsReceivingMode:
       
   727             EditReceivingModeL();
       
   728             break;
       
   729         case EMmsSettingsReceivingAnonymous:
       
   730             EditReceivingAnonymousL( aEnterPressed );
       
   731             break;
       
   732         case EMmsSettingsReceivingAds:
       
   733             EditReceivingAdsL( aEnterPressed );
       
   734             break;
       
   735         case EMmsSettingsReceiveReport:
       
   736             EditReceiveReportsL( );
       
   737             break;
       
   738         case EMmsSettingsDenyDeliveryReport:
       
   739             EditDenySendingDeliveryReportsL( aEnterPressed );
       
   740             break;
       
   741         case EMmsSettingsValidityPeriod:
       
   742             EditValidityPeriodL();
       
   743             break;
       
   744         case EMmsSettingsImageSize:
       
   745             EditImageSizeL( aEnterPressed );
       
   746             break;
       
   747         case EMmsSettingsCreationMode:     
       
   748             EditCreationModeL( aEnterPressed );
       
   749             break;
       
   750         default:
       
   751             __ASSERT_DEBUG( EFalse, Panic( EMmsSettingsWrongParameters ) );
       
   752             break;
       
   753         } // switch
       
   754     iListbox->DrawItem( aIndex );
       
   755     }
       
   756 
       
   757 
       
   758 // ---------------------------------------------------------
       
   759 // CMmsSettingsDialog::SetAndGetSettingItemL(TInt& aCurrentItem, TUint aList, TInt aItem)
       
   760 // Sets the ui for the setting item and returns true if item selection
       
   761 // is accepted. Selected value is passed as a parameter.
       
   762 //
       
   763 // ---------------------------------------------------------
       
   764 //
       
   765 TBool CMmsSettingsDialog::SetAndGetSettingItemL( TInt& aCurrentItem, 
       
   766                                                 TInt aList, 
       
   767                                                 TInt aItem)
       
   768     {
       
   769     TBool isOk = EFalse;
       
   770     TResourceReader reader;
       
   771     iEikonEnv->CreateResourceReaderLC( reader, aList );
       
   772     
       
   773     CDesCArrayFlat* items = new ( ELeave ) CDesCArrayFlat( KSettingsGranularity );
       
   774     CleanupStack::PushL( items );
       
   775     
       
   776     // Get the labels from resources
       
   777     const TInt count = reader.ReadInt16();
       
   778 
       
   779     for ( TInt loop = 0; loop < count; loop++ )
       
   780         {
       
   781         HBufC* label = reader.ReadHBufCL();
       
   782         if ( ( aList == R_RECEIVING_MMS_LIST && ( iSettingsFlags & EReceivingAlwaysManualDisabled ) && loop == EMmsSettingsReceivingManualAlways ) ||
       
   783             ( aList == R_RECEIVING_MMS_LIST && ( iSettingsFlags & EReceivingOffDisabled ) && loop == EMmsSettingsReceivingDisabledAlways ) ||
       
   784             ( aList == R_RECEIVING_MMS_LIST && ( iSettingsFlags & EReceivingAutomaticHomeDisabled ) && loop == EMmsSettingsReceivingAutomaticHome ) ||
       
   785             ( aList == R_MMS_IMAGE_SIZE_LIST && iMmsSettings->CreationMode() == EMmsCreationModeRestricted && loop == EMmsSettingsImageLarge ) )
       
   786             {
       
   787             delete label;
       
   788             }
       
   789         else
       
   790             {
       
   791             CleanupStack::PushL( label );
       
   792             TPtr pLabel = label->Des();
       
   793             AknTextUtils::DisplayTextLanguageSpecificNumberConversion( pLabel );
       
   794             items->AppendL( pLabel );
       
   795             CleanupStack::PopAndDestroy( label );
       
   796             }
       
   797         label = NULL;
       
   798         }
       
   799     
       
   800     if ( aList == R_RECEIVING_MMS_LIST )
       
   801         {
       
   802         // 3. removed, update 4
       
   803         if (    ( iSettingsFlags & EReceivingAlwaysManualDisabled ) 
       
   804             &&  aCurrentItem == EMmsSettingsReceivingDisabledAlways )
       
   805             {
       
   806             aCurrentItem--;
       
   807             }
       
   808         // 2. removed, update 3 & 4
       
   809         if (    ( iSettingsFlags & EReceivingAutomaticHomeDisabled ) 
       
   810             &&  aCurrentItem >= EMmsSettingsReceivingAutomaticHome )
       
   811             {
       
   812             // Adjust the index for every setting that comes after AutomaticAtHome when it is hidden
       
   813             aCurrentItem--;
       
   814             }
       
   815         }
       
   816 
       
   817     CAknRadioButtonSettingPage* dlg = new ( ELeave ) CAknRadioButtonSettingPage(
       
   818         R_MMS_SETTING_PAGE, 
       
   819         aCurrentItem, 
       
   820         items );
       
   821 
       
   822     dlg->SetSettingTextL( iItems->At( aItem ).iLabelText );
       
   823     if ( dlg->ExecuteLD( CAknSettingPage::EUpdateWhenChanged ) ) 
       
   824         {
       
   825         // Adjust the index back after the user has made the selection
       
   826         if ( aList == R_RECEIVING_MMS_LIST )
       
   827             {
       
   828             // 2. removed, update 3 & 4
       
   829             if (    ( iSettingsFlags & EReceivingAutomaticHomeDisabled ) 
       
   830                 &&  aCurrentItem >= EMmsSettingsReceivingAutomaticHome )
       
   831                 {
       
   832                 // Adjust the index for every setting that comes after AutomaticAtHome when it is hidden
       
   833                 aCurrentItem++;
       
   834                 }
       
   835 
       
   836             // 3. removed, update 4
       
   837             if (    ( iSettingsFlags & EReceivingAlwaysManualDisabled ) 
       
   838                 &&  aCurrentItem >= EMmsSettingsReceivingManualAlways )
       
   839                 {
       
   840                 
       
   841                 aCurrentItem++;
       
   842                 }
       
   843             }
       
   844 
       
   845         isOk = ETrue;
       
   846         }
       
   847     
       
   848     CleanupStack::PopAndDestroy( 2 ); //items & reader 
       
   849 
       
   850     return isOk;
       
   851     }
       
   852 
       
   853 // ---------------------------------------------------------
       
   854 // CMmsSettingsDialog::EditReceivingModeL()
       
   855 // ---------------------------------------------------------
       
   856 //
       
   857 void CMmsSettingsDialog::EditReceivingModeL()
       
   858     {
       
   859     TInt currentItem = iItems->At( EMmsSettingsReceivingMode ).iCurrentNumber;
       
   860 
       
   861     if ( SetAndGetSettingItemL(
       
   862             currentItem,
       
   863             R_RECEIVING_MMS_LIST,
       
   864             EMmsSettingsReceivingMode ) )
       
   865         {
       
   866         switch ( currentItem )
       
   867             {
       
   868             case EMmsSettingsReceivingAutomaticHome:
       
   869                 {
       
   870                 iMmsSettings->SetReceivingModeHome( EMmsReceivingAutomatic );
       
   871                 iMmsSettings->SetReceivingModeForeign( EMmsReceivingManual );
       
   872                 break;
       
   873                 }
       
   874             case EMmsSettingsReceivingAutomaticAlways:
       
   875                 iMmsSettings->SetReceivingModeHome( EMmsReceivingAutomatic );
       
   876                 iMmsSettings->SetReceivingModeForeign( EMmsReceivingAutomatic );
       
   877                 break;
       
   878             case EMmsSettingsReceivingManualAlways:
       
   879                 {
       
   880                 iMmsSettings->SetReceivingModeHome( EMmsReceivingManual );
       
   881                 iMmsSettings->SetReceivingModeForeign( EMmsReceivingManual );
       
   882                 break;
       
   883                 }
       
   884             case EMmsSettingsReceivingDisabledAlways:
       
   885                 iMmsSettings->SetReceivingModeHome( EMmsReceivingReject );
       
   886                 iMmsSettings->SetReceivingModeForeign( EMmsReceivingReject );
       
   887                 break;
       
   888             default:
       
   889                 break;
       
   890             }
       
   891         //to be sure that we have the selected item  
       
   892         iItems->At( EMmsSettingsReceivingMode ).iCurrentNumber = currentItem; 
       
   893         
       
   894         SetArrayItem( EMmsSettingsReceivingMode, currentItem );
       
   895         }
       
   896     }
       
   897 
       
   898 
       
   899 // ---------------------------------------------------------
       
   900 // CMmsSettingsDialog::EditReceivingAnonymousL
       
   901 // Edits the value for receiving anonymous messages.
       
   902 //
       
   903 // ---------------------------------------------------------
       
   904 //
       
   905 void CMmsSettingsDialog::EditReceivingAnonymousL( TBool aEnterPressed )
       
   906     {
       
   907     TBool isOk = EFalse;
       
   908     TInt currentItem = iItems->At( EMmsSettingsReceivingAnonymous ).iCurrentNumber;
       
   909     if ( aEnterPressed )
       
   910         {
       
   911         currentItem ^= 1;
       
   912         }
       
   913     else
       
   914         {
       
   915         isOk = SetAndGetSettingItemL( 
       
   916             currentItem, 
       
   917             R_MMS_YES_NO_LIST, 
       
   918             EMmsSettingsReceivingAnonymous );
       
   919         }
       
   920         
       
   921     if ( aEnterPressed || isOk )
       
   922         {
       
   923         switch ( currentItem )
       
   924             {
       
   925             case EMmsSettingsNo:
       
   926                 iMmsSettings->SetAcceptAnonymousMessages( EFalse );
       
   927                 break;
       
   928             case EMmsSettingsYes: // flow through
       
   929             default:
       
   930                 iMmsSettings->SetAcceptAnonymousMessages( ETrue );
       
   931                 break;
       
   932             }
       
   933         SetArrayItem( EMmsSettingsReceivingAnonymous, currentItem );
       
   934         CEikFormattedCellListBox* settingListBox =
       
   935             static_cast<CEikFormattedCellListBox*>( Control(EDlgSettingListBox ) );
       
   936         settingListBox->DrawNow();
       
   937         }                   
       
   938     }
       
   939 
       
   940 
       
   941 // ---------------------------------------------------------
       
   942 // CMmsSettingsDialog::EditReceivingAdsL
       
   943 // Edits the value for receiving advertisements
       
   944 //
       
   945 // ---------------------------------------------------------
       
   946 //
       
   947 void CMmsSettingsDialog::EditReceivingAdsL( TBool aEnterPressed )
       
   948     {
       
   949     TBool isOk = EFalse;
       
   950     TInt currentItem = iItems->At( EMmsSettingsReceivingAds ).iCurrentNumber;
       
   951     if ( aEnterPressed )
       
   952         {
       
   953         currentItem ^= 1;
       
   954         }
       
   955     else
       
   956         {
       
   957         isOk = SetAndGetSettingItemL( 
       
   958             currentItem, 
       
   959             R_MMS_YES_NO_LIST, 
       
   960             EMmsSettingsReceivingAds );
       
   961         }
       
   962         
       
   963     if (aEnterPressed || isOk)
       
   964         {
       
   965         switch (currentItem)
       
   966             {
       
   967             case EMmsSettingsNo:
       
   968                 iMmsSettings->SetAcceptAdvertisementMessages( EFalse );
       
   969                 break;
       
   970             case EMmsSettingsYes: // flow through
       
   971             default:
       
   972                 iMmsSettings->SetAcceptAdvertisementMessages( ETrue );
       
   973                 break;
       
   974             }
       
   975         SetArrayItem(EMmsSettingsReceivingAds, currentItem);
       
   976         CEikFormattedCellListBox* settingListBox =
       
   977             static_cast<CEikFormattedCellListBox*>( Control( EDlgSettingListBox ) );
       
   978         settingListBox->DrawNow();
       
   979         }                   
       
   980     }
       
   981 // ---------------------------------------------------------
       
   982 // CMmsSettingsDialog::EditReceiveReportsL
       
   983 // Edits the value for receiving reports.
       
   984 //
       
   985 // ---------------------------------------------------------
       
   986 //
       
   987 void CMmsSettingsDialog::EditReceiveReportsL( )
       
   988     {       
       
   989     TInt currentItem = iItems->At( EMmsSettingsReceiveReport ).iCurrentNumber;
       
   990 
       
   991     if ( SetAndGetSettingItemL(
       
   992             currentItem, 
       
   993             R_MCE_MMS_REPORTS, 
       
   994             EMmsSettingsReceiveReport ) )
       
   995         {
       
   996         SetReceiveReportSetting( static_cast<TMmsSettingsReceiveReportValues>( currentItem ) );
       
   997         }
       
   998     SetArrayItem( EMmsSettingsReceiveReport, currentItem );
       
   999     CEikFormattedCellListBox* settingListBox =
       
  1000         static_cast<CEikFormattedCellListBox*>( Control( EDlgSettingListBox ) );
       
  1001     settingListBox->DrawNow();
       
  1002     }
       
  1003 
       
  1004 // ---------------------------------------------------------
       
  1005 // SetReceiveReportSetting( TMmsSettingsReceiveReportValues aReceiveReport )
       
  1006 // Stores the value for receive report settings.
       
  1007 //
       
  1008 // ---------------------------------------------------------
       
  1009 //
       
  1010 void CMmsSettingsDialog::SetReceiveReportSetting( TMmsSettingsReceiveReportValues aReceiveReport )
       
  1011     {
       
  1012     switch ( aReceiveReport )
       
  1013         {
       
  1014         case EMmsSettingsReceiveReportBoth:
       
  1015             iMmsSettings->SetDeliveryReportWanted( EMmsYes );
       
  1016             iMmsSettings->SetReadReplyReportWanted( EMmsYes );
       
  1017             break;
       
  1018         case EMmsSettingsReceiveReportDelivery:
       
  1019             iMmsSettings->SetDeliveryReportWanted( EMmsYes );
       
  1020             iMmsSettings->SetReadReplyReportWanted( EMmsNo );
       
  1021             break;
       
  1022         case EMmsSettingsReceiveReportNone:
       
  1023             iMmsSettings->SetDeliveryReportWanted( EMmsNo );
       
  1024             iMmsSettings->SetReadReplyReportWanted( EMmsNo );
       
  1025             break;
       
  1026         default:
       
  1027             __ASSERT_DEBUG_NO_LEAVE( Panic( EMmsSettingsWrongParameters ) );
       
  1028             iMmsSettings->SetDeliveryReportWanted( EMmsNo );
       
  1029             iMmsSettings->SetReadReplyReportWanted( EMmsNo );
       
  1030             break;
       
  1031         }
       
  1032     }
       
  1033 // ---------------------------------------------------------
       
  1034 // CMmsSettingsDialog::EditDenySendingDeliveryReportL
       
  1035 // Edits the value for sending delivery reports.
       
  1036 //
       
  1037 // ---------------------------------------------------------
       
  1038 //
       
  1039 void CMmsSettingsDialog::EditDenySendingDeliveryReportsL( TBool aEnterPressed )
       
  1040     {
       
  1041     TBool isOk = EFalse;
       
  1042     TInt currentItem = iItems->At( EMmsSettingsDenyDeliveryReport ).iCurrentNumber;
       
  1043     
       
  1044     if ( aEnterPressed )
       
  1045         {
       
  1046         currentItem ^= 1;
       
  1047         }
       
  1048     else
       
  1049         {
       
  1050         isOk = SetAndGetSettingItemL(
       
  1051             currentItem, 
       
  1052             R_MMS_YES_NO_LIST, 
       
  1053             EMmsSettingsDenyDeliveryReport );
       
  1054         }
       
  1055         
       
  1056     if ( aEnterPressed || isOk )
       
  1057         {
       
  1058         switch ( currentItem )
       
  1059             {
       
  1060             case EMmsSettingsNo:
       
  1061                 iMmsSettings->SetDeliveryReportSendingAllowed( EMmsDeliveryReportAllowedYes );
       
  1062                 iMmsSettings->SetReadReplyReportSendingAllowed( ETrue );
       
  1063                 break;
       
  1064             case EMmsSettingsYes: // flow through
       
  1065             default:
       
  1066                 iMmsSettings->SetDeliveryReportSendingAllowed( EMmsDeliveryReportAllowedNo );
       
  1067                 iMmsSettings->SetReadReplyReportSendingAllowed( EFalse );
       
  1068                 break;
       
  1069             }
       
  1070         SetArrayItem( EMmsSettingsDenyDeliveryReport, currentItem );
       
  1071         CEikFormattedCellListBox* settingListBox =
       
  1072             static_cast<CEikFormattedCellListBox*>( Control( EDlgSettingListBox ) );
       
  1073         settingListBox->DrawNow();
       
  1074         }                   
       
  1075     }
       
  1076 
       
  1077 
       
  1078 // ---------------------------------------------------------
       
  1079 // CMmsSettingsDialog::EditValidityPeriodL
       
  1080 // Edits the value for validity period
       
  1081 //
       
  1082 // ---------------------------------------------------------
       
  1083 //
       
  1084 void CMmsSettingsDialog::EditValidityPeriodL()
       
  1085     {
       
  1086     TInt currentItem = iItems->At( EMmsSettingsValidityPeriod ).iCurrentNumber;
       
  1087     
       
  1088     if (SetAndGetSettingItemL( currentItem, R_MMS_VALIDITY_PERIOD_LIST, EMmsSettingsValidityPeriod ))
       
  1089         {
       
  1090         switch (currentItem)
       
  1091             {
       
  1092             case EMmsSettingsValidityPeriod1h:
       
  1093                 SetValidityPeriodSetting( KMmsValidityPeriod1h );
       
  1094                 break;
       
  1095             case EMmsSettingsValidityPeriod6h:
       
  1096                 SetValidityPeriodSetting( KMmsValidityPeriod6h );
       
  1097                 break;
       
  1098             case EMmsSettingsValidityPeriod24h:
       
  1099                 SetValidityPeriodSetting( KMmsValidityPeriod24h );
       
  1100                 break;
       
  1101             case EMmsSettingsValidityPeriod3d:
       
  1102                 SetValidityPeriodSetting( KMmsValidityPeriod3Days );
       
  1103                 break;
       
  1104             case EMmsSettingsValidityPeriodWeek:
       
  1105                 SetValidityPeriodSetting( KMmsValidityPeriodWeek );
       
  1106                 break;
       
  1107             case EMmsSettingsValidityPeriodMaximum:
       
  1108             default: // default to max
       
  1109                 SetValidityPeriodSetting( KMmsValidityPeriodMax );
       
  1110                 break;
       
  1111             }
       
  1112             SetArrayItem( EMmsSettingsValidityPeriod, currentItem );
       
  1113         }                   
       
  1114     }       
       
  1115 
       
  1116 
       
  1117 // ---------------------------------------------------------
       
  1118 // CMmsSettingsDialog::SetValidityPeriodSetting(TInt32 aValidityPeriod)
       
  1119 // Stores the value for validity period settings.
       
  1120 //
       
  1121 // ---------------------------------------------------------
       
  1122 //
       
  1123 void CMmsSettingsDialog::SetValidityPeriodSetting( TInt32 aValidityPeriod )
       
  1124     {
       
  1125     iMmsSettings->SetExpiryInterval( aValidityPeriod );
       
  1126     }
       
  1127 
       
  1128 // ---------------------------------------------------------
       
  1129 // CMmsSettingsDialog::EditAccessPointL
       
  1130 //
       
  1131 // ---------------------------------------------------------
       
  1132 //
       
  1133 TBool CMmsSettingsDialog::EditAccessPointL()
       
  1134     {
       
  1135     TUint32 currentItem = iItems->At( EMmsSettingsAccessPoint ).iCurrentNumber;
       
  1136     
       
  1137 
       
  1138     TInt bearers = EApBearerTypeGPRS; 
       
  1139     if ( iSettingsFlags & ECSDEnabled )
       
  1140         {
       
  1141         bearers |= ( EApBearerTypeCSD | EApBearerTypeHSCSD );
       
  1142         }
       
  1143 
       
  1144     TUint32 selectedAp = KMaxTUint32;   // invalid value
       
  1145     TInt taskDone = MmsApSelect::SelectMmsAccessPointL(
       
  1146         *iCommsDb,
       
  1147         currentItem,
       
  1148         selectedAp,
       
  1149         bearers );
       
  1150 
       
  1151     // Note: taskDone == KApUiEventDeleted is not handled here.
       
  1152     // Basically the user can delete the AP that was selected. This is noticed
       
  1153     // & complained when closing Settings dialog.
       
  1154     CApUtils* apUtils = CApUtils::NewLC( *iCommsDb );
       
  1155     TBuf<KCommsDbSvrMaxFieldLength> apName;
       
  1156 
       
  1157     if( !ApExistsL( apUtils, currentItem ) && taskDone == 0 ) //if ap has been deleted, set "must be defined"
       
  1158         {
       
  1159         selectedAp = 0;
       
  1160         }//if
       
  1161     else if( selectedAp == KMaxTUint32 )
       
  1162         {
       
  1163         selectedAp = currentItem;
       
  1164         }
       
  1165     GetNameForApL( selectedAp, apName );
       
  1166     SetArrayItem( EMmsSettingsAccessPoint, selectedAp, apName );
       
  1167 
       
  1168     // Use cases numbered:
       
  1169     if ( taskDone || selectedAp != 0 )
       
  1170         {  
       
  1171         // 1) sp selected 
       
  1172         // 2) previously ap selected but 'back' now
       
  1173         // 3) none selected 
       
  1174         while ( iMmsSettings->AccessPointCount() )
       
  1175             {
       
  1176             iMmsSettings->DeleteAccessPointL( 0 );
       
  1177             }
       
  1178             
       
  1179         if ( selectedAp != 0 )
       
  1180             {
       
  1181             // 1) sp selected, 2) previously ap selected but 'back' now
       
  1182             iMmsSettings->AddAccessPointL( selectedAp, 0 );
       
  1183             }
       
  1184         }
       
  1185     // else - 4) previously none selected and 'back' now    
       
  1186 
       
  1187     CleanupStack::PopAndDestroy(); // apUtils
       
  1188 
       
  1189     return ( taskDone & ( KApUiEventExitRequested | KApUiEventShutDownRequested ) );
       
  1190     }
       
  1191 
       
  1192 
       
  1193 // ---------------------------------------------------------
       
  1194 // CMmsSettingsDialog::GetNameForApL
       
  1195 // Get a name for the given access point id
       
  1196 //
       
  1197 // ---------------------------------------------------------
       
  1198 //
       
  1199 void CMmsSettingsDialog::GetNameForApL( TUint32 aId, TDes& aName )
       
  1200     {
       
  1201     aName.Zero();
       
  1202     CApUtils* apUtils = CApUtils::NewLC( *iCommsDb );
       
  1203     if ( !ApExistsL( apUtils, aId ) )
       
  1204         {
       
  1205         // No access point -> "Compulsory"
       
  1206         HBufC* text = iEikonEnv->AllocReadResourceLC( R_MMS_SETTINGS_COMPULSORY );
       
  1207         aName.Copy( *text );
       
  1208         CleanupStack::PopAndDestroy(); // text
       
  1209         }
       
  1210     else
       
  1211         {
       
  1212         apUtils->NameL( aId, aName );
       
  1213         }
       
  1214     CleanupStack::PopAndDestroy(); // apUtils
       
  1215     }
       
  1216 
       
  1217 
       
  1218 // ---------------------------------------------------------
       
  1219 // CMmsSettingsDialog::EditImageSizeL
       
  1220 // Edits the value for image size setting.
       
  1221 //
       
  1222 // ---------------------------------------------------------
       
  1223 //
       
  1224 void CMmsSettingsDialog::EditImageSizeL( TBool aEnterPressed )
       
  1225     {
       
  1226     TBool isOk = EFalse;
       
  1227     TInt currentItem = iItems->At( EMmsSettingsImageSize ).iCurrentNumber;
       
  1228 
       
  1229     if ( aEnterPressed &&
       
  1230         iMmsSettings->CreationMode() != EMmsCreationModeRestricted )
       
  1231         {
       
  1232         currentItem ^= 1;
       
  1233         isOk = ETrue;
       
  1234         }
       
  1235     else
       
  1236         {
       
  1237         // We come here either from "Options -> Change" or with selection key
       
  1238         // in "restricted" mode (opens a list with a single item).
       
  1239         isOk = SetAndGetSettingItemL(
       
  1240             currentItem,
       
  1241             R_MMS_IMAGE_SIZE_LIST,
       
  1242             EMmsSettingsImageSize );
       
  1243         }
       
  1244 
       
  1245     if ( isOk )
       
  1246         {
       
  1247         switch ( currentItem )
       
  1248             {
       
  1249             case EMmsSettingsImageLarge:
       
  1250                 iMmsSettings->SetImageWidth( KMmsUniImageLargeWidth );
       
  1251                 iMmsSettings->SetImageHeight( KMmsUniImageLargeHeight );
       
  1252                 break;
       
  1253             case EMmsSettingsImageSmall: // flow through
       
  1254             default:
       
  1255                 iMmsSettings->SetImageWidth( KMmsUniImageSmallWidth );
       
  1256                 iMmsSettings->SetImageHeight( KMmsUniImageSmallHeight );
       
  1257                 break;
       
  1258             }
       
  1259         SetArrayItem( EMmsSettingsImageSize, currentItem );
       
  1260         CEikFormattedCellListBox* settingListBox =
       
  1261             static_cast<CEikFormattedCellListBox*>( Control( EDlgSettingListBox ) );
       
  1262         settingListBox->DrawNow();
       
  1263         }                   
       
  1264     }
       
  1265 
       
  1266 
       
  1267 // ---------------------------------------------------------
       
  1268 // CMmsSettingsDialog::EditCreationModeL
       
  1269 // Edits the value for creation mode setting.
       
  1270 //
       
  1271 // ---------------------------------------------------------
       
  1272 //
       
  1273 void CMmsSettingsDialog::EditCreationModeL( TBool /*aEnterPressed*/ )
       
  1274     {
       
  1275     if ( !( iSettingsFlags & ECreationModeChangeEnabled ) )
       
  1276         {
       
  1277         ShowInformationNoteL( R_MMSUI_INFO_CANNOT_CHANGE_CMODE );
       
  1278         return;
       
  1279         }
       
  1280 
       
  1281     TInt enumMode = EMmsSettingsCreationMode;
       
  1282 
       
  1283     TInt currentItem = iItems->At( enumMode ).iCurrentNumber;
       
  1284     
       
  1285     if ( SetAndGetSettingItemL( currentItem, R_MMS_CREATION_MODE_LIST, enumMode) )
       
  1286         {
       
  1287         TInt32 oldMode = GetCreationMode();
       
  1288         switch ( currentItem )
       
  1289             {
       
  1290             case EMmsSettingsCreationModeRestricted:
       
  1291                 iMmsSettings->SetCreationMode( EMmsCreationModeRestricted );
       
  1292                 if ( oldMode != currentItem &&
       
  1293                     ( iMmsSettings->ImageWidth() != KMmsUniImageSmallWidth ||
       
  1294                       iMmsSettings->ImageHeight() != KMmsUniImageSmallHeight ) )
       
  1295                     {
       
  1296                     iMmsSettings->SetImageWidth( KMmsUniImageSmallWidth );
       
  1297                     iMmsSettings->SetImageHeight( KMmsUniImageSmallHeight );
       
  1298                     SetArrayItem( EMmsSettingsImageSize, EMmsSettingsImageSmall );
       
  1299                     ShowInformationNoteL( R_MMSUI_INFO_IMAGE_SIZE_CHANGED );
       
  1300                     iListbox->DrawItem( EMmsSettingsImageSize );
       
  1301                     }
       
  1302                 break;
       
  1303             case EMmsSettingsCreationModeFree:
       
  1304                 {
       
  1305                 if ( oldMode != currentItem )
       
  1306                     {
       
  1307                     CAknQueryDialog* confirmQuery = CAknQueryDialog::NewL();
       
  1308                     if ( confirmQuery->ExecuteLD( R_MMSUI_QUERY_CHANGE_TO_FREE ) )
       
  1309                         {
       
  1310                         iMmsSettings->SetCreationMode( EMmsCreationModeFree );
       
  1311                         }
       
  1312                     else
       
  1313                         {
       
  1314                         currentItem = oldMode;
       
  1315                         }
       
  1316                     }
       
  1317                 }
       
  1318                 break;
       
  1319             default:
       
  1320             case EMmsSettingsCreationModeGuided:
       
  1321                 iMmsSettings->SetCreationMode( EMmsCreationModeWarning );
       
  1322                 break;
       
  1323             }
       
  1324             SetArrayItem( enumMode, currentItem );
       
  1325         }                   
       
  1326 
       
  1327     }
       
  1328 
       
  1329 // ---------------------------------------------------------
       
  1330 // CMmsSettingsDialog::GetCreationMode
       
  1331 // Maps creation mode value from engine to SettingsDialog values
       
  1332 //
       
  1333 // ---------------------------------------------------------
       
  1334 //
       
  1335 TInt32 CMmsSettingsDialog::GetCreationMode()
       
  1336     {
       
  1337     switch ( iMmsSettings->CreationMode() )
       
  1338         {
       
  1339         case EMmsCreationModeRestricted:
       
  1340             return EMmsSettingsCreationModeRestricted;
       
  1341         case EMmsCreationModeFree:
       
  1342             return EMmsSettingsCreationModeFree;
       
  1343         case EMmsCreationModeWarning:
       
  1344         default:
       
  1345             return EMmsSettingsCreationModeGuided;
       
  1346         }
       
  1347     }
       
  1348 
       
  1349 // ---------------------------------------------------------
       
  1350 // CMmsSettingsDialog::SetTitleTextL()
       
  1351 // Makes the status pane
       
  1352 //
       
  1353 // ---------------------------------------------------------
       
  1354 //
       
  1355 void CMmsSettingsDialog::SetTitleTextL()
       
  1356     {   
       
  1357     CEikStatusPane *sp = ( static_cast<CAknAppUi*>
       
  1358         ( CEikonEnv::Static()->EikAppUi() ) )->StatusPane();
       
  1359     iTitlePane = static_cast<CAknTitlePane*>
       
  1360         ( sp->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) );
       
  1361     
       
  1362     //save old title
       
  1363     iPreviousTitleText = ( *iTitlePane->Text() ).Alloc();
       
  1364         
       
  1365     // set new title
       
  1366     HBufC* text = text = StringLoader::LoadLC( R_MMS_SETTINGS_TITLE_TEXT );
       
  1367     iTitlePane->SetTextL( *text );
       
  1368     CleanupStack::PopAndDestroy(); // text
       
  1369     }
       
  1370 
       
  1371 
       
  1372 // ---------------------------------------------------------
       
  1373 // CMmsSettingsDialog::LaunchHelpL
       
  1374 // launch help using context
       
  1375 // 
       
  1376 // ---------------------------------------------------------
       
  1377 //
       
  1378 void CMmsSettingsDialog::LaunchHelpL()
       
  1379     {
       
  1380     if ( iSettingsFlags & EHelpFeatureSupported )
       
  1381         {
       
  1382         CCoeAppUi* editorAppUi = static_cast<CCoeAppUi*>( ControlEnv()->AppUi() );
       
  1383       
       
  1384         CArrayFix<TCoeHelpContext>* helpContext = editorAppUi->AppHelpContextL();   
       
  1385         HlpLauncher::LaunchHelpApplicationL( iEikonEnv->WsSession(), helpContext );
       
  1386         }
       
  1387     }
       
  1388 
       
  1389 
       
  1390 // ---------------------------------------------------------
       
  1391 // CMmsSettingsDialog::GetHelpContext
       
  1392 // returns helpcontext as aContext
       
  1393 // 
       
  1394 // ---------------------------------------------------------
       
  1395 //
       
  1396 void CMmsSettingsDialog::GetHelpContext
       
  1397         ( TCoeHelpContext& aContext ) const
       
  1398     {
       
  1399     if ( iSettingsFlags & EHelpFeatureSupported )
       
  1400         {
       
  1401         aContext.iMajor = KUidMce;
       
  1402         aContext.iContext = KMCE_HLP_SETTINGS_MMS;
       
  1403         }
       
  1404     }
       
  1405 
       
  1406 // ---------------------------------------------------------
       
  1407 // CMmsSettingsDialog::ShowInformationNoteL
       
  1408 // ---------------------------------------------------------
       
  1409 //
       
  1410 void CMmsSettingsDialog::ShowInformationNoteL( TInt aResourceId )
       
  1411     {
       
  1412     CAknInformationNote* note = new ( ELeave ) CAknInformationNote( ETrue );
       
  1413     HBufC* string = StringLoader::LoadLC( aResourceId );
       
  1414     note->ExecuteLD( *string );
       
  1415     CleanupStack::PopAndDestroy(); //string
       
  1416     }
       
  1417 
       
  1418 //  End of File