emailuis/emailui/inc/FreestyleEmailUiMailListVisualiser.h
branchRCL_3
changeset 25 3533d4323edc
child 26 968773a0b6ef
equal deleted inserted replaced
24:d189ee25cf9d 25: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:  FreestyleEmailUi double line list visualiser definition
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef __FREESTYLEEMAILUI_MAILLISTVISUALISER_H__
       
    21 #define __FREESTYLEEMAILUI_MAILLISTVISUALISER_H__
       
    22 
       
    23 // SYSTEM INCLUDES
       
    24 #include <eikmobs.h>
       
    25 //<cmail>
       
    26 #include "fscontrolbarobserver.h"
       
    27 #include "fstreelistobserver.h"
       
    28 #include "cfsmailcommon.h"
       
    29 #include "mfsmaileventobserver.h"
       
    30 #include "fsccontactactionmenudefines.h"
       
    31 //</cmail>
       
    32 #include "FSEmailBuildFlags.h"
       
    33 
       
    34 #include <touchfeedback.h>
       
    35 #include <touchlogicalfeedback.h>
       
    36 
       
    37 // INTERNAL INCLUDES
       
    38 #include "FreestyleEmailUiViewBase.h"
       
    39 #include "FreestyleEmailUiListVisualiser.h"
       
    40 #include "FreestyleEmailUiConstants.h"
       
    41 #include "FreestyleEmailUiControlBarCallback.h"
       
    42 #include "FreestyleEmailUiUtilities.h"
       
    43 #include "FreestyleEmailUiContactHandlerObserver.h"
       
    44 #include "cmailboxstateext.h"
       
    45 
       
    46 // FORWARD DECLARATIONS
       
    47 class CAlfTextVisual;
       
    48 class CAlfGridLayout;
       
    49 class CFSEmailUiList;
       
    50 class CAlfImageVisual;
       
    51 class CAlfDeckLayout;
       
    52 class CAlfAnchorLayout;
       
    53 class CFSEmailUiMailListModelItem;
       
    54 class CFSEmailUiMailListModel;
       
    55 class CListModeChanger;
       
    56 class CFreestyleEmailUiTextureManager;
       
    57 class CFSMailFolder;
       
    58 class CFSMailClient;
       
    59 class CFSMailAddress;
       
    60 class CFsTreeList;
       
    61 class CFsTreeVisualizerBase;
       
    62 class MFsTreeItemData;
       
    63 class MFsTreeItemVisualizer;
       
    64 class CFreestyleEmailUiTextureManager;
       
    65 class CFreestyleEmailUiMailListControl;
       
    66 class CFreestyleEmailUiAppUi;
       
    67 class CFsControlBar;
       
    68 class CFSMailMessage;
       
    69 class CFsMailFolder;
       
    70 class CFsTreePlainOneLineNodeData;
       
    71 class CFsTreePlainOneLineNodeVisualizer;
       
    72 class MFsControlButtonInterface;
       
    73 class CPbkxContactActionMenu;
       
    74 class CMailListUpdater;
       
    75 class CMsgMovedNoteTimer;
       
    76 class CIdle;
       
    77 class CESMRIcalViewer;
       
    78 class CAknWaitDialog;
       
    79 class CDateChangeTimer;
       
    80 class CFsTreePlainTwoLineItemData;
       
    81 class CFsTreePlainTwoLineItemVisualizer;
       
    82 class CEUiEmailListTouchManager;
       
    83 class MFSMailIterator;
       
    84 class CAknStylusPopUpMenu;
       
    85 class CFSEmailUiGenericTimer;
       
    86 template <class T> struct TDeleteTask;
       
    87 
       
    88 /**
       
    89  * CMailListModelUpdater
       
    90  *
       
    91  * Asynchronous mail list updater.
       
    92  *
       
    93  */
       
    94 class CMailListModelUpdater : public CActive
       
    95     {
       
    96 private:
       
    97 
       
    98     // Updater state
       
    99     enum TState
       
   100         {
       
   101         // Idle state. Updater is doing nothing.
       
   102         EIdle,
       
   103         // Initializing state. Get ready for the update.
       
   104         EInitialize,
       
   105         // Fetching state. Fetch the messages for the model.
       
   106         EFetch,
       
   107         // Finalizing state. Model update done.
       
   108         EFinalize
       
   109         };
       
   110 
       
   111 public:
       
   112 
       
   113     // Updater observer
       
   114     class MObserver
       
   115         {
       
   116     public:
       
   117         /**
       
   118          * Called when an error has occured.
       
   119          */
       
   120         virtual void UpdateErrorL(TInt aError) = 0;
       
   121 
       
   122         /**
       
   123          * Called when update begins.
       
   124          */
       
   125         virtual void UpdateBeginL() = 0;
       
   126 
       
   127         /**
       
   128          * Called when new messages fetched.
       
   129          */
       
   130         virtual void UpdateProgressL(TFsTreeItemId& aParentId, RPointerArray<CFSMailMessage>& aMessages) = 0;
       
   131 
       
   132         /**
       
   133          * Called when update is completed.
       
   134          */
       
   135         virtual void UpdateCompleteL() = 0;
       
   136 
       
   137         /**
       
   138          * Update cancelled.
       
   139          * @param aForceRefresh If ETrue, model will be fully refreshed on next activation.
       
   140          */
       
   141         virtual void UpdateCancelled(const TBool aForceRefresh) = 0;
       
   142         };
       
   143 
       
   144 public:
       
   145     /**
       
   146      * 
       
   147      */
       
   148     static CMailListModelUpdater* NewL();
       
   149 
       
   150     /**
       
   151      * Constructor
       
   152      */
       
   153     CMailListModelUpdater();
       
   154 
       
   155     /**
       
   156      * Destructor
       
   157      */
       
   158     ~CMailListModelUpdater();
       
   159 
       
   160 public:
       
   161 
       
   162     /**
       
   163      * Reference to sorting criteria array.
       
   164      */
       
   165     RArray<TFSMailSortCriteria>& Sorting();
       
   166 
       
   167     /**
       
   168      * Update model.
       
   169      */
       
   170     void UpdateModelL(MObserver& aObserver, MFSMailIterator* aIterator, TInt aBlockSize);
       
   171 
       
   172     /**
       
   173      * Returns ETrue if updating.
       
   174      */
       
   175     TBool IsUpdating() const;
       
   176 
       
   177 public: // from CActive
       
   178 
       
   179     /**
       
   180      * @see CActive::RunL
       
   181      */
       
   182     void RunL();
       
   183 
       
   184     /**
       
   185      * @see CActive::DoCancel
       
   186      */
       
   187     void DoCancel();
       
   188     /**
       
   189      * @see CActive::RunError
       
   190      */
       
   191     TInt RunError(TInt aError);
       
   192 
       
   193 private:
       
   194 
       
   195     /**
       
   196      * Signal self with given error code and set a new state.
       
   197      */
       
   198     void Signal(TState aState, TInt aError = KErrNone);
       
   199 
       
   200     /**
       
   201      * Initialize update.
       
   202      */
       
   203     void InitializeL();
       
   204 
       
   205     /**
       
   206      * Fetch one step.
       
   207      */
       
   208     void FetchL();
       
   209 
       
   210     /**
       
   211      * Finalize update.
       
   212      */
       
   213     void FinalizeL();
       
   214 
       
   215     /**
       
   216      * Reset to uninitialized state.
       
   217      */
       
   218     void Reset();
       
   219 private:
       
   220     void ConstructL();
       
   221 
       
   222 private:
       
   223 
       
   224     RArray<TFSMailSortCriteria> iSorting;
       
   225     TFSMailMsgId iId;
       
   226     TState iState;
       
   227     TInt iItemsFetched;
       
   228     MObserver* iObserver;
       
   229     MFSMailIterator* iIterator;
       
   230     TFsTreeItemId iParentId;
       
   231     TInt iBlockSize;
       
   232     RTimer iTimer;
       
   233     };
       
   234 
       
   235 struct SMailListItem
       
   236 	{
       
   237 	TFsTreeItemId iListItemId;
       
   238 	MFsTreeItemData* iTreeItemData;
       
   239 	MFsTreeItemVisualizer* iTreeItemVisualiser;
       
   240 	};
       
   241 
       
   242 struct STimeDateFormats
       
   243 	{
       
   244 	TDateFormat iDateFormat;
       
   245 	TChar iDateSeparator;
       
   246 	TTimeFormat iTimeFormat;
       
   247 	TChar iTimeSeparator;
       
   248 	TLocalePos iAmPmPosition;
       
   249 	};
       
   250 
       
   251 enum TMailListUiControls
       
   252 	{
       
   253 	EControlBarComponent=0,
       
   254 	EMailListComponent
       
   255 	};
       
   256 
       
   257 enum TListControlType
       
   258 	{
       
   259 	EListControlTypeSingleLinePreviewOff=0,
       
   260 	EListControlTypeSingleLinePreviewOn,
       
   261 	EListControlTypeDoubleLinePreviewOff,
       
   262 	EListControlTypeDoubleLinePreviewOn
       
   263 	};
       
   264 
       
   265 enum TListControlSeparatorValue
       
   266 	{
       
   267 	EListControlSeparatorDisabled=0,
       
   268 	EListControlSeparatorEnabled
       
   269 	};
       
   270 
       
   271 // <cmail>
       
   272 class CFSEmailUiMailListVisualiser : public CFsEmailUiViewBase,
       
   273 									 public MFsControlBarObserver,
       
   274 									 public MFSEmailUiFolderListCallback,
       
   275 									 public MFSEmailUiSortListCallback,
       
   276 									 public MFsTreeListObserver,
       
   277 									 public MFSEmailUiContactHandlerObserver,
       
   278 									 public CMailListModelUpdater::MObserver,
       
   279                                      public MEmailMailboxState,
       
   280                                      public MFSEmailUiGenericTimerCallback
       
   281 // </cmail>
       
   282 	{
       
   283 friend class CMailListUpdater;
       
   284 private:
       
   285 
       
   286 	    // Refresh state
       
   287 	    enum TRefreshState
       
   288 	        {
       
   289             ERefreshNone,
       
   290 	        // Full refresh needed. Update model and redraw entire list.
       
   291 	        EFullRefreshNeeded,
       
   292 	        // Partial refresh needed.
       
   293 	        EPartialRefreshNeeded,
       
   294 	        // Focus to the beginning.
       
   295 	        EFocusChangeNeeded
       
   296 	        };
       
   297 	    
       
   298 	    // states for sorting timer
       
   299 	    enum TSortState
       
   300 	    	{
       
   301 	    	ESortNone,
       
   302 	    	ESortRequested,
       
   303 	    	ESortStarted,
       
   304 	    	ESortPostponed,
       
   305 	    	ESortCompleted,
       
   306 	    	ESortStartError
       
   307 	    	};
       
   308 public:
       
   309 	static CFSEmailUiMailListVisualiser* NewL(CAlfEnv& aEnv, CFreestyleEmailUiAppUi* aAppUi, CAlfControlGroup& aMailListControlGroup);
       
   310 	static CFSEmailUiMailListVisualiser* NewLC(CAlfEnv& aEnv, CFreestyleEmailUiAppUi* aAppUi, CAlfControlGroup& aMailListControlGroup);
       
   311     virtual ~CFSEmailUiMailListVisualiser();
       
   312     void PrepareForExit();
       
   313 
       
   314 	void DynInitMenuPaneL(TInt aResourceId, CEikMenuPane* aMenuPane);
       
   315 	// Refresh the whole list
       
   316 	void RefreshL( TFSMailMsgId* aFocusToMessage = NULL );
       
   317 	// From view
       
   318 	TUid Id() const;
       
   319 	// <cmail> Toolbar
       
   320 	/*void DoActivateL(const TVwsViewId& aPrevViewId,
       
   321 	                 TUid aCustomMessageId,
       
   322 	                 const TDesC8& aCustomMessage);*/
       
   323     // </cmail> Toolbar
       
   324 	TInt NewEmailsInModelL() const;
       
   325 	TInt EmailsInModelL() const;
       
   326 	CFSEmailUiMailListModel* Model();
       
   327 	// Current active folder
       
   328 	TFSMailMsgId FolderId();
       
   329 	// Dynamic variant switch, called by appui
       
   330 	void HandleDynamicVariantSwitchL( CFsEmailUiViewBase::TDynamicSwitchType aType );
       
   331 	void HandleDynamicVariantSwitchOnBackgroundL( CFsEmailUiViewBase::TDynamicSwitchType aType );
       
   332 	// Handle foregroundevent
       
   333 	void HandleForegroundEventL( TBool aForeground );
       
   334 	// Sets softkeys
       
   335 	void SetViewSoftkeysL( TInt aResourceId );
       
   336 	void SetMskL();
       
   337 	// Highlighted index
       
   338 	TInt HighlightedIndex() const;
       
   339 	void SetHighlightedIndexL( TInt aWantedIndex );
       
   340 	// Event handling forwarded from control
       
   341 	TBool OfferEventL( const TAlfEvent& aEvent );
       
   342 
       
   343     // <cmail>
       
   344 	/**
       
   345 	 * Open highlighted mail or node.
       
   346 	 * (Touchwork: Called from touch manager)
       
   347 	 */
       
   348 	void DoHandleListItemOpenL();
       
   349 
       
   350 	/**
       
   351      * Open folderlist or shortlist.
       
   352      * (Touchwork: Called from touch manager)
       
   353      *
       
   354      * @param TInt button id. (shortlist or folderlist)
       
   355      */
       
   356 	void DoHandleControlBarOpenL( TInt aControlBarButtonId );
       
   357 
       
   358     /**
       
   359      * Open action menu.
       
   360      * (Touchwork: Called from touch manager)
       
   361      */
       
   362 	void DoHandleListItemLongTapL( const TPoint& aPoint );
       
   363 
       
   364     /**
       
   365      * Get control which is currently focused.
       
   366      * (Touchwork: Called from touch manager)
       
   367      *
       
   368      * @return TInt id of control
       
   369      */
       
   370 	TInt GetFocusedControl() const;
       
   371 
       
   372     /**
       
   373      * Set control bar as focused control.
       
   374      * (Touchwork: Called from touch manager)
       
   375      */
       
   376 	void SetControlBarFocusedL();
       
   377 
       
   378     /**
       
   379      * Set tree list as focused control.
       
   380      * (Touchwork: Called from touch manager)
       
   381      */
       
   382 	void SetTreeListFocusedL();
       
   383 
       
   384     /**
       
   385      * Helper function for disable controls to send
       
   386      * any events.
       
   387      * (Touchwork)
       
   388      *
       
   389      * @param TBool state of controls.
       
   390      */
       
   391 	void DisableMailList( TBool aValue );
       
   392 	// </cmail>
       
   393 
       
   394 	// Command handling
       
   395 	void HandleCommandL(TInt aCommand);
       
   396 	// Read status
       
   397 	void ChangeReadStatusOfHighlightedL( TBool aRead );
       
   398 	void ChangeReadStatusOfMarkedL( TBool aRead );
       
   399 	void ChangeReadStatusOfIndexL( TBool aRead, TInt aIndex );
       
   400 	// Delete messages
       
   401 	void DeleteMessagesL();
       
   402 	// Move to drafts
       
   403 	void MoveMessagesToDraftsL();
       
   404 
       
   405 	// From base class MFSEmailUiFolderListCallback
       
   406 	// Handle folder list selection
       
   407 	void FolderSelectedL( TFSMailMsgId aSelectedFolderId,
       
   408 	 					 TFSEmailUiCtrlBarResponse aResponse );
       
   409 	void MailboxSelectedL( TFSMailMsgId aSelectedFolderId );
       
   410 	TRect FolderButtonRect();
       
   411 
       
   412 	// From base class MFSEmailUiSortListCallback
       
   413 	void SortOrderChangedL( TFSMailSortField aSortField,
       
   414 	 					   TFSEmailUiCtrlBarResponse aResponse );
       
   415 	TRect SortButtonRect();
       
   416 
       
   417 	// Update theme colors
       
   418 	void UpdateThemeL(const TBool aSystemUpdate = ETrue);
       
   419 
       
   420 	// Navigation functions, used mainly from viewer
       
   421 	TBool IsNextMsgAvailable( TFSMailMsgId aCurrentMsgId, TFSMailMsgId& aFoundNextMsgId, TFSMailMsgId& aFoundNextMsgFolder ) const;
       
   422 	TBool IsPreviousMsgAvailable( TFSMailMsgId aCurrentMsgId, TFSMailMsgId& aFoundPreviousMsgId, TFSMailMsgId& aFoundPrevMsgFolder ) const;
       
   423 	TInt MoveToNextMsgL( TFSMailMsgId aCurrentMsgId, TFSMailMsgId& aFoundNextMsgId );
       
   424 	TInt MoveToPreviousMsgL( TFSMailMsgId aCurrentMsgId, TFSMailMsgId& aFoundPreviousMsgId );
       
   425 	TInt MoveToPreviousMsgAfterDeleteL( TFSMailMsgId aFoundPreviousMsgId );
       
   426 
       
   427 	/**
       
   428      * Sets the manual mailbox syncronisation flag if the user chose
       
   429      * to synchorise mail box from the menu
       
   430      */
       
   431     void ManualMailBoxSync( TBool aManualMailBoxSync );
       
   432 
       
   433     // Returns ETrue if mailbox is syncronizing and EFalse if not
       
   434     TBool GetLatestSyncState();
       
   435 
       
   436 	void GetMarkedMessagesL( RArray<TFSMailMsgId>& aMessageIDs ) const;
       
   437 	CFsTreeList& GetMailList();
       
   438 	// Get message ID corresponding given list ID. If the list ID is for a node, its first child message ID is returned.
       
   439 	TFSMailMsgId MsgIdFromListId( TFsTreeItemId aListId ) const;
       
   440 
       
   441     void HandleMailBoxEventL( TFSMailEvent aEvent, TFSMailMsgId aMailbox,
       
   442         TAny* aParam1, TAny* aParam2, TAny* aParam3 );
       
   443 
       
   444 // from base class MFsTreeListObserver
       
   445 
       
   446     /** Handles tree list events. */
       
   447     // <cmail> Touch
       
   448     void TreeListEventL( const TFsTreeListEvent aEvent,
       
   449                          const TFsTreeItemId aId,
       
   450                          const TPoint& aPoint );
       
   451     // </cmail>
       
   452 
       
   453 // from base class MFSEmailUiContactHandlerObserver
       
   454 
       
   455     /** Handles completed contact handler event. */
       
   456     void OperationCompleteL( TContactHandlerCmd aCmd,
       
   457         const RPointerArray<CFSEmailUiClsItem>& aContacts );
       
   458     void OperationErrorL( TContactHandlerCmd, TInt aError );
       
   459 
       
   460     /**
       
   461     * Called when CDateChangeTimer completes. This happens when either when date
       
   462     * changes or when user alters the system time. Redraws the list to ensure that
       
   463     * time stamp texts in emails and nodes are up-to-date.
       
   464     */
       
   465     void NotifyDateChangedL();
       
   466 
       
   467     // Sets aActiveMailboxId and aActiveFolderId from iMailFolder if available
       
   468     TInt GetActiveFolderId(TFSMailMsgId& aActiveMailboxId, TFSMailMsgId& aActiveFolderId) const;
       
   469 
       
   470     // Creates CMailboxStateExtension with this class set as dataprovider
       
   471     void CreateExtensionL();
       
   472 
       
   473     // check from settings if manual or auto sync
       
   474     TBool CheckAutoSyncSettingL();
       
   475     
       
   476 public: // from MFSEmailUiGenericTimerCallback
       
   477 
       
   478     /**
       
   479      * From MFSEmailUiGenericTimerCallback.
       
   480      * Generic timer event callback.
       
   481      * Handles insertion of new mails into mail list.
       
   482      */
       
   483     void TimerEventL( CFSEmailUiGenericTimer* aTriggeredTimer );
       
   484 
       
   485 private: // from
       
   486 
       
   487     /**
       
   488      * @see CFsEmailUiViewBase::ChildDoActivateL
       
   489      */
       
   490     void ChildDoActivateL( const TVwsViewId& aPrevViewId,
       
   491             TUid aCustomMessageId,
       
   492             const TDesC8& aCustomMessage );
       
   493     void ChildDoDeactivate();
       
   494     void GetParentLayoutsL( RPointerArray<CAlfVisual>& aLayoutArray ) const;
       
   495     TFSEmailUiTextures GetSortButtonTextureIndex();
       
   496 	void FadeOut(TBool aDirectionOut);
       
   497     
       
   498     /**
       
   499 	 * @see CFsEmailUiViewBase::SetStatusBarLayout
       
   500 	 */
       
   501     void SetStatusBarLayout();
       
   502 
       
   503 private: // Private functions
       
   504     CFSEmailUiMailListVisualiser( CAlfEnv& aEnv, CFreestyleEmailUiAppUi* aAppUi,
       
   505         CAlfControlGroup& aMailListControlGroup );
       
   506     void ConstructL();
       
   507 
       
   508 	// Refresh funcions
       
   509     void InsertNewMessagesL( const RArray<TFSMailMsgId>& aMessages );
       
   510     void InsertNewMessageL( CFSMailMessage* aNewMessage, const TBool aAllowRefresh ); // ownership is transferred
       
   511 
       
   512     void RefreshListItemsL();
       
   513     void RefreshListItemsL(TFsTreeItemId& aLatestNodeId,
       
   514         const TInt aStartIndex, const TInt aEndIndex);
       
   515     // Refresh the list order only
       
   516     void RefreshOrderL();
       
   517 
       
   518     // To start refreshing asynchronously
       
   519     void RefreshDeferred( TFSMailMsgId* aFocusToMessage = NULL );
       
   520     static TInt DoRefresh( TAny* aSelfPtr );
       
   521     void CompletePendingRefresh();
       
   522 
       
   523     // Create and insert one list node item according to given model item.
       
   524     // Omitting the argument aChildIdx causes the new node to be appended at the end of the list.
       
   525     TFsTreeItemId InsertNodeItemL( TInt aModelIndex, TInt aChildIndex = KErrNotFound, const TBool aAllowRefresh = EFalse );
       
   526     // Create and insert one list item according the given model item. The item is added under the given node.
       
   527     // Omitting the argument aChildIdx causes the new item to be appended as last child of the node.
       
   528     TFsTreeItemId InsertListItemL( TInt aModelIndex, TFsTreeItemId aParentNodeId, TInt aChildIdx = KErrNotFound, TBool aAllowRefresh = ETrue );
       
   529 
       
   530     // from CMailListModelUpdater::MObserver
       
   531 
       
   532     /**
       
   533      * @see CMailListModelUpdater::MObserver::UpdateErrorL
       
   534      */
       
   535     void UpdateErrorL(TInt aError);
       
   536 
       
   537     /**
       
   538      * @see CMailListModelUpdater::MObserver::UpdateBeginL
       
   539      */
       
   540     void UpdateBeginL();
       
   541 
       
   542     /**
       
   543      * @see CMailListModelUpdater::MObserver::UpdateProgressL
       
   544      */
       
   545     void UpdateProgressL(TFsTreeItemId& aParentId, RPointerArray<CFSMailMessage>& aMessages);
       
   546 
       
   547     /**
       
   548      * @see CMailListModelUpdater::MObserver::UpdateCompleteL
       
   549      */
       
   550     void UpdateCompleteL();
       
   551 
       
   552     /**
       
   553      * @see CMailListModelUpdater::MObserver::UpdateCancelled
       
   554      */
       
   555     void UpdateCancelled(const TBool aForceRefresh);
       
   556 
       
   557 	// Mail model update
       
   558     void SortMailListModelAsyncL();
       
   559     TBool UpdateMailListModelAsyncL(TInt aBlockSize);
       
   560 	void UpdateMailListModelL();
       
   561 	void CreateModelItemsL( RPointerArray<CFSMailMessage>& aMessages );
       
   562 	void DeleteSortWaitNote();
       
   563 
       
   564 	// Create title divider model item for the given message. Separator text depends on active sorting mode.
       
   565 	CFSEmailUiMailListModelItem* CreateSeparatorModelItemLC( CFSMailMessage& aMessage ) const;
       
   566 
       
   567 	// Checks if the given messages belong under the same title divider. This depends on the currect sorting mode.
       
   568 	TBool MessagesBelongUnderSameSeparatorL( const CFSMailMessage& aMessage1, const CFSMailMessage& aMessage2 ) const;
       
   569 
       
   570 	// Rescale UI
       
   571 	void SetMailListLayoutAnchors();
       
   572 
       
   573 	// Control bar functions
       
   574 	void CreateControlBarLayoutL();
       
   575 	void ScaleControlBarL();
       
   576 	void SetSortButtonTextAndIconL();
       
   577 	HBufC* GetSortButtonTextLC();
       
   578     void HandleControlBarEvent( TFsControlBarEvent aEvent, TInt aData );
       
   579 
       
   580 	// Followup flag
       
   581 	void SetMessageFollowupFlagL();
       
   582 
       
   583 	void CreatePlainNodeL( const TDesC* aItemDataBuff,
       
   584                            CFsTreePlainOneLineNodeData* &aItemData,
       
   585                            CFsTreePlainOneLineNodeVisualizer* &aNodeVisualizer ) const;
       
   586 
       
   587 	// Move messages to folder
       
   588 	TInt MoveMsgsToFolderL( const TFSMailMsgId& aDestinationFolderId );
       
   589 
       
   590 	// Collapse/Expand nodes
       
   591 	void ExpandAllNodesL();
       
   592 	void CollapseAllNodesL();
       
   593 	void ExpandOrCollapseL();
       
   594 
       
   595 	// Mark control functions
       
   596     /**
       
   597      * Mark all items
       
   598      */	
       
   599 	void MarkAllItemsL();
       
   600 
       
   601     /**
       
   602      * Unmark all items
       
   603      */	
       
   604 	void UnmarkAllItemsL();
       
   605 	
       
   606     /**
       
   607      * Exit from marking mode
       
   608 	 * @return TInt count of marked items
       
   609      */	
       
   610 	TInt CountMarkedItemsL();
       
   611 
       
   612     /**
       
   613      * Check if all items are marked
       
   614      */    
       
   615 	TBool AreAllItemsMarked();
       
   616 	
       
   617     /**
       
   618      * Check if all items are unmarked
       
   619      */
       
   620 	TBool AreAllItemsUnmarked();
       
   621 	
       
   622     /**
       
   623      * Check if all marked items are read
       
   624      */	
       
   625 	TBool AreAllMarkedItemsReadL();
       
   626 
       
   627     /**
       
   628      * Check if all marked items are unread
       
   629      */	
       
   630 	TBool AreAllMarkedItemsUnreadL();
       
   631 	
       
   632     /**
       
   633      * Exit from marking mode
       
   634      */
       
   635 	void ExitMarkingModeL();
       
   636 	
       
   637     /**
       
   638      * Enter to marking mode
       
   639      */	
       
   640 	void EnterMarkingModeL();
       
   641 	
       
   642     /**
       
   643      * Refresh marking mode
       
   644      */	
       
   645 	void RefreshMarkingModeL();
       
   646 	
       
   647     /**
       
   648      * Display marking mode title text
       
   649      */ 
       
   650     void DisplayMarkingModeTitleTextL();
       
   651     
       
   652     /**
       
   653      * Remove marking mode title text
       
   654      */ 
       
   655     void RemoveMarkingModeTitleTextL();
       
   656 
       
   657     /**
       
   658      * Displays or remove marking mode background
       
   659      */
       
   660     void DisplayMarkingModeBgL( TBool aDisplay );
       
   661     
       
   662     /**
       
   663      * Mark/unmark items under current separator.
       
   664      *
       
   665      * @param aMarked If ETrue mark all items else unmark.
       
   666      * @param aSeparatorId Id of the separator.
       
   667      */
       
   668     void MarkItemsUnderSeparatorL( TBool aMarked, TInt aSeparatorId );
       
   669 	
       
   670     /**
       
   671      * Check if all items are marked under separator
       
   672      *
       
   673      * @param aSeparatorId Id of the separator.
       
   674      * @return TBool ETrue if all items are marked under separator
       
   675      */	
       
   676     TBool AreAllItemsMarkedUnderSeparatorL( TInt aSeparatorId );
       
   677     
       
   678     /**
       
   679      * Restore marking status
       
   680      */
       
   681 	void MarkMessagesIfFoundL( const RArray<TFSMailMsgId>& aMessageIDs );
       
   682 
       
   683 	// Message deletion internal functions
       
   684 	void DeleteFocusedMessageL();
       
   685 	void DeleteMarkedMessagesL();
       
   686     void DeleteMessagesUnderNodeL( const TFsTreeItemId aNodeId );
       
   687     void ConfirmAndStartDeleteTaskL( TDeleteTask<CFSEmailUiMailListVisualiser>* aTask );
       
   688     TBool ConfirmDeleteL( const TInt aItemCount, const TFsTreeItemId aItemId ) const;
       
   689     static TInt DoExecuteDeleteTask( TAny* aSelfPtr );
       
   690     void HandleDeleteTaskL( const RFsTreeItemIdList& aEntries );
       
   691     void HandleDeleteTaskLeavingCodeL( const RFsTreeItemIdList& aEntries );
       
   692 
       
   693 	// Helper functions to access model data
       
   694 	TFSMailMsgId MsgIdFromIndex( TInt aItemIdx ) const;
       
   695 	CFSMailMessage& MsgPtrFromListIdL( TFsTreeItemId aListId );
       
   696     const CFSMailMessage& MsgPtrFromListIdL( TFsTreeItemId aListId ) const;
       
   697 
       
   698 	// Item data and visualiser helper functions
       
   699 	MFsTreeItemData* ItemDataFromItemId( TFsTreeItemId aItemId );
       
   700 	MFsTreeItemVisualizer* ItemVisualiserFromItemId( TFsTreeItemId aItemId );
       
   701 
       
   702 	// Helpers to get the ordinal of a message in the iModel
       
   703 	TInt ItemIndexFromMessageId( const TFSMailMsgId& aMessageId ) const;
       
   704 	TInt NextMessageIndex( TInt aCurMsgIdx ) const;
       
   705 	TInt PreviousMessageIndex( TInt aCurMsgIdx ) const;
       
   706 	TInt ModelIndexFromListId( TFsTreeItemId aItemId ) const;
       
   707 
       
   708 	// Open highlighted mail
       
   709 	void OpenHighlightedMailL();
       
   710 	void OpenMailItemL( TFsTreeItemId aMailItem );
       
   711 
       
   712 	// Create folder name buffer, either from database or from actual folder name
       
   713 	HBufC* CreateFolderNameLC( const CFSMailFolder* aFolder ) const;
       
   714 
       
   715 	// Shortcut specific toggles
       
   716 	void ShortcutReadUnreadToggleL();
       
   717 	void ShortcutCollapseExpandAllToggleL();
       
   718 
       
   719 	// Utility functions to check if all nodes are expanded or collapsed
       
   720 	TBool AllNodesCollapsed() const;
       
   721 	TBool AllNodesExpanded() const;
       
   722 
       
   723 	// Utility functions to check if mark as read/unread options should be available in menus
       
   724 	TBool IsMarkAsReadAvailableL() const;
       
   725 	TBool IsMarkAsUnreadAvailableL() const;
       
   726 
       
   727 	// Utility function to get list of entries which will be targeted by the Actions menu commands.
       
   728 	// The list contains either marked entries or the focused message entry or is empty.
       
   729 	void GetActionsTargetEntriesL( RFsTreeItemIdList& aListItems ) const;
       
   730 
       
   731 	// Stylus menu specific functions
       
   732 	void LaunchStylusPopupMenuL( const TPoint& aPoint );
       
   733 
       
   734 	// Compose, reply, reply all and forward
       
   735 	void CreateNewMsgL();
       
   736 	void ReplyL( CFSMailMessage* aMsgPtr );
       
   737 	void ReplyAllL( CFSMailMessage* aMsgPtr );
       
   738 	void ForwardL( CFSMailMessage* aMsgPtr );
       
   739 	void DoReplyForwardL( TEditorLaunchMode aMode, CFSMailMessage* aMsgPtr = NULL );
       
   740 
       
   741 	// Some misc housekeeping functions
       
   742 	void RemoveUnnecessaryNodesL();
       
   743 	void UpdateMailListSettingsL();
       
   744 	void UpdateMailListTimeDateSettings();
       
   745 	STimeDateFormats MailListTimeDateSettings();
       
   746 
       
   747 	// Request to update list item data from given message pointer
       
   748     void UpdateItemDataL( CFsTreePlainTwoLineItemData* aData, const CFSMailMessage* aMsgPtr );
       
   749 
       
   750 	// Request to update preview pane data for list id with msg ptr
       
   751 	void UpdatePreviewPaneTextForItemL( TFsTreeItemId aListItemId, CFSMailMessage* aMsgPtr );
       
   752 	void UpdatePreviewPaneTextForItemL( CFsTreePlainTwoLineItemData* aTwoLineItemData, CFSMailMessage* aMsgPtr );
       
   753     void UpdatePreviewPaneTextIfNecessaryL( TFsTreeItemId aListItemId, TBool aUpdateItem = ETrue );
       
   754 
       
   755 	// Sender/Recipient text depending on the mail folder
       
   756 	HBufC* GetListFirstTextLineL( const CFSMailMessage* aMsgPtr );
       
   757 
       
   758 	// Reload message pointer from mail client and update list item contents to match it. Item is
       
   759 	// removed if it isn't valid anymore.
       
   760 	void UpdateItemAtIndexL( TInt aIndex );
       
   761 
       
   762 	// Check validity of highlighted msg and remove from list if needed
       
   763 	// EFalse indicates that mail was not valid anymore.
       
   764 	TBool CheckValidityOfHighlightedMsgL();
       
   765 
       
   766 	// Icon update for msg item
       
   767 	void UpdateMsgIconAndBoldingL( CFSMailMessage* aMsgPtr );
       
   768 	void UpdateMsgIconAndBoldingL( TInt aListIndex, TBool aRefreshItem = ETrue );
       
   769 	void UpdateMsgIconAndBoldingL( CFsTreePlainTwoLineItemData* aItemData,
       
   770 	                               CFsTreePlainTwoLineItemVisualizer* aItemVis,
       
   771 	                               CFSMailMessage* aMsgPtr );
       
   772 
       
   773 	// Message removing from list if found
       
   774 	void RemoveMsgItemsFromListIfFoundL( const RArray<TFSMailMsgId>& aEntryIds );
       
   775 
       
   776 	// Branding functions
       
   777 	void SetBrandedMailBoxIconL();
       
   778 	void SetMailboxNameToStatusPaneL();
       
   779 	void SetBrandedListWatermarkL();
       
   780 
       
   781     // Gives the parent node if the item has one. Returns KErrNotFound if no parent node available.
       
   782     TFsTreeItemId ParentNode( TFsTreeItemId aItemId ) const;
       
   783 
       
   784     // Either marks or unmarks the current item depending on the current marking state
       
   785     // as stored in iListMarkItemsState. Used for marking when shift is depressed while
       
   786     // scrolling. Returns ETrue if the highlighted item is markable.
       
   787     TBool DoScrollMarkUnmarkL();
       
   788 
       
   789     //When maillist is activated this method handles the connection icon change
       
   790     void ConnectionIconHandling();
       
   791 
       
   792     void SetListAndCtrlBarFocusL();
       
   793 
       
   794     void SetMailListItemsExtendedL();
       
   795 
       
   796     void DoFirstStartL();
       
   797 
       
   798     // Called when flip state is changed
       
   799     void FlipStateChangedL( TBool aFlipOpen );
       
   800 
       
   801     /**
       
   802      * Handles the focus state changes
       
   803      * @param aVisible Indicates if focus should become visible or removed
       
   804      */
       
   805     void FocusVisibilityChange( TBool aVisible );
       
   806 
       
   807     /**
       
   808      * Update texts in command area buttons
       
   809      */
       
   810     void UpdateButtonTextsL();
       
   811 
       
   812     /**
       
   813      * Tests whether a point is inside the control.
       
   814      *
       
   815      * @param aControl  Control that is tested.
       
   816      * @param aPoint    Point in display coordinates.
       
   817      *
       
   818      * @return  <code>ETrue</code>, if the point is inside one of the
       
   819      *          control's visuals. Otherwise <code>EFalse</code>.
       
   820      */
       
   821     TBool HitTest( const CAlfControl& aControl, const TPoint& aPoint ) const;
       
   822 
       
   823     /**
       
   824      * Handles arrow events in portrait mode.
       
   825      *
       
   826      * @param aScancode Standard scan code.
       
   827      * @param aEvent Event.
       
   828      * @param aShiftState Shift state.
       
   829      *
       
   830      * @return <code>ETrue</code>, if consumed, <code>EFalse</code> otherwise.
       
   831      */
       
   832     TBool HandleArrowEventInPortraitL( const TInt aScancode,
       
   833             const TAlfEvent& aEvent, const TBool aShiftState );
       
   834     /**
       
   835      * Handles arrow events in landscape mode.
       
   836      *
       
   837      * @param aScancode Standard scan code.
       
   838      * @param aEvent Event.
       
   839      * @param aShiftState Shift state.
       
   840      *
       
   841      * @return <code>ETrue</code>, if consumed, <code>EFalse</code> otherwise.
       
   842      */
       
   843     TBool HandleArrowEventInLandscapeL( const TInt aScancode,
       
   844             const TAlfEvent& aEvent, const TBool aShiftState );
       
   845 
       
   846 private: // data types
       
   847 
       
   848 
       
   849 private: // Private objects
       
   850     // Extension to support Ozone-plugin's check for active mailbox
       
   851     CMailboxStateExtension* iExtension;
       
   852     // Reference to Alf environment
       
   853     CAlfEnv& iEnv;
       
   854   	// Mail list updater timer
       
   855 	// Timer delays mail update to prevent unnesessary redraw events
       
   856 	CMailListUpdater* iMailListUpdater;
       
   857 	// Msg moved note timer
       
   858 	CMsgMovedNoteTimer* iMsgNoteTimer;
       
   859   	// Screen layout uses iMailListControl
       
   860 	CAlfAnchorLayout* iScreenAnchorLayout;
       
   861   	// Control bar control and layout and store visual pointer
       
   862 	CFsControlBar* iControlBarControl;
       
   863 	CAlfVisual* iControlBarVisual;
       
   864  	CAlfDeckLayout* iControlBarLayout;
       
   865   	// Mail List control and layout
       
   866     CFreestyleEmailUiMailListControl* iMailListControl;
       
   867  	CAlfDeckLayout* iListLayout;
       
   868     CAlfImageVisual* iTitleDividerBgVisual;
       
   869     CFSEmailUiMailListModel* iModel;
       
   870   	CFsTreeList* iMailList;
       
   871     CFsTreeVisualizerBase* iMailTreeListVisualizer;
       
   872   	TInt iNumSlots;
       
   873    	CFSMailFolder* iMailFolder;
       
   874     TInt iNewEmailsInModel;
       
   875 	RArray<SMailListItem> iTreeItemArray;
       
   876     RArray<TInt> iButtonsIds;
       
   877     TInt iFocusedControl;
       
   878     TBool iToolbarInUse;
       
   879     TInt iListMode;
       
   880     TInt iNodesInUse;
       
   881     TInt iNewEmailButtonId;
       
   882 	TInt iFolderListButtonId;
       
   883 	TInt iSortButtonId;
       
   884 	TInt iImageButtonId;
       
   885 	MFsControlButtonInterface* iIconButton;
       
   886 	MFsControlButtonInterface* iNewEmailButton;
       
   887 	MFsControlButtonInterface* iFolderListButton;
       
   888 	MFsControlButtonInterface* iSortButton;
       
   889 	TBool iThisViewActive;
       
   890 	CPbkxContactActionMenu* iActionMenu;
       
   891     TFSMailSortCriteria iCurrentSortCriteria;
       
   892 	// Set to indicate whether items should be marked or unmarked
       
   893 	TBool iListMarkItemsState;
       
   894 	// Set to indicate if Shift key is being held down in which case selection key has mark/unmark functionality
       
   895 	TBool iShiftDepressed;
       
   896 	// Set to indicate has other key events occured during hash key press (in which case hash is used as shift and not handled individually)
       
   897 	TBool iOtherKeyPressedWhileShiftDepressed;
       
   898 	// Move to folder toggle
       
   899 	TBool iMoveToFolderOngoing;
       
   900 	// Timers
       
   901 	CFSEmailUiGenericTimer* iMsgMoveTimer;
       
   902 	//ETrue if user started the sync
       
   903 	TBool iManualMailBoxSync;
       
   904 	TAknUiZoom iCurrentZoomLevel;
       
   905 	STimeDateFormats iDateFormats;
       
   906 	TRect iCurrentClientRect;
       
   907 	CAlfTexture* iMailBoxIconTexture;
       
   908 	CAlfTexture* iMailBoxWatermarkTexture;
       
   909 	TBool iSkinChanged;
       
   910 	TBool iDateChanged;
       
   911 	TFSMailMsgId iLatestOpenedMrId;
       
   912 	TBool iListOrderMayBeOutOfDate;
       
   913 	CAknWaitDialog* iDeletingWaitNote;
       
   914 	CDateChangeTimer* iDateChangeTimer;
       
   915 	TBool iFirstStartCompleted;
       
   916 	// generic use async callback object
       
   917 	CAsyncCallBack* iAsyncCallback;
       
   918 	// async callback for deferred redrawing
       
   919 	CAsyncCallBack* iAsyncRedrawer;
       
   920 	TFSMailMsgId iMsgToFocusAfterRedraw;
       
   921 	HBufC* iNewEmailText;
       
   922 
       
   923     CEUiEmailListTouchManager* iTouchManager;
       
   924     CAknStylusPopUpMenu* iStylusPopUpMenu;
       
   925     TBool iStylusPopUpMenuVisible;
       
   926 
       
   927     TBool iShowReplyAll;
       
   928     // Was focus visible in the ListView.
       
   929     TDeleteTask<CFSEmailUiMailListVisualiser>* iDeleteTask;
       
   930     TBool iLastFocus;
       
   931     //used to prevent Call application execution (on keyup of call button) when call to contact required
       
   932     TBool iConsumeStdKeyYes_KeyUp;
       
   933     CMailListModelUpdater* iMailListModelUpdater;
       
   934     TBool iForceRefresh;
       
   935     // true if message viewer/editor is open to disable background list updates
       
   936     TBool iMailOpened;
       
   937     // tactile feed back -- not owned
       
   938     MTouchFeedback* iTouchFeedBack;
       
   939 	// Is device in marking mode
       
   940 	TBool iMarkingMode;
       
   941 	// Exit marking mode when view is back to mail list view
       
   942 	TBool iMarkingModeWaitingToExit;
       
   943 	// Marking mode title variables
       
   944 	CAlfTextVisual* iMarkingModeTextVisual;
       
   945 	CAlfLayout* iMarkingModeTextParentLayout;
       
   946 	CAlfAnchorLayout* iMarkingModeTextContentLayout;
       
   947 	TPoint iMarkingModeTextPos;
       
   948 	TSize iMarkingModeTextSize;
       
   949 	TRect iMarkingModeTextRect;
       
   950 	// sorting info dialog
       
   951     CAknWaitDialog* iSortWaitNote;
       
   952     //sorting timer
       
   953     CFSEmailUiGenericTimer* iSortTimer;
       
   954     TSortState iSortState; //states of the sorting timer
       
   955     TInt iSortTryCount;   // number of tries that it will make to retry start sorting
       
   956     // timer generates events for inserting new mails into mail list
       
   957     CFSEmailUiGenericTimer* iNewMailTimer;
       
   958     
       
   959     // array keeps IDs of new mails which should be added into mail list 
       
   960     RArray<TFSMailMsgId> iNewMailIds;
       
   961 
       
   962     // skin text colors for the list items
       
   963     TRgb iFocusedTextColor;
       
   964     TRgb iNormalTextColor;
       
   965     TRgb iNodeTextColor;
       
   966     };
       
   967 
       
   968 
       
   969 // Definition of the mail updater timer. This timer is used for
       
   970 // delayed drawing of the mail list to avoid viewsrv:11 panics.
       
   971 class CMailListUpdater : public CTimer
       
   972     {
       
   973 public:
       
   974     static CMailListUpdater* NewL( CFSEmailUiMailListVisualiser* aMailListVisualiser );
       
   975     ~CMailListUpdater();
       
   976     void StartL( TBool aIsSorting = EFalse );
       
   977     void Stop();
       
   978     void RunL();
       
   979 
       
   980 protected:
       
   981     CMailListUpdater( CFSEmailUiMailListVisualiser* aMailListVisualiser );
       
   982 
       
   983 private:
       
   984     CFSEmailUiMailListVisualiser* iMailListVisualiser;
       
   985     TBool iIsSorting;
       
   986     CAknWaitDialog* iWaitNote;
       
   987     };
       
   988 
       
   989 // Delayd note timer
       
   990 class CMsgMovedNoteTimer : public CTimer
       
   991     {
       
   992 public:
       
   993     static CMsgMovedNoteTimer* NewL( CFreestyleEmailUiAppUi* aAppUi, CFSEmailUiMailListVisualiser* aMailListVisualiser );
       
   994     ~CMsgMovedNoteTimer();
       
   995     void Start( TInt aMsgCount, const TFSMailMsgId aDestinationFolderId );
       
   996     void Stop();
       
   997     void RunL();
       
   998 
       
   999 protected:
       
  1000     CMsgMovedNoteTimer( CFreestyleEmailUiAppUi* aAppUi, CFSEmailUiMailListVisualiser* aMailListVisualiser );
       
  1001 
       
  1002 private:
       
  1003     CFreestyleEmailUiAppUi* iAppUi;
       
  1004     CFSEmailUiMailListVisualiser* iMailListVisualiser;
       
  1005     TFSMailMsgId iDestinationFolderId;
       
  1006     TInt iMsgCount;
       
  1007     };
       
  1008 
       
  1009 // Date changing timer. Updates the mail list when date changes.
       
  1010 class CDateChangeTimer : public CTimer
       
  1011     {
       
  1012 public:
       
  1013     static CDateChangeTimer* NewL( CFSEmailUiMailListVisualiser& aMailListVisualiser );
       
  1014     ~CDateChangeTimer();
       
  1015     void Start();
       
  1016     void RunL();
       
  1017     TInt DayCount();
       
  1018     
       
  1019 protected:
       
  1020     CDateChangeTimer( CFSEmailUiMailListVisualiser& aMailListVisualiser );
       
  1021 
       
  1022 private:
       
  1023     CFSEmailUiMailListVisualiser& iMailListVisualiser;
       
  1024     TInt iDayCount;
       
  1025     };
       
  1026 
       
  1027 #endif