emailuis/emailui/inc/FreestyleEmailUiWizardObserver.h
branchRCL_3
changeset 64 3533d4323edc
equal deleted inserted replaced
63:d189ee25cf9d 64:3533d4323edc
       
     1 /*
       
     2 * Copyright (c) 2007-2008 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:  Handles interaction with setup wizard
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef CFSEMAILUIWIZARDOBSERVER_H
       
    20 #define CFSEMAILUIWIZARDOBSERVER_H
       
    21 
       
    22 //  INCLUDES
       
    23 #include <AknWaitNoteWrapper.h>
       
    24 //<cmail>
       
    25 #include "cfsmailcommon.h"
       
    26 //</cmail>
       
    27 
       
    28 
       
    29 // FORWARD DECLARATIONS
       
    30 class CFreestyleEmailUiAppUi;
       
    31 class CFSEmailUiLauncherGridVisualiser;
       
    32 
       
    33 /**
       
    34  * Freestyle email wizard observer
       
    35  * Handles wizard lauching and the events received from one.
       
    36  *
       
    37  */
       
    38 class CFSEmailUiWizardObserver : public CBase,
       
    39                                  public MAknBackgroundProcess
       
    40 	{
       
    41 
       
    42 public:
       
    43   
       
    44     /**
       
    45      * Destructor.
       
    46      *
       
    47      */  
       
    48   	 ~CFSEmailUiWizardObserver();
       
    49 
       
    50     /**
       
    51      * Two-phased constructor.
       
    52      * Creates a new instance of class
       
    53      *
       
    54      * @returns CFSMailPluginManager instance
       
    55      */
       
    56   	 static CFSEmailUiWizardObserver* NewL( 
       
    57   	    CFreestyleEmailUiAppUi* aAppUi,
       
    58         CFSEmailUiLauncherGridVisualiser* aMainUiGridVisualiser );
       
    59   	
       
    60     /**
       
    61      * Two-phased constructor.
       
    62      * Creates a new instance of class
       
    63      *
       
    64      * @returns CFSMailPluginManager instance
       
    65      */
       
    66   	 static CFSEmailUiWizardObserver* NewLC( 
       
    67   	    CFreestyleEmailUiAppUi* aAppUi,
       
    68         CFSEmailUiLauncherGridVisualiser* aMainUiGridVisualiser );
       
    69     
       
    70     /**
       
    71      * Called from CFreestyleEmailUiAppUi::ConstructL.
       
    72      * Launches wizard if we don't have any mailboxes configured yet when 
       
    73      * Email Ui is started, 
       
    74      * OR
       
    75      * if there were parameters set by the wizard in central repository,
       
    76      * a wait note is started, and - via StepL - the framework is notified 
       
    77      * about the parameters by calling its method WizardDataAvailableL.
       
    78      *
       
    79      */
       
    80      void DoWizardStartupActionsL();
       
    81 	 
       
    82 	/**
       
    83      * When FS EMail is running and a setup wizard is finished, 
       
    84      * it will send the UI a message with a KNullDesC as message content.
       
    85      * UI will recognize this, start wait note and - via StepL - it will call 
       
    86      * the framework's method WizardDataAvailableL.
       
    87      * FS EMail will be brought to foreground if it is not already.
       
    88      */
       
    89 	 void HandleMessage( TUint32 aClientHandleOfTargetWindowGroup,
       
    90                          TUid aMessageUid,
       
    91                          const TDesC8& aMessageParameters );
       
    92 	 
       
    93 	/**
       
    94      * If FS Email was brought to foreground in HandleMessage, 
       
    95      * a wait note is started and - via StepL - framework's WizardDataAvailableL 
       
    96      * will be called.
       
    97      */
       
    98 	 void HandleForegroundEventL( TBool aForeground );
       
    99 	 
       
   100 public: //from MFSMailEventObserver
       
   101     /**
       
   102      * Framework event message. 
       
   103      * Used here to catch the events thrown from new mailbox creation process.
       
   104      * In the wizard observer only the events TFSEventNewMailbox and
       
   105      * TFSEventMailboxCreationFailure are catched. When either of these two 
       
   106      * is received the wait note is dismissed.
       
   107      *
       
   108      * @param aEvent One of pre-defined events in TFSMailEvent
       
   109      * @param aMailbox maibox related for this event
       
   110      * @param aParam1 intepretation is event specific (see TFSMailEvent descriptions)
       
   111      * @param aParam2 intepretation is event specific
       
   112      * @param aParam3 intepretation is event specific
       
   113      */
       
   114     void EventL( TFSMailEvent aEvent, TFSMailMsgId aMailbox, 
       
   115                  TAny* aParam1, TAny* aParam2, TAny* aParam3);
       
   116 	 
       
   117 public: // from MAknBackgroundProcess
       
   118     
       
   119     /**
       
   120      * The execution accesses this function when the "Creating new mailbox" wait note
       
   121      * is executed. From this method, framework's WizardDataAvailableL will be called.
       
   122      * This is done only once, ensured by the flag iInformAboutParams.
       
   123      */
       
   124     void StepL();
       
   125 	
       
   126 	/**
       
   127      * @return ETrue if the displayed wait note should be dismissed.
       
   128      */
       
   129 	TBool IsProcessDone() const;
       
   130 	
       
   131 	void ProcessFinished();
       
   132 	
       
   133 	void DialogDismissedL( TInt /*aButtonId*/ ); 
       
   134 	
       
   135 	/**
       
   136      * @return Returns KErrNone because the method StepL does not leave.
       
   137      */
       
   138 	TInt CycleError( TInt aError );
       
   139 	 
       
   140 protected:
       
   141 
       
   142     /**
       
   143      * C++ default constructor.
       
   144      *
       
   145      */
       
   146     CFSEmailUiWizardObserver( CFreestyleEmailUiAppUi* aAppUi,
       
   147                               CFSEmailUiLauncherGridVisualiser* aMainUiGridVisualiser );
       
   148     
       
   149     /**
       
   150      * ConstructL
       
   151      *
       
   152      */
       
   153 	void ConstructL();
       
   154 
       
   155 private:
       
   156     
       
   157     /**
       
   158      * Helper method which tells framework (with WizardDataAvailableL) that 
       
   159      * there are parameters in the central repository with which framework 
       
   160      * can create a new mail account.
       
   161      * After calling FW, clears the centrep keys.
       
   162      * If WizardDataAvailableL leaved or returned an error other than KErrNone, 
       
   163      * an error message is displayed.
       
   164      */
       
   165     void InformFrameworkAboutParamsL();
       
   166     
       
   167     /**
       
   168      * Helper method that launches the "Creating new mailbox" wait note. 
       
   169      * After calling the wait note's ExecuteL, StepL is called and this way
       
   170      * framework's WizardDataAvailableL gets called.
       
   171      */
       
   172     void StartWaitNoteL();
       
   173 
       
   174 private: // Data
       
   175     
       
   176     CFreestyleEmailUiAppUi* iAppUi;                             //does not own
       
   177     CFSEmailUiLauncherGridVisualiser* iMainUiGridVisualiser;    //does not own
       
   178     
       
   179     // For displaying the "Creating new mailbox" wait note
       
   180     CAknWaitNoteWrapper* iWaitNote;
       
   181     
       
   182     // Tells if the wait note is to be dismissed.
       
   183     TBool iProcessComplete;
       
   184     
       
   185     // WizardDataAvailableL is called (new mailbox possibly created) only after we have 
       
   186 	// received a certain kind of message in HandleMessageL() from mailbox setup wizard.
       
   187 	// This boolean is used to notify that that kind of message has been received and 
       
   188 	// that FS EMail was brought to foreground after that.
       
   189     TBool iForegroundAfterWizardMessage;
       
   190     
       
   191 	// this makes sure that the code in StepL() in run only once (in one process)
       
   192 	TBool iInformAboutParams;
       
   193     
       
   194     // For some reason the framework is sending the UI multiple TFSEventNewMailbox events
       
   195     // which causes crash in FW when the Inbox of the new mailbox is accessed 
       
   196     // for the second time.
       
   197     // Use of this can be removed when UI gets only one TFSEventNewMailbox for sure.
       
   198     TBool iNewMailboxEventHandlingAllowed;
       
   199     
       
   200     // <cmail>
       
   201     // Id of the created mailbox
       
   202     TFSMailMsgId iNewlyCreatedMailboxId;
       
   203     // flag informing that new mailbox was created
       
   204     TBool iNewMailboxCreated;
       
   205     // </cmail>
       
   206     };
       
   207     
       
   208 
       
   209 #endif  // CFSEMAILUIWIZARDOBSERVER_H
       
   210 
       
   211 // End of File