emailuis/emailui/inc/FreestyleEmailUiAppui.h
branchRCL_3
changeset 64 3533d4323edc
child 70 968773a0b6ef
equal deleted inserted replaced
63:d189ee25cf9d 64:3533d4323edc
       
     1 /*
       
     2 * Copyright (c) 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:  FreestyleEmailUiAppUi class definition
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef __FREESTYLEEMAILUI_APPUI_H__
       
    20 #define __FREESTYLEEMAILUI_APPUI_H__
       
    21 
       
    22 // SYSTEM INCLUDES
       
    23 #include <aknViewAppUi.h>
       
    24 //<cmail> SF
       
    25 #include <alf/alfenv.h>
       
    26 #include <alf/alfdisplay.h>
       
    27 //</cmail>
       
    28 #include <cntdef.h>
       
    29 #include <cntviewbase.h>
       
    30 // <cmail> CPhCltDialer.h API removed
       
    31 //#include <CPhCltDialer.h>
       
    32 #include <etelmm.h>
       
    33 // </cmail>
       
    34 #include <TPbkContactItemField.h>
       
    35 #include <hwrmdomainpskeys.h> // For flip change status.
       
    36 //<cmail>
       
    37 #include "mfsmailrequestobserver.h"
       
    38 #include "mfsmaileventobserver.h"
       
    39 #include "FreestyleEmailUiUtilities.h"
       
    40 //</cmail>
       
    41 #include <msvapi.h>
       
    42 #include <cstack.h>
       
    43 #include <iaupdateobserver.h>
       
    44 #include "cfsmailcommon.h"
       
    45 #include "cmailcustomstatuspaneindicators.h"
       
    46 
       
    47 // INTERNAL INCLUDES
       
    48 #include "cconnectionstatusqueryext.h"
       
    49 #include "FreestyleEmailUiPropertySubscriber.h"
       
    50 #include "FreestyleEmailUiConstants.h"
       
    51 
       
    52 // FORWARD DECLARATIONS
       
    53 class CFreestyleEmailUiView;
       
    54 class CFSEmailUiViewerControl;
       
    55 class CFSEmailUiLauncherGrid;
       
    56 class CFSEmailUiLauncherGridVisualiser;
       
    57 class CFSEmailUiGridMenuModel;
       
    58 class CFSEmailUiLayoutHandler;
       
    59 class CFSEmailUiViewSwitchTimer;
       
    60 class CFSEmailUiList;
       
    61 class CFSEmailUiMailListVisualiser;
       
    62 class CFSMailClient;
       
    63 class CFSMailMessage;
       
    64 class CFSMailFolder;
       
    65 class CFSMailBox;
       
    66 class CMailListUpdater;
       
    67 class CFSEmailUiEditor;
       
    68 class CAknInfoPopupNoteController;
       
    69 class CFSEmailUiSingleListModel;
       
    70 class CFSEmailUiSingleListVisualiser;
       
    71 class CFreestyleEmailUiTextureManager;
       
    72 class CFSEmailUiEditorVisualiser;
       
    73 class CFSEmailUiMsgDetailsVisualiser;
       
    74 class CFSEmailUiFolderListVisualiser;
       
    75 class CNcsComposeView;
       
    76 class CAknsLayeredBackgroundControlContext;
       
    77 class CAlfAnchorLayout;
       
    78 class CFsTreeList;
       
    79 class CFSEmailCRHandler;
       
    80 class CFSEmailUiAttachmentsListVisualiser;
       
    81 class CFreestyleEmailUiAttachmentsListControl;
       
    82 class MFSEmailUiFolderListCallback;
       
    83 class MFSEmailUiSortListCallback;
       
    84 class MFsControlButtonInterface;
       
    85 class CFSEmailUiSendAttachmentsListVisualiser;
       
    86 class TFSProgress;
       
    87 class CFSEmailUiDownloadManagerVisualiser;
       
    88 class CFreestyleEmailUiDownloadManagerControl;
       
    89 class CAlfLayout;
       
    90 class CFSEmailUiSearchListVisualiser;
       
    91 class CFSEmailUiStatusIndicator;
       
    92 class CFsEmailUiHtmlViewerView;
       
    93 class CAknWaitNoteWrapper;
       
    94 class CFSEmailUiActionMenu;
       
    95 class CFSEmailUiShortcutBinding;
       
    96 class CFSEmailUiWizardObserver;
       
    97 class CDocumentHandler;
       
    98 class CAknProgressDialog;
       
    99 class CEikProgressInfo;
       
   100 class CFsEmailUiViewBase;
       
   101 class CVPbkContactManager;
       
   102 class CESMRIcalViewer;
       
   103 class CFsEmailFileHandleShutter;
       
   104 class CFsLayoutManager;
       
   105 class CIAUpdate;
       
   106 class CIAUpdateParameters;
       
   107 class CFSEmailUiAutosyncMonitor;
       
   108 class CEUiExitGuardian;
       
   109 class CAknNavigationDecorator;
       
   110 class CFSEmailDownloadInfoMediator;
       
   111 class MAknNaviDecoratorObserver;
       
   112 class CCustomStatuspaneIndicators;
       
   113 
       
   114 /**
       
   115  * TDisplayImagesCache
       
   116  *
       
   117  * Non-persistant cache for display images per message. When user allows images to be downloaded
       
   118  * for a message, that message's id will be stored into the cache. Later if the message is re-opened
       
   119  * and it is found in cache, images are allowed to be downloaded no matter what the global setting
       
   120  * is. Message is added to cache only when the user presses the button, it will be removed from cache
       
   121  * if the mailbox or the message itself is deleted.
       
   122  */
       
   123 class TDisplayImagesCache
       
   124     {
       
   125 public:
       
   126 
       
   127     /**
       
   128      * Destructor
       
   129      */
       
   130     ~TDisplayImagesCache();
       
   131 
       
   132     /**
       
   133      * Add message to cache.
       
   134      */
       
   135     void AddMessageL( const CFSMailMessageBase& aMsg );
       
   136 
       
   137     /**
       
   138      * Remove message from cache.
       
   139      */
       
   140     void RemoveMessage( const CFSMailMessageBase& aMsg );
       
   141 
       
   142     /**
       
   143      * Check if the message is in cache. Returns ETrue if the message is found.
       
   144      */
       
   145     TBool Contains( const CFSMailMessageBase& aMsg ) const;
       
   146 
       
   147     /**
       
   148      * Removes message from cache.
       
   149      */
       
   150     void RemoveMessage( const TFSMailMsgId& aBoxId, const TFSMailMsgId& aMsgId );
       
   151 
       
   152     /**
       
   153      * Removes mailbox from cache.
       
   154      */
       
   155     void RemoveMailbox( const TFSMailMsgId& aBoxId );
       
   156 
       
   157 private: // internal methods
       
   158 
       
   159     /**
       
   160      * Adds message to cache.
       
   161      */
       
   162     void AddMessageL( const TFSMailMsgId& aBoxId, const TFSMailMsgId& aMsgId );
       
   163 
       
   164     /**
       
   165      * Check if the message is in cache. Returns ETrue if the message is found.
       
   166      */
       
   167     TBool Contains( const TFSMailMsgId& aBoxId, const TFSMailMsgId& aMsgId ) const;
       
   168 
       
   169     /**
       
   170      * Returns index for given mailbox in cache or KErrNotFound if the mailbox cannot
       
   171      * be found.
       
   172      */
       
   173     TInt MailBoxIndex( const TFSMailMsgId& aBoxId ) const;
       
   174 
       
   175     /**
       
   176      * Adds new mailbox and returns index in cache.
       
   177      */
       
   178     void AddMailBoxL( const TFSMailMsgId& aBoxId, TInt& aCacheIndex );
       
   179 
       
   180 private:
       
   181 
       
   182     /**
       
   183      * Cache item.
       
   184      */
       
   185     class TItem
       
   186         {
       
   187     public:
       
   188         /**
       
   189          * Constructor
       
   190          */
       
   191         TItem( const TFSMailMsgId& aBoxId );
       
   192 
       
   193         /**
       
   194          * Destructor
       
   195          */
       
   196         ~TItem();
       
   197 
       
   198         /**
       
   199          * Returns ETrue if given message Id is found in this box.
       
   200          */
       
   201         TBool Contains( const TFSMailMsgId& aMsgId ) const;
       
   202 
       
   203         /**
       
   204          * Adds new message Id into box.
       
   205          */
       
   206         void AddMessageL( const TFSMailMsgId& aMsgId );
       
   207 
       
   208         /**
       
   209          * Removes message from box.
       
   210          */
       
   211         void RemoveMessage( const TFSMailMsgId& aMsgId );
       
   212 
       
   213         /**
       
   214          * Comparator for TLinearOrder, compares two items
       
   215          */
       
   216         static TInt CompareItem( const TItem& aItem1, const TItem& aItem2 );
       
   217 
       
   218     private:
       
   219 
       
   220         /**
       
   221          * Comparator for TLinearOrder, compares two message Ids
       
   222          */
       
   223         static TInt CompareMsgId( const TFSMailMsgId& aId1, const TFSMailMsgId& aId2 );
       
   224 
       
   225         /**
       
   226          * Returns index of the message in box or KErrNotFound.
       
   227          */
       
   228         TInt MessageIndex( const TFSMailMsgId& aMsgId ) const;
       
   229 
       
   230     private:
       
   231 
       
   232         // Mailbox Id
       
   233         TFSMailMsgId iMailBoxId;
       
   234 
       
   235         // Message Ids
       
   236         RArray<TFSMailMsgId> iMessageIds;
       
   237         };
       
   238 
       
   239     // Cache
       
   240     RArray<TItem> iCache;
       
   241     };
       
   242 
       
   243 
       
   244 class CFreestyleEmailUiAppUi : public CAknViewAppUi,
       
   245     			               public MAlfActionObserver,
       
   246     			               public MFSMailRequestObserver,
       
   247     			               public MFSMailEventObserver,
       
   248     			               public MMsvSessionObserver,
       
   249     			               public MIAUpdateObserver,
       
   250     			               public MFSEmailUiGenericTimerCallback,
       
   251     			               public MFreestyleEmailUiPropertyChangedObserver
       
   252     {
       
   253 friend class CMailListUpdater;
       
   254 public:
       
   255 
       
   256     CFreestyleEmailUiAppUi( CAlfEnv& aEnv );
       
   257     void ConstructL();
       
   258     ~CFreestyleEmailUiAppUi();
       
   259 	CAlfDisplay& Display();
       
   260 	CAlfEnv& AlfEnv();
       
   261    // void HandleCommandL(TInt aCommand);
       
   262     void HandleActionL(const TAlfActionCommand& aActionCommand);
       
   263 	// <cmail>
       
   264     void ProcessCommandL( TInt aCommand );
       
   265 	// </cmail>
       
   266 	void HandleCommandL( TInt aCommand );
       
   267 
       
   268 	// View switching functions
       
   269 	void EnterFsEmailViewL( TUid aViewId );
       
   270 	void EnterFsEmailViewL( TUid aViewId, TUid aCustomMessageId, const TDesC8& aCustomMessage );
       
   271 	void EnterPluginSettingsViewL( TUid aViewId, TUid aCustomMessageId, const TDesC8& aCustomMessage );
       
   272 	void ReturnFromPluginSettingsView();
       
   273     void ViewActivatedExternallyL( TUid aViewId );
       
   274 
       
   275     void SetSwitchingToBackground( TBool aValue );
       
   276     TBool SwitchingToBackground() const;
       
   277 
       
   278 	/**
       
   279 	 * Tries to activate the local view where the current view was navigated from.
       
   280 	 * Activates the grid view if no other previous view available.
       
   281 	 * @return UID of the view to be activated
       
   282 	 */
       
   283 	TUid ReturnToPreviousViewL( const TDesC8& aCustomMessage = KNullDesC8 );
       
   284 
       
   285 	void ReturnFromHtmlViewerL( TBool aMessageWasDeleted = EFalse );
       
   286 
       
   287     // Clears the navigation history used with Back functionality.
       
   288     // Thus, next call to ReturnToPreviousViewL() will return to the main grid.
       
   289     void EraseViewHistory();
       
   290 
       
   291 	// Create new mail with compose command
       
   292 	void CreateNewMailL();
       
   293 
       
   294 	// Returns pointer to the current active view. Ownership not transferred.
       
   295 	CFsEmailUiViewBase* CurrentActiveView();
       
   296     // Returns pointer to the previous active view. Ownership not transferred.
       
   297     CFsEmailUiViewBase* PreviousActiveView();
       
   298     // Tells if plugin settings view is currently open
       
   299     TBool IsPluginSettingsViewActive();
       
   300 
       
   301 	// getter to generic components
       
   302 	CFSEmailUiLayoutHandler* LayoutHandler();
       
   303 	CFreestyleEmailUiTextureManager* FsTextureManager();
       
   304 //	CFSEmailUiStatusIndicator* StatusIndicator();
       
   305 
       
   306 	// Functions used by grid and viewer
       
   307 	TInt NewEmailsInModelL();
       
   308 	TInt EmailsInModelL();
       
   309 	TInt EmailIndexInModel();
       
   310 
       
   311     /**
       
   312     * LaunchEditorL
       
   313     * Launch editor with the given address in TO-field and focus in MSG-field
       
   314     * @param aToAddress The email address to put in TO-field on startup. Ownership
       
   315     * is not transferred.
       
   316     */
       
   317 	void LaunchEditorL( CFSMailAddress* aToAddress );
       
   318 
       
   319     /**
       
   320     * LaunchEditorL
       
   321     * Launch editor
       
   322     * @param aMode The mode in which the editor is started
       
   323     * @param aParams Editor launch parameters
       
   324     */
       
   325 	void LaunchEditorL( TEditorLaunchMode aMode, const TEditorLaunchParams& aParams );
       
   326 
       
   327 	CFSMailClient* GetMailClient();
       
   328 	CFSEmailCRHandler* GetCRHandler();
       
   329 
       
   330 	// Gets active mailbox pointer from the UI
       
   331 	// Ownership IS NOT transferred to the callers
       
   332 	CFSMailBox* GetActiveMailbox();
       
   333 
       
   334 	void SubscribeMailboxL( TFSMailMsgId aActiveMailboxId );
       
   335 	void SetActiveMailboxL( TFSMailMsgId aActiveMailboxId, TBool aAutoSync = ETrue );
       
   336 	void StartMonitoringL();
       
   337 	CMsvSession* GetMsvSession();
       
   338 
       
   339 	TFSMailMsgId GetActiveBoxInboxId();
       
   340 	TFSMailMsgId GetActiveMailboxId();
       
   341 
       
   342     /**
       
   343     * Show folder list or sort list as control bar popup list.
       
   344     *
       
   345     * @param aCurrentSortCriteria Current sort criteria in mail list
       
   346     * @param aFolderId/Type Folder id/type of the currently active mail folder
       
   347     * @param aCallback Callback pointer to use when reporting user selection
       
   348     * @param aButton Selected control bar button, used when positioning the list
       
   349     */
       
   350 	void ShowFolderListInPopupL( const TFSMailMsgId aFolderType,
       
   351                                  MFSEmailUiFolderListCallback* aCallback,
       
   352 								 MFsControlButtonInterface* aButton );
       
   353 	void ShowSortListInPopupL( const TFSMailSortCriteria aCurrentSortCriteria,
       
   354 	                           const TFSFolderType aFolderType,
       
   355 							   MFSEmailUiSortListCallback* aCallback,
       
   356 							   MFsControlButtonInterface* aButton );
       
   357 	void FolderPopupClosed();
       
   358 
       
   359 	// Transition effects for Alf layouts, call these in doactivate and dodeactivate.
       
   360 	TBool ViewSwitchingOngoing();
       
   361 
       
   362 	// Force Sync on active mailbox.
       
   363 	void SyncActiveMailBoxL();
       
   364 
       
   365 	// Stop mailbox sync
       
   366 	void StopActiveMailBoxSyncL();
       
   367 
       
   368 	// From sync observer
       
   369 	void RequestResponseL( TFSProgress aEvent, TInt aRequestId );
       
   370 
       
   371     /**
       
   372      * Helper method to be called from Settings. Launches mailbox setup wizard.
       
   373      */
       
   374      void LaunchWizardL();
       
   375 
       
   376     // Overriden exit
       
   377     void Exit();
       
   378 
       
   379     void ExitNow();
       
   380 
       
   381     const CFSEmailUiShortcutBinding& ShortcutBinding() const;
       
   382 
       
   383     // Navigation functions, used mainly from viewer
       
   384     TBool IsNextMsgAvailable( TFSMailMsgId aCurrentMsgId, TFSMailMsgId& aFoundNextMsgId, TFSMailMsgId& aFoundNextMsgFolder );
       
   385     TBool IsPreviousMsgAvailable( TFSMailMsgId aCurrentMsgId, TFSMailMsgId& aFoundPreviousMsgId, TFSMailMsgId& aFoundPrevMsgFolder );
       
   386     TInt MoveToNextMsgL( TFSMailMsgId aCurrentMsgId, TFSMailMsgId& aFoundNextMsgId );
       
   387     TInt MoveToPreviousMsgL( TFSMailMsgId aCurrentMsgId, TFSMailMsgId& aFoundPreviousMsgId );
       
   388     TInt MoveToPreviousMsgAfterDeleteL( TFSMailMsgId aFoundPreviousMsgId );
       
   389 
       
   390     /** Returns document handler. */
       
   391     CDocumentHandler& DocumentHandler();
       
   392 
       
   393     /**
       
   394      * Returns reference file handle shutter. The shutter is set to observe
       
   395      * embedded application exit events delegated by the appui's document
       
   396      * handler and it closes the set file handle on exit event. */
       
   397     CFsEmailFileHandleShutter& FileHandleShutter();
       
   398 
       
   399     // Returns unmodifiable reference to the current title pane text
       
   400     const TDesC& TitlePaneTextL();
       
   401     // Sets given text to title pane
       
   402     void SetTitlePaneTextL( const TDesC& aText );
       
   403     // Resets title pane text to its default value
       
   404     void ResetTitlePaneTextL();
       
   405     // Sets active mailbox name to title pane
       
   406     void SetActiveMailboxNameToStatusPaneL();
       
   407 
       
   408     // Set connection status icon of title pane to visible
       
   409     void ShowTitlePaneConnectionStatus();
       
   410     // Set connection status icon of title pane to hided
       
   411     void HideTitlePaneConnectionStatus();
       
   412     void GetConnectionStatusL( CConnectionStatusQueryExtension::TConnectionStatus& aConnStatus );
       
   413     // Draw connection status icon into title pane if set as visible.
       
   414     // It is also possible to force connection indicator to wanted value
       
   415     // to achieve better user experience.
       
   416     void UpdateTitlePaneConnectionStatus( TForcedStatus aForcedStatus = ENoForce );
       
   417     // Return pointer to custom status pane indicators object
       
   418     // Which can be used to show priority and followup flags
       
   419     // on navi pane area. (Real navipane is not used)
       
   420     CCustomStatuspaneIndicators* GetStatusPaneIndicatorContainer();
       
   421 
       
   422     // Getter for appui owned virtual phonebook manager
       
   423     CVPbkContactManager& GetVPbkManagerL();
       
   424 
       
   425     // MessageReader implementation
       
   426     void StartReadingEmailsL();
       
   427     TBool MessageReaderSupportsFreestyle();
       
   428 
       
   429     static TBool AppUiExitOngoing();
       
   430 
       
   431     // Meeting request viewer instance, owned by the appui
       
   432     CESMRIcalViewer* MrViewerInstanceL();
       
   433 
       
   434     // Get Mail viewer instance, owned by the AppUi
       
   435     CFsEmailUiHtmlViewerView& MailViewer();
       
   436 
       
   437     // Get Folder list instance, owned by the AppUi
       
   438     CFSEmailUiFolderListVisualiser& FolderList();
       
   439 
       
   440     // Get Launcher grid instance, owned by the AppUi
       
   441     CFSEmailUiLauncherGridVisualiser& LauncherGrid();
       
   442 
       
   443     // View loading in idle
       
   444     TInt ViewLoadIdleCallbackFunctionL();
       
   445 
       
   446     /**
       
   447      * Sets the manual mailbox connection flag if the
       
   448      * user chose to connect mail boxes from the menu
       
   449      */
       
   450     void ManualMailBoxConnectAll( TBool aManualMailBoxConnectAll );
       
   451     void ManualMailBoxDisconnectAll( TBool aManualMailBoxConnectAll );
       
   452 
       
   453 	// For showing mailbox query
       
   454 	void GridStarted( TBool aStartedFromOds );
       
   455     void ShowMailboxQueryL();
       
   456 
       
   457     void DoAutoConnectL();
       
   458 
       
   459     CFSEmailDownloadInfoMediator* DownloadInfoMediator();
       
   460 
       
   461     // <cmail>
       
   462     TDisplayMode DisplayMode() const;
       
   463     // </cmail>
       
   464 
       
   465 
       
   466 
       
   467 
       
   468 	/**
       
   469      * Returns the current flip status.
       
   470      * @return True if the flip is open, false otherwise.
       
   471      */
       
   472     TBool IsFlipOpen() const;
       
   473 
       
   474     TDisplayImagesCache& DisplayImagesCache();
       
   475 
       
   476     // Set flag for judging if there is a embedded app in FSEmail.
       
   477     void SetEmbeddedApp( TBool aEmbeddedApp );
       
   478 
       
   479     // Return embedded app.
       
   480     TBool EmbeddedApp() const;
       
   481 
       
   482     // Set flag for judging if previous app is embedded.
       
   483     void SetEmbeddedAppToPreviousApp( TBool aEmbeddedApp );
       
   484 
       
   485     // if previous app is embedded.
       
   486     TBool EmbeddedAppIsPreviousApp() const;
       
   487 
       
   488     // Set flag for judging if email editor started from embedded app.
       
   489     void SetEditorStartedFromEmbeddedApp( TBool aEmbeddedApp );
       
   490 
       
   491     // if email editor started from embedded app.
       
   492     TBool EditorStartedFromEmbeddedApp() const;
       
   493 
       
   494     // returns last seen pointer position
       
   495     const TPoint& LastSeenPointerPosition() const;
       
   496     
       
   497     // returns last seen ws event type
       
   498     TInt LastSeenWsEventType();
       
   499 
       
   500     // Runs fake sync animation (needed for better user experience as
       
   501     // otherwise in some connection/sync states pressing "send & receive"
       
   502     // wouldn't have any visible effect.
       
   503     void RunFakeSyncAnimL();
       
   504 
       
   505 public: //from MFSMailEventObserver
       
   506     /**
       
   507      * Framework event message.
       
   508      * Used here to catch the events thrown from new mailbox creation process.
       
   509      *
       
   510      * @param aEvent One of pre-defined events in TFSMailEvent
       
   511      * @param aMailbox maibox related for this event
       
   512      * @param aParam1 intepretation is event specific (see TFSMailEvent descriptions)
       
   513      * @param aParam2 intepretation is event specific (see TFSMailEvent descriptions)
       
   514      * @param aParam3 intepretation is event specific (see TFSMailEvent descriptions)
       
   515      */
       
   516     void EventL( TFSMailEvent aEvent, TFSMailMsgId aMailbox,
       
   517                  TAny* aParam1, TAny* aParam2, TAny* aParam3);
       
   518 
       
   519 public:
       
   520 	void HandleSessionEventL( TMsvSessionEvent aEvent, TAny* aArg1, TAny* aArg2, TAny* aArg3 );
       
   521 
       
   522 public: // MIAUpdateObserver
       
   523     virtual void CheckUpdatesComplete( TInt aErrorCode, TInt aAvailableUpdates );
       
   524     virtual void UpdateQueryComplete( TInt aErrorCode, TBool aUpdateNow );
       
   525     virtual void UpdateComplete( TInt aErrorCode, CIAUpdateResult* aResultDetails );
       
   526 
       
   527 public:
       
   528 
       
   529     /**
       
   530     * StartEndKeyCapture
       
   531     * Start key capture for end-key
       
   532     */
       
   533     void StartEndKeyCapture();
       
   534 
       
   535     /**
       
   536     * StopEndKeyCapture
       
   537     * Stop key capture for end-key
       
   538     */
       
   539     void StopEndKeyCapture();
       
   540 
       
   541     /**
       
   542      * Accessor for navipane decorator object.
       
   543      * @param aViewId: Caller identify itself by giving the view Id (see FreestyleEmailUiConstants.h)
       
   544      * This is used for choosing correct decorator.
       
   545      * @return instance of correct navidecorator. NULL if aView doesn't match.
       
   546      */
       
   547     CAknNavigationDecorator* NaviDecoratorL( const TUid aViewId );
       
   548 
       
   549 public:
       
   550 
       
   551     /**
       
   552      * From MFSEmailUiGenericTimerCallback.
       
   553      * Generic timer event callback.
       
   554      */
       
   555     virtual void TimerEventL( CFSEmailUiGenericTimer* aTriggeredTimer );
       
   556 
       
   557     /**
       
   558     * Sets visibility for focus.
       
   559     *
       
   560     * @param aVisible EFalse if focus should be hidden.
       
   561     * @return whether or not focus was already visible.
       
   562     */
       
   563     TBool SetFocusVisibility( TBool aVisible );
       
   564 
       
   565     /**
       
   566     * IsFocusShown
       
   567     * Used for finding out if focus is visible.
       
   568     * @return whether or not the focus is visible.
       
   569     */
       
   570     TBool IsFocusShown() const;
       
   571 
       
   572 
       
   573 public: // From MFreestyleEmailUiPropertyChangedObserver.
       
   574 
       
   575 	void PropertyChangedL( TInt aValue );
       
   576 
       
   577 
       
   578 protected:
       
   579 	TKeyResponse HandleKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType );
       
   580     void HandleResourceChangeL(TInt aType);
       
   581 	void HandleWsEventL(const TWsEvent &aEvent,
       
   582  	                    CCoeControl *aDestination);
       
   583 
       
   584  	void HandleForegroundEventL( TBool aForeground );
       
   585     MCoeMessageObserver::TMessageResponse HandleMessageL( TUint32 aClientHandleOfTargetWindowGroup,
       
   586                                                           TUid aMessageUid,
       
   587                                                           const TDesC8& aMessageParameters );
       
   588 
       
   589 private:
       
   590     void DoHandleResourceChangeL(TInt aType);
       
   591 	void UpdateSettingsListModelL();
       
   592 	CAlfTexture& LoadItemIconL( TInt aUid );
       
   593     void ProvideBitmapL(TInt aId, CFbsBitmap*& aBitmap,
       
   594                                   CFbsBitmap*& aMaskBitmap);
       
   595 
       
   596     /**
       
   597      * Helper method for launching a setup wizard, or handling data received from one.
       
   598      */
       
   599     void DoWizardStartupActionsL();
       
   600 
       
   601     TBool IsViewInHistoryStack( TUid aViewId ) const;
       
   602 
       
   603     void ReturnToViewL( TUid aViewId, TUid aCustomMessageId = TUid::Null(), const TDesC8& aCustomMessage = KNullDesC8 );
       
   604 
       
   605     // Checks updates from IAD client
       
   606     void CheckUpdatesL();
       
   607     void AllUpdateActivitiesCompleted();
       
   608 
       
   609 	// This async callback functionality is needed because UI and app construction
       
   610 	// cannot jam while the new mailbox query has been displayed
       
   611    	static TInt DisplayCreateQueryL( TAny* aSelfPtr );
       
   612    	void DisplayCreateMailboxQueryL();
       
   613 
       
   614    	// Send self to background.
       
   615    	void SendToBackground();
       
   616 
       
   617    	/*
       
   618    	 * Called from ConstructL during start of application.
       
   619    	 * Constructs navipane(s) that are used by different views.
       
   620    	 */
       
   621    	void ConstructNaviPaneL();
       
   622 
       
   623     // Create custom status pane indicators. (priority and followup)
       
   624     void CreateStatusPaneIndicatorsL();
       
   625     // Delete custom status pane indicators
       
   626     void DeleteStatusPaneIndicators();
       
   627 
       
   628     // Load specified resource file, file name may (and should) contain wild
       
   629     // cards. aFilePath should contain drive letter if some specific drive
       
   630     // is wanted to be searched first. Returns the resource file offset of the
       
   631     // found file. Leaves if resource file not found.
       
   632     TInt LoadResourceFileL( const TDesC& aFileName,
       
   633                             const TDesC& aFilePath );
       
   634 
       
   635 private:
       
   636 	// ALF environment NOTE: Display removed from Alfred version
       
   637     CAlfEnv* iEnv;
       
   638 
       
   639     // Pointers to current and previous active views
       
   640     CFsEmailUiViewBase* iCurrentActiveView; // not owned
       
   641     CFsEmailUiViewBase* iPreviousActiveView; // not owned
       
   642     CStack<CFsEmailUiViewBase, EFalse>* iNavigationHistory; // items not owned
       
   643 
       
   644  	CFSEmailDownloadInfoMediator* iDwnldMediator;
       
   645 
       
   646      // Pointers to actual display control groups containing UI elements
       
   647     CAlfControlGroup* iGridControlGroup;
       
   648   	CAlfControlGroup* iMailListControlGroup;
       
   649     CAlfControlGroup* iEmailViewerControlGroup;
       
   650   	CAlfControlGroup* iFolderListControlGroup;
       
   651   	CAlfControlGroup* iSettingsListControlGroup;
       
   652    	CAlfControlGroup* iSendingAnimationControlGroup;
       
   653   	CAlfControlGroup* iMsgDetailsControlGroup;
       
   654   	CAlfControlGroup* iAttachmentControlGroup;
       
   655   	CAlfControlGroup* iComposerControlGroup;
       
   656   	CAlfControlGroup* iDownloadManagerControlGroup;
       
   657   	CAlfControlGroup* iSearchResultControlGroup;
       
   658   	CAlfControlGroup* iStatusIndicatorControlGroup;
       
   659   	CAlfControlGroup* iHtmlViewerControlGroup;
       
   660 
       
   661  	// FS Email UI specific layout handler object
       
   662     CFSEmailUiLayoutHandler* iLayoutHandler;
       
   663 
       
   664 	// FS specific layout
       
   665         //<cmail> layout manager doesn't exists in cmail
       
   666 	//CFsLayoutManager* iLayoutManager;
       
   667         //</cmail>
       
   668 
       
   669 	// FS Email UI specific texture mngr object
       
   670  	CFreestyleEmailUiTextureManager* iFsTextureManager;
       
   671 
       
   672 	// Main UI grid control and view
       
   673   	CFSEmailUiLauncherGrid* iMainUiGrid;
       
   674     CFSEmailUiLauncherGridVisualiser* iMainUiGridVisualiser;
       
   675 
       
   676 	// Mail view
       
   677 	CFSEmailUiMailListVisualiser* iMailListVisualiser;
       
   678 
       
   679 	// Message editor view
       
   680 	CNcsComposeView* iComposeView;
       
   681 
       
   682 	// Html viewer view
       
   683 	CFsEmailUiHtmlViewerView* iHtmlViewerView;
       
   684 	TUid iHtmlViewerViewId;  
       
   685 
       
   686 	// Message details view
       
   687 	CFSEmailUiMsgDetailsVisualiser* iMsgDetailsVisualiser;
       
   688 
       
   689 	// Folder list view
       
   690 	CFSEmailUiFolderListVisualiser* iFolderListVisualiser;
       
   691 
       
   692 	// Attachment list
       
   693 	CFSEmailUiAttachmentsListVisualiser* iAttachmentListVisualiser;
       
   694 	CFreestyleEmailUiAttachmentsListControl* iAttachmentHanlerControl;
       
   695 
       
   696     // Download manager removed.
       
   697 
       
   698 	// Search result list view
       
   699 	CFSEmailUiSearchListVisualiser* iSearchListVisualiser;
       
   700 
       
   701 	// Status indicator
       
   702 	CFSEmailUiStatusIndicator* iStatusIndicator;
       
   703 
       
   704     // Mailclient, list of mailboxes, active mailbox and
       
   705     // latest opened folder
       
   706     CFSMailClient* iMailClient;
       
   707 
       
   708  	// Active mailbox, pointer owned by the APP UI!
       
   709  	CFSMailBox* iActiveMailbox;
       
   710 
       
   711 	TFSMailMsgId iActiveBoxInboxId;
       
   712 	TFSMailMsgId iActiveMailboxId;
       
   713 
       
   714 	// Mail sending progress dialog
       
   715 	CAknProgressDialog* iSendingProgressDialog;
       
   716 	CEikProgressInfo* iSendingProgressInfo;
       
   717 
       
   718 	// Phonebook engine and resource handle
       
   719 	TInt iPhCltResHandle;
       
   720 
       
   721 	// Central repository handler
       
   722 	CFSEmailCRHandler*	iCRHandler;
       
   723 
       
   724 	// End key capture handles
       
   725 	TInt32 iEndCaptureHandle;
       
   726 	TInt32 iEndUpDownCaptureHandle;
       
   727 
       
   728     CMsvSession* iMsvSession;
       
   729 
       
   730     CFSEmailUiActionMenu* iActionMenuHandler;
       
   731 
       
   732 	RArray<TFSMailMsgId> iSubscribedMailBoxes;
       
   733 	RArray<TUint> iSubscribedMailBoxesIds;
       
   734 
       
   735 
       
   736 	// Helper class for keyboard shortcut handling
       
   737 	CFSEmailUiShortcutBinding* iShortcutBinder;
       
   738 
       
   739 	CFSEmailUiWizardObserver* iWizardObserver;
       
   740 
       
   741     CDocumentHandler* iDocumentHandler;
       
   742     CFsEmailFileHandleShutter* iFileHandleShutter;
       
   743 
       
   744 	TBool iConstructComplete;
       
   745 
       
   746 	TInt iSyncStatusReqId;
       
   747 
       
   748 	TBool iIsForeground;
       
   749 
       
   750   	CIdle* iViewLoadIdle;
       
   751 	TCallBack* iViewLoadIdleCallback;
       
   752 	TBool iIsCaptured;
       
   753 
       
   754     CVPbkContactManager* iVpkContactManager;
       
   755 
       
   756     //This is used to pass needed information to messagereader
       
   757 	HBufC8* iCustomMessageToMessageReader;
       
   758 
       
   759 	// Meeting request viewer instance
       
   760   	CESMRIcalViewer* iMRViewer;
       
   761 
       
   762   	// Flag to be used to disable online/offline note in automated
       
   763   	// Mailbob online
       
   764   	TBool iAutomatedMailBoxOnline;
       
   765 
       
   766 	// Value indicating that msg reader is supported, KErrNone if supported.
       
   767   	TInt iMsgReaderIsSupported;
       
   768   	// For IAD
       
   769     CIAUpdate* iUpdateClient;
       
   770     CIAUpdateParameters* iUpdateParameters;
       
   771 
       
   772     // For feature manager
       
   773     TBool iFeatureManagerInitialized;
       
   774 
       
   775     // ETrue if user started the connect all
       
   776     TBool iManualMailBoxConnectAll;
       
   777     TBool iManualMailBoxDisconnectAll;
       
   778 
       
   779     // ETrue if the screen layout has chaged while the application was on background
       
   780     TBool iPendingLayoutSwitch;
       
   781 
       
   782     // Startup mailbox creation query flag.
       
   783     TBool iStartupQueryShown;
       
   784     TBool iGridStarted;
       
   785     TBool iGridFirstStartFromOds;
       
   786     TBool iSettingsViewActive;
       
   787     TBool iIADUpdateCompleted;
       
   788 
       
   789     CFSEmailUiAutosyncMonitor* iAutoSyncMonitor;
       
   790 
       
   791     // Async callback for create mailbox query
       
   792     // This is needed because query can not stop execution of UI construction
       
   793     CAsyncCallBack* iNewBoxQueryAsyncCallback;
       
   794 
       
   795     // Exit guardian.
       
   796     CEUiExitGuardian* iExitGuardian;
       
   797 
       
   798     // navipane decorator
       
   799     // (used at least in mail viewer)
       
   800     CAknNavigationDecorator* iNaviDecorator2MailViewer;
       
   801 
       
   802     // Resource file offset for message editor external resources
       
   803     TInt iMsgEditorResourceOffset;
       
   804 
       
   805     // Resource file offset for FSMailServer external resources
       
   806     TInt iFSMailServerResourceOffset;
       
   807 
       
   808     // Custom status pane indicators
       
   809     CCustomStatuspaneIndicators* iStatusPaneIndicators;
       
   810     TBool iConnectionStatusVisible;
       
   811     CFSEmailUiGenericTimer* iConnectionStatusIconAnimTimer;
       
   812     CFSEmailUiGenericTimer* iFakeSyncAnimStopTimer;
       
   813     CFbsBitmap* iConnectionIconBitmap;
       
   814     CFbsBitmap* iConnectionIconMask;
       
   815     TInt iConnectionStatusIconAngle;
       
   816     TForcedStatus iForcedConnectionStatus;
       
   817 
       
   818     // Set true, when application is going to be switched to backgound
       
   819     // after the view deactivation.
       
   820     TBool iSwitchingToBackground;
       
   821 
       
   822     TDisplayImagesCache iDisplayImagesCache;
       
   823 
       
   824     // For handling the flip state.
       
   825     CFreestyleEmailUiPropertySubscriber* iPropertySubscriber;
       
   826     TBool iFlipOpen;
       
   827 
       
   828     /// Focus visibility state
       
   829     TBool iFocusVisible;
       
   830     TBool iTouchFeedbackCreated;
       
   831 
       
   832     // Embedded app flag.
       
   833     TBool iHasEmbeddedApp;
       
   834 
       
   835     // Flag for judging if previous app is embedded app.
       
   836     TBool iPreviousAppEmbedded;
       
   837 
       
   838     // Flag for judging if email editor started from embedded app.
       
   839     TBool iEditorStartedFromEmbeddedApp;
       
   840 
       
   841     TPoint iLastPointerPosition;
       
   842     TInt iLastWsEventType; // EEventPointer or EEventKey    
       
   843     };
       
   844 
       
   845 
       
   846 /**
       
   847 *  CFSEmailUiAutosyncMonitor.
       
   848 * Needed for auto sync feature, not wanted when roaming.
       
   849 */
       
   850 class CFSEmailUiAutosyncMonitor : public CActive
       
   851     {
       
   852     public:
       
   853         enum TNetworkStatus
       
   854             {
       
   855             EStatusUnknown = 0,
       
   856             EHomenetwork,
       
   857             ERoaming,
       
   858             ERequestCancelled
       
   859             };
       
   860 
       
   861         enum TMonitoringStatus
       
   862             {
       
   863             EInactive = 0,
       
   864             ERequestingNetworkStatus,
       
   865             EDone
       
   866             };
       
   867 
       
   868         static CFSEmailUiAutosyncMonitor* NewL( CFreestyleEmailUiAppUi& aAppUi );
       
   869         ~CFSEmailUiAutosyncMonitor();
       
   870 
       
   871     public:
       
   872         void StartMonitoring( );
       
   873         void StopMonitoring( );
       
   874 
       
   875     private:
       
   876         void RunL();
       
   877         void DoCancel();
       
   878         TInt RunError( TInt aError );
       
   879 
       
   880     private:
       
   881         CFSEmailUiAutosyncMonitor( CFreestyleEmailUiAppUi& aAppUi );
       
   882         void ConstructL();
       
   883 
       
   884     private:
       
   885         TMonitoringStatus iMonitoringStatus;
       
   886         CFreestyleEmailUiAppUi& iAppUi;
       
   887         RTelServer iServer;
       
   888         RMobilePhone iPhone;
       
   889         RMobilePhone::TMobilePhoneRegistrationStatus iRegisterationStatus;
       
   890         RTelServer::TPhoneInfo iPhoneInfo;
       
   891     };
       
   892 
       
   893 
       
   894 
       
   895 #endif // __FREESTYLEEMAILUI_APPUI_H__
       
   896