messagingappbase/mcesettings/src/MceSettingsGeneralSettingsDialog.cpp
branchRCL_3
changeset 60 7fdbb852d323
child 71 17302fa075e1
equal deleted inserted replaced
57:ebe688cedc25 60:7fdbb852d323
       
     1 /*
       
     2 * Copyright (c) 2002 - 2007 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  
       
    15 *     Message centre's general settings dialog.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 // INCLUDE FILES
       
    22 
       
    23 #include <aknViewAppUi.h>
       
    24 #include <AknDlgShut.h>
       
    25 #include <muiusettingsarray.h>  // CMuiuSettingsArray
       
    26 
       
    27 #include <centralrepository.h>
       
    28 #include <messaginginternalcrkeys.h>
       
    29 #include <e32property.h>
       
    30 #include <messaginginternalpskeys.h>
       
    31 #include <e32capability.h>
       
    32 
       
    33 #include "MceSettingsGeneralSettingsDialog.h"
       
    34 #include "MceSettingsMoveProgress.h"    // CMceMoveProgress
       
    35 #include "MceSettingsIds.hrh"
       
    36 #include "MceSettingsAccountManager.h"
       
    37 #include <MceSettings.rsg>
       
    38 
       
    39 #include <CAknMemorySelectionSettingItem.h> // CAknMemorySelectionSettingPage
       
    40 #include <msvuids.h>            // KUidMsvServiceEntry
       
    41 #include <akninputblock.h>      // CAknInputBlock
       
    42 #include <aknnotewrappers.h>    // CAknErrorNote
       
    43 #include <bautils.h>            // BaflUtils
       
    44 
       
    45 #include <MuiuOperationWait.h>  // CMuiuOperationWait
       
    46 #include <sysutil.h>            // Sysutil
       
    47 
       
    48 #include <csxhelp/mce.hlp.hrh>
       
    49 #include <featmgr.h>
       
    50 #include <hlplch.h>             // For HlpLauncher
       
    51 #include "MceSettingsUtils.h"
       
    52 
       
    53 #ifdef RD_MULTIPLE_DRIVE
       
    54 #include <AknCommonDialogsDynMem.h> // Media type
       
    55 #include <CAknMemorySelectionDialogMultiDrive.h> // CAknMemorySelectionDialogMultiDrive
       
    56 #include <driveinfo.h>          // DriveInfo
       
    57 #endif //RD_MULTIPLE_DRIVE
       
    58 #include <e32cmn.h>             // RBuf
       
    59 
       
    60 #include <bldvariant.hrh>
       
    61 #include <data_caging_path_literals.hrh>
       
    62 #include <msvids.h>
       
    63 #include <mtudreg.h>
       
    64 #include <miutset.h>
       
    65 #include <SendUiConsts.h>
       
    66 // CONSTANTS
       
    67 
       
    68 #define KMceApplicationUidValue         0x100058C5
       
    69 const TUid KMceApplicationUid           = {KMceApplicationUidValue};
       
    70 
       
    71 const TInt KMceDefaultSentItemsCount    = 15;
       
    72 const TInt KMceDefaultSentItemsOn       = 0; // first item in list array is 'On'
       
    73 const TInt KMceDefaultSentItemsOff      = 1; // second item in list array is 'Off'
       
    74 const TInt KMceDefaultSentItems         = 1; // == On
       
    75 
       
    76 const TInt KMceEmptyMessageStore        = 40000; // size of empty message store
       
    77 const TInt KMceEditorsWaitInterval      = 4000000; // wait one second,that message editors close
       
    78 
       
    79 const TInt KMSKPosition = 3;
       
    80 
       
    81 const TInt KMceListTypeTwoRow       = 0;
       
    82 const TInt KMceListTypeOneRow       = 1;
       
    83 
       
    84 #define KUidMsgTypeCmailMtmVal               0x2001F406
       
    85 
       
    86 #ifdef _DEBUG
       
    87 _LIT( KPanicText, "MceSettings" );
       
    88 const TInt KCRepositorySettingFailure = 1;
       
    89 #endif
       
    90 #ifdef RD_MESSAGING_GENERAL_SETTINGS_RENOVATION
       
    91 _LIT( KMceDirAndFile,"MceSettings.rsc" );
       
    92 #endif // RD_MESSAGING_GENERAL_SETTINGS_RENOVATION
       
    93 
       
    94 // MODULE DATA STRUCTURES
       
    95 enum TMceGeneralSettings
       
    96     {
       
    97     EMceGeneralSettingsSentItemsInUse,
       
    98     EMceGeneralSettingsSentItemsCount,
       
    99     EMceGeneralSettingsMemoryInUse,
       
   100     EMceGeneralSettingsInboxListType,
       
   101     EMceGeneralSettingsMailListType
       
   102     };
       
   103 // These constants are added to handle 	"show e-mails in groups", when R_MCE_GENERAL_SETTINGS_ITEMS is used for MCESETTINGS.
       
   104 const TInt MceGeneralSettingsInboxListType = 2;
       
   105 const TInt MceGeneralSettingsMailListType = 3;
       
   106 #ifdef RD_MULTIPLE_DRIVE
       
   107 const TInt KSpaceDelimiter=' ';
       
   108 #endif //RD_MULTIPLE_DRIVE
       
   109 
       
   110 // ================= MEMBER FUNCTIONS =======================
       
   111 
       
   112 EXPORT_C TInt CMceGeneralSettingsDialog::CreateAndExecuteL(
       
   113     CMsvSession* aSession, MMsvSessionObserver& aObserver )
       
   114     {
       
   115 #ifdef RD_MESSAGING_GENERAL_SETTINGS_RENOVATION
       
   116     // general settings are list item in the list
       
   117     CMceGeneralSettingsDialog* generalSettingsDlg =
       
   118         new (ELeave) CMceGeneralSettingsDialog( aSession, aObserver, NULL );
       
   119     CleanupStack::PushL( generalSettingsDlg );
       
   120     generalSettingsDlg->ConstructL( R_MCE_GENERAL_SETTINGS_CHOICE_MENUBAR );
       
   121     CleanupStack::Pop( generalSettingsDlg ); 
       
   122     return generalSettingsDlg->ExecuteLD( R_MCE_GENERAL_SETTINGS );
       
   123 #else
       
   124     User::Leave( KErrNotSupported );
       
   125     return KErrNotSupported;
       
   126 #endif // RD_MESSAGING_GENERAL_SETTINGS_RENOVATION
       
   127     }
       
   128 
       
   129 // C++ default constructor can NOT contain any code that
       
   130 // might leave.
       
   131 // ----------------------------------------------------
       
   132 // CMceGeneralSettingsDialog::Constructor
       
   133 // ----------------------------------------------------
       
   134 CMceGeneralSettingsDialog::CMceGeneralSettingsDialog( 
       
   135     CMsvSession* aSession, 
       
   136     MMsvSessionObserver& aObserver, 
       
   137     MMceSettingsAccountManager* aManager )
       
   138     :
       
   139 #ifdef RD_MESSAGING_GENERAL_SETTINGS_RENOVATION
       
   140     CMceSettingsTitlePaneHandlerDialog(),
       
   141     iSession( aSession ), iObserver( aObserver ),
       
   142     iResources( *CCoeEnv::Static() ), iAccountManager( aManager ),
       
   143 #else
       
   144     CMceSettingsTitlePaneHandlerDialog(),
       
   145     iSession( aSession ), iObserver(aObserver ), iAccountManager( aManager ),
       
   146 #endif
       
   147     iChangeDrive(EFalse),
       
   148 	iIsThirdPartyMail( EFalse )
       
   149 	
       
   150     {
       
   151     }
       
   152 
       
   153 
       
   154 void CMceGeneralSettingsDialog::ConstructL( TInt aResource )
       
   155     {
       
   156 #ifdef RD_MESSAGING_GENERAL_SETTINGS_RENOVATION
       
   157     TParse fp;
       
   158     fp.Set( KMceDirAndFile, &KDC_RESOURCE_FILES_DIR , NULL );
       
   159     TFileName fileName = fp.FullName();
       
   160 
       
   161     iResources.OpenL( fileName );
       
   162 #endif
       
   163     CMceSettingsTitlePaneHandlerDialog::ConstructL( aResource );
       
   164 	iIsThirdPartyMail = IsThirdPartyMailBoxL();
       
   165     }
       
   166 
       
   167 // ----------------------------------------------------
       
   168 // CMceGeneralSettingsDialog::Destructor
       
   169 // ----------------------------------------------------
       
   170 CMceGeneralSettingsDialog::~CMceGeneralSettingsDialog()
       
   171     {    
       
   172 #ifdef RD_MESSAGING_GENERAL_SETTINGS_RENOVATION
       
   173     iResources.Close();
       
   174 #endif // RD_MESSAGING_GENERAL_SETTINGS_RENOVATION
       
   175     // don't delete iAccountManager
       
   176     }
       
   177 
       
   178 // ----------------------------------------------------
       
   179 // CMceGeneralSettingsDialog::OkToExitL
       
   180 // ----------------------------------------------------
       
   181 TInt CMceGeneralSettingsDialog::OkToExitL( TInt aButtonId )
       
   182     {
       
   183     TBool okToExit = CAknDialog::OkToExitL( aButtonId );
       
   184     if ( aButtonId == EAknSoftkeyBack || okToExit )
       
   185         {
       
   186         CRepository* repository = NULL;
       
   187         TRAPD( ret, repository = CRepository::NewL( KCRUidMuiuSettings ) );
       
   188         CleanupStack::PushL( repository );
       
   189 
       
   190         if ( ret == KErrNone )
       
   191             {
       
   192             ret = repository->Set( KMuiuSentItemsInUse, 
       
   193             ( *iMceSettingsArray )[EMceGeneralSettingsSentItemsInUse].iCurrentNumber == KMceDefaultSentItemsOn );
       
   194             __ASSERT_DEBUG( !ret, User::Panic( KPanicText,KCRepositorySettingFailure ) );
       
   195 #ifdef _DEBUG
       
   196             TInt setValue = ( *iMceSettingsArray )[EMceGeneralSettingsSentItemsInUse].iCurrentNumber;
       
   197             setValue = ( setValue == KMceDefaultSentItemsOn );
       
   198 #endif
       
   199 
       
   200             ret = repository->Set( KMuiuSentItemsCount,
       
   201                 ( *iMceSettingsArray )[EMceGeneralSettingsSentItemsCount].iCurrentNumber );
       
   202             __ASSERT_DEBUG( !ret, User::Panic(KPanicText,KCRepositorySettingFailure) );
       
   203 #ifdef _DEBUG
       
   204             setValue = ( *iMceSettingsArray )[EMceGeneralSettingsSentItemsCount].iCurrentNumber;
       
   205 #endif
       
   206 
       
   207             if ( iMemoryInUse )
       
   208                 {
       
   209                 ret = repository->Set( KMuiuInboxMessageListType,
       
   210                   ( *iMceSettingsArray )[EMceGeneralSettingsInboxListType].iCurrentNumber );
       
   211                 }
       
   212             else
       
   213                 {
       
   214                 ret = repository->Set( KMuiuInboxMessageListType,
       
   215                   ( *iMceSettingsArray )[MceGeneralSettingsInboxListType].iCurrentNumber );
       
   216                 }
       
   217             __ASSERT_DEBUG( !ret, User::Panic(KPanicText,KCRepositorySettingFailure) );            
       
   218 
       
   219             if ( iIsThirdPartyMail )
       
   220                 {
       
   221                 if ( iMemoryInUse )
       
   222                     {
       
   223                     ret = repository->Set( KMuiuMailMessageListType,
       
   224                       ( *iMceSettingsArray )[EMceGeneralSettingsMailListType].iCurrentNumber );
       
   225                     }
       
   226                 else
       
   227                     {
       
   228                     ret = repository->Set( KMuiuMailMessageListType,
       
   229                       ( *iMceSettingsArray )[MceGeneralSettingsMailListType].iCurrentNumber );
       
   230                     }
       
   231                 __ASSERT_DEBUG( !ret, User::Panic(KPanicText,KCRepositorySettingFailure) );
       
   232                 }
       
   233             
       
   234             }
       
   235         CleanupStack::Pop( repository );
       
   236         delete repository;
       
   237         }
       
   238 
       
   239     if ( aButtonId == EMceSettingsCmdSettingsDialogOpen || 
       
   240           aButtonId == EMceSettingsCmdSettingsDialogChange )
       
   241         {
       
   242         ProcessCommandL( aButtonId );
       
   243         okToExit = EFalse; // Cannot exit, since MSK was pressed
       
   244         }
       
   245     else if ( aButtonId != EEikBidCancel && okToExit )
       
   246         {
       
   247         RestoreTitleTextL();
       
   248         }
       
   249     return okToExit;
       
   250     }
       
   251 
       
   252 // ----------------------------------------------------
       
   253 // CMceGeneralSettingsDialog::HandleListBoxEventL
       
   254 // ----------------------------------------------------
       
   255 void CMceGeneralSettingsDialog::HandleListBoxEventL(
       
   256     CEikListBox* /*aListBox*/,
       
   257     TListBoxEvent aEventType )
       
   258     {    
       
   259     CEikTextListBox* list=STATIC_CAST( CEikTextListBox*, 
       
   260         Control( EMceSettingsIdOtherItems ) );
       
   261     switch(aEventType)
       
   262         {
       
   263         case EEventEnterKeyPressed:
       
   264         case EEventItemSingleClicked:
       
   265             {            
       
   266             TInt item = list->CurrentItemIndex();            
       
   267             if ( iMemoryInUse && item == EMceGeneralSettingsMemoryInUse )               
       
   268                 {
       
   269                 HandleMemoryInUseDialogL();
       
   270                 }
       
   271             else
       
   272                 {
       
   273                 iMceSettingsArray->EditItemL( item, ETrue );               
       
   274                 list->DrawNow();
       
   275                 }
       
   276             }
       
   277             break;
       
   278             
       
   279         default:
       
   280             break;
       
   281         }
       
   282     }
       
   283 
       
   284 // ----------------------------------------------------
       
   285 // CMceGeneralSettingsDialog::ProcessCommandL
       
   286 // ----------------------------------------------------
       
   287 void CMceGeneralSettingsDialog::ProcessCommandL( TInt aCommandId )
       
   288     {
       
   289     CAknDialog::ProcessCommandL( aCommandId ); // hides menu
       
   290     if ( aCommandId == EMceSettingsCmdSettingsDialogExit )
       
   291         {
       
   292         if (iAvkonViewAppUi->ExitHidesInBackground()) 
       
   293             { 
       
   294             iAvkonViewAppUi->ProcessCommandL( EAknCmdHideInBackground );
       
   295             }
       
   296         else
       
   297             {
       
   298             iAvkonViewAppUi->ProcessCommandL( EAknCmdExit );
       
   299             }
       
   300         return;
       
   301         }
       
   302 
       
   303     
       
   304     CEikTextListBox* list=STATIC_CAST( CEikTextListBox*, 
       
   305         Control( EMceSettingsIdOtherItems ) );
       
   306 
       
   307     switch ( aCommandId )
       
   308         {
       
   309         case EMceSettingsCmdSettingsDialogOpen:
       
   310             {            
       
   311             TInt item = list->CurrentItemIndex();
       
   312             if ( iMemoryInUse && item == EMceGeneralSettingsMemoryInUse )               
       
   313                 {
       
   314                 HandleMemoryInUseDialogL();
       
   315                 }
       
   316             else
       
   317                 {
       
   318                 iMceSettingsArray->EditItemL( item, EFalse );                
       
   319                 list->DrawNow();
       
   320                 }       
       
   321             }
       
   322             break;           
       
   323 
       
   324         case EMceSettingsCmdSettingsDialogHelp:
       
   325                 {
       
   326                 LaunchHelpL();                
       
   327                 }
       
   328                 break;           
       
   329         
       
   330         case EMceSettingsCmdSettingsDialogChange:
       
   331                 {
       
   332                 TInt item = list->CurrentItemIndex();
       
   333             if ( iMemoryInUse && item == EMceGeneralSettingsMemoryInUse )               
       
   334                 {
       
   335                 HandleMemoryInUseDialogL();
       
   336                 }
       
   337             else
       
   338                 {
       
   339                 iMceSettingsArray->EditItemL( item,  ETrue );                
       
   340                 list->DrawNow();
       
   341                 }                        
       
   342             }
       
   343             break; 
       
   344         default :
       
   345             break;
       
   346         }
       
   347     }
       
   348 
       
   349 
       
   350 // ----------------------------------------------------
       
   351 // CMceGeneralSettingsDialog::PreLayoutDynInitL
       
   352 // ----------------------------------------------------
       
   353 void CMceGeneralSettingsDialog::PreLayoutDynInitL( )
       
   354     {
       
   355     //check if 'Memory in use' -option is enabled in mce settings
       
   356     iMemoryInUse = ETrue;
       
   357     iMemoryInUse = MceSettingsUtils::MemoryInUseOptionL();
       
   358 
       
   359     CEikTextListBox* list=STATIC_CAST( CEikTextListBox*, 
       
   360         Control( EMceSettingsIdOtherItems ) );
       
   361 
       
   362     // Setting scrollbar-indicators on
       
   363     list->CreateScrollBarFrameL( ETrue );
       
   364     list->ScrollBarFrame()->SetScrollBarVisibilityL(
       
   365         CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto );
       
   366 
       
   367     if ( iMemoryInUse )
       
   368         {
       
   369         iMceSettingsArray = CMuiuSettingsArray::NewL( R_MCE_GENERAL_MMC );
       
   370         }
       
   371     else
       
   372         {
       
   373         iMceSettingsArray = CMuiuSettingsArray::NewL( R_MCE_GENERAL_SETTINGS_ITEMS );
       
   374         } 
       
   375 
       
   376     list->SetListBoxObserver( this );
       
   377 
       
   378     CRepository* repository = NULL;
       
   379     TRAPD( ret, repository = CRepository::NewL( KCRUidMuiuSettings ) );
       
   380     CleanupStack::PushL( repository );
       
   381 
       
   382     if ( ret == KErrNone )
       
   383         {
       
   384         TInt i;
       
   385         if ( repository->Get( KMuiuSentItemsInUse, i ) != KErrNone )
       
   386             {
       
   387             i = KMceDefaultSentItems;
       
   388             }
       
   389         ( *iMceSettingsArray )[EMceGeneralSettingsSentItemsInUse].iCurrentNumber =
       
   390                 i ? KMceDefaultSentItemsOn : KMceDefaultSentItemsOff;
       
   391  
       
   392         if ( repository->Get(KMuiuSentItemsCount, i ) != KErrNone )
       
   393             {
       
   394             i = KMceDefaultSentItemsCount;
       
   395             }
       
   396         ( *iMceSettingsArray )[EMceGeneralSettingsSentItemsCount].iCurrentNumber = i;
       
   397         ( *iMceSettingsArray )[EMceGeneralSettingsSentItemsCount].iUserText.Num( i );
       
   398         
       
   399         // Get one/two row list type selection
       
   400         if ( repository->Get( KMuiuInboxMessageListType, i ) != KErrNone )
       
   401             {
       
   402             i = KMceListTypeTwoRow;
       
   403             }
       
   404         if ( iMemoryInUse )
       
   405             {
       
   406             ( *iMceSettingsArray )[EMceGeneralSettingsInboxListType].iCurrentNumber =
       
   407                    i ? KMceListTypeOneRow : KMceListTypeTwoRow;
       
   408             }
       
   409         else
       
   410             {
       
   411             ( *iMceSettingsArray )[MceGeneralSettingsInboxListType].iCurrentNumber =
       
   412                    i ? KMceListTypeOneRow : KMceListTypeTwoRow;
       
   413             }
       
   414         
       
   415         if ( iIsThirdPartyMail )
       
   416             {
       
   417              // Get one/two row list type selection
       
   418              if ( repository->Get( KMuiuMailMessageListType, i ) != KErrNone )
       
   419                  {
       
   420                  i = KMceListTypeOneRow;
       
   421                  }
       
   422              if ( iMemoryInUse )
       
   423                  {
       
   424                  ( *iMceSettingsArray )[EMceGeneralSettingsMailListType].iCurrentNumber =
       
   425                          i ? KMceListTypeOneRow : KMceListTypeTwoRow;
       
   426                  }
       
   427              else
       
   428                  {
       
   429                  ( *iMceSettingsArray )[MceGeneralSettingsMailListType].iCurrentNumber =
       
   430                         i ? KMceListTypeOneRow : KMceListTypeTwoRow;
       
   431                  }
       
   432             }
       
   433         else
       
   434             {
       
   435             if ( iMemoryInUse )
       
   436                 {
       
   437                 iMceSettingsArray->Delete(EMceGeneralSettingsMailListType);
       
   438                 }
       
   439             else
       
   440                 {
       
   441                 iMceSettingsArray->Delete(MceGeneralSettingsMailListType);
       
   442                 }
       
   443             }
       
   444         }
       
   445 
       
   446     if ( iMemoryInUse )
       
   447         {
       
   448         UpdateMemorySelectionL();
       
   449         }
       
   450 
       
   451     CleanupStack::Pop( repository ); 
       
   452     delete repository;
       
   453 
       
   454     CTextListBoxModel* model=list->Model();
       
   455     model->SetItemTextArray( iMceSettingsArray );
       
   456 
       
   457     StoreTitleTextAndSetNewL( R_MCE_SETTINGS_TITLE_GENERAL );
       
   458     SetMSKButtonL();
       
   459     }
       
   460 
       
   461 //  ----------------------------------------------------
       
   462 // CMceGeneralSettingsDialog::SetTransferError
       
   463 // Catches the error when failed moving message store
       
   464 //  ----------------------------------------------------
       
   465 void CMceGeneralSettingsDialog::SetTransferError( TInt aError )
       
   466     {
       
   467     iTransferError = aError;
       
   468     }    
       
   469 
       
   470 // ----------------------------------------------------
       
   471 // CMceGeneralSettingsDialog::MoveMessageStoreL
       
   472 // starts copying/moving message store
       
   473 // if move, aDeleteCopiedStore is ETrue, if copy EFalse
       
   474 // ----------------------------------------------------
       
   475 void CMceGeneralSettingsDialog::MoveMessageStoreL( TInt currentDrive, 
       
   476          TInt driveNumber, TBool aDeleteCopiedStore )
       
   477     {    
       
   478     if( !CheckIsServerBusyL() )
       
   479         {
       
   480         CAknInputBlock* comAbs=CAknInputBlock::NewLC();  
       
   481         iTransferError  = KErrNone;
       
   482         CMceMoveProgress* moveProgress=CMceMoveProgress::NewL(
       
   483             iSession, iObserver, currentDrive, driveNumber, aDeleteCopiedStore,*this, EFalse );
       
   484            
       
   485         CleanupStack::PushL( moveProgress );
       
   486         if ( iAccountManager )
       
   487             {
       
   488             iAccountManager->SetChangeMessageStore( EFalse );
       
   489             }
       
   490 
       
   491         moveProgress->InitializingL();
       
   492         
       
   493         // KErrAccessDenied: when MC is read-only
       
   494         // preventing messaging close. Todo: anyother erro cases?       
       
   495         if ( iTransferError != KErrAccessDenied && iAccountManager )
       
   496             {
       
   497             iAccountManager->SetChangeMessageStore( ETrue );
       
   498             }
       
   499 
       
   500         // cannot delete CMceMoveProgress, 
       
   501         // because CMceMessageTransHandler is cancelled-> has to be deleted in CMceMoveProgress
       
   502         CleanupStack::Pop( moveProgress ); 
       
   503         CleanupStack::PopAndDestroy( comAbs );
       
   504         }
       
   505     }
       
   506 
       
   507 
       
   508 // ----------------------------------------------------
       
   509 // CMceGeneralSettingsDialog::CheckIsServerBusyL
       
   510 // checks, if connection is on
       
   511 // return ETrue, if connection is on
       
   512 // ----------------------------------------------------
       
   513 TBool CMceGeneralSettingsDialog::CheckIsServerBusyL()
       
   514     {
       
   515     TInt outstanding=iSession->OutstandingOperationsL();
       
   516 
       
   517     if (outstanding==0)
       
   518         {
       
   519         // check to see if any mailboxes are open - otherwise we could miss client side operations
       
   520         CMsvEntry* root=CMsvEntry::NewL( *iSession, 
       
   521                      KMsvRootIndexEntryIdValue, 
       
   522                      TMsvSelectionOrdering(KMsvNoGrouping, EMsvSortByNone, ETrue ) );
       
   523         CleanupStack::PushL( root );
       
   524         CMsvEntrySelection* sel=root->ChildrenWithTypeL( KUidMsvServiceEntry );
       
   525         CleanupStack::PushL( sel );
       
   526         const TMsvEntry* tentry=NULL;
       
   527         for ( TInt cc=sel->Count(); --cc>=0 && !outstanding ;)
       
   528             {
       
   529             tentry=&( root->ChildDataL( ( *sel )[cc] ) );
       
   530             if ( tentry->Connected() )
       
   531                 {
       
   532                 outstanding++;
       
   533                 }
       
   534             }
       
   535 
       
   536         CleanupStack::PopAndDestroy( sel );
       
   537         CleanupStack::PopAndDestroy( root );
       
   538         }
       
   539 
       
   540     if (outstanding>0)
       
   541         {
       
   542         HBufC* text = StringLoader::LoadLC( R_MCE_SETTINGS_SERVER_BUSY, CCoeEnv::Static() );
       
   543         CAknErrorNote* note = new ( ELeave ) CAknErrorNote();
       
   544         note->ExecuteLD( *text );
       
   545         CleanupStack::PopAndDestroy( text ); 
       
   546         return ETrue;
       
   547         }
       
   548 
       
   549     return EFalse;
       
   550     }
       
   551 
       
   552 // ----------------------------------------------------
       
   553 // CMceGeneralSettingsDialog::FindSourcePathL
       
   554 // gives message store path in aPath, when drive number is got
       
   555 //
       
   556 // ----------------------------------------------------
       
   557 void CMceGeneralSettingsDialog::FindSourcePathL( TInt aDrive, TFileName& aPath ) const
       
   558     {
       
   559     GetMessageDriveL( aDrive, aPath );
       
   560     TParsePtrC pptr( KMsvDefaultFolder );
       
   561     aPath.Append( pptr.Path() );
       
   562     }
       
   563 
       
   564 // ----------------------------------------------------
       
   565 // CMceGeneralSettingsDialog::GetMessageDriveL
       
   566 // gives drive letter and drive delimiter in aPath,
       
   567 // when drive number is got
       
   568 // ----------------------------------------------------
       
   569 void CMceGeneralSettingsDialog::GetMessageDriveL( TInt aDrive, TDes& aPath ) const
       
   570     {
       
   571     TChar driveLetter;
       
   572     User::LeaveIfError( iEikonEnv->FsSession().DriveToChar( aDrive, driveLetter ) );
       
   573     aPath.Zero();
       
   574     aPath.Append( driveLetter );
       
   575     aPath.Append( TChar( KDriveDelimiter ) );
       
   576     }
       
   577 
       
   578 // ----------------------------------------------------
       
   579 // CMceGeneralSettingsDialog::UpdateMemorySelectionL
       
   580 // sets correct string in General settings memory in use -option
       
   581 //
       
   582 // ----------------------------------------------------
       
   583 void CMceGeneralSettingsDialog::UpdateMemorySelectionL()
       
   584     {
       
   585     RFs& fs=iEikonEnv->FsSession();    
       
   586 
       
   587 #ifndef RD_MULTIPLE_DRIVE
       
   588     if ( TInt( iSession->CurrentDriveL() ) == EDriveC )
       
   589         {
       
   590         HBufC* text = StringLoader::LoadLC( R_MCE_SETTINGS_PHONE_MEMORY, iEikonEnv );
       
   591 
       
   592         ( *iMceSettingsArray )[EMceGeneralSettingsMemoryInUse].iUserText.Copy( *text );
       
   593         CleanupStack::PopAndDestroy( text );  
       
   594         }
       
   595     else
       
   596         { 
       
   597         TVolumeInfo volumeinfo;
       
   598         fs.Volume( volumeinfo, TInt(iSession->CurrentDriveL() ) );
       
   599         if( volumeinfo.iName.Length() > 0 ) // Volume has a label
       
   600            { // Use volume label as memory card name
       
   601            ( *iMceSettingsArray )[EMceGeneralSettingsMemoryInUse].iUserText.Copy( volumeinfo.iName );
       
   602            }
       
   603         else
       
   604            {
       
   605            HBufC* text = StringLoader::LoadLC( R_MCE_SETTINGS_MEMORY_CARD, iEikonEnv );
       
   606            ( *iMceSettingsArray )[EMceGeneralSettingsMemoryInUse].iUserText.Copy( *text );
       
   607            CleanupStack::PopAndDestroy( text );
       
   608            }
       
   609         }
       
   610 
       
   611 #else
       
   612     TInt currentDrive = TInt( iSession->CurrentDriveL() );
       
   613     
       
   614     TVolumeInfo volumeinfo;
       
   615     fs.Volume( volumeinfo, TInt( currentDrive ) );
       
   616     if( volumeinfo.iName.Length() > 0 ) // Volume has a label
       
   617         { // Use volume label as memory card name
       
   618         TDriveName driveName(TDriveUnit( currentDrive ).Name() );
       
   619         RBuf newtxt;
       
   620         newtxt.CreateL( driveName.Length() + volumeinfo.iName.Length() + 1 ); // 1 for space
       
   621         CleanupClosePushL( newtxt );
       
   622         
       
   623         newtxt.Append( driveName );
       
   624         newtxt.Append( KSpaceDelimiter );
       
   625         newtxt.Append( volumeinfo.iName );        
       
   626               
       
   627         ( *iMceSettingsArray )[EMceGeneralSettingsMemoryInUse].iUserText.Copy( newtxt );        
       
   628         CleanupStack::PopAndDestroy( &newtxt );
       
   629         }
       
   630     else
       
   631         {
       
   632         HBufC *driveNameText = MakeDriveNameStringLC( currentDrive );
       
   633         ( *iMceSettingsArray )[EMceGeneralSettingsMemoryInUse].iUserText.Copy( *driveNameText );
       
   634         CleanupStack::PopAndDestroy( driveNameText );        
       
   635         }
       
   636 
       
   637 #endif //RD_MULTIPLE_DRIVE
       
   638     CEikTextListBox* list=STATIC_CAST( CEikTextListBox*, 
       
   639         Control( EMceSettingsIdOtherItems ) );
       
   640     list->DrawNow();
       
   641 
       
   642     CRepository* repository = NULL;
       
   643     TRAPD( ret, repository = CRepository::NewL( KCRUidMuiuSettings ) );
       
   644     CleanupStack::PushL( repository );
       
   645 
       
   646     if ( ret == KErrNone )
       
   647         {
       
   648         ret = repository->Set( KMuiuMemoryInUse, TInt( iSession->CurrentDriveL() ) );
       
   649         __ASSERT_DEBUG( !ret, User::Panic( KPanicText,KCRepositorySettingFailure ) );
       
   650         }
       
   651 
       
   652     CleanupStack::Pop( repository );
       
   653     delete repository;
       
   654     }
       
   655 
       
   656 // ----------------------------------------------------
       
   657 // CMceGeneralSettingsDialog::ShutdownAppsL
       
   658 // closes sms, mms and mail applications,
       
   659 // before changing message store
       
   660 // ----------------------------------------------------
       
   661 TBool CMceGeneralSettingsDialog::ShutdownAppsL() const
       
   662     {
       
   663     RProperty property;
       
   664 
       
   665     User::LeaveIfError( property.Attach( KPSUidMuiu,KMuiuSysOpenMsgEditors ) );
       
   666     CleanupClosePushL( property );
       
   667     
       
   668     TInt i = 0;
       
   669     if ( property.Get(i) != KErrNone )
       
   670         {
       
   671         i = 0;
       
   672         }
       
   673     if ( i != 0 )
       
   674         {
       
   675         // clients are open
       
   676         CAknQueryDialog* closeDialog = CAknQueryDialog::NewL();
       
   677 
       
   678         HBufC* text = NULL;
       
   679         text = StringLoader::LoadLC( R_MCE_CLOSE_MESSAGES_CONFIRM, CCoeEnv::Static() );
       
   680         closeDialog->SetPromptL( *text );
       
   681         CleanupStack::PopAndDestroy( text );
       
   682 
       
   683         // Do you want to close all the open messages?
       
   684         if ( !closeDialog->ExecuteLD( R_MCE_MOVE_CONFIRM ) )            
       
   685             {
       
   686             CleanupStack::PopAndDestroy( &property );
       
   687             return EFalse;
       
   688             }
       
   689         else
       
   690             {
       
   691             i = 0;
       
   692             property.Set( KPSUidMuiu, KMuiuSysOpenMsgEditors, i );
       
   693             
       
   694             // wait a second
       
   695             User::After( KMceEditorsWaitInterval );
       
   696             }
       
   697         }
       
   698     CleanupStack::PopAndDestroy( &property );
       
   699     return ETrue;
       
   700     }
       
   701 
       
   702 
       
   703 // ----------------------------------------------------
       
   704 // CMceGeneralSettingsDialog::HandleMemoryInUseDialogL
       
   705 // handles Memory in Use option
       
   706 // 
       
   707 // ----------------------------------------------------
       
   708 void CMceGeneralSettingsDialog::HandleMemoryInUseDialogL()
       
   709     {
       
   710     if ( !ShutdownAppsL() )
       
   711         {
       
   712         // User does not want to close open messages
       
   713         return;
       
   714         }
       
   715     
       
   716     if(iChangeDrive)
       
   717         {
       
   718         return;
       
   719         }
       
   720 
       
   721     RFs& fs=iEikonEnv->FsSession();
       
   722     
       
   723 #ifdef RD_MULTIPLE_DRIVE     
       
   724     // Memory selection dialog from Avkon    
       
   725     CAknMemorySelectionDialogMultiDrive* dlg = CAknMemorySelectionDialogMultiDrive::NewL(
       
   726             ECFDDialogTypeNormal, 
       
   727             0, // Default resource Id
       
   728             EFalse,
       
   729             AknCommonDialogsDynMem::EMemoryTypePhone |
       
   730             AknCommonDialogsDynMem::EMemoryTypeInternalMassStorage | 
       
   731             AknCommonDialogsDynMem::EMemoryTypeMMCExternal  );
       
   732 
       
   733     CleanupStack::PushL( dlg );
       
   734     TInt currentDrive = TInt( iSession->CurrentDriveL() ); 
       
   735     TDriveNumber driveNumber = static_cast<TDriveNumber>( currentDrive );
       
   736     CAknMemorySelectionDialogMultiDrive::TReturnKey value = dlg->ExecuteL( driveNumber );
       
   737     CleanupStack::PopAndDestroy( dlg );
       
   738      
       
   739     TInt selectedDrive; 
       
   740     //if the user didn't press cancel key
       
   741     if (value != CAknMemorySelectionDialogMultiDrive::ERightSoftkey )
       
   742         { 
       
   743         selectedDrive = static_cast<TInt>( driveNumber );
       
   744         }
       
   745     // if the user press cancel
       
   746     else
       
   747         { 
       
   748         return;
       
   749         }           
       
   750     
       
   751 #else            
       
   752     TInt currentDrive = TInt( iSession->CurrentDriveL() );
       
   753     CAknMemorySelectionSettingPage::TMemory memory( CAknMemorySelectionSettingPage::EPhoneMemory );
       
   754 
       
   755     CAknMemorySelectionSettingPage* dlg = CAknMemorySelectionSettingPage::NewL();
       
   756     CleanupStack::PushL( dlg ); 
       
   757 
       
   758     HBufC* text = StringLoader::LoadLC( R_MCE_SETTINGS_GEN_HEADING, iEikonEnv );  
       
   759     dlg->SetTitleL( *text ); 
       
   760     CleanupStack::PopAndDestroy( text );                
       
   761             
       
   762     if ( currentDrive == EDriveC )
       
   763         {                
       
   764         memory = CAknMemorySelectionSettingPage::EPhoneMemory;
       
   765         }
       
   766     else
       
   767         {                
       
   768         memory = CAknMemorySelectionSettingPage::EMemoryCard;
       
   769         }
       
   770 
       
   771     CAknMemorySelectionSettingPage::TReturnKey value = dlg->ExecuteL( memory );
       
   772     CleanupStack::PopAndDestroy( dlg );
       
   773 
       
   774     if ( value == CAknMemorySelectionSettingPage::ERightSoftkey )
       
   775        //Cancel was pressed;
       
   776         {
       
   777         return;
       
   778         }
       
   779 
       
   780     TInt selectedDrive;
       
   781     if ( memory == CAknMemorySelectionSettingPage::EPhoneMemory )
       
   782         {
       
   783         selectedDrive = EDriveC;            
       
   784         }
       
   785     else
       
   786         {
       
   787         selectedDrive = EDriveE;
       
   788         }
       
   789 #endif // RD_MULTIPLE_DRIVE
       
   790 
       
   791     if (selectedDrive == currentDrive )
       
   792         {
       
   793         // no change, memory has not been changed
       
   794         UpdateMemorySelectionL(); 
       
   795         return;                
       
   796         }        
       
   797     else
       
   798         {
       
   799         TBool storeExist = EFalse;
       
   800         TRAPD( error, storeExist = iSession->DriveContainsStoreL( selectedDrive ) );
       
   801 
       
   802         if ( !error && storeExist )              
       
   803             {            
       
   804             //if server is busy, do not change store
       
   805             if( CheckIsServerBusyL() )
       
   806                 {
       
   807                 return;
       
   808                 }
       
   809             CAknInputBlock* comAbs=CAknInputBlock::NewLC();  
       
   810             // change message store
       
   811             CMuiuOperationWait* waiter=CMuiuOperationWait::NewLC();
       
   812 
       
   813             CMsvProgressReporterOperation* reportOp =
       
   814                     CMsvProgressReporterOperation::NewL( *iSession, waiter->iStatus );
       
   815             CleanupStack::PushL( reportOp );
       
   816 
       
   817             reportOp->SetProgressVisibilityDelay(EFalse);
       
   818             HBufC* text = StringLoader::LoadLC( R_MCE_SETTINGS_SWITCHING_MESSAGE_STORE, 
       
   819                        iEikonEnv );  
       
   820             reportOp->SetTitleL( *text ); 
       
   821 
       
   822             reportOp->SetCanCancelL( EFalse);
       
   823 
       
   824             CleanupStack::PopAndDestroy( text );
       
   825             iChangeDrive = ETrue;
       
   826             CMsvOperation* changeOp=iSession->ChangeDriveL( selectedDrive, reportOp->RequestStatus() );
       
   827             reportOp->SetOperationL( changeOp );
       
   828 
       
   829             waiter->Start();
       
   830             iChangeDrive = EFalse;
       
   831             CleanupStack::PopAndDestroy( reportOp );
       
   832             CleanupStack::PopAndDestroy( waiter );
       
   833             CleanupStack::PopAndDestroy( comAbs );
       
   834                   
       
   835             //memory has been changed
       
   836             UpdateMemorySelectionL();           
       
   837             }
       
   838         else       
       
   839             {
       
   840 //#ifdef RD_MULTIPLE_DRIVE
       
   841 //            //Todo: Check the memory statue here, if it's read-only then show error note
       
   842 //            // Wait for UIcr approved            
       
   843 //            TUint driveStatus( 0 ); 
       
   844 //            User::LeaveIfError( DriveInfo::GetDriveStatus( fs, driveNumber, driveStatus ) );
       
   845 //            if ( driveStatus & DriveInfo::EDriveReadOnly )
       
   846 //                {
       
   847 //                HBufC* text = StringLoader::LoadLC( R_MCE_SETTINGS_CANNOT_MOVE_STORE, 
       
   848 //        	                                                           CCoeEnv::Static() );
       
   849 //        	    CAknErrorNote* note = new (ELeave) CAknErrorNote();
       
   850 //        	    note->ExecuteLD(*text);
       
   851 //        	    CleanupStack::PopAndDestroy( text );
       
   852 //        	
       
   853 //        	    return;
       
   854 //                }
       
   855 //#endif     
       
   856    
       
   857             // copy/move message store
       
   858             CAknQueryDialog* moveDialog = CAknQueryDialog::NewL();  
       
   859 
       
   860             // Do you want to copy all messages to the messaging store?
       
   861             if ( moveDialog->ExecuteLD( R_MCE_MOVE_CONFIRM ) )
       
   862                 {    
       
   863                 // Yes:
       
   864                 // other question: Do you want to save the original messages?
       
   865                 CAknQueryDialog* movesaveDialog = CAknQueryDialog::NewL();
       
   866           
       
   867                 HBufC* text = NULL;
       
   868                 text = StringLoader::LoadLC( R_MCE_MOVE_SAVE_CONFIRM, CCoeEnv::Static() );
       
   869                 movesaveDialog->SetPromptL( *text );
       
   870                 CleanupStack::PopAndDestroy( text );
       
   871                         
       
   872                 if ( movesaveDialog->ExecuteLD( R_MCE_MOVE_CONFIRM ) )
       
   873                     {
       
   874                     //Yes: Copy messages                     
       
   875                     MoveMessageStoreL( currentDrive, selectedDrive, EFalse );
       
   876                     }
       
   877                 else
       
   878                     {
       
   879                     //No: Move messages
       
   880                     MoveMessageStoreL( currentDrive, selectedDrive, ETrue );
       
   881                     }
       
   882                 }
       
   883             else
       
   884                 {
       
   885                 // No: show empty message storage
       
   886 
       
   887                 //if server is busy, do not change store
       
   888                 if( CheckIsServerBusyL() )
       
   889                     {
       
   890                     return;
       
   891                     }
       
   892 
       
   893                 // when empty store is created, it takes memory about 40kb
       
   894                 // check first free memory
       
   895                 if ( SysUtil::DiskSpaceBelowCriticalLevelL( &iEikonEnv->FsSession(), 
       
   896                         KMceEmptyMessageStore, selectedDrive ) )
       
   897                     {
       
   898                     User::Leave( KErrDiskFull );
       
   899                     }
       
   900                 CAknInputBlock* comAbs=CAknInputBlock::NewLC(); 
       
   901                 CMuiuOperationWait* waiter=CMuiuOperationWait::NewLC(); 
       
   902 
       
   903                 CMsvProgressReporterOperation* reportOp =
       
   904                             CMsvProgressReporterOperation::NewL( *iSession, waiter->iStatus );
       
   905                 CleanupStack::PushL( reportOp );
       
   906 
       
   907                 reportOp->SetProgressVisibilityDelay(EFalse);
       
   908                 HBufC* text = StringLoader::LoadLC( R_MCE_SETTINGS_SWITCHING_MESSAGE_STORE, 
       
   909                                                                         iEikonEnv );  
       
   910                 reportOp->SetTitleL( *text ); 
       
   911 
       
   912                 reportOp->SetCanCancelL( EFalse);
       
   913 
       
   914                 CleanupStack::PopAndDestroy( text );
       
   915                 iChangeDrive = ETrue;
       
   916                 CMsvOperation* changeOp=iSession->ChangeDriveL( selectedDrive, 
       
   917                                                                                                 reportOp->RequestStatus() );
       
   918                 reportOp->SetOperationL( changeOp );
       
   919 
       
   920                 waiter->Start();
       
   921                 iChangeDrive = EFalse;
       
   922                 CleanupStack::PopAndDestroy( reportOp ); 
       
   923                 CleanupStack::PopAndDestroy( waiter );
       
   924                 CleanupStack::PopAndDestroy( comAbs );
       
   925                 UpdateMemorySelectionL();
       
   926                 }                
       
   927             }
       
   928 		
       
   929         CEikTextListBox* list=STATIC_CAST( CEikTextListBox*, 
       
   930             Control( EMceSettingsIdOtherItems ) );
       
   931         list->DrawNow();        
       
   932         }    
       
   933    }
       
   934 
       
   935 
       
   936 // ----------------------------------------------------
       
   937 // CMceGeneralSettingsDialog::GetHelpContext
       
   938 // returns helpcontext as aContext
       
   939 //
       
   940 // ----------------------------------------------------
       
   941 void CMceGeneralSettingsDialog::GetHelpContext
       
   942         ( TCoeHelpContext& aContext ) const
       
   943     {
       
   944     aContext.iMajor = KMceApplicationUid;
       
   945     aContext.iContext = KMCE_HLP_SETTINGS_GEN;
       
   946     }
       
   947 
       
   948 // ----------------------------------------------------
       
   949 // CMceGeneralSettingsDialog::DynInitMenuPaneL
       
   950 // ----------------------------------------------------
       
   951 void CMceGeneralSettingsDialog::DynInitMenuPaneL( TInt aResourceId, CEikMenuPane* aMenuPane )
       
   952     {
       
   953     if ( aResourceId == R_MCE_GENERAL_SETTINGS_CHOICE_MENUPANE )
       
   954         {
       
   955         aMenuPane->SetItemDimmed( EMceSettingsCmdSettingsDialogHelp, 
       
   956             !FeatureManager::FeatureSupported( KFeatureIdHelp ) );               
       
   957         }
       
   958     }
       
   959 
       
   960 // ----------------------------------------------------
       
   961 // CMceGeneralSettingsDialog::LaunchHelpL
       
   962 // Launch help using context
       
   963 // 
       
   964 // ----------------------------------------------------
       
   965 void CMceGeneralSettingsDialog::LaunchHelpL() const
       
   966     { 
       
   967     CCoeAppUi* appUi = STATIC_CAST( CCoeAppUi*, ControlEnv()->AppUi() );       
       
   968     CArrayFix<TCoeHelpContext>* helpContext = appUi->AppHelpContextL();   
       
   969     HlpLauncher::LaunchHelpApplicationL( iEikonEnv->WsSession(), helpContext );
       
   970     }
       
   971 
       
   972 // ----------------------------------------------------
       
   973 // CMceGeneralSettingsDialog::ChangeMessageStoreL
       
   974 // Changes the drive of the message store
       
   975 //
       
   976 // ----------------------------------------------------
       
   977 #ifdef RD_MULTIPLE_DRIVE
       
   978 void CMceGeneralSettingsDialog::ChangeMessageStoreL( TInt aTargetDrive )
       
   979 #else
       
   980 void CMceGeneralSettingsDialog::ChangeMessageStoreL()
       
   981 #endif //RD_MULTIPLE_DRIVE
       
   982     {
       
   983     //if server is busy, do not change store
       
   984     if( CheckIsServerBusyL() )
       
   985         {
       
   986         return;
       
   987         }
       
   988 
       
   989     RFs& fs=iEikonEnv->FsSession();
       
   990     
       
   991     TInt driveNumber;
       
   992     
       
   993 #ifdef RD_MULTIPLE_DRIVE
       
   994     driveNumber = aTargetDrive;
       
   995 #else
       
   996     // Get the current drive
       
   997     TInt currentDrive=TInt( iSession->CurrentDriveL() );
       
   998 
       
   999     if ( currentDrive == EDriveC )
       
  1000         {
       
  1001         driveNumber = EDriveE;            
       
  1002         }
       
  1003     else
       
  1004         {
       
  1005         driveNumber = EDriveC;
       
  1006         }
       
  1007 #endif //RD_MULTIPLE_DRIVE
       
  1008 
       
  1009     // change message store
       
  1010     CMuiuOperationWait* waiter=CMuiuOperationWait::NewLC();
       
  1011 
       
  1012     CMsvProgressReporterOperation* reportOp =
       
  1013                          CMsvProgressReporterOperation::NewL( *iSession, waiter->iStatus );
       
  1014     CleanupStack::PushL( reportOp );
       
  1015 
       
  1016     HBufC* text = StringLoader::LoadLC( R_MCE_SETTINGS_SWITCHING_MESSAGE_STORE, 
       
  1017                                                              iEikonEnv );  
       
  1018     reportOp->SetTitleL( *text ); 
       
  1019 
       
  1020     reportOp->SetCanCancelL( EFalse );
       
  1021 
       
  1022     CleanupStack::PopAndDestroy( text );
       
  1023             
       
  1024     CMsvOperation* changeOp=iSession->ChangeDriveL( driveNumber, reportOp->RequestStatus() );
       
  1025     reportOp->SetOperationL( changeOp );
       
  1026 
       
  1027     waiter->Start();
       
  1028     
       
  1029     CleanupStack::PopAndDestroy( reportOp );
       
  1030     CleanupStack::PopAndDestroy( waiter ); 
       
  1031     }
       
  1032     
       
  1033     
       
  1034 // ----------------------------------------------------
       
  1035 // void CMceGeneralSettingsDialog::SetMSKButtonL()
       
  1036 // ----------------------------------------------------
       
  1037 void CMceGeneralSettingsDialog::SetMSKButtonL()
       
  1038     {
       
  1039     CEikTextListBox* list=STATIC_CAST(
       
  1040                     CEikTextListBox*,
       
  1041                     Control( EMceSettingsIdOtherItems) );
       
  1042     const TInt index = list->CurrentItemIndex();
       
  1043     const TInt numberOfItem = list->Model()->NumberOfItems();
       
  1044     const TInt resourceId = index==0 ?
       
  1045          R_MCE_MSK_BUTTON_CHANGE : R_MCE_MSK_BUTTON_OPEN;
       
  1046     CEikButtonGroupContainer& cba = ButtonGroupContainer();
       
  1047     cba.SetCommandL( KMSKPosition, resourceId );
       
  1048     cba.DrawNow();
       
  1049     }
       
  1050 
       
  1051 #ifdef RD_MULTIPLE_DRIVE
       
  1052 // ----------------------------------------------------
       
  1053 // CMceGeneralSettingsDialog::MakeDriveNameStringLC
       
  1054 // ----------------------------------------------------
       
  1055 HBufC* CMceGeneralSettingsDialog::MakeDriveNameStringLC( TInt aDriveNumber )
       
  1056     {       
       
  1057     // get drive later and delimiter, e.g. "C:"
       
  1058     TDriveName driveName(TDriveUnit( aDriveNumber ).Name() );
       
  1059     
       
  1060     TUint driveStatus( 0 );
       
  1061     RFs& fs=iEikonEnv->FsSession();
       
  1062     User::LeaveIfError( DriveInfo::GetDriveStatus( fs, aDriveNumber, driveStatus ) );     
       
  1063     
       
  1064     //Following flitters are referred to filemanager application
       
  1065     if ( driveStatus & DriveInfo::EDriveInternal )
       
  1066         {
       
  1067         //Device Memory and Mass storage drives
       
  1068         if ( driveStatus & DriveInfo::EDriveExternallyMountable )
       
  1069             {
       
  1070             return StringLoader::LoadLC( R_MCE_SETT_MEM_MASS_STORAGE, driveName, iEikonEnv );
       
  1071             }
       
  1072         else 
       
  1073             {
       
  1074             return StringLoader::LoadLC( R_MCE_SETT_MEM_DEVICE, driveName, iEikonEnv );
       
  1075             }
       
  1076         }
       
  1077     //memory card
       
  1078     else
       
  1079         {
       
  1080         return StringLoader::LoadLC( R_MCE_SETT_MEM_MEMORY_CARD, driveName, iEikonEnv );            
       
  1081         }
       
  1082     }
       
  1083 #endif //RD_MULTIPLE_DRIVE
       
  1084 
       
  1085 // ---------------------------------------------------------
       
  1086 // CMceGeneralSettingsDialog::IsThirdPartyMailBox()
       
  1087 // 
       
  1088 // ---------------------------------------------------------
       
  1089 //
       
  1090 TBool CMceGeneralSettingsDialog::IsThirdPartyMailBoxL()
       
  1091     {
       
  1092     CMsvEntry* entry = iSession->GetEntryL( KMsvRootIndexEntryId );
       
  1093     CleanupStack::PushL( entry );
       
  1094     TInt cnt = entry->Count();
       
  1095     TBool isThirdPartyMail = EFalse;
       
  1096     for ( TInt i=0; i < cnt ; i++)
       
  1097         {
       
  1098         if ( (*entry)[i].iType.iUid == KUidMsvServiceEntryValue &&
       
  1099              (*entry)[i].Id() != KMsvLocalServiceIndexEntryIdValue &&
       
  1100              ( !( (*entry)[i].iMtm.iUid == KUidMsgTypeCmailMtmVal ||
       
  1101                   (*entry)[i].iMtm == KSenduiMtmImap4Uid          || 
       
  1102                   (*entry)[i].iMtm == KSenduiMtmPop3Uid           ||
       
  1103                   (*entry)[i].iMtm == KSenduiMtmSmtpUid   ))   &&
       
  1104              IsEmailEntryL((*entry)[i]))
       
  1105            {
       
  1106            isThirdPartyMail = ETrue;
       
  1107            break;
       
  1108            }
       
  1109         }
       
  1110     CleanupStack::PopAndDestroy( entry );
       
  1111     return isThirdPartyMail;
       
  1112     }
       
  1113 
       
  1114 // ---------------------------------------------------------
       
  1115 // CMceGeneralSettingsDialog::IsEmailEntryL
       
  1116 // 
       
  1117 // ---------------------------------------------------------
       
  1118 //
       
  1119 TBool CMceGeneralSettingsDialog::IsEmailEntryL(TMsvEntry tentry)
       
  1120     {
       
  1121     TBool IsEmail = EFalse;
       
  1122 
       
  1123     CMtmUiDataRegistry* uiRegistry =
       
  1124                          CMtmUiDataRegistry::NewL( *iSession );
       
  1125     CleanupStack::PushL(uiRegistry);
       
  1126     if ( uiRegistry->IsPresent( tentry.iMtm ) &&
       
  1127          uiRegistry->IsPresent( KUidMsgTypePOP3 ) )
       
  1128          {
       
  1129           TUid mailMTMTechType =
       
  1130                   uiRegistry->TechnologyTypeUid( KUidMsgTypePOP3 );
       
  1131           if( uiRegistry->TechnologyTypeUid( tentry.iMtm ) == mailMTMTechType )
       
  1132                 {
       
  1133                 IsEmail = ETrue;
       
  1134                 }
       
  1135          }
       
  1136     CleanupStack::PopAndDestroy( uiRegistry );
       
  1137         
       
  1138     return IsEmail;
       
  1139     }
       
  1140 //  End of File