email/imum/Utils/Src/IMSSettingsWizard.cpp
changeset 0 72b543305e3a
equal deleted inserted replaced
-1:000000000000 0:72b543305e3a
       
     1 /*
       
     2 * Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  IMSSettingsWizard.cpp
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include <e32base.h>
       
    22 #include <badesca.h>                // CDesCArrayFlat
       
    23 #include <avkon.hrh>                // Softkey enumerations
       
    24 #include <cemailaccounts.h>         // CEmailAccounts
       
    25 #include <smtpset.h>                // CImSmtpSettings
       
    26 #include <imapset.h>                // CImImap4Settings
       
    27 #include <pop3set.h>                // CImPop3Settings
       
    28 #include <iapprefs.h>               // CImIAPPreferences
       
    29 #include <StringLoader.h>           // StringLoader
       
    30 #include <aknmessagequerydialog.h>  // CAknMessageQueryDialog
       
    31 #include <MuiuMsvUiServiceUtilities.h> // MsvUiServiceUtilities
       
    32 #include <eikrted.h>                // CEikRichTextEditor
       
    33 #include <txtrich.h>                // CRichText
       
    34 #include <AknInfoPopupNoteController.h>
       
    35 #include <mtudcbas.h>				// CBaseMtmUiData
       
    36 #include <mtmuibas.h>		        // CBaseMtmUi
       
    37 #include <mtsr.h>                   // CMtmRegistryControl
       
    38 
       
    39 #include <MtmExtendedCapabilities.hrh>
       
    40 #include <MTMStore.h>				// CMtmStore
       
    41 #include "MuiuDynamicSettingsItemFinderInterface.h"
       
    42 #include "MuiuDynamicSettingsDialog.h"
       
    43 #include <SendUiConsts.h>
       
    44 
       
    45 #include <ImumUtils.rsg>
       
    46 
       
    47 #include "ImumInSettingsData.h"
       
    48 #include "ImumInternalApiImpl.h"
       
    49 #include "ImumInMailboxServicesImpl.h"
       
    50 #include "IMSSettingsNoteUi.h"
       
    51 #include "IMSSettingsWizard.h"
       
    52 #include "IMSWTextEditorPage.h"
       
    53 #include "IMSWRadiobuttonPage.h"
       
    54 #include "IMSSettingsItemApprover.h"
       
    55 #include "IMASPageIds.hrh"
       
    56 #include "EmailUtils.H"
       
    57 #include "EmailFeatureUtils.h"
       
    58 #include "ComDbUtl.h"               // CMsvCommDbUtilities
       
    59 #include "ImumUtilsLogging.h"
       
    60 #include "ImumPanic.h"
       
    61 #include "IMSWizardControl.h"
       
    62 
       
    63 // EXTERNAL DATA STRUCTURES
       
    64 // EXTERNAL FUNCTION PROTOTYPES
       
    65 // CONSTANTS
       
    66 const TText KIMASCharDot = '.';
       
    67 const TText KIMASCharAt = '@';
       
    68 const TInt KMaxPages = 6;
       
    69 const TInt KMsToWaitBeforePopup = 2000;
       
    70 const TInt KMsToWaitBeforeRePopup = 6000;
       
    71 
       
    72 // MACROS
       
    73 // LOCAL CONSTANTS AND MACROS
       
    74 // MODULE DATA STRUCTURES
       
    75 // LOCAL FUNCTION PROTOTYPES
       
    76 // FORWARD DECLARATIONS
       
    77 
       
    78 // ============================ MEMBER FUNCTIONS ===============================
       
    79 
       
    80 // ----------------------------------------------------------------------------
       
    81 // CIMSSettingsWizard::CIMSSettingsWizard()
       
    82 // ----------------------------------------------------------------------------
       
    83 //
       
    84 CIMSSettingsWizard::CIMSSettingsWizard(
       
    85     CIMSSettingsUi& aDialog,
       
    86     CImumInternalApiImpl& aMailboxApi,
       
    87     CEikFormattedCellListBox& aListBox,
       
    88     CIMSWizardControl& aHelpContainer,
       
    89     CAknTitlePane& aTitlePane,
       
    90     CMuiuFlags& aFlags )
       
    91     :
       
    92     CIMSSettingsBaseUI( aDialog, aMailboxApi, aListBox,
       
    93     					aTitlePane, aFlags ),
       
    94     iCurrentItem( KNullUid ),
       
    95     iWizState( EWizStateQuerying ),
       
    96     iPageEdit( NULL ),
       
    97     iPageRadioBtn( NULL ),
       
    98     iCurPage( 0 ),
       
    99     iPageText( NULL ),
       
   100     iHelpContainer( aHelpContainer )
       
   101     {
       
   102     }
       
   103 
       
   104 // ----------------------------------------------------------------------------
       
   105 // CIMSSettingsWizard::~CIMSSettingsWizard()
       
   106 // ----------------------------------------------------------------------------
       
   107 //
       
   108 CIMSSettingsWizard::~CIMSSettingsWizard()
       
   109     {
       
   110     IMUM_CONTEXT( CIMSSettingsWizard::~CIMSSettingsWizard, 0, KLogUi );
       
   111     IMUM_IN();
       
   112 
       
   113     iProtocolArray.Close();
       
   114     delete iPageText;
       
   115     delete iMtmStore;
       
   116 
       
   117     iPageEdit = NULL;
       
   118     iPageRadioBtn = NULL;
       
   119 
       
   120     if ( iWizardLauncher )
       
   121         {
       
   122         iWizardLauncher->Cancel();
       
   123         }
       
   124 
       
   125     delete iWizardLauncher;
       
   126 
       
   127     IMUM_OUT();
       
   128     }
       
   129 
       
   130 // ----------------------------------------------------------------------------
       
   131 // CIMSSettingsWizard::ConstructL()
       
   132 // ----------------------------------------------------------------------------
       
   133 //
       
   134 void CIMSSettingsWizard::ConstructL( CEikButtonGroupContainer& aSoftkeys,
       
   135     const TDesC& aEmailAddress )
       
   136     {
       
   137     IMUM_CONTEXT( CIMSSettingsWizard::ConstructL, 0, KLogUi );
       
   138     IMUM_IN();
       
   139 
       
   140     BaseUiConstructL( aSoftkeys, R_IMAS_WIZARD );
       
   141 
       
   142 	iMtmStore = CMtmStore::NewL(iMailboxApi.MsvSession());
       
   143 
       
   144     // Clear the flags
       
   145     for ( TUint flag = EWizFlagLastFlag; --flag >= EWizFlagFirstFlag; )
       
   146         {
       
   147         ClearFlag( flag );
       
   148         }
       
   149 
       
   150     SettingsStartedL( aEmailAddress );
       
   151     
       
   152     // Hide the unnecessary scrollbar from the first page of the wizard
       
   153     CEikScrollBarFrame* scrollbar = iListBox.ScrollBarFrame();
       
   154     if ( scrollbar )
       
   155     	{
       
   156     	scrollbar->SetScrollBarVisibilityL( CEikScrollBarFrame::EOff, CEikScrollBarFrame::EOff );    	
       
   157     	}
       
   158     
       
   159 	IMUM_OUT();
       
   160     }
       
   161 
       
   162 // ----------------------------------------------------------------------------
       
   163 // CIMSSettingsWizard::NewL()
       
   164 // ----------------------------------------------------------------------------
       
   165 //
       
   166 CIMSSettingsWizard* CIMSSettingsWizard::NewL(
       
   167     CIMSSettingsUi& aDialog,
       
   168     CImumInternalApiImpl& aMailboxApi,
       
   169     CEikFormattedCellListBox& aListBox,
       
   170     CIMSWizardControl& aHelpContainer,
       
   171     CAknTitlePane& aTitlePane,
       
   172     CEikButtonGroupContainer& aSoftkeys,
       
   173     CMuiuFlags& aFlags,
       
   174     const TDesC& aEmailAddress )
       
   175     {
       
   176     CIMSSettingsWizard* self = NewLC(
       
   177         aDialog, aMailboxApi,
       
   178         aListBox, aHelpContainer, aTitlePane, aSoftkeys, aFlags, aEmailAddress );
       
   179     CleanupStack::Pop( self );
       
   180 
       
   181     return self;
       
   182     }
       
   183 
       
   184 // ----------------------------------------------------------------------------
       
   185 // CIMSSettingsWizard::NewLC()
       
   186 // ----------------------------------------------------------------------------
       
   187 //
       
   188 CIMSSettingsWizard* CIMSSettingsWizard::NewLC(
       
   189     CIMSSettingsUi& aDialog,
       
   190     CImumInternalApiImpl& aMailboxApi,
       
   191     CEikFormattedCellListBox& aListBox,
       
   192     CIMSWizardControl& aHelpContainer,
       
   193     CAknTitlePane& aTitlePane,
       
   194     CEikButtonGroupContainer& aSoftkeys,
       
   195     CMuiuFlags& aFlags,
       
   196     const TDesC& aEmailAddress )
       
   197     {
       
   198     IMUM_STATIC_CONTEXT( CIMSSettingsWizard::NewLC, 0, utils, KLogUi );
       
   199     IMUM_IN();
       
   200 
       
   201     CIMSSettingsWizard* self =
       
   202         new ( ELeave ) CIMSSettingsWizard(
       
   203             aDialog, aMailboxApi,
       
   204             aListBox, aHelpContainer, aTitlePane, aFlags );
       
   205     CleanupStack::PushL( self );
       
   206     self->ConstructL( aSoftkeys, aEmailAddress );
       
   207 
       
   208 	IMUM_OUT();
       
   209     return self;
       
   210     }
       
   211 
       
   212 // ----------------------------------------------------------------------------
       
   213 // CIMSSettingsWizard::DefinePageNumberStringL()
       
   214 // ----------------------------------------------------------------------------
       
   215 //
       
   216 void CIMSSettingsWizard::DefinePageNumberStringL()
       
   217     {
       
   218     IMUM_CONTEXT( CIMSSettingsWizard::DefinePageNumberStringL, 0, KLogUi );
       
   219     IMUM_IN();
       
   220 
       
   221     CArrayFix<TInt>* array = new ( ELeave ) CArrayFixFlat<TInt>( 1 );
       
   222     CleanupStack::PushL( array );
       
   223 
       
   224     // If current page is zero, increase it to 1
       
   225     if ( iCurPage == 0 )
       
   226     	{
       
   227     	iCurPage++;
       
   228     	}
       
   229 
       
   230     array->AppendL( iCurPage );
       
   231     array->AppendL( KMaxPages );
       
   232 
       
   233     delete iPageText;
       
   234     iPageText = NULL;
       
   235 
       
   236     // Load page number to descriptor
       
   237 	iPageText = StringLoader::LoadL(
       
   238 	R_MBXS_SETTINGS_MAIL_NEWBOX_PAGES, *array );
       
   239 
       
   240 
       
   241     CleanupStack::PopAndDestroy( array );
       
   242     array = NULL;
       
   243     IMUM_OUT();
       
   244     }
       
   245 
       
   246 // ----------------------------------------------------------------------------
       
   247 // CIMSSettingsWizard::SettingsStartedL()
       
   248 // ----------------------------------------------------------------------------
       
   249 //
       
   250 TBool CIMSSettingsWizard::SettingsStartedL( const TDesC& aEmailAddress )
       
   251     {
       
   252     IMUM_CONTEXT( CIMSSettingsWizard::SettingsStartedL, 0, KLogUi );
       
   253 	IMUM_IN();
       
   254 
       
   255     // Set the titlepane text
       
   256     HBufC* text = StringLoader::LoadL( R_MBXS_SETTINGS_NEW_BOX );
       
   257     CleanupStack::PushL( text );
       
   258     SetTitlePaneTextL( *text );
       
   259     CleanupStack::PopAndDestroy( text );
       
   260 
       
   261     HidePermanently( ToUid( EIMAWRadioButtonIapAlwaysAsk ), ETrue );
       
   262 
       
   263     CMuiuSettingsEditText* email = static_cast<CMuiuSettingsEditText*>(
       
   264         GetItem( TUid::Uid( EIMAWEmailAddress ) ) );
       
   265     TMuiuSettingsText emailText;
       
   266 
       
   267     if ( aEmailAddress.Length() )
       
   268         {
       
   269         emailText = aEmailAddress;
       
   270         email->SetText( &emailText );
       
   271         SettingsItemDefineServers( *email->Text() );
       
   272         SettingsItemDefineMailboxName( *email->Text() );
       
   273         SetFlag( EWizFlagSkipEmail );
       
   274 
       
   275         SetFlag( EWizFlagPluginDetected );
       
   276         iWizardLauncher = CIMSWizardLauncher::NewL( *this, iDialog );
       
   277 
       
   278         //Next prevents the original info screen and buttons from flashing
       
   279         //on the screen
       
   280         iSoftkeys->SetVisibility( EFalse, this );
       
   281 
       
   282         if ( iHelpContainer.CountComponentControls() )
       
   283             {
       
   284             iHelpContainer.ComponentControl( 0 )->MakeVisible( EFalse );
       
   285             }
       
   286         }
       
   287     else
       
   288         {
       
   289         // Hide the listbox and the helpscreen
       
   290         // The buttons should be hidden here too for the dialog
       
   291         SetHideItems( ETrue, R_IMAS_WIZARD, ETrue );
       
   292         iDialog.MakeLineVisible( EIMSWizardRichTxtEditorContainer, ETrue);
       
   293 
       
   294         //TMuiuSettingsText at;
       
   295         emailText.Append( KIMASCharAt );
       
   296         email->SetText( &emailText );
       
   297         }
       
   298 
       
   299 
       
   300 	IMUM_OUT();
       
   301     return EFalse;
       
   302     }
       
   303 
       
   304 // ----------------------------------------------------------------------------
       
   305 // CIMSSettingsWizard::OkToExitL()
       
   306 // ----------------------------------------------------------------------------
       
   307 //
       
   308 TInt CIMSSettingsWizard::OkToExitL( const TInt /* aButtonId */ )
       
   309     {
       
   310     IMUM_CONTEXT( CIMSSettingsWizard::OkToExitL, 0, KLogUi );
       
   311     IMUM_IN();
       
   312 
       
   313     // If wizard is running (setting page is on display), let setting page
       
   314     // and wizard loop to exit before exiting. Save exit flags to reinstate
       
   315     // them when wizard loop exists.
       
   316     if ( Flag( EWizFlagStateRunning ) )
       
   317         {
       
   318         ChangeFlag( EWizFlagShouldExit, Flag( EImumSettingShouldExit ) );
       
   319         ChangeFlag( EWizFlagShouldClose, Flag( EImumSettingShouldClose ) );
       
   320         IMUM_OUT();
       
   321         return EFalse;
       
   322         }
       
   323 
       
   324     // Show query for exit
       
   325     TInt result = 1;
       
   326 
       
   327     // Check if user has to be asked about the exit
       
   328     if ( Flag( EImumSettingQueryClose ) && !Flag( EWizFlagForcedCancel ))
       
   329         {
       
   330         if ( !Flag( EWizFlagCompleted ) )
       
   331             {
       
   332             result = CIMSSettingsNoteUi::ShowQueryL(
       
   333 	                R_MBXS_SETTINGS_NEW_BOX_EXIT_QUERY,
       
   334 	                R_EMAIL_CONFIRMATION_QUERY );
       
   335             if ( !result && Flag( EWizFlagPluginDetected ) )
       
   336                 {
       
   337                 iWizardLauncher->StartLauncher();
       
   338                 ClearFlag( EWizFlagShouldExit );
       
   339                 ClearFlag( EWizFlagShouldClose );
       
   340                 }
       
   341             }
       
   342         }
       
   343 
       
   344 	IMUM_OUT();
       
   345     return result;
       
   346     }
       
   347 
       
   348 
       
   349 // ----------------------------------------------------------------------------
       
   350 // CIMSSettingsWizard::KeyPressSoftkey()
       
   351 // ----------------------------------------------------------------------------
       
   352 //
       
   353 TBool CIMSSettingsWizard::KeyPressSoftkey(
       
   354     const TInt aButton )
       
   355     {
       
   356     IMUM_CONTEXT( CIMSSettingsWizard::KeyPressSoftkey, 0, KLogUi );
       
   357     IMUM_IN();
       
   358 
       
   359     TInt error = KErrNone;
       
   360 
       
   361     // Check which of the keys has been pressed
       
   362     if ( aButton == EAknSoftkeyBack )
       
   363         {
       
   364         if ( iWizState == EWizStateQuerying )
       
   365             {
       
   366             SetFlag( EImumSettingShouldClose );
       
   367             }
       
   368         else
       
   369             {
       
   370             TRAP( error, KeyPressBackL() );
       
   371             }
       
   372         }
       
   373     else
       
   374         {
       
   375         if ( iWizState == EWizStateQuerying )
       
   376             {
       
   377 			WizRunStart();
       
   378             TRAP( error,
       
   379             		while( Flag( EWizFlagStateRunning ) )
       
   380             				 {
       
   381             				 WizRunStepL();
       
   382             				 } );
       
   383             }
       
   384         else
       
   385             {
       
   386             TRAP( error, KeyPressNextL() );
       
   387             }
       
   388         }
       
   389 
       
   390     __ASSERT_DEBUG( error == KErrNone,
       
   391         User::Panic( KIMSWizardPanic, error ) );
       
   392 
       
   393     IMUM_OUT();
       
   394     return ETrue;
       
   395     }
       
   396 
       
   397 // ----------------------------------------------------------------------------
       
   398 // CIMSSettingsWizard::KeyPressOKButtonL()
       
   399 // ----------------------------------------------------------------------------
       
   400 //
       
   401 TBool CIMSSettingsWizard::KeyPressOKButtonL( const TInt /* aButton */ )
       
   402     {
       
   403     IMUM_CONTEXT( CIMSSettingsWizard::KeyPressOKButtonL, 0, KLogUi );
       
   404     IMUM_IN();
       
   405 
       
   406     // In help screen, ok button opens the first page
       
   407     if ( iWizState == EWizStateQuerying )
       
   408         {
       
   409         KeyPressSoftkey( EAknSoftkeyShow );
       
   410         }
       
   411     // Text page editing ongoing, call correct page
       
   412     else if ( iSettingPage && Flag( EWizFlagTextEditPage ) )
       
   413         {
       
   414         iPageEdit->KeyPressedSelectL();
       
   415         }
       
   416     // Radio button page editing ongoing, call correct page
       
   417     else if ( iSettingPage && Flag( EWizFlagRadioButtonPage ) )
       
   418         {
       
   419         iPageRadioBtn->KeyPressedSelectL();
       
   420         }
       
   421     else
       
   422         {
       
   423         // Nothing
       
   424         }
       
   425 
       
   426 	IMUM_OUT();
       
   427     return ETrue;
       
   428     }
       
   429 
       
   430 // ----------------------------------------------------------------------------
       
   431 // CIMSSettingsWizard::KeyPressNextL()
       
   432 // ----------------------------------------------------------------------------
       
   433 //
       
   434 void CIMSSettingsWizard::KeyPressNextL()
       
   435     {
       
   436     IMUM_CONTEXT( CIMSSettingsWizard::KeyPressNextL, 0, KLogUi );
       
   437     IMUM_IN();
       
   438 
       
   439     SetFlag( EWizFlagNextKeyPressed );
       
   440 
       
   441     // Text page editing ongoing, call correct page
       
   442     if ( iSettingPage && Flag( EWizFlagTextEditPage ) )
       
   443         {
       
   444         iPageEdit->KeyPressedNextL();
       
   445         }
       
   446     // Radio button page editing ongoing, call correct page
       
   447     else if ( iSettingPage && Flag( EWizFlagRadioButtonPage ) )
       
   448         {
       
   449         iPageRadioBtn->KeyPressedNextL();
       
   450         }
       
   451     else
       
   452         {
       
   453         // Nothing
       
   454         }
       
   455 
       
   456 	IMUM_OUT();
       
   457     }
       
   458 
       
   459 // ----------------------------------------------------------------------------
       
   460 // CIMSSettingsWizard::KeyPressBackL()
       
   461 // ----------------------------------------------------------------------------
       
   462 //
       
   463 void CIMSSettingsWizard::KeyPressBackL()
       
   464     {
       
   465     IMUM_CONTEXT( CIMSSettingsWizard::KeyPressBackL, 0, KLogUi );
       
   466     IMUM_IN();
       
   467 
       
   468     SetFlag( EWizFlagBackKeyPressed );
       
   469 
       
   470     // Text page editing ongoing, call correct page
       
   471     if ( iSettingPage && Flag( EWizFlagTextEditPage ) )
       
   472         {
       
   473         iPageEdit->KeyPressedBackL();
       
   474         }
       
   475     // Radio button page editing ongoing, call correct page
       
   476     else if ( iSettingPage && Flag( EWizFlagRadioButtonPage ) )
       
   477         {
       
   478         iPageRadioBtn->KeyPressedBackL();
       
   479         }
       
   480     else
       
   481         {
       
   482         // Nothing
       
   483         }
       
   484     if ( Flag( EWizFlagPluginDetected ) && iCurrentItem.iUid == EIMAWProtocol )
       
   485         {
       
   486         SetFlag( EImumSettingShouldClose );
       
   487         }
       
   488 
       
   489     IMUM_OUT();
       
   490     }
       
   491 
       
   492 // ----------------------------------------------------------------------------
       
   493 // CIMSSettingsWizard::EventItemEditStartsL
       
   494 // ----------------------------------------------------------------------------
       
   495 //
       
   496 TMuiuPageEventResult CIMSSettingsWizard::EventItemEditStartsL(
       
   497     CMuiuSettingBase& /* aBaseItem */ )
       
   498     {
       
   499     IMUM_CONTEXT( CIMSSettingsWizard::EventItemEditStartsL, 0, KLogUi );
       
   500     IMUM_IN();
       
   501 
       
   502     iNoteDialog = ShowMailSettingsPopupAfterL(
       
   503         iCurrentItem, KMsToWaitBeforePopup );
       
   504 
       
   505 	IMUM_OUT();
       
   506     return EMuiuPageEventResultApproved;
       
   507     }
       
   508 
       
   509 /******************************************************************************
       
   510 
       
   511     Wizard state machine
       
   512 
       
   513 ******************************************************************************/
       
   514 
       
   515 // ----------------------------------------------------------------------------
       
   516 // CIMSSettingsWizard::WizRunStart()
       
   517 // ----------------------------------------------------------------------------
       
   518 //
       
   519 void CIMSSettingsWizard::WizRunStart()
       
   520     {
       
   521     // This function is called, when user starts the wizard by
       
   522     // pressing Start-key or by choosing options->Start
       
   523     SetFlag( EWizFlagStateRunning );
       
   524     iWizState = EWizStateStarted;
       
   525     }
       
   526 
       
   527 
       
   528 // ----------------------------------------------------------------------------
       
   529 // CIMSSettingsWizard::WizRunStepL()
       
   530 // ----------------------------------------------------------------------------
       
   531 //
       
   532 TBool CIMSSettingsWizard::WizRunStepL()
       
   533 	{
       
   534 	IMUM_CONTEXT( CIMSSettingsWizard::WizRunStepL, 0, KLogUi );
       
   535 	IMUM_IN();
       
   536 
       
   537 	// Run wizard step and change state
       
   538     WizStateMachineL();
       
   539     WizStateChangeStateL();
       
   540 
       
   541 	IMUM_OUT();
       
   542     return Flag( EWizFlagStateRunning );
       
   543 	}
       
   544 
       
   545 
       
   546 // ----------------------------------------------------------------------------
       
   547 // CIMSSettingsWizard::WizStateChangeStateL()
       
   548 // ----------------------------------------------------------------------------
       
   549 //
       
   550 void CIMSSettingsWizard::WizStateChangeStateL()
       
   551     {
       
   552     IMUM_CONTEXT( CIMSSettingsWizard::WizStateChangeStateL, 0, KLogUi );
       
   553     IMUM_IN();
       
   554 
       
   555     // if EWizFlagShouldExit or EWizFlagShouldClose are on, OkToExitL()
       
   556     // inquiry was received while wizard is running. Should exit wizard
       
   557     // loop immediately.
       
   558     if ( Flag( EWizFlagShouldExit ) || Flag( EWizFlagShouldClose ) )
       
   559         {
       
   560         // Reinstate exit flags as they were reset after we declined
       
   561         // exit request in OkToExitL().
       
   562         ChangeFlag( EImumSettingShouldExit, Flag( EWizFlagShouldExit ) );
       
   563         ChangeFlag( EImumSettingShouldClose, Flag( EWizFlagShouldClose ) );
       
   564 
       
   565         ClearFlag( EWizFlagStateRunning ); // exit wizard loop
       
   566         IMUM_OUT();
       
   567         return;
       
   568         }
       
   569 
       
   570     // This seperate function is meant only to chage the state of the
       
   571     // state machine.
       
   572     switch ( iWizState )
       
   573         {
       
   574         // After wizard has been initialized, go straight to page open state
       
   575         case EWizStateStarted:
       
   576             iWizState = EWizStateEditPage;
       
   577             break;
       
   578 
       
   579         // After new item has been chosen, Change to editing mode
       
   580         case EWizStateDeterminePage:
       
   581             iWizState = EWizStateEditPage;
       
   582             break;
       
   583 
       
   584         // After the item has been edited, check that the changes are ok
       
   585         case EWizStateEditPage:
       
   586             iWizState = EWizFinishEditing;
       
   587             break;
       
   588 
       
   589         // After validating item, the wizard can be exited by succesfully
       
   590         // finishing the wizard, or by returning back to help screen
       
   591         case EWizFinishEditing:
       
   592             iWizState = ( Flag( EWizFlagExiting ) ||
       
   593                           Flag( EImumSettingShouldExit ) ) ?
       
   594                  EWizStateExit : EWizStateDeterminePage;
       
   595             break;
       
   596 
       
   597         // As default, try to leave the wizard
       
   598         default:
       
   599         case EWizStateExit:
       
   600             iWizState = ( !Flag( EWizFlagCompleted ) && !Flag( EWizFlagForcedCancel )) ?
       
   601                  EWizStateQuerying : EWizStateStarted;
       
   602             break;
       
   603 
       
   604         }
       
   605     IMUM_OUT();
       
   606     }
       
   607 
       
   608 // ----------------------------------------------------------------------------
       
   609 // CIMSSettingsWizard::WizStateMachineL()
       
   610 // ----------------------------------------------------------------------------
       
   611 //
       
   612 void CIMSSettingsWizard::WizStateMachineL()
       
   613     {
       
   614     IMUM_CONTEXT( CIMSSettingsWizard::WizStateMachineL, 0, KLogUi );
       
   615     IMUM_IN();
       
   616 
       
   617     switch ( iWizState )
       
   618         {
       
   619         // This is executed, when wizard is started
       
   620         case EWizStateStarted:
       
   621             WizHandleStateInitializeL();
       
   622             break;
       
   623 
       
   624         // In this state, the wizard chooses the next item to be edited
       
   625         case EWizStateDeterminePage:
       
   626             WizHandleStateDeterminePage();
       
   627             break;
       
   628 
       
   629         // Start editing the actual item
       
   630         case EWizStateEditPage:
       
   631             WizHandleStateEditL();
       
   632             break;
       
   633 
       
   634         // Check that the item is ok, so that the editing can be continued
       
   635         case EWizFinishEditing:
       
   636             WizHandleStateFinishEditingL();
       
   637             break;
       
   638 
       
   639         // Handle the exiting from the wizard
       
   640         default:
       
   641         case EWizStateExit:
       
   642             WizHandleStateExitL();
       
   643             break;
       
   644         }
       
   645     IMUM_OUT();
       
   646     }
       
   647 
       
   648 // ----------------------------------------------------------------------------
       
   649 // CIMSSettingsWizard::WizHandleStateInitializeL()
       
   650 // ----------------------------------------------------------------------------
       
   651 //
       
   652 void CIMSSettingsWizard::WizHandleStateInitializeL()
       
   653     {
       
   654     IMUM_CONTEXT( CIMSSettingsWizard::WizHandleStateInitializeL, 0, KLogUi );
       
   655     IMUM_IN();
       
   656 
       
   657     SetHideItems( ETrue, R_IMAS_WIZARD, ETrue );
       
   658 
       
   659     iDialog.MakeLineVisible( EIMSWizardRichTxtEditorContainer, EFalse);
       
   660 
       
   661     iCurrentItem.iUid = EIMAWProtocol;
       
   662 
       
   663     // if protocoll for mailbox has not yet been selected the iCurPage is set to 0 so that
       
   664     // wizard page number text is only updated after the number of pages is known.
       
   665     if ( iProtocol == KNullUid )
       
   666     	iCurPage = 0;
       
   667 
       
   668     // Clear all flags except EWizFlagStateRunning
       
   669     for ( TInt flag = EWizFlagExiting; flag <= EWizFlagTextEditPage; flag++ )
       
   670         {
       
   671         ClearFlag( flag );
       
   672         }
       
   673 
       
   674     iPageEdit = NULL;
       
   675     iPageRadioBtn = NULL;
       
   676 	IMUM_OUT();
       
   677     }
       
   678 
       
   679 // ----------------------------------------------------------------------------
       
   680 // CIMSSettingsWizard::WizHandlePageForward()
       
   681 // ----------------------------------------------------------------------------
       
   682 //
       
   683 void CIMSSettingsWizard::WizHandlePageForward()
       
   684     {
       
   685     IMUM_CONTEXT( CIMSSettingsWizard::WizHandlePageForward, 0, KLogUi );
       
   686     IMUM_IN();
       
   687 
       
   688     iCurrentItem.iUid++;
       
   689     iCurPage++;
       
   690 
       
   691     ClearFlag( EWizFlagItemApproved );
       
   692     ClearFlag( EWizFlagNextKeyPressed );
       
   693 
       
   694 	IMUM_OUT();
       
   695     }
       
   696 
       
   697 // ----------------------------------------------------------------------------
       
   698 // CIMSSettingsWizard::WizHandlePageBackward()
       
   699 // ----------------------------------------------------------------------------
       
   700 //
       
   701 void CIMSSettingsWizard::WizHandlePageBackward()
       
   702     {
       
   703     IMUM_CONTEXT( CIMSSettingsWizard::WizHandlePageBackward, 0, KLogUi );
       
   704 	IMUM_IN();
       
   705 
       
   706     iCurrentItem.iUid--;
       
   707     iCurPage--;
       
   708 
       
   709     ClearFlag( EWizFlagBackKeyPressed );
       
   710 
       
   711     IMUM_OUT();
       
   712     }
       
   713 
       
   714 // ----------------------------------------------------------------------------
       
   715 // CIMSSettingsWizard::WizHandleStateDeterminePage()
       
   716 // ----------------------------------------------------------------------------
       
   717 //
       
   718 void CIMSSettingsWizard::WizHandleStateDeterminePage()
       
   719     {
       
   720     IMUM_CONTEXT( CIMSSettingsWizard::WizHandleStateDeterminePage, 0, KLogUi );
       
   721     IMUM_IN();
       
   722 
       
   723     // When next key is pressed and the item is approved, change to next page
       
   724     if ( Flag( EWizFlagNextKeyPressed ) &&
       
   725          Flag( EWizFlagItemApproved ) )
       
   726         {
       
   727         WizHandlePageForward();
       
   728         }
       
   729     // When back key is pressed, change to previous page
       
   730     else if ( Flag( EWizFlagBackKeyPressed ) )
       
   731         {
       
   732         WizHandlePageBackward();
       
   733         }
       
   734     else
       
   735         {
       
   736         // Just open the same page again, as it has not been filled correctly
       
   737         ClearFlag( EWizFlagNextKeyPressed );
       
   738         }
       
   739 
       
   740 	IMUM_OUT();
       
   741     }
       
   742 
       
   743 // ----------------------------------------------------------------------------
       
   744 // CIMSSettingsWizard::WizHandleStateEditL()
       
   745 // ----------------------------------------------------------------------------
       
   746 //
       
   747 void CIMSSettingsWizard::WizHandleStateEditL()
       
   748     {
       
   749     IMUM_CONTEXT( CIMSSettingsWizard::WizHandleStateEditL, 0, KLogUi );
       
   750     IMUM_IN();
       
   751 
       
   752     // Get the item from the list
       
   753     CMuiuSettingBase* setting = GetItem( iCurrentItem );
       
   754     User::LeaveIfNull( setting );
       
   755 
       
   756     // When editing other edit settings, create page with next and back
       
   757     if ( setting->iItemType == EMuiuDynSetItemEditText )
       
   758         {
       
   759         SetFlag( EWizFlagTextEditPage );
       
   760         }
       
   761     // For radiobutton pages, show next and back
       
   762     else if ( setting->iItemType == EMuiuDynSetRadioButtonArray )
       
   763         {
       
   764         SetFlag( EWizFlagRadioButtonPage );
       
   765         }
       
   766     // Iap is radiobutton page
       
   767     else if ( iCurrentItem.iUid == EIMAWIap )
       
   768         {
       
   769         SetFlag( EWizFlagRadioButtonPage );
       
   770         }
       
   771     else
       
   772         {
       
   773         // do nothing
       
   774         }
       
   775 
       
   776     DefinePageNumberStringL();
       
   777 
       
   778     //Checks if email editor should be skipped
       
   779     if ( !CheckEmailSkip() )
       
   780         {
       
   781         // Begin editing the page
       
   782         OpenSettingPageL( *setting );
       
   783         }
       
   784 
       
   785     delete iNoteDialog;
       
   786     iNoteDialog = NULL;
       
   787 
       
   788 	IMUM_OUT();
       
   789     }
       
   790 
       
   791 // ----------------------------------------------------------------------------
       
   792 // CIMSSettingsWizard::WizHandleStateFinishEditingL()
       
   793 // ----------------------------------------------------------------------------
       
   794 //
       
   795 void CIMSSettingsWizard::WizHandleStateFinishEditingL()
       
   796     {
       
   797     IMUM_CONTEXT( CIMSSettingsWizard::WizHandleStateFinishEditingL, 0, KLogUi );
       
   798     IMUM_IN();
       
   799 
       
   800     // Should exit when:
       
   801     // Back key pressed and first page  OR
       
   802     if ( Flag( EWizFlagBackKeyPressed ) &&
       
   803          iCurrentItem.iUid == EIMAWProtocol )
       
   804         {
       
   805         SetFlag( EWizFlagExiting );
       
   806         }
       
   807 
       
   808     // Next key pressed and item validated and last item
       
   809     if ( Flag( EWizFlagNextKeyPressed ) )
       
   810         {
       
   811        	TBool isInternal = iMailboxApi.MailboxUtilitiesL().IsMailMtm( iProtocol, ETrue );
       
   812 
       
   813 		if ( !isInternal && iCurrentItem.iUid == EIMAWProtocol )
       
   814 			{
       
   815             TBool completed = ETrue;
       
   816 			//This should not make the utils code leave
       
   817 			TRAP_IGNORE( CallExternalMtmWizardL( iProtocol, completed ) );
       
   818             if (!completed)
       
   819                 {
       
   820                 ClearFlag( EWizFlagNextKeyPressed );
       
   821                 }
       
   822 			}
       
   823 		else
       
   824 			{
       
   825             // Get the item to be edited
       
   826             CMuiuSettingBase* base = GetItem( iCurrentItem );
       
   827 
       
   828             if ( iCurrentItem.iUid == EIMAWMailboxName )
       
   829                 {
       
   830                 ChangeFlag( EWizFlagExiting, Flag( EWizFlagItemApproved ) );
       
   831             	}
       
   832             }
       
   833         }
       
   834 
       
   835     if ( Flag ( EWizFlagNextKeyPressed ) || Flag ( EWizFlagBackKeyPressed ) )
       
   836         {
       
   837         // Clear the flags while exiting
       
   838         ClearFlag( EWizFlagRadioButtonPage );
       
   839         }
       
   840     ClearFlag( EWizFlagTextEditPage );
       
   841     iPageEdit = NULL;
       
   842     iPageRadioBtn = NULL;
       
   843 
       
   844     IMUM_OUT();
       
   845     }
       
   846 
       
   847 // ----------------------------------------------------------------------------
       
   848 // CIMSSettingsWizard::WizHandleStateExitL()
       
   849 // ----------------------------------------------------------------------------
       
   850 //
       
   851 void CIMSSettingsWizard::WizHandleStateExitL()
       
   852     {
       
   853     IMUM_CONTEXT( CIMSSettingsWizard::WizHandleStateExitL, 0, KLogUi );
       
   854     IMUM_IN();
       
   855 
       
   856     // Stop the wizard
       
   857     ClearFlag( EWizFlagStateRunning );
       
   858 
       
   859     // If the last item is approved, complete the wizard
       
   860     if ( Flag( EWizFlagNextKeyPressed ) &&
       
   861         iCurrentItem.iUid == EIMAWMailboxName )
       
   862         {
       
   863         ChangeFlag( EWizFlagCompleted, CheckCompleted() );
       
   864         }
       
   865 
       
   866     // In case wizard is not completed, but just returned back to help screen
       
   867    	if ( !Flag( EWizFlagCompleted ) && !Flag( EWizFlagForcedCancel ))
       
   868         {
       
   869         iDialog.MakeLineVisible( EIMSWizardRichTxtEditorContainer, ETrue);
       
   870         }
       
   871     else
       
   872         {
       
   873         if( Flag( EWizFlagCompleted ) )
       
   874         	{
       
   875    			// Show the information query to the user
       
   876         	// before leaving the wizard.
       
   877    			CIMSSettingsNoteUi::ShowQueryL(
       
   878                 R_MBXS_SETTINGS_MAIL_NEWBOX_FINAL, R_EMAIL_INFORMATION_QUERY, ETrue );
       
   879         	}
       
   880         SetFlag( EImumSettingShouldClose );
       
   881         }
       
   882 
       
   883 	IMUM_OUT();
       
   884     }
       
   885 
       
   886 
       
   887 /******************************************************************************
       
   888 
       
   889     Item handling
       
   890 
       
   891 ******************************************************************************/
       
   892 
       
   893 // ----------------------------------------------------------------------------
       
   894 // CIMSSettingsWizard::EventItemEditEndsL()
       
   895 // ----------------------------------------------------------------------------
       
   896 //
       
   897 TInt CIMSSettingsWizard::EventItemEditEndsL(
       
   898     CMuiuSettingBase& aBaseItem )
       
   899     {
       
   900     IMUM_CONTEXT( CIMSSettingsWizard::EventItemEditEndsL, 0, KLogUi );
       
   901     IMUM_IN();
       
   902 
       
   903     if ( Flag( EWizFlagItemApproved ) )
       
   904         {
       
   905         // Set item as approved accoding to the settings
       
   906         aBaseItem.iItemFlags.SetFlag( EMuiuDynItemValidated );
       
   907 
       
   908         SettingsItemProcessItemL( aBaseItem );
       
   909         }
       
   910 
       
   911 	IMUM_OUT();
       
   912     return KErrNone;
       
   913     }
       
   914 
       
   915 // ----------------------------------------------------------------------------
       
   916 // CIMSSettingsWizard::EventItemEvaluateRadioButton()
       
   917 // ----------------------------------------------------------------------------
       
   918 //
       
   919 TMuiuPageEventResult CIMSSettingsWizard::EventItemEvaluateRadioButton(
       
   920     const CMuiuSettingBase& aBaseItem,
       
   921     TInt& aNewValue )
       
   922     {
       
   923     IMUM_CONTEXT( CIMSSettingsWizard::EventItemEvaluateRadioButton, 0, KLogUi );
       
   924 	IMUM_IN();
       
   925 
       
   926     // Test the item with the approver
       
   927     TIMSApproverEvent event;
       
   928     TMuiuPageEventResult result = iItemApprover->EvaluateValue(
       
   929         event, aBaseItem, aNewValue );
       
   930 
       
   931     // The EWizFlagItemApproved has to be updated according to result of the
       
   932     // validation. When flag is ETrue, next page can be opened
       
   933     TBool approved = ( result == EMuiuPageEventResultApproved );
       
   934     ChangeFlag( EWizFlagItemApproved, approved );
       
   935     if ( !approved )
       
   936         {
       
   937         // Needs to clear this as CMuiuDynamicSettingsDialog opens the
       
   938         // same page again without returning to wizard.
       
   939         ClearFlag( EWizFlagNextKeyPressed );
       
   940         }
       
   941 
       
   942     IMUM_OUT();
       
   943     return result;
       
   944     }
       
   945 
       
   946 // ----------------------------------------------------------------------------
       
   947 // CIMSSettingsWizard::EventItemEvaluateText()
       
   948 // ----------------------------------------------------------------------------
       
   949 //
       
   950 TMuiuPageEventResult CIMSSettingsWizard::EventItemEvaluateText(
       
   951     const CMuiuSettingBase& aBaseItem,
       
   952     TDes& aNewText )
       
   953     {
       
   954     IMUM_CONTEXT( CIMSSettingsWizard::EventItemEvaluateText, 0, KLogUi );
       
   955     IMUM_IN();
       
   956 
       
   957     // Test the item with the approver
       
   958     TIMSApproverEvent event;
       
   959     TMuiuPageEventResult result = iItemApprover->EvaluateText(
       
   960         event, aBaseItem, aNewText );
       
   961 
       
   962     // The EWizFlagItemApproved has to be updated according to result of the
       
   963     // validation. When flag is ETrue, next page can be opened
       
   964     TBool approved = ( result == EMuiuPageEventResultApproved );
       
   965     ChangeFlag( EWizFlagItemApproved, approved );
       
   966     if ( !approved )
       
   967         {
       
   968         // Needs to clear this as CMuiuDynamicSettingsDialog opens the
       
   969         // same page again without returning to wizard.
       
   970         ClearFlag( EWizFlagNextKeyPressed );
       
   971         }
       
   972 
       
   973     IMUM_OUT();
       
   974     return result;
       
   975     }
       
   976 
       
   977 // ----------------------------------------------------------------------------
       
   978 // CIMSSettingsWizard::SettingsItemProcessItemL()
       
   979 // ----------------------------------------------------------------------------
       
   980 //
       
   981 void CIMSSettingsWizard::SettingsItemProcessItemL(
       
   982     CMuiuSettingBase& aBaseItem )
       
   983     {
       
   984     IMUM_CONTEXT( CIMSSettingsWizard::SettingsItemProcessItemL, 0, KLogUi );
       
   985     IMUM_IN();
       
   986 
       
   987     switch ( aBaseItem.iItemId.iUid )
       
   988         {
       
   989         case EIMAWProtocol:
       
   990             SettingsItemProcessProtocol( aBaseItem );
       
   991             break;
       
   992 
       
   993         case EIMAWEmailAddress:
       
   994             SettingsItemProcessEmailL( aBaseItem );
       
   995             break;
       
   996 
       
   997         case EIMAWIap:
       
   998             SettingsItemProcessIapL( aBaseItem );
       
   999             break;
       
  1000 
       
  1001         default:
       
  1002             break;
       
  1003         }
       
  1004 
       
  1005 	IMUM_OUT();
       
  1006     }
       
  1007 
       
  1008 // ----------------------------------------------------------------------------
       
  1009 // CIMSSettingsWizard::SettingsItemProcessProtocol()
       
  1010 // ----------------------------------------------------------------------------
       
  1011 //
       
  1012 void CIMSSettingsWizard::SettingsItemProcessProtocol(
       
  1013     CMuiuSettingBase& aBaseItem )
       
  1014     {
       
  1015     IMUM_CONTEXT( CIMSSettingsWizard::SettingsItemProcessProtocol, 0, KLogUi );
       
  1016 
       
  1017    	iProtocol.iUid = iProtocolArray[aBaseItem.Value()];
       
  1018    	if ( iProtocol == KSenduiMtmImap4Uid )
       
  1019    	    {
       
  1020    	    SettingsItemDefineNormalWizardArray();
       
  1021    	    }
       
  1022     }
       
  1023 
       
  1024 // ----------------------------------------------------------------------------
       
  1025 // CIMSSettingsWizard::SettingsItemDefineNormalWizardArray()
       
  1026 // ----------------------------------------------------------------------------
       
  1027 //
       
  1028 void CIMSSettingsWizard::SettingsItemDefineNormalWizardArray()
       
  1029     {
       
  1030     IMUM_CONTEXT( CIMSSettingsWizard::SettingsItemDefineNormalWizardArray, 0, KLogUi );
       
  1031 
       
  1032     // Unhide all the items
       
  1033     HidePermanently( ToUid( EIMAWProtocol ), EFalse );
       
  1034     HidePermanently( ToUid( EIMAWEmailAddress ), EFalse );
       
  1035     HidePermanently( ToUid( EIMAWReceivingServer ), EFalse );
       
  1036     HidePermanently( ToUid( EIMAWSendingServer ), EFalse );
       
  1037     HidePermanently( ToUid( EIMAWIap ), EFalse );
       
  1038     HidePermanently( ToUid( EIMAWMailboxName ), EFalse );
       
  1039     }
       
  1040 
       
  1041 // ----------------------------------------------------------------------------
       
  1042 // CIMSSettingsWizard::SettingsItemProcessEmailL()
       
  1043 // ----------------------------------------------------------------------------
       
  1044 //
       
  1045 void CIMSSettingsWizard::SettingsItemProcessEmailL(
       
  1046     CMuiuSettingBase& aBaseItem )
       
  1047     {
       
  1048     IMUM_CONTEXT( CIMSSettingsWizard::SettingsItemProcessEmailL, 0, KLogUi );
       
  1049 
       
  1050     CMuiuSettingsEditText* email =
       
  1051         static_cast<CMuiuSettingsEditText*>( &aBaseItem );
       
  1052 
       
  1053     // Define new server address and mailbox name, if the email address changes
       
  1054     if ( email->Text() &&
       
  1055          email->Text()->CompareC( iTemporaryText ) )
       
  1056         {
       
  1057         // Fill rest of the items
       
  1058         SettingsItemDefineServers( *email->Text() );
       
  1059         SettingsItemDefineMailboxName( *email->Text() );
       
  1060         }
       
  1061 
       
  1062     email = NULL;
       
  1063     iTemporaryText.Zero();
       
  1064 
       
  1065     }
       
  1066 
       
  1067 // ----------------------------------------------------------------------------
       
  1068 // CIMSSettingsWizard::SettingsItemProcessIapL()
       
  1069 // ----------------------------------------------------------------------------
       
  1070 //
       
  1071 void CIMSSettingsWizard::SettingsItemProcessIapL(
       
  1072     CMuiuSettingBase& aBaseItem )
       
  1073     {
       
  1074     IMUM_CONTEXT( CIMSSettingsWizard::SettingsItemProcessIapL, 0, KLogUi );
       
  1075 
       
  1076     CIMSSettingsAccessPointItem* iapItem =
       
  1077         static_cast<CIMSSettingsAccessPointItem*>( &aBaseItem );
       
  1078 
       
  1079     // Update the iap item, but use the radio button as reference point
       
  1080     SetItemIapItemL( *iapItem );
       
  1081     }
       
  1082 
       
  1083 // ----------------------------------------------------------------------------
       
  1084 // CIMSSettingsWizard::SettingsItemDefineServerL()
       
  1085 // ----------------------------------------------------------------------------
       
  1086 //
       
  1087 void CIMSSettingsWizard::SettingsItemDefineServers(
       
  1088     const TDesC& aEmailAddress )
       
  1089     {
       
  1090     IMUM_CONTEXT( CIMSSettingsWizard::SettingsItemDefineServers, 0, KLogUi );
       
  1091 
       
  1092     // Fetch the item
       
  1093     CMuiuSettingsEditText* outgoing = static_cast<CMuiuSettingsEditText*>(
       
  1094         GetItem( TUid::Uid( EIMAWSendingServer ) ) );
       
  1095     CMuiuSettingsEditText* incoming = static_cast<CMuiuSettingsEditText*>(
       
  1096         GetItem( TUid::Uid( EIMAWReceivingServer ) ) );
       
  1097 
       
  1098     if ( outgoing && incoming )
       
  1099         {
       
  1100         TMuiuSettingsText newAddress;
       
  1101         TInt len = aEmailAddress.Length();
       
  1102 
       
  1103         // Find index after '@' character
       
  1104         TInt index = aEmailAddress.Locate( KIMASCharAt ) + 1;
       
  1105         newAddress.Zero();
       
  1106         newAddress.Append( KIMASCharDot );
       
  1107         newAddress.Append( aEmailAddress.Right( len - index ) );
       
  1108 
       
  1109         // Finally copy the address
       
  1110         outgoing->SetText( &newAddress );
       
  1111         incoming->SetText( &newAddress );
       
  1112         }
       
  1113 
       
  1114     outgoing = NULL;
       
  1115     incoming = NULL;
       
  1116 
       
  1117     }
       
  1118 
       
  1119 // ----------------------------------------------------------------------------
       
  1120 // CIMSSettingsWizard::SettingsItemDefineMailboxName()
       
  1121 // ----------------------------------------------------------------------------
       
  1122 //
       
  1123 void CIMSSettingsWizard::SettingsItemDefineMailboxName(
       
  1124     const TDesC& aEmailAddress )
       
  1125     {
       
  1126     IMUM_CONTEXT( CIMSSettingsWizard::SettingsItemDefineMailboxName, 0, KLogUi );
       
  1127 
       
  1128     // Fetch the item
       
  1129     CMuiuSettingsEditText* name = static_cast<CMuiuSettingsEditText*>(
       
  1130         GetItem( TUid::Uid( EIMAWMailboxName ) ) );
       
  1131     TInt len = aEmailAddress.Length();
       
  1132 
       
  1133     if ( name && len > 0 )
       
  1134         {
       
  1135         // Clear the old name and prepare the new
       
  1136         TMuiuSettingsText newAddress;
       
  1137 
       
  1138         // Find the first letter after '@' character and set the string
       
  1139         // to name field
       
  1140         TInt firstLetterIndex = aEmailAddress.Locate( KIMASCharAt ) + 1;
       
  1141         newAddress.Append( aEmailAddress.Right( len - firstLetterIndex ) );
       
  1142 
       
  1143         // Find the first '.' character and remove it and
       
  1144         // all the text after it
       
  1145         TInt pointCharIndex = newAddress.Locate( KIMASCharDot );
       
  1146         if ( pointCharIndex > 0 )
       
  1147             {
       
  1148             newAddress.Delete( pointCharIndex, newAddress.Length() - 1 );
       
  1149             }
       
  1150 
       
  1151         // Validate the generated account name
       
  1152         TIMSApproverEvent event;
       
  1153         name->iItemFlags.SetFlag( EIMSApproverGenerate );
       
  1154         iItemApprover->EvaluateText( event, *name, newAddress );
       
  1155         name->iItemFlags.ClearFlag( EIMSApproverGenerate );
       
  1156 
       
  1157         // Finally copy the address
       
  1158         name->SetText( &newAddress );
       
  1159         }
       
  1160 
       
  1161     // Clean up
       
  1162     name = NULL;
       
  1163 
       
  1164     }
       
  1165 
       
  1166 
       
  1167 // ----------------------------------------------------------------------------
       
  1168 // CIMSSettingsWizard::CheckEmailSkip()
       
  1169 // ----------------------------------------------------------------------------
       
  1170 //
       
  1171 TBool CIMSSettingsWizard::CheckEmailSkip()
       
  1172     {
       
  1173     TBool ok = EFalse;
       
  1174     if ( Flag( EWizFlagSkipEmail ) && iCurrentItem.iUid == EIMAWEmailAddress )
       
  1175         {
       
  1176         ClearFlag( EWizFlagSkipEmail );
       
  1177         CMuiuSettingsEditText* email = static_cast<CMuiuSettingsEditText*>(
       
  1178             GetItem( TUid::Uid( EIMAWEmailAddress ) ) );
       
  1179         TRAPD( error, ok =
       
  1180             MsvUiServiceUtilities::IsValidEmailAddressL( *email->Text() ) );
       
  1181         if ( !error && ok )
       
  1182             {
       
  1183             CMuiuSettingBase* emailItem = GetItem( TUid::Uid( EIMAWEmailAddress ) );
       
  1184             emailItem->iItemFlags.SetFlag( EMuiuDynItemValidated );
       
  1185             SetFlag( EWizFlagItemApproved );
       
  1186             SetFlag( EWizFlagNextKeyPressed );
       
  1187             }
       
  1188         else
       
  1189             {
       
  1190             // Should not leave just show the email address
       
  1191             TRAP_IGNORE( CIMSSettingsNoteUi::ShowNoteL(
       
  1192                 R_IMUM_EDIT_OWN_EMAIL_ADDRESS_ERROR_TEXT,
       
  1193                 EIMSInformationNote, ETrue ) );
       
  1194             }
       
  1195         }
       
  1196     return ok;
       
  1197     }
       
  1198 
       
  1199 /******************************************************************************
       
  1200 
       
  1201     Custom settings
       
  1202 
       
  1203 ******************************************************************************/
       
  1204 
       
  1205 // ----------------------------------------------------------------------------
       
  1206 // CIMSSettingsWizard::AcquireCustomSettingPageL()
       
  1207 // ----------------------------------------------------------------------------
       
  1208 //
       
  1209 void CIMSSettingsWizard::AcquireCustomSettingPageL(
       
  1210     CAknSettingPage*& aReturnPage,
       
  1211     TMuiuDynSetUpdateMode& aReturnUpdateMode,
       
  1212     TInt& aReturnSettingValue,
       
  1213     TMuiuSettingsText& aReturnSettingText,
       
  1214     CDesCArrayFlat& aReturnRadioButtonArray,
       
  1215     CMuiuSettingBase& aParamBaseItem )
       
  1216     {
       
  1217     IMUM_CONTEXT( CIMSSettingsWizard::AcquireCustomSettingPageL, 0, KLogUi );
       
  1218 
       
  1219     switch ( aParamBaseItem.iItemId.iUid )
       
  1220         {
       
  1221         // Radiobutton pages
       
  1222         case EIMAWProtocol:
       
  1223             aReturnPage = AcquireProtocolPageL(
       
  1224                 aReturnSettingValue, aReturnUpdateMode,
       
  1225                 aReturnRadioButtonArray, aParamBaseItem );
       
  1226             break;
       
  1227 
       
  1228         // Text editors
       
  1229         case EIMAWEmailAddress:
       
  1230         case EIMAWSendingServer:
       
  1231         case EIMAWReceivingServer:
       
  1232         case EIMAWMailboxName:
       
  1233             aReturnPage = AcquireCustomTextEditorL(
       
  1234                 aReturnSettingText, aReturnUpdateMode,
       
  1235                 aParamBaseItem );
       
  1236             break;
       
  1237 
       
  1238         case EIMAWIap:
       
  1239             aReturnPage = AcquireCustomIapPageL(
       
  1240                 aReturnSettingValue, aReturnUpdateMode,
       
  1241                 aReturnRadioButtonArray, aParamBaseItem );
       
  1242             break;
       
  1243 
       
  1244         default:
       
  1245             break;
       
  1246         }
       
  1247 
       
  1248     }
       
  1249 
       
  1250 // ----------------------------------------------------------------------------
       
  1251 // CIMSSettingsWizard::AcquireCustomRadioButtonPageL()
       
  1252 // ----------------------------------------------------------------------------
       
  1253 //
       
  1254 CAknSettingPage* CIMSSettingsWizard::AcquireCustomRadioButtonPageL(
       
  1255     TInt& aReturnSettingValue,
       
  1256     TMuiuDynSetUpdateMode& aReturnUpdateMode,
       
  1257     MDesCArray& aReturnRadioButtonArray,
       
  1258     CMuiuSettingBase& aParamBaseItem )
       
  1259     {
       
  1260     IMUM_CONTEXT( CIMSSettingsWizard::AcquireCustomRadioButtonPageL, 0, KLogUi );
       
  1261 
       
  1262     iPageRadioBtn =
       
  1263         ( CIMSSettingsWizardRadioButtonPage::NewL(
       
  1264             *this, R_IMAS_WIZARD_DIALOG_LISTBOX_NEXT_BACK,
       
  1265             aReturnSettingValue, &aReturnRadioButtonArray, *iPageText ) );
       
  1266 
       
  1267     // Define the page properties
       
  1268     iPageRadioBtn->SetSettingTextL( *aParamBaseItem.iItemLabel );
       
  1269 
       
  1270     // Set updatemode to accept setting only when the setting is
       
  1271     // accepted
       
  1272     aReturnUpdateMode = CAknSettingPage::EUpdateWhenAccepted;
       
  1273 
       
  1274     return iPageRadioBtn;
       
  1275     }
       
  1276 
       
  1277 // ----------------------------------------------------------------------------
       
  1278 // CIMSSettingsWizard::AcquireCustomTextEditorL()
       
  1279 // ----------------------------------------------------------------------------
       
  1280 //
       
  1281 CAknSettingPage* CIMSSettingsWizard::AcquireCustomTextEditorL(
       
  1282     TMuiuSettingsText& aReturnSettingText,
       
  1283     TMuiuDynSetUpdateMode& aReturnUpdateMode,
       
  1284     CMuiuSettingBase& aParamBaseItem )
       
  1285     {
       
  1286     IMUM_CONTEXT( CIMSSettingsWizard::AcquireCustomTextEditorL, 0, KLogUi );
       
  1287 
       
  1288     // Allow zero length with wizard, the setting won't be accepted
       
  1289     // anyway, when empty
       
  1290     TInt settingPageFlags = GetTextEditorFlags( aParamBaseItem );
       
  1291 
       
  1292     // Determine buttons
       
  1293     TInt page = ( aParamBaseItem.iItemId.iUid == EIMAWMailboxName ) ?
       
  1294         R_IMAS_WIZARD_DIALOG_EDWIN_FINISH_BACK :
       
  1295         R_IMAS_WIZARD_DIALOG_EDWIN_NEXT_BACK;
       
  1296 
       
  1297     // Create the text editir page
       
  1298     iPageEdit =
       
  1299         ( CIMSSettingsWizardEditTextPage::NewL(
       
  1300             *this, page, *&aReturnSettingText, *iPageText,
       
  1301             settingPageFlags ) );
       
  1302 
       
  1303     // Define the page properties
       
  1304     iPageEdit->SetSettingTextL( *aParamBaseItem.iItemLabel );
       
  1305     CMuiuSettingsEditText* textEditor =
       
  1306         static_cast<CMuiuSettingsEditText*>( &aParamBaseItem );
       
  1307     iPageEdit->TextControl()->SetTextLimit(
       
  1308         textEditor->iItemMaxLength );
       
  1309     aReturnSettingText.Copy( *textEditor->Text() );
       
  1310     iTemporaryText.Zero();
       
  1311     iTemporaryText.Copy( *textEditor->Text() );
       
  1312 
       
  1313     // Set updatemode to accept setting only when the setting is
       
  1314     // accepted
       
  1315     aReturnUpdateMode = CAknSettingPage::EUpdateWhenAccepted;
       
  1316 
       
  1317     return iPageEdit;
       
  1318     }
       
  1319 
       
  1320 // ----------------------------------------------------------------------------
       
  1321 // CIMSSettingsWizard::AcquireCustomIapPageL()
       
  1322 // ----------------------------------------------------------------------------
       
  1323 //
       
  1324 CAknSettingPage* CIMSSettingsWizard::AcquireCustomIapPageL(
       
  1325     TInt& aReturnSettingValue,
       
  1326     TMuiuDynSetUpdateMode& aReturnUpdateMode,
       
  1327     CDesCArrayFlat& aReturnRadioButtonArray,
       
  1328     CMuiuSettingBase& aParamBaseItem )
       
  1329     {
       
  1330     IMUM_CONTEXT( CIMSSettingsWizard::AcquireCustomIapPageL, 0, KLogUi );
       
  1331 
       
  1332     CIMSSettingsAccessPointItem* iapItem =
       
  1333         static_cast<CIMSSettingsAccessPointItem*>( &aParamBaseItem );
       
  1334 
       
  1335     // Initialize item in the first round
       
  1336     if ( !aParamBaseItem.iItemFlags.Flag( EMuiuDynItemChecked ) )
       
  1337         {
       
  1338         aParamBaseItem.iItemFlags.SetFlag( EMuiuDynItemChecked );
       
  1339         iMailboxApi.CommDbUtilsL().InitItemAccessPointL( *iapItem, ETrue );
       
  1340         }
       
  1341 
       
  1342     // Create the button array
       
  1343     CDesCArrayFlat* buttons = &aReturnRadioButtonArray;
       
  1344 
       
  1345     TRAPD( error, iMailboxApi.CommDbUtilsL().FillCustomIapArrayL( *buttons ) );
       
  1346     if ( error != KErrNone )
       
  1347         {
       
  1348         __ASSERT_DEBUG( EFalse,
       
  1349             User::Panic( KIMSWizardPanic, error ) );
       
  1350         }
       
  1351 
       
  1352     // The correct radiobutton index is fetched from the item
       
  1353     aReturnSettingValue = iMailboxApi.CommDbUtilsL().GetWizardRadioButton( *iapItem );
       
  1354 
       
  1355     AcquireCustomRadioButtonPageL(
       
  1356         aReturnSettingValue, aReturnUpdateMode, *buttons, aParamBaseItem );
       
  1357 
       
  1358     // Focus the first access point, when no items selected
       
  1359     if ( aParamBaseItem.Value() == KErrNotFound )
       
  1360         {
       
  1361         TInt staticCount = iMailboxApi.CommDbUtilsL().StaticIAPCount();
       
  1362         TInt highlight = buttons->Count() > staticCount ? staticCount : 0;
       
  1363 
       
  1364         iPageRadioBtn->ListBoxControl()->SetCurrentItemIndexAndDraw( highlight );
       
  1365         }
       
  1366 
       
  1367     return iPageRadioBtn;
       
  1368     }
       
  1369 
       
  1370 // ----------------------------------------------------------------------------
       
  1371 // CIMSSettingsWizard::AcquireProtocolPageL()
       
  1372 // ----------------------------------------------------------------------------
       
  1373 //
       
  1374 CAknSettingPage* CIMSSettingsWizard::AcquireProtocolPageL(
       
  1375     TInt& aReturnSettingValue,
       
  1376     TMuiuDynSetUpdateMode& aReturnUpdateMode,
       
  1377     CDesCArrayFlat& aReturnRadioButtonArray,
       
  1378     CMuiuSettingBase& aParamBaseItem )
       
  1379     {
       
  1380     IMUM_CONTEXT( CIMSSettingsWizard::AcquireProtocolPageL, 0, KLogUi );
       
  1381 	IMUM_IN();
       
  1382 
       
  1383     CDesCArrayFlat* buttons = &aReturnRadioButtonArray;
       
  1384 
       
  1385 	CMtmUiDataRegistry* uiDataMtmRegistry = CMtmUiDataRegistry::NewL( iMailboxApi.MsvSession() );
       
  1386 	CleanupStack::PushL( uiDataMtmRegistry );
       
  1387 	CBaseMtmUiData* uiData = NULL;
       
  1388 
       
  1389     // Initialize the button/protocol ID mapping table
       
  1390     iProtocolArray.Reset();
       
  1391 	iProtocolArray.AppendL( KSenduiMtmImap4UidValue );
       
  1392 	iProtocolArray.AppendL( KSenduiMtmPop3UidValue );
       
  1393 
       
  1394 	for ( TInt i = uiDataMtmRegistry->NumRegisteredMtmDlls(); --i >= 0; )
       
  1395 		{
       
  1396         TUid mtmType = uiDataMtmRegistry->MtmTypeUid(i);
       
  1397 
       
  1398         if ( uiDataMtmRegistry->TechnologyTypeUid( mtmType ) == KSenduiTechnologyMailUid )
       
  1399             {
       
  1400             TRAPD( err, uiData = &( iMtmStore->MtmUiDataL( mtmType ) ) );
       
  1401 
       
  1402             if ( err == KErrNone )
       
  1403                 {
       
  1404                 CheckMtmWizardSupportL( *uiData, *buttons );
       
  1405                 iMtmStore->ReleaseMtmUiData( mtmType );
       
  1406                 }
       
  1407             }
       
  1408 		}
       
  1409 
       
  1410 	CleanupStack::PopAndDestroy( uiDataMtmRegistry );
       
  1411 	uiDataMtmRegistry = NULL;
       
  1412 
       
  1413     AcquireCustomRadioButtonPageL(
       
  1414         aReturnSettingValue, aReturnUpdateMode, *buttons, aParamBaseItem );
       
  1415 
       
  1416     IMUM_OUT();
       
  1417 
       
  1418     return iPageRadioBtn;
       
  1419     }
       
  1420 
       
  1421 // ----------------------------------------------------------------------------
       
  1422 // CIMSSettingsWizard::CheckMtmWizardSupportL()
       
  1423 // Checks if spesified MTM has ability to launch added-on wizard from email
       
  1424 // creation wizard
       
  1425 // ----------------------------------------------------------------------------
       
  1426 //
       
  1427 void CIMSSettingsWizard::CheckMtmWizardSupportL(
       
  1428     CBaseMtmUiData& aMtmUiData,
       
  1429     CDesCArrayFlat& aRadioButtons
       
  1430     )
       
  1431     {
       
  1432 	IMUM_CONTEXT( CIMSSettingsWizard::CheckMtmWizardSupportL, 0, KLogUi );
       
  1433 	IMUM_IN();
       
  1434 
       
  1435     const CArrayFix<CBaseMtmUiData::TMtmUiFunction>& funcs =
       
  1436         aMtmUiData.MtmSpecificFunctions();
       
  1437     TInt  funcIndex = -1;
       
  1438     TBool found = EFalse;
       
  1439 
       
  1440     while ( ( ++funcIndex < funcs.Count() ) && found == EFalse )
       
  1441         {
       
  1442         CBaseMtmUiData::TMtmUiFunction func = funcs.At( funcIndex );
       
  1443 
       
  1444         if ( func.iFunctionId == KMtmUiFunctionSettingsWizard )
       
  1445             {
       
  1446             aRadioButtons.AppendL( func.iCaption );
       
  1447             iProtocolArray.AppendL( aMtmUiData.Type().iUid );
       
  1448             found = ETrue;
       
  1449             }
       
  1450         }
       
  1451     IMUM_OUT();
       
  1452     }
       
  1453 
       
  1454 
       
  1455 /******************************************************************************
       
  1456 
       
  1457     Account creating
       
  1458 
       
  1459 ******************************************************************************/
       
  1460 
       
  1461 // ----------------------------------------------------------------------------
       
  1462 // CIMSSettingsWizard::StoreSettingsToAccountL()
       
  1463 // ----------------------------------------------------------------------------
       
  1464 //
       
  1465 void CIMSSettingsWizard::StoreSettingsToAccountL(
       
  1466     CImumInSettingsData& aSettings )
       
  1467     {
       
  1468     IMUM_CONTEXT( CIMSSettingsWizard::StoreSettingsToAccountL, 0, KLogUi );
       
  1469 
       
  1470 
       
  1471     SetPreviousTitlePaneText();
       
  1472 
       
  1473     // Make sure that all settings really are ok
       
  1474     if ( !Flag( EWizFlagCompleted ) )
       
  1475         {
       
  1476         // Settings not ok, don't try to create them
       
  1477         aSettings.ResetAll();
       
  1478 
       
  1479         return;
       
  1480         }
       
  1481 
       
  1482     TUid protocol;
       
  1483     if ( iProtocol == KSenduiMtmImap4Uid )
       
  1484         {
       
  1485         protocol = KSenduiMtmImap4Uid;
       
  1486         }
       
  1487     else
       
  1488         {
       
  1489         protocol = KSenduiMtmPop3Uid;
       
  1490         }
       
  1491 
       
  1492     // First get the items and check they can be used
       
  1493     CMuiuSettingsEditText* emailAddress =
       
  1494         static_cast<CMuiuSettingsEditText*>(
       
  1495             GetItem( TUid::Uid( EIMAWEmailAddress ) ) );
       
  1496     User::LeaveIfNull( emailAddress );
       
  1497 
       
  1498     CMuiuSettingsEditText* outgoingAddress =
       
  1499         static_cast<CMuiuSettingsEditText*>(
       
  1500             GetItem( TUid::Uid( EIMAWSendingServer ) ) );
       
  1501     User::LeaveIfNull( outgoingAddress );
       
  1502 
       
  1503 
       
  1504     CMuiuSettingsEditText* incomingAddress =
       
  1505         static_cast<CMuiuSettingsEditText*>(
       
  1506             GetItem( TUid::Uid( EIMAWReceivingServer ) ) );
       
  1507     User::LeaveIfNull( incomingAddress );
       
  1508 
       
  1509     CIMSSettingsAccessPointItem* iapPreference =
       
  1510         static_cast<CIMSSettingsAccessPointItem*>(
       
  1511             GetItem( TUid::Uid( EIMAWIap ) ) );
       
  1512     User::LeaveIfNull( iapPreference );
       
  1513     // Resolve Access Point type, and actual ID; it is assumed
       
  1514     // that Default Connection is always first in the list
       
  1515     if( iapPreference->iIapRadioButton <= 0 )
       
  1516     	{
       
  1517     	iapPreference->iIap.iResult = CMManager::EDefaultConnection;
       
  1518     	iapPreference->iIap.iId = 0; // default conn id
       
  1519     	}
       
  1520     else
       
  1521     	{
       
  1522     	iapPreference->iIap.iResult = CMManager::EConnectionMethod;
       
  1523     	iapPreference->iIap.iId = iMailboxApi.CommDbUtilsL().GetIapIdL(
       
  1524     			iapPreference->iIapRadioButton );
       
  1525 
       
  1526     	}
       
  1527 
       
  1528     CMuiuSettingsEditText* mailboxName =
       
  1529         static_cast<CMuiuSettingsEditText*>(
       
  1530             GetItem( TUid::Uid( EIMAWMailboxName ) ) );
       
  1531     User::LeaveIfNull( mailboxName );
       
  1532 
       
  1533     // Create settings data object through the interface
       
  1534     iMailboxApi.MailboxServicesImplL().FillCompulsorySettingsL(
       
  1535         aSettings,
       
  1536         protocol,
       
  1537         *emailAddress->Text(),
       
  1538         *incomingAddress->Text(),
       
  1539         *outgoingAddress->Text(),
       
  1540         iapPreference->iIap.iId,
       
  1541         *mailboxName->Text() );
       
  1542 
       
  1543     // Store the exit code, so the settings will be saved
       
  1544     iBaseUiFlags.SetFlag( EImumSettingSave );
       
  1545 
       
  1546     // Cleanup
       
  1547     emailAddress = NULL;
       
  1548     incomingAddress = NULL;
       
  1549     outgoingAddress = NULL;
       
  1550     iapPreference = NULL;
       
  1551     mailboxName = NULL;
       
  1552 
       
  1553     }
       
  1554 
       
  1555 /******************************************************************************
       
  1556 
       
  1557     Utilitites
       
  1558 
       
  1559 ******************************************************************************/
       
  1560 
       
  1561 // ----------------------------------------------------------------------------
       
  1562 // CIMSSettingsWizard::CheckCompleted()
       
  1563 // ----------------------------------------------------------------------------
       
  1564 //
       
  1565 TBool CIMSSettingsWizard::CheckCompleted()
       
  1566     {
       
  1567     IMUM_CONTEXT( CIMSSettingsWizard::CheckCompleted, 0, KLogUi );
       
  1568 
       
  1569     // Get the array of main resource
       
  1570     CMuiuDynFinderItemArray* array = GetResource( R_IMAS_WIZARD, EFalse );
       
  1571 
       
  1572     // Search through the array, and if all items are ready, return true
       
  1573     TInt item = array->Count();
       
  1574     TBool ok = item > 0;
       
  1575     while ( --item >= 0 )
       
  1576         {
       
  1577         TMuiuFlags flags = ( *array )[item].iItem->iItemFlags;
       
  1578 
       
  1579         // All visible items are checked and one failure is enough to
       
  1580         // make the array unfinished
       
  1581         ok = flags.Flag( EMuiuDynItemPermanentlyHidden ) ||
       
  1582              flags.Flag( EMuiuDynItemValidated ) && ok;
       
  1583         }
       
  1584 
       
  1585     return ok;
       
  1586     }
       
  1587 
       
  1588 // -----------------------------------------------------------------------------
       
  1589 // CIMSSettingsWizard::PostponePopup()
       
  1590 // PostponePopup is used to move time forward
       
  1591 // when popup will be displayed. This is needed
       
  1592 // to prevent situation when user is typing
       
  1593 // e.g. email address and popup will be displayed
       
  1594 // after user is typed a half of address but
       
  1595 // original time has experied.
       
  1596 // -----------------------------------------------------------------------------
       
  1597 //
       
  1598 void CIMSSettingsWizard::PostponePopup()
       
  1599     {
       
  1600     IMUM_CONTEXT( CIMSSettingsWizard::PostponePopup, 0, KLogUi );
       
  1601     IMUM_IN();
       
  1602 
       
  1603     if( iNoteDialog )
       
  1604         {
       
  1605         iNoteDialog->SetTimeDelayBeforeShow( KMsToWaitBeforeRePopup );
       
  1606         iNoteDialog->ShowInfoPopupNote();
       
  1607         }
       
  1608 
       
  1609     IMUM_OUT();
       
  1610     }
       
  1611 
       
  1612 // -----------------------------------------------------------------------------
       
  1613 // CIMSSettingsWizard::ShowMailSettingsPopupAfter()
       
  1614 // -----------------------------------------------------------------------------
       
  1615 //
       
  1616 CAknInfoPopupNoteController* CIMSSettingsWizard::ShowMailSettingsPopupAfterL(
       
  1617     const TUid& aId,
       
  1618     TInt aAfterMs )
       
  1619     {
       
  1620     IMUM_CONTEXT( CIMSSettingsWizard::ShowMailSettingsPopupAfterL, 0, KLogUi );
       
  1621 
       
  1622     CAknInfoPopupNoteController* noteDialog = NULL;
       
  1623     switch ( aId.iUid )
       
  1624         {
       
  1625         case EIMAWProtocol:
       
  1626             noteDialog = CIMSSettingsNoteUi::ShowPopupL( 
       
  1627                 R_IMUM_POPUP_MAILBOX_TYPE, aAfterMs );
       
  1628             break;
       
  1629 
       
  1630         case EIMAWEmailAddress:
       
  1631             noteDialog = CIMSSettingsNoteUi::ShowPopupL(
       
  1632                 R_IMUM_POPUP_MY_EMAIL_ADDRESS, aAfterMs );
       
  1633             break;
       
  1634 
       
  1635         case EIMAWSendingServer:
       
  1636             noteDialog = CIMSSettingsNoteUi::ShowPopupL(
       
  1637                 R_IMUM_POPUP_OUTGOING_SERVER, aAfterMs );
       
  1638             break;
       
  1639 
       
  1640         case EIMAWReceivingServer:
       
  1641             noteDialog = CIMSSettingsNoteUi::ShowPopupL(
       
  1642                 R_IMUM_POPUP_INCOMING_SERVER, aAfterMs );
       
  1643             break;
       
  1644 
       
  1645         case EIMAWIap:
       
  1646             noteDialog = CIMSSettingsNoteUi::ShowPopupL(
       
  1647                 R_IMUM_POPUP_DEFINING_ACCESS_POINT, aAfterMs );
       
  1648             break;
       
  1649 
       
  1650         case EIMAWMailboxName:
       
  1651             noteDialog = CIMSSettingsNoteUi::ShowPopupL(
       
  1652                 R_IMUM_POPUP_MAILBOX_NAME, aAfterMs );
       
  1653             break;
       
  1654 
       
  1655         default:
       
  1656             __ASSERT_DEBUG( EFalse,
       
  1657                 User::Panic( KIMSWizardPanic, KErrUnknown ) );
       
  1658             break;
       
  1659         }
       
  1660 
       
  1661     return noteDialog;
       
  1662     }
       
  1663 
       
  1664 // -----------------------------------------------------------------------------
       
  1665 // CIMSSettingsWizard::CallExternalMtmWizardL()
       
  1666 // Calls added-on MTM-wizard
       
  1667 // -----------------------------------------------------------------------------
       
  1668 //
       
  1669 void CIMSSettingsWizard::CallExternalMtmWizardL( const TUid& aMtmUid, TBool& aCompleted )
       
  1670 	{
       
  1671 	IMUM_CONTEXT( CIMSSettingsWizard::CallExternalMtmWizardL, 0, KLogUi );
       
  1672 	IMUM_IN();
       
  1673 
       
  1674 	TInt completed( 0 );
       
  1675     TPckgBuf<TInt> buf( completed );
       
  1676 
       
  1677 	CBaseMtmUi& mtmUi = iMtmStore->ClaimMtmUiL( aMtmUid );
       
  1678 
       
  1679     CMsvEntrySelection* emptySelection = new (ELeave) CMsvEntrySelection;
       
  1680     CleanupStack::PushL( emptySelection );
       
  1681 
       
  1682 	TRAP_IGNORE( mtmUi.InvokeSyncFunctionL(
       
  1683 		KMtmUiFunctionSettingsWizard, *emptySelection, buf) );
       
  1684 
       
  1685 	iMtmStore->ReleaseMtmUi( aMtmUid );
       
  1686 
       
  1687 	CleanupStack::PopAndDestroy( emptySelection );
       
  1688 	emptySelection = NULL;
       
  1689 
       
  1690     aCompleted = (buf() != 1);
       
  1691 
       
  1692     // Makes the wizard exit
       
  1693     if ( aCompleted )
       
  1694         {
       
  1695        	SetFlag( EWizFlagExiting );
       
  1696     	SetFlag( EWizFlagForcedCancel );
       
  1697     	IMUM0(0, "MTM wizard has returned an exit code!");
       
  1698         }
       
  1699 
       
  1700     IMUM_OUT();
       
  1701 	}
       
  1702 
       
  1703 //  End of File