messagingappbase/mcesettings/src/MceSettingsDialog.cpp
changeset 79 2981cb3aa489
equal deleted inserted replaced
25:84d9eb65b26f 79:2981cb3aa489
       
     1 /*
       
     2 * Copyright (c) 2002 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 *     Message centre's settings dialog.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 // INCLUDE FILES
       
    22 
       
    23 #include <eikapp.h>
       
    24 #include <MuiuMsvUiServiceUtilities.h> //MsvUiServiceUtilities
       
    25 #include <MtmExtendedCapabilities.hrh>
       
    26 #include <msvuids.h>
       
    27 #include <mtudreg.h>
       
    28 #include <MTMStore.h>
       
    29 #include <aknnotewrappers.h>
       
    30 #include <aknradiobuttonsettingpage.h>
       
    31 #include <aknViewAppUi.h>
       
    32 
       
    33 #include <apgcli.h>
       
    34 #include <MceSettings.rsg>
       
    35 #include "MceSettingsDialog.h"
       
    36 #include "MceSettingsGeneralSettingsDialog.h"
       
    37 #include "MceSettingsArrays.h"
       
    38 #include "MceSettingsSessionObserver.h"
       
    39 #include "MceSettingsIds.hrh"
       
    40 #include "MceSettingsMultipleServicesDialog.h"
       
    41 
       
    42 #include <featmgr.h>
       
    43 #include <hlplch.h>             // For HlpLauncher
       
    44 #include <csxhelp/mce.hlp.hrh>
       
    45 #include <SenduiMtmUids.h>
       
    46 
       
    47 #include <bldvariant.hrh>
       
    48 #include <data_caging_path_literals.hrh>
       
    49 
       
    50 #include "MceSettingsUtils.h"
       
    51 #include <RCustomerServiceProfileCache.h>
       
    52 // CONSTANTS
       
    53 
       
    54 _LIT( KMceDirAndFile,"MceSettings.rsc" );
       
    55 
       
    56 #define KMceApplicationUidValue     0x100058C5
       
    57 const TUid KMceApplicationUid       = {KMceApplicationUidValue};
       
    58 
       
    59 const TUid KCBSApplicationId        = {0x101F4CD3};
       
    60 const TUid KCBSApplicationSettingsViewId    = {6};
       
    61 const TInt KMceSettingsExtraItems           = 2;
       
    62 const TInt KMceSettingsCBS                  = 2;
       
    63 const TInt KMceSettingsCBSUid               = 42;
       
    64 
       
    65 
       
    66 
       
    67 // ================= MEMBER FUNCTIONS =======================
       
    68 
       
    69 
       
    70 // C++ default constructor can NOT contain any code that
       
    71 // might leave.
       
    72 //
       
    73 CMceSettingsDialog::CMceSettingsDialog()
       
    74 :   CMceSettingsTitlePaneHandlerDialog(),  
       
    75     iResources( *CCoeEnv::Static() ),    
       
    76     iLaunchedFromMce( EFalse ),
       
    77     iDialogOpen(EFalse)
       
    78     {
       
    79     }
       
    80 
       
    81 // ----------------------------------------------------
       
    82 // CMceSettingsDialog::Constructor
       
    83 // ----------------------------------------------------
       
    84 CMceSettingsDialog::CMceSettingsDialog(
       
    85     CMceUidNameArray& aSettingsItemsArray,
       
    86     MMceSettingsAccountManager* aManager, 
       
    87     CMsvSession* aSession )
       
    88 :   CMceSettingsTitlePaneHandlerDialog(),  
       
    89     iResources( *CCoeEnv::Static() ),  
       
    90     iMsgTypesSettings( &aSettingsItemsArray ),
       
    91     iAccountManager( aManager ),
       
    92     iSession( aSession ),    
       
    93     iLaunchedFromMce( ETrue ),    
       
    94     iDialogOpen(EFalse)
       
    95     {
       
    96     }
       
    97 
       
    98 
       
    99 // ----------------------------------------------------
       
   100 // CMceSettingsDialog::Destructor
       
   101 // ----------------------------------------------------
       
   102 EXPORT_C CMceSettingsDialog::~CMceSettingsDialog()
       
   103     {
       
   104     iResources.Close();
       
   105     if ( !iLaunchedFromMce )
       
   106         {
       
   107         // if launched from mce then mce owns this array!
       
   108         delete iMsgTypesSettings;
       
   109         }
       
   110     delete iSessionObserver;
       
   111     // dont delete iSession, it is not owed by this class
       
   112     // dont delete iAccountManager, it is not owed by this class 
       
   113     }
       
   114 
       
   115 // ----------------------------------------------------
       
   116 // CMceSettingsDialog::ConstructL
       
   117 // ----------------------------------------------------
       
   118 void CMceSettingsDialog::ConstructL()
       
   119     {
       
   120     TParse fp;
       
   121     fp.Set( KMceDirAndFile, &KDC_RESOURCE_FILES_DIR , NULL );
       
   122     TFileName fileName = fp.FullName();
       
   123 
       
   124     iResources.OpenL( fileName );
       
   125     CAknDialog::ConstructL( R_MCE_SETTINGS_DIALOG_MENUBAR );
       
   126 
       
   127     iSessionObserver = CMceSettingsSessionObserver::NewL( iSession );
       
   128     if ( !iAccountManager )
       
   129         {
       
   130         iAccountManager = iSessionObserver;
       
   131         }
       
   132     if ( !iSession )
       
   133         {
       
   134         iSession = &iSessionObserver->Session();
       
   135         }
       
   136     if ( !iMsgTypesSettings )
       
   137         {
       
   138         iMsgTypesSettings = CMceUidNameArray::NewL();
       
   139         }
       
   140     FeatureManager::InitializeLibL();
       
   141     if ( FeatureManager::FeatureSupported( KFeatureIdSelectableEmail ) )
       
   142         {
       
   143 		iProductIncludesSelectableEmail = ETrue;
       
   144        	}
       
   145     else
       
   146        	{
       
   147 		iProductIncludesSelectableEmail = EFalse;	
       
   148        	}
       
   149 	FeatureManager::UnInitializeLib();
       
   150     }
       
   151 
       
   152 // ----------------------------------------------------
       
   153 // CMceSettingsDialog::ConstructL
       
   154 // ----------------------------------------------------
       
   155 EXPORT_C CMceSettingsDialog* CMceSettingsDialog::NewL()
       
   156     {
       
   157     CMceSettingsDialog* dialog = new (ELeave) CMceSettingsDialog();
       
   158     CleanupStack::PushL( dialog );
       
   159     dialog->ConstructL();
       
   160     CleanupStack::Pop( dialog );
       
   161     return dialog;
       
   162     }
       
   163 
       
   164 // ----------------------------------------------------
       
   165 // CMceSettingsDialog::ConstructL
       
   166 // ----------------------------------------------------
       
   167 EXPORT_C CMceSettingsDialog* 
       
   168     CMceSettingsDialog::NewL( CMceUidNameArray& aSettingsItemsArray,
       
   169     MMceSettingsAccountManager* aManager, CMsvSession* aSession ) 
       
   170     {
       
   171     CMceSettingsDialog* dialog = new (ELeave) CMceSettingsDialog( 
       
   172                                                     aSettingsItemsArray, aManager, aSession );
       
   173     CleanupStack::PushL( dialog );
       
   174     dialog->ConstructL();
       
   175     CleanupStack::Pop( dialog );
       
   176     return dialog;
       
   177     }
       
   178 
       
   179 // ----------------------------------------------------
       
   180 // CMceSettingsDialog::OkToExitL
       
   181 // ----------------------------------------------------
       
   182 EXPORT_C TInt CMceSettingsDialog::OkToExitL( TInt aButtonId )
       
   183     {
       
   184     TBool okToExit = CAknDialog::OkToExitL( aButtonId );
       
   185     if ( aButtonId == EMceSettingsCmdSettingsDialogOpen )
       
   186         {
       
   187         // Middle soft key pressed
       
   188         ProcessCommandL( aButtonId );
       
   189         okToExit = EFalse; // Cannot exit, since MSK was pressed
       
   190         }
       
   191     else if ( aButtonId != EEikBidCancel && okToExit )
       
   192         {
       
   193         RestoreTitleTextL();
       
   194         }
       
   195     return okToExit;
       
   196     }
       
   197 
       
   198 // ----------------------------------------------------
       
   199 // CMceSettingsDialog::ProcessCommandL
       
   200 // ----------------------------------------------------
       
   201 EXPORT_C void CMceSettingsDialog::ProcessCommandL( TInt aCommandId )
       
   202     {
       
   203     CAknDialog::ProcessCommandL( aCommandId ); // hides menu
       
   204     if ( aCommandId == EMceSettingsCmdSettingsDialogExit )
       
   205         {
       
   206         if (iAvkonViewAppUi->ExitHidesInBackground()) 
       
   207             { 
       
   208             iAvkonViewAppUi->ProcessCommandL( EAknCmdHideInBackground );
       
   209             }
       
   210         else
       
   211             {
       
   212             iAvkonViewAppUi->ProcessCommandL( EAknCmdExit );
       
   213             }
       
   214         
       
   215         return;
       
   216         }
       
   217 
       
   218 
       
   219     switch ( aCommandId )
       
   220         {
       
   221         case EMceSettingsCmdSettingsDialogOpen:
       
   222             OpenSubSettingsL();
       
   223             break;
       
   224         
       
   225         case EMceSettingsCmdSettingsDialogHelp:
       
   226             {
       
   227             LaunchHelpL();                
       
   228             }
       
   229             break;
       
   230            
       
   231         default :
       
   232             break;
       
   233         }
       
   234     }
       
   235 
       
   236 // ----------------------------------------------------
       
   237 // CMceSettingsDialog::DynInitMenuPaneL
       
   238 // ----------------------------------------------------
       
   239 EXPORT_C void CMceSettingsDialog::DynInitMenuPaneL( TInt aResourceId, CEikMenuPane* aMenuPane )
       
   240     {
       
   241     if ( aResourceId == R_MCE_SETTINGS_DIALOG_MENUPANE )
       
   242         {
       
   243         aMenuPane->SetItemDimmed( EMceSettingsCmdSettingsDialogHelp,
       
   244             !FeatureManager::FeatureSupported( KFeatureIdHelp ) );
       
   245 
       
   246         }
       
   247     }
       
   248 
       
   249 // ----------------------------------------------------
       
   250 // CMceSettingsDialog::PreLayoutDynInitL
       
   251 // ----------------------------------------------------
       
   252 EXPORT_C void CMceSettingsDialog::PreLayoutDynInitL( )
       
   253     {
       
   254     TBool csp = MceSettingsUtils::CspBitsL();    
       
   255     iCbs = EFalse;
       
   256     if ( FeatureManager::FeatureSupported( KFeatureIdCellBroadcast ) )
       
   257         {
       
   258         iCbs = ETrue;
       
   259         if ( csp )
       
   260             {
       
   261             iCbs = CheckCspBitL();
       
   262             }
       
   263         }
       
   264     StoreTitleTextAndSetNewL( R_MCE_SETTINGS_TITLE );
       
   265 
       
   266     if ( !iLaunchedFromMce )
       
   267         {
       
   268         LoadAllMtmsL();
       
   269         }
       
   270     
       
   271     CEikTextListBox* list=STATIC_CAST( CEikTextListBox*, 
       
   272         Control( EMceSettingsDialogChoiceList ) );
       
   273     // Scrollbar
       
   274     list->CreateScrollBarFrameL(ETrue);
       
   275     list->ScrollBarFrame()->SetScrollBarVisibilityL(
       
   276         CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto );
       
   277 
       
   278     CTextListBoxModel* model=list->Model();
       
   279     model->SetItemTextArray( iMsgTypesSettings );
       
   280     model->SetOwnershipType( ELbmDoesNotOwnItemArray );
       
   281     list->SetListBoxObserver( this );
       
   282     }
       
   283 
       
   284 
       
   285 // ----------------------------------------------------
       
   286 // CMceSettingsDialog::ExecuteLD
       
   287 // ----------------------------------------------------
       
   288 EXPORT_C TInt CMceSettingsDialog::ExecuteLD( )
       
   289     {
       
   290 
       
   291     TInt returnValue = CAknDialog::ExecuteLD( R_MCE_SETTINGS_DIALOG );
       
   292     
       
   293     
       
   294     return returnValue;
       
   295     }
       
   296 
       
   297 // ----------------------------------------------------
       
   298 // CMceSettingsDialog::LoadAllMtmsL
       
   299 // ----------------------------------------------------
       
   300 void CMceSettingsDialog::LoadAllMtmsL()
       
   301     {
       
   302     iMsgTypesSettings->Reset();
       
   303     CMtmUiDataRegistry* uiRegistry = iSessionObserver->UiRegistry(); // owed by iSessionObserver
       
   304     CMtmStore* mtmStore = iSessionObserver->MtmStore(); // owed by iSessionObserver
       
   305     const TInt count = uiRegistry->NumRegisteredMtmDlls();
       
   306     TInt loop = 0;
       
   307     for ( loop = 0; loop < count; loop++ )
       
   308         {
       
   309         LoadMtmL( uiRegistry->MtmTypeUid( loop ), *mtmStore, *uiRegistry );
       
   310         }
       
   311 
       
   312     CMsvEntry* rootEntry = iSession->GetEntryL( KMsvRootIndexEntryIdValue );
       
   313     CleanupStack::PushL( rootEntry );  
       
   314 
       
   315     // Then add MTMs which have service but cannot create messages (wap push in practice)
       
   316     CMsvEntrySelection* sel =
       
   317         MsvUiServiceUtilities::GetListOfAccountsL( *iSession );
       
   318     CleanupStack::PushL( sel );
       
   319     TMsvId id;
       
   320     const TInt numAccounts=sel->Count();
       
   321     for ( loop = 0; loop<numAccounts; loop++)
       
   322         {
       
   323         id = sel->At(loop);
       
   324         TMsvEntry tentry;
       
   325         TMsvId serviceId;	
       
   326         TInt err = iSession->GetEntry( id, serviceId, tentry );
       
   327      
       
   328         if ( err == KErrNone  && uiRegistry->IsPresent( tentry.iMtm ) )
       
   329             {
       
   330             TUid techType = uiRegistry->TechnologyTypeUid( tentry.iMtm );
       
   331             TBool found = EFalse;
       
   332 
       
   333             for ( TInt loop2 = iMsgTypesSettings->Count()-1 ;loop2 >= 0; loop2-- )
       
   334                 {
       
   335                 TUid uidAlreadyAdded = (*iMsgTypesSettings)[loop2].iUid;
       
   336                 if ( uiRegistry->TechnologyTypeUid( uidAlreadyAdded ) == techType )
       
   337                     {
       
   338                     found = ETrue;
       
   339                     break;
       
   340                     }
       
   341                 }
       
   342 
       
   343             if ( !found )
       
   344                 {
       
   345                 iMsgTypesSettings->AppendL( TUidNameInfo(
       
   346                     tentry.iMtm,
       
   347                     uiRegistry->RegisteredMtmDllInfo( tentry.iMtm ).HumanReadableName()
       
   348                     ));
       
   349                 }
       
   350             }
       
   351         }
       
   352     CleanupStack::PopAndDestroy( sel );    
       
   353     CleanupStack::PopAndDestroy( rootEntry ); 
       
   354 
       
   355     // this is not used anywhere, two last items in the list are
       
   356     // ALWAYS cbs settings and mce general settings
       
   357 
       
   358     SortAndChangeSmsMmsEmailFirstL();
       
   359 
       
   360     TUid uid;
       
   361     uid.iUid = KMceSettingsCBSUid;
       
   362 
       
   363 	if(iCbs)
       
   364 	{
       
   365     	HBufC* text = StringLoader::LoadL( R_MCE_CBS_SETTINGS_TEXT, iEikonEnv );
       
   366     	TUidNameInfo cbsSettings( uid, *text );
       
   367     	delete text;
       
   368     	iMsgTypesSettings->AppendL( cbsSettings );
       
   369 	}
       
   370 
       
   371     HBufC* text = StringLoader::LoadL( R_MCE_GENERAL_SETTINGS_TEXT, iEikonEnv );
       
   372     TUidNameInfo generalSettings( uid, *text );
       
   373     delete text;
       
   374     iMsgTypesSettings->AppendL( generalSettings );
       
   375 
       
   376     }
       
   377 
       
   378 
       
   379 // ----------------------------------------------------
       
   380 // CMceSettingsDialog::LoadMtmL
       
   381 // ----------------------------------------------------
       
   382 void CMceSettingsDialog::LoadMtmL( 
       
   383             const TUid aMtmType, 
       
   384             CMtmStore& aMtmStore, 
       
   385             const CMtmUiDataRegistry& aUiRegistry )
       
   386     {
       
   387     CBaseMtmUiData* uiData = NULL;
       
   388     TRAPD( err, ( uiData = &(aMtmStore.MtmUiDataL(aMtmType)) ) );
       
   389     if( err != KErrNone )
       
   390         {
       
   391         return;
       
   392         }
       
   393 
       
   394     TInt response;
       
   395     TUid canSend={KUidMtmQueryCanCreateNewMsgValue};
       
   396     TInt canSendResponse=uiData->QueryCapability( canSend, response );
       
   397 
       
   398     TBool foundSettings = EFalse;
       
   399     const CArrayFix<CBaseMtmUiData::TMtmUiFunction>& funcs =
       
   400         uiData->MtmSpecificFunctions();
       
   401     const TInt numFuncs = funcs.Count();
       
   402     for (TInt funcIndex = 0; funcIndex < numFuncs && !foundSettings; funcIndex++ )
       
   403         {
       
   404         CBaseMtmUiData::TMtmUiFunction func = funcs.At( funcIndex );
       
   405         if ( func.iFunctionId == KMtmUiMceSettings )
       
   406             {
       
   407             iMsgTypesSettings->AppendL( TUidNameInfo(
       
   408                 aMtmType,
       
   409                 func.iCaption ) );
       
   410             foundSettings = ETrue;
       
   411             }
       
   412         } // end for
       
   413     if ( canSendResponse == KErrNone && !foundSettings )
       
   414         {
       
   415         iMsgTypesSettings->AppendL( TUidNameInfo(
       
   416             aMtmType,
       
   417             aUiRegistry.RegisteredMtmDllInfo(aMtmType).HumanReadableName()
       
   418             ));
       
   419         }
       
   420     }
       
   421 
       
   422 
       
   423 // ----------------------------------------------------
       
   424 // CMceSettingsDialog::HandleListBoxEventL
       
   425 // ----------------------------------------------------
       
   426 void CMceSettingsDialog::HandleListBoxEventL(
       
   427     CEikListBox* /*aListBox*/,
       
   428     TListBoxEvent aEventType )
       
   429     {
       
   430     switch(aEventType)
       
   431         {
       
   432         case EEventEnterKeyPressed:
       
   433         case EEventItemSingleClicked:
       
   434             ProcessCommandL( EMceSettingsCmdSettingsDialogOpen );
       
   435         break;
       
   436         default:
       
   437         break;
       
   438         }
       
   439     }
       
   440 
       
   441 
       
   442 // ----------------------------------------------------
       
   443 // CMceSettingsDialog::OpenSubSettingsL
       
   444 // ----------------------------------------------------
       
   445 void CMceSettingsDialog::OpenSubSettingsL()
       
   446     {    
       
   447     CEikTextListBox* list=STATIC_CAST( CEikTextListBox*, 
       
   448         Control( EMceSettingsDialogChoiceList ) );
       
   449     const TInt numberOfItems = list->Model()->NumberOfItems();
       
   450     TInt choice = list->CurrentItemIndex();
       
   451 
       
   452     // Run time Cell Broadcast variant.
       
   453     TInt removedSettingItems = 0;
       
   454     if ( !iCbs )
       
   455     {
       
   456         removedSettingItems++;
       
   457     }
       
   458 
       
   459     if ( choice < numberOfItems - KMceSettingsExtraItems + removedSettingItems )
       
   460         {
       
   461         TBool  canCreateNewAccount = iAccountManager->CanCreateNewAccountL(
       
   462             (*iMsgTypesSettings)[choice].iUid );
       
   463 
       
   464         if ( canCreateNewAccount )
       
   465             {
       
   466             if(iDialogOpen)
       
   467              	{
       
   468              	return;
       
   469             	}
       
   470             iDialogOpen = ETrue;	
       
   471            	if ( iProductIncludesSelectableEmail )
       
   472 				{
       
   473             	CMceSettingsMultipleServicesDialog::LaunchDialogL( 
       
   474                 		           *iAccountManager,  
       
   475                 		           ( *iMsgTypesSettings )[choice].iUid, 
       
   476                 		           *iSession,
       
   477                 		           R_MCE_SETTINGS_MULTIPLE_SERVICES_DIALOG_MENUBAR_WITH_SELECTABLE_EMAIL,
       
   478                 		           R_MCE_SETTINGS_MULTIPLE_SERVICES_DIALOG );          
       
   479 				}
       
   480 			else
       
   481 				{
       
   482             	CMceSettingsMultipleServicesDialog::LaunchDialogL( 
       
   483                 		     *iAccountManager,  
       
   484                 		     ( *iMsgTypesSettings )[choice].iUid, 
       
   485                 		     *iSession,
       
   486                 		     R_MCE_SETTINGS_MULTIPLE_SERVICES_DIALOG_MENUBAR,
       
   487                 		     R_MCE_SETTINGS_MULTIPLE_SERVICES_DIALOG );          
       
   488 				}
       
   489             iDialogOpen = EFalse;
       
   490             }
       
   491         else
       
   492             {
       
   493             // mtm cannot create new accounts, edit only FIRST service if exists
       
   494             CMsvEntrySelection* sel =
       
   495                 MsvUiServiceUtilities::GetListOfAccountsWithMTML( *iSession, 
       
   496                                                             (*iMsgTypesSettings)[choice].iUid );
       
   497 
       
   498             CleanupStack::PushL( sel );
       
   499 
       
   500             if ( sel->Count() > 0 )
       
   501                 {
       
   502                 iAccountManager->EditAccountL( (*sel)[0] );
       
   503                 }
       
   504             else
       
   505                 { // service disappeared?
       
   506 
       
   507                 }
       
   508             CleanupStack::PopAndDestroy( sel );
       
   509             }
       
   510         } // end if ( choice < numberOfItems )
       
   511     else if ( iCbs && choice == numberOfItems - KMceSettingsCBS )
       
   512         {
       
   513         // CBS settings are second from the end of the list
       
   514         TVwsViewId viewId( KCBSApplicationId, KCBSApplicationSettingsViewId );
       
   515         STATIC_CAST( CCoeAppUi*, ControlEnv()->AppUi())->ActivateViewL( viewId );
       
   516         }
       
   517     else
       
   518         {
       
   519         // general settings are list item in the list        
       
   520         CMceGeneralSettingsDialog* generalSettingsDlg =
       
   521             new (ELeave) CMceGeneralSettingsDialog( iSession, *iSessionObserver, iAccountManager );
       
   522         CleanupStack::PushL( generalSettingsDlg );
       
   523         generalSettingsDlg->ConstructL( R_MCE_GENERAL_SETTINGS_CHOICE_MENUBAR );
       
   524         CleanupStack::Pop( generalSettingsDlg ); // generalSettingsDlg
       
   525         generalSettingsDlg->ExecuteLD( R_MCE_GENERAL_SETTINGS );
       
   526         }
       
   527 
       
   528     }
       
   529 
       
   530 
       
   531 // ---------------------------------------------------------
       
   532 // CMceSettingsDialog::SortAndChangeSmsMmsEmailFirstL
       
   533 // ---------------------------------------------------------
       
   534 //
       
   535 void CMceSettingsDialog::SortAndChangeSmsMmsEmailFirstL()
       
   536     {
       
   537     iMsgTypesSettings->Sort(ECmpFolded);    
       
   538 
       
   539     ChangeMsgTypeTopL( *iMsgTypesSettings, KSenduiMtmPostcardUid );
       
   540     ChangeMsgTypeTopL( *iMsgTypesSettings, KSenduiMtmSyncMLEmailUid );
       
   541     ChangeMsgTypeTopL( *iMsgTypesSettings, KSenduiMtmSmtpUid );
       
   542     ChangeMsgTypeTopL( *iMsgTypesSettings, KSenduiMtmAudioMessageUid );
       
   543     // SMS & MMS still have own settings although the editor is common.
       
   544     ChangeMsgTypeTopL( *iMsgTypesSettings, KSenduiMtmMmsUid );
       
   545     ChangeMsgTypeTopL( *iMsgTypesSettings, KSenduiMtmSmsUid );
       
   546     }
       
   547 
       
   548 // ---------------------------------------------------------
       
   549 // CMceSettingsDialog::ChangeMsgTypeTopL
       
   550 // ---------------------------------------------------------
       
   551 //
       
   552 void CMceSettingsDialog::ChangeMsgTypeTopL( CUidNameArray& aArray, TUid aMsgType ) const
       
   553     {
       
   554     TInt loop = 0;
       
   555     // first change email to the top
       
   556     for (loop=1; loop < aArray.Count(); loop++)
       
   557         {
       
   558         if (aArray[loop].iUid == aMsgType)
       
   559             {
       
   560             TUidNameInfo info = aArray[loop];
       
   561             aArray.InsertL( 0, info );
       
   562             aArray.Delete( loop+1 );
       
   563             break;
       
   564             }
       
   565         }
       
   566     }
       
   567 
       
   568 // ----------------------------------------------------
       
   569 // CMceSettingsDialog::LaunchHelpL
       
   570 // Launch help using context
       
   571 // 
       
   572 // ----------------------------------------------------
       
   573 void CMceSettingsDialog::LaunchHelpL() const
       
   574     { 
       
   575     CCoeAppUi* appUi = STATIC_CAST(CCoeAppUi*, ControlEnv()->AppUi());       
       
   576     CArrayFix<TCoeHelpContext>* helpContext = appUi->AppHelpContextL();   
       
   577     HlpLauncher::LaunchHelpApplicationL( iEikonEnv->WsSession(), helpContext );
       
   578     }
       
   579 
       
   580 
       
   581 // ----------------------------------------------------
       
   582 // CMceSettingsDialog::GetHelpContext
       
   583 // returns helpcontext as aContext
       
   584 //
       
   585 // ----------------------------------------------------
       
   586 void CMceSettingsDialog::GetHelpContext
       
   587         (TCoeHelpContext& aContext) const
       
   588     {
       
   589     aContext.iMajor = KMceApplicationUid;
       
   590     aContext.iContext = KMCE_HLP_SETTINGS;
       
   591     }
       
   592 
       
   593 // ----------------------------------------------------
       
   594 // CMceSettingsDialog::CheckCspBitL
       
   595 // returns ETrue if Cell Broadcast csp bit is on
       
   596 //
       
   597 // ----------------------------------------------------
       
   598 TBool CMceSettingsDialog::CheckCspBitL( ) const
       
   599     {
       
   600     RCustomerServiceProfileCache csp;
       
   601 
       
   602     TInt error = csp.Open();
       
   603     if ( error )
       
   604         {        
       
   605         return ETrue;  
       
   606         }
       
   607     
       
   608     RMobilePhone::TCspTeleservices params;
       
   609     TInt retVal = csp.CspTeleServices( params );
       
   610     csp.Close();
       
   611 
       
   612     if ( retVal == KErrNone )
       
   613         {
       
   614         if ( ( params&RMobilePhone::KCspSMCB ) != 0 )
       
   615             {
       
   616             // Cell Broadcast CSP bit is on
       
   617             return ETrue;
       
   618             }
       
   619         else
       
   620             {
       
   621             // Cell Broadcast CSP bit is off
       
   622             return EFalse;
       
   623             }
       
   624         }
       
   625     else
       
   626         {
       
   627         // Error: By default show CBS service
       
   628         return ETrue;
       
   629         }
       
   630 
       
   631     }
       
   632 
       
   633 //  End of File