emailuis/emailui/src/FreestyleEmailUiMailListVisualiser.cpp
branchRCL_3
changeset 8 e1b6206813b4
parent 3 a4d6f1ea0416
child 10 f5907b1a1053
equal deleted inserted replaced
4:e7aa27f58ae1 8:e1b6206813b4
    22 #include <AknUtils.h>
    22 #include <AknUtils.h>
    23 #include <gulicon.h>
    23 #include <gulicon.h>
    24 #include <StringLoader.h>
    24 #include <StringLoader.h>
    25 #include <FreestyleEmailUi.rsg>
    25 #include <FreestyleEmailUi.rsg>
    26 #include <featmgr.h>
    26 #include <featmgr.h>
    27 #include "CFSMailClient.h"
    27 #include "cfsmailclient.h"
    28 #include "CFSMailBox.h"
    28 #include "cfsmailbox.h"
    29 #include "CFSMailFolder.h"
    29 #include "cfsmailfolder.h"
    30 #include "fscontrolbar.h"
    30 #include "fscontrolbar.h"
    31 #include "fscontrolbuttoninterface.h"
    31 #include "fscontrolbuttoninterface.h"
    32 #include "fstreelist.h"
    32 #include "fstreelist.h"
    33 #include "fstreevisualizerbase.h"
    33 #include "fstreevisualizerbase.h"
    34 #include "fstreeplainonelinenodedata.h"
    34 #include "fstreeplainonelinenodedata.h"
    35 #include "fstreeplainonelinenodevisualizer.h"
    35 #include "fstreeplainonelinenodevisualizer.h"
    36 #include "fstreeplaintwolineitemdata.h"
    36 #include "fstreeplaintwolineitemdata.h"
    37 #include "fstreeplaintwolineitemvisualizer.h"
    37 #include "fstreeplaintwolineitemvisualizer.h"
    38 #include "CFSMailCommon.h"
    38 #include "cfsmailcommon.h"
    39 #include "ceuiemaillisttouchmanager.h"
    39 #include "ceuiemaillisttouchmanager.h"
    40 #include "FSEmailBuildFlags.h"
    40 #include "FSEmailBuildFlags.h"
    41 #include "cfsccontactactionmenu.h"
    41 #include "cfsccontactactionmenu.h"
    42 #include "mfsccontactactionmenumodel.h"
    42 #include "mfsccontactactionmenumodel.h"
    43 
    43 
    50 #include <alf/alfstatic.h>
    50 #include <alf/alfstatic.h>
    51 
    51 
    52 #include <aknnotewrappers.h>
    52 #include <aknnotewrappers.h>
    53 #include <msvapi.h>
    53 #include <msvapi.h>
    54 #include <akntitle.h>
    54 #include <akntitle.h>
    55 #include "ESMailSettingsPluginUids.hrh"
    55 #include "esmailsettingspluginuids.hrh"
    56 #include "ESMailSettingsPlugin.h"
    56 #include "esmailsettingsplugin.h"
    57 #include "MFSMailBrandManager.h"
    57 #include "mfsmailbrandmanager.h"
    58 #include <AknWaitDialog.h>
    58 #include <AknWaitDialog.h>
    59 #include <aknlayoutscalable_apps.cdl.h>
    59 #include <aknlayoutscalable_apps.cdl.h>
    60 #include <layoutmetadata.cdl.h>
    60 #include <layoutmetadata.cdl.h>
    61 #include <csxhelp/cmail.hlp.hrh>
    61 #include <csxhelp/cmail.hlp.hrh>
    62 // Meeting request
    62 // Meeting request
    76 #include "FreestyleEmailUi.hrh"
    76 #include "FreestyleEmailUi.hrh"
    77 #include "FreestyleEmailUiTextureManager.h"
    77 #include "FreestyleEmailUiTextureManager.h"
    78 #include "FreestyleEmailUiMailListControl.h"
    78 #include "FreestyleEmailUiMailListControl.h"
    79 #include "FreestyleEmailUiMailViewerVisualiser.h"
    79 #include "FreestyleEmailUiMailViewerVisualiser.h"
    80 #include "FreestyleEmailUiStatusIndicator.h"
    80 #include "FreestyleEmailUiStatusIndicator.h"
    81 #include "FreestyleEmailCenRepHandler.h"
    81 #include "freestyleemailcenrephandler.h"
    82 #include "FreestyleEmailUiFolderListVisualiser.h"
    82 #include "FreestyleEmailUiFolderListVisualiser.h"
    83 #include "FreestyleEmailUiShortcutBinding.h"
    83 #include "FreestyleEmailUiShortcutBinding.h"
    84 #include "FreestyleEmailUiMsgDetailsVisualiser.h"
    84 #include "FreestyleEmailUiMsgDetailsVisualiser.h"
    85 #include "FreestyleEmailDownloadInformationMediator.h"
    85 #include "FreestyleEmailDownloadInformationMediator.h"
    86 #include "FreestyleEmailUiContactHandler.h"
    86 #include "FreestyleEmailUiContactHandler.h"
   468     CFreestyleEmailUiAppUi* aAppUi, CAlfControlGroup& aMailListControlGroup )
   468     CFreestyleEmailUiAppUi* aAppUi, CAlfControlGroup& aMailListControlGroup )
   469     : CFsEmailUiViewBase( aMailListControlGroup, *aAppUi ),
   469     : CFsEmailUiViewBase( aMailListControlGroup, *aAppUi ),
   470     iEnv( aEnv ),
   470     iEnv( aEnv ),
   471     iListMarkItemsState( ETrue ), //Initlly list has no markings
   471     iListMarkItemsState( ETrue ), //Initlly list has no markings
   472     iMoveToFolderOngoing( EFalse ),
   472     iMoveToFolderOngoing( EFalse ),
   473     iConsumeStdKeyYes_KeyUp( EFalse ) // use to prevent Call application execution if call for contact processed
   473     iConsumeStdKeyYes_KeyUp( EFalse ), // use to prevent Call application execution if call for contact processed
       
   474     iMailOpened(EFalse)
   474 	{
   475 	{
   475     FUNC_LOG;
   476     FUNC_LOG;
   476 	}
   477 	}
   477 
   478 
   478 // ---------------------------------------------------------------------------
   479 // ---------------------------------------------------------------------------
   599             iMailList->SetFocusedItemL( iTreeItemArray[0].iListItemId );
   600             iMailList->SetFocusedItemL( iTreeItemArray[0].iListItemId );
   600             }
   601             }
   601         }
   602         }
   602     SetListAndCtrlBarFocusL();
   603     SetListAndCtrlBarFocusL();
   603     iAppUi.StartMonitoringL();
   604     iAppUi.StartMonitoringL();
       
   605     TIMESTAMP( "Locally stored messages fetched for message list" );    
   604     }
   606     }
   605 
   607 
   606 // ---------------------------------------------------------------------------
   608 // ---------------------------------------------------------------------------
   607 // @see CMailListModelUpdater::MObserver::UpdateCancelled
   609 // @see CMailListModelUpdater::MObserver::UpdateCancelled
   608 // ---------------------------------------------------------------------------
   610 // ---------------------------------------------------------------------------
  1039     CFSEmailUiMailListModelItem* newItem =
  1041     CFSEmailUiMailListModelItem* newItem =
  1040         CFSEmailUiMailListModelItem::NewLC( aNewMessage, ETypeMailItem );
  1042         CFSEmailUiMailListModelItem::NewLC( aNewMessage, ETypeMailItem );
  1041     TInt idx = KErrNotFound;
  1043     TInt idx = KErrNotFound;
  1042     TFsTreeItemId parentId = KFsTreeRootID;
  1044     TFsTreeItemId parentId = KFsTreeRootID;
  1043     TInt childIdx = KErrNotFound;
  1045     TInt childIdx = KErrNotFound;
       
  1046     TInt moveViewPortPosition = 0;
  1044 
  1047 
  1045     if ( !iNodesInUse )
  1048     if ( !iNodesInUse )
  1046         {
  1049         {
  1047         // Simple case: nodes are not in use. Just insert to correct place under root node.
  1050         // Simple case: nodes are not in use. Just insert to correct place under root node.
  1048         idx = iModel->GetInsertionPointL( *newItem );
  1051         idx = iModel->GetInsertionPointL( *newItem );
  1077                     static_cast<CFSEmailUiMailListModelItem*>( iModel->Item(idx) );
  1080                     static_cast<CFSEmailUiMailListModelItem*>( iModel->Item(idx) );
  1078                 TFsTreeItemId nextNodeId = nextNode->CorrespondingListId();
  1081                 TFsTreeItemId nextNodeId = nextNode->CorrespondingListId();
  1079                 TInt nodeIdxUnderRoot = iMailList->ChildIndex( KFsTreeRootID, nextNodeId );
  1082                 TInt nodeIdxUnderRoot = iMailList->ChildIndex( KFsTreeRootID, nextNodeId );
  1080                 InsertNodeItemL( idx-1, nodeIdxUnderRoot, aAllowRefresh );
  1083                 InsertNodeItemL( idx-1, nodeIdxUnderRoot, aAllowRefresh );
  1081                 }
  1084                 }
       
  1085             moveViewPortPosition += iAppUi.LayoutHandler()->OneLineListItemHeight(); 
  1082             }
  1086             }
  1083         else
  1087         else
  1084             {
  1088             {
  1085             // Suitable parent node exists and was found
  1089             // Suitable parent node exists and was found
  1086             parentNode = static_cast<CFSEmailUiMailListModelItem*>( iModel->Item(parentIdx) );
  1090             parentNode = static_cast<CFSEmailUiMailListModelItem*>( iModel->Item(parentIdx) );
  1091     // Insert the model item
  1095     // Insert the model item
  1092     iModel->InsertL( newItem, idx );
  1096     iModel->InsertL( newItem, idx );
  1093     CleanupStack::Pop( newItem );
  1097     CleanupStack::Pop( newItem );
  1094 
  1098 
  1095     // Insert the tree list item
  1099     // Insert the tree list item
  1096     InsertListItemL( idx, parentId, childIdx, aAllowRefresh );
  1100     TPoint viewPortCenterPos = iMailTreeListVisualizer->ViewPosition();
       
  1101     TPoint viewPortTopPos = iMailTreeListVisualizer->ViewPortTopPosition();
       
  1102     TInt itemPos = iMailTreeListVisualizer->GetItemWorldPosition( idx );
       
  1103     TBool refresh = viewPortTopPos.iY != 0 && itemPos < viewPortCenterPos.iY;
       
  1104      
       
  1105     if( refresh )
       
  1106     	{
       
  1107 		InsertListItemL( idx, parentId, childIdx, EFalse );
       
  1108 		// viewPort update needed
       
  1109 		moveViewPortPosition += iAppUi.LayoutHandler()->TwoLineListItemHeight(); // add mail item height
       
  1110 		viewPortCenterPos.iY += moveViewPortPosition;
       
  1111 		iMailTreeListVisualizer->ViewPositionChanged( viewPortCenterPos, EFalse, 1 );
       
  1112     	}
       
  1113     else
       
  1114     	{
       
  1115     	InsertListItemL( idx, parentId, childIdx, aAllowRefresh );
       
  1116     	}
  1097 
  1117 
  1098     // Move focus after insertion if necessary
  1118     // Move focus after insertion if necessary
  1099     if ( firstItemWasFocused )
  1119     if ( firstItemWasFocused )
  1100         {
  1120         {
  1101         TFsTreeItemId firstItemId = iMailList->Child( KFsTreeRootID, 0 );
  1121         TFsTreeItemId firstItemId = iMailList->Child( KFsTreeRootID, 0 );
  1222 void CFSEmailUiMailListVisualiser::ChildDoActivateL(const TVwsViewId& aPrevViewId,
  1242 void CFSEmailUiMailListVisualiser::ChildDoActivateL(const TVwsViewId& aPrevViewId,
  1223                      TUid aCustomMessageId,
  1243                      TUid aCustomMessageId,
  1224                      const TDesC8& aCustomMessage)
  1244                      const TDesC8& aCustomMessage)
  1225 	{
  1245 	{
  1226     FUNC_LOG;
  1246     FUNC_LOG;
       
  1247     TIMESTAMP( "Opening message list view" );
  1227     iShowReplyAll = EFalse;
  1248     iShowReplyAll = EFalse;
  1228 
  1249 
  1229 	if ( !iFirstStartCompleted )
  1250 	if ( !iFirstStartCompleted )
  1230 	    {
  1251 	    {
  1231 	    DoFirstStartL();
  1252 	    DoFirstStartL();
  1489 
  1510 
  1490     iCurrentClientRect = clientRect;
  1511     iCurrentClientRect = clientRect;
  1491 	iThisViewActive = ETrue;
  1512 	iThisViewActive = ETrue;
  1492 
  1513 
  1493 	// Set email indicator off.. user has checked the new emails
  1514 	// Set email indicator off.. user has checked the new emails
  1494 	TFsEmailUiUtility::ToggleEmailIconL(EFalse);
  1515 	TFsEmailUiUtility::ToggleEmailIconL(EFalse, activationData.iMailBoxId );
  1495 
  1516 
  1496 	iShiftDepressed = EFalse; // clear state just in case
  1517 	iShiftDepressed = EFalse; // clear state just in case
  1497 
  1518 
  1498 	// Inform MR observer if needed, special MR case, returning from attachment list
  1519 	// Inform MR observer if needed, special MR case, returning from attachment list
  1499 	iAppUi.MailViewer().CompletePendingMrCommand();
  1520 	iAppUi.MailViewer().CompletePendingMrCommand();
  1509 	    iControlBarControl->MakeSelectorVisible( iAppUi.IsFocusShown() );
  1530 	    iControlBarControl->MakeSelectorVisible( iAppUi.IsFocusShown() );
  1510 	    }
  1531 	    }
  1511 	UpdateButtonTextsL();
  1532 	UpdateButtonTextsL();
  1512 	FocusVisibilityChange( iAppUi.IsFocusShown() );
  1533 	FocusVisibilityChange( iAppUi.IsFocusShown() );
  1513 	iAppUi.ShowTitlePaneConnectionStatus();
  1534 	iAppUi.ShowTitlePaneConnectionStatus();
       
  1535 	TIMESTAMP( "Message list view opened" );
  1514 	}
  1536 	}
  1515 
  1537 
  1516 // ---------------------------------------------------------------------------
  1538 // ---------------------------------------------------------------------------
  1517 // Sets status bar layout
  1539 // Sets status bar layout
  1518 // ---------------------------------------------------------------------------
  1540 // ---------------------------------------------------------------------------
  1608 	    currentFolderType = iMailFolder->GetFolderType();
  1630 	    currentFolderType = iMailFolder->GetFolderType();
  1609 	    }
  1631 	    }
  1610 
  1632 
  1611     // MAIN MENU ***************************************************************************
  1633     // MAIN MENU ***************************************************************************
  1612 	if ( aResourceId == R_FSEMAILUI_MAILLIST_MENUPANE )
  1634 	if ( aResourceId == R_FSEMAILUI_MAILLIST_MENUPANE )
  1613 		{
  1635 	    {
       
  1636             // Sync/cancel sync
       
  1637 	    CFSMailBox* activeMailbox = iAppUi.GetActiveMailbox();
       
  1638 	    TBool supportsSync = activeMailbox->HasCapability( EFSMBoxCapaSupportsSync );
       
  1639                 
       
  1640             // flag to hide or show SyncButton
       
  1641             TBool hideSync = GetLatestSyncState();
       
  1642             if(activeMailbox->CurrentSyncState()==StartingSync) hideSync=EFalse;
       
  1643         
       
  1644             // hide or show options: Sync/cancel sync
       
  1645             if ( !supportsSync )
       
  1646                 {
       
  1647                 aMenuPane->SetItemDimmed( EFsEmailUiCmdCancelSync, ETrue );
       
  1648                 aMenuPane->SetItemDimmed( EFsEmailUiCmdSync, ETrue );
       
  1649                 }
       
  1650              else if ( hideSync || iMailListModelUpdater->IsUpdating() )
       
  1651                 {
       
  1652                 aMenuPane->SetItemDimmed( EFsEmailUiCmdSync, ETrue );
       
  1653                 }
       
  1654              else
       
  1655                 {
       
  1656                 aMenuPane->SetItemDimmed( EFsEmailUiCmdCancelSync, ETrue );
       
  1657                 }
       
  1658  	
  1614 		// Saves a focus visibility.
  1659 		// Saves a focus visibility.
  1615 		iLastFocus = EFalse;
  1660 		iLastFocus = EFalse;
  1616 		if( iFocusedControl == EMailListComponent && IsFocusShown() )
  1661 		if( iFocusedControl == EMailListComponent && IsFocusShown() )
  1617 		    {
  1662 		    {
  1618 		    iLastFocus = ETrue;
  1663 		    iLastFocus = ETrue;
  1900 	{
  1945 	{
  1901     FUNC_LOG;
  1946     FUNC_LOG;
  1902 	iMailList->RemoveAllL();
  1947 	iMailList->RemoveAllL();
  1903 	iTreeItemArray.Reset();
  1948 	iTreeItemArray.Reset();
  1904 
  1949 
       
  1950     // when we get refresh mail list updates should be fully enabled	
       
  1951     iMailOpened = EFalse;
       
  1952 	
  1905 	RefreshListItemsL();
  1953 	RefreshListItemsL();
  1906 
  1954 
  1907 	if ( !iModel->Count() )
  1955 	if ( !iModel->Count() )
  1908 		{
  1956 		{
  1909 		iFocusedControl = EControlBarComponent;
  1957 		iFocusedControl = EControlBarComponent;
  2996 // HandleForegroundEventL
  3044 // HandleForegroundEventL
  2997 // Function checks in foregroundevent that whether settings have changed and
  3045 // Function checks in foregroundevent that whether settings have changed and
  2998 // If there is a need to refresh the list.
  3046 // If there is a need to refresh the list.
  2999 // ---------------------------------------------------------------------------
  3047 // ---------------------------------------------------------------------------
  3000 //
  3048 //
  3001 void CFSEmailUiMailListVisualiser::HandleForegroundEventL()
  3049 void CFSEmailUiMailListVisualiser::HandleForegroundEventL( TBool aForeground )
  3002 	{
  3050 	{
  3003     FUNC_LOG;
  3051     FUNC_LOG;
  3004 	if ( iFirstStartCompleted ) // Safety
  3052     if( iMailFolder ) 
       
  3053         {
       
  3054         TFsEmailUiUtility::ToggleEmailIconL(EFalse, iMailFolder->GetMailBoxId() );
       
  3055         }
       
  3056     if ( aForeground && iFirstStartCompleted ) // Safety
  3005 	    {
  3057 	    {
  3006 	    // Update mail list settings and date formats, is done every time
  3058 	    // Update mail list settings and date formats, is done every time
  3007 	    // the user might have changed these in settings, so the list needs to refresh
  3059 	    // the user might have changed these in settings, so the list needs to refresh
  3008 	    // Store previous modes
  3060 	    // Store previous modes
  3009 	    TInt prevListMode = iListMode;
  3061 	    TInt prevListMode = iListMode;
  3073 // ---------------------------------------------------------------------------
  3125 // ---------------------------------------------------------------------------
  3074 //
  3126 //
  3075 void CFSEmailUiMailListVisualiser::HandleCommandL( TInt aCommand )
  3127 void CFSEmailUiMailListVisualiser::HandleCommandL( TInt aCommand )
  3076     {
  3128     {
  3077     FUNC_LOG;
  3129     FUNC_LOG;
       
  3130     TIMESTAMP( "Message list command for handling" );
  3078     CompletePendingRefresh();
  3131     CompletePendingRefresh();
  3079 
  3132 
  3080     // custom command handling for launching plugin settings
  3133     // custom command handling for launching plugin settings
  3081    	if ( EFsEmailUiCmdSettingsBaseCommandId <= aCommand
  3134    	if ( EFsEmailUiCmdSettingsBaseCommandId <= aCommand
  3082    		 && EFsEmailUiCmdSettingsBaseCommandIdMax > aCommand )
  3135    		 && EFsEmailUiCmdSettingsBaseCommandIdMax > aCommand )
  3131 
  3184 
  3132     switch( aCommand )
  3185     switch( aCommand )
  3133         {
  3186         {
  3134     	case EAknSoftkeyOpen:
  3187     	case EAknSoftkeyOpen:
  3135             {
  3188             {
       
  3189             TIMESTAMP( "Open email selected from message list" );
  3136             if( !iAppUi.IsFocusShown() )
  3190             if( !iAppUi.IsFocusShown() )
  3137                 {
  3191                 {
  3138                 iAppUi.SetFocusVisibility( ETrue );
  3192                 iAppUi.SetFocusVisibility( ETrue );
  3139                 break;
  3193                 break;
  3140                 }
  3194                 }
  3141             }
  3195             }
  3142        	case EAknSoftkeySelect:
  3196        	case EAknSoftkeySelect:
  3143        	    {
  3197        	    {
       
  3198        	    TIMESTAMP( "Open email selected from message list" );    
  3144        	    if ( iFocusedControl == EMailListComponent )
  3199        	    if ( iFocusedControl == EMailListComponent )
  3145        	        {
  3200        	        {
  3146        	        CFSEmailUiMailListModelItem* item = dynamic_cast<CFSEmailUiMailListModelItem*>(iModel->Item(HighlightedIndex()));
  3201        	        CFSEmailUiMailListModelItem* item = dynamic_cast<CFSEmailUiMailListModelItem*>(iModel->Item(HighlightedIndex()));
  3147        	        // MAIL ITEM; OPEN MAIL
  3202        	        // MAIL ITEM; OPEN MAIL
  3148        	        if ( item && item->ModelItemType() == ETypeMailItem )
  3203        	        if ( item && item->ModelItemType() == ETypeMailItem )
  3209 				}
  3264 				}
  3210         	break;
  3265         	break;
  3211         case EEikCmdExit:
  3266         case EEikCmdExit:
  3212         case EAknSoftkeyExit:
  3267         case EAknSoftkeyExit:
  3213         case EFsEmailUiCmdExit:
  3268         case EFsEmailUiCmdExit:
       
  3269             TIMESTAMP( "Exit selected from message list" );
  3214             iAppUi.Exit();
  3270             iAppUi.Exit();
  3215             break;
  3271             break;
  3216        	case EFsEmailUiCmdCalActionsReplyAsMail:
  3272        	case EFsEmailUiCmdCalActionsReplyAsMail:
  3217 		case EFsEmailUiCmdActionsReply:
  3273 		case EFsEmailUiCmdActionsReply:
  3218 			{
  3274 			{
       
  3275 			TIMESTAMP( "Reply to selected from message list" );
  3219    	   	 	ReplyL( NULL ); // Function will check marked/highlighted msg
  3276    	   	 	ReplyL( NULL ); // Function will check marked/highlighted msg
  3220 			}
  3277 			}
  3221             break;
  3278             break;
  3222 		case EFsEmailUiCmdActionsReplyAll:
  3279 		case EFsEmailUiCmdActionsReplyAll:
  3223 			{
  3280 			{
       
  3281 			TIMESTAMP( "Reply to all selected from message list" );
  3224 			ReplyAllL( NULL ); // Function will check marked/highlighted msg
  3282 			ReplyAllL( NULL ); // Function will check marked/highlighted msg
  3225 			}
  3283 			}
  3226             break;
  3284             break;
  3227        	case EFsEmailUiCmdCalActionsForwardAsMail:
  3285        	case EFsEmailUiCmdCalActionsForwardAsMail:
  3228 		case EFsEmailUiCmdActionsForward:
  3286 		case EFsEmailUiCmdActionsForward:
  3229 			{
  3287 			{
       
  3288 			TIMESTAMP( "Forward selected from message list" );
  3230            	ForwardL( NULL ); // Function will check marked/highlighted msg
  3289            	ForwardL( NULL ); // Function will check marked/highlighted msg
  3231 			}
  3290 			}
  3232             break;
  3291             break;
  3233        	case EFsEmailUiCmdActionsCallSender:
  3292        	case EFsEmailUiCmdActionsCallSender:
  3234 			{
  3293 			{
  3344             }
  3403             }
  3345             break;
  3404             break;
  3346        	case EFsEmailUiCmdActionsDeleteCalEvent:
  3405        	case EFsEmailUiCmdActionsDeleteCalEvent:
  3347 		case EFsEmailUiCmdActionsDelete:
  3406 		case EFsEmailUiCmdActionsDelete:
  3348 			{
  3407 			{
       
  3408 			TIMESTAMP( "Delete to selected from message list" );    
  3349 			TInt index = HighlightedIndex();
  3409 			TInt index = HighlightedIndex();
  3350 			CFSEmailUiMailListModelItem* item =
  3410 			CFSEmailUiMailListModelItem* item =
  3351 				dynamic_cast<CFSEmailUiMailListModelItem*>(
  3411 				dynamic_cast<CFSEmailUiMailListModelItem*>(
  3352 						iModel->Item( index ) );
  3412 						iModel->Item( index ) );
  3353 
  3413 
  3368 				}
  3428 				}
  3369 			}
  3429 			}
  3370             break;
  3430             break;
  3371 		case EFsEmailUiCmdCompose:
  3431 		case EFsEmailUiCmdCompose:
  3372 			{
  3432 			{
       
  3433 			TIMESTAMP( "Create new message selected from message list" );    
  3373 			CreateNewMsgL();
  3434 			CreateNewMsgL();
  3374 			}
  3435 			}
  3375 			break;
  3436 			break;
  3376        	case EFsEmailUiCmdMessageDetails:
  3437        	case EFsEmailUiCmdMessageDetails:
  3377 			{
  3438 			{
  3419        		}
  3480        		}
  3420        		break;
  3481        		break;
  3421        	case EFsEmailUiCmdOpen:
  3482        	case EFsEmailUiCmdOpen:
  3422         case EFsEmailUiCmdActionsOpen:
  3483         case EFsEmailUiCmdActionsOpen:
  3423         	{
  3484         	{
       
  3485         	TIMESTAMP( "Open email selected from message list" );        
  3424 	        if ( iFocusedControl == EMailListComponent )
  3486 	        if ( iFocusedControl == EMailListComponent )
  3425 	            {
  3487 	            {
  3426 	            // Opening can happen only when there's exactly one message marked or in focus
  3488 	            // Opening can happen only when there's exactly one message marked or in focus
  3427 	            if ( actionTargetItems.Count() == 1 )
  3489 	            if ( actionTargetItems.Count() == 1 )
  3428 	                {
  3490 	                {
  3534 			    if(!GetLatestSyncState())
  3596 			    if(!GetLatestSyncState())
  3535 			        {
  3597 			        {
  3536 			        iAppUi.SyncActiveMailBoxL();
  3598 			        iAppUi.SyncActiveMailBoxL();
  3537 			        // Sync was started by the user
  3599 			        // Sync was started by the user
  3538 			        ManualMailBoxSync(ETrue);
  3600 			        ManualMailBoxSync(ETrue);
  3539                     iAppUi.ManualMailBoxSync( ETrue );
  3601                                 iAppUi.ManualMailBoxSync( ETrue );
  3540 			        }
  3602 			        }
  3541 			    }
  3603 			    }
  3542 			}
  3604 			}
  3543 			break;
  3605 			break;
  3544        	case EFsEmailUiCmdCancelSync:
  3606        	case EFsEmailUiCmdCancelSync:
  3545        		{
  3607        		{
  3546 			TBool supportsSync = iAppUi.GetActiveMailbox()->HasCapability( EFSMBoxCapaSupportsSync );
  3608 		TBool supportsSync = iAppUi.GetActiveMailbox()->HasCapability( EFSMBoxCapaSupportsSync );
  3547 			if ( supportsSync )
  3609 		if ( supportsSync )
  3548 				{
  3610 		    {
  3549 	       		iAppUi.StopActiveMailBoxSyncL();
  3611 	            iAppUi.StopActiveMailBoxSyncL();
  3550 				}
  3612 	            // Sync was started by the user
       
  3613 	            ManualMailBoxSync(ETrue);
       
  3614 	            iAppUi.ManualMailBoxSync( ETrue );
       
  3615 		    }
  3551        		}
  3616        		}
  3552        		break;
  3617        		break;
  3553         case EFsEmailUiCmdGoOffline:
  3618         case EFsEmailUiCmdGoOffline:
  3554         	{
  3619         	{
  3555     	   	iAppUi.GetActiveMailbox()->GoOfflineL();
  3620     	   	iAppUi.GetActiveMailbox()->GoOfflineL();
  3779 
  3844 
  3780 	    default:
  3845 	    default:
  3781         	break;
  3846         	break;
  3782         } // switch ( aCommand )
  3847         } // switch ( aCommand )
  3783     CleanupStack::PopAndDestroy( &actionTargetItems );
  3848     CleanupStack::PopAndDestroy( &actionTargetItems );
       
  3849     TIMESTAMP( "Message list selected operation done" );    
  3784     }
  3850     }
  3785 
  3851 
  3786 // ---------------------------------------------------------------------------
  3852 // ---------------------------------------------------------------------------
  3787 //
  3853 //
  3788 //
  3854 //
  4337                             if ( item && item->ModelItemType() == ETypeMailItem )
  4403                             if ( item && item->ModelItemType() == ETypeMailItem )
  4338                                 {
  4404                                 {
  4339                                 CFSMailMessage* messagePtr = &item->MessagePtr();
  4405                                 CFSMailMessage* messagePtr = &item->MessagePtr();
  4340                                 if ( messagePtr )
  4406                                 if ( messagePtr )
  4341                                     {
  4407                                     {
       
  4408                                     TIMESTAMP( "Open email selected from message list" );    
  4342                                     OpenHighlightedMailL();
  4409                                     OpenHighlightedMailL();
  4343                                     return EKeyWasConsumed;
  4410                                     return EKeyWasConsumed;
  4344                                     }
  4411                                     }
  4345                                 }
  4412                                 }
  4346                             // SEPARAOR ITEM; COLLAPSE / EXPAND NODE
  4413                             // SEPARAOR ITEM; COLLAPSE / EXPAND NODE
  4549         if ( item && item->ModelItemType() == ETypeMailItem )
  4616         if ( item && item->ModelItemType() == ETypeMailItem )
  4550             {
  4617             {
  4551             CFSMailMessage* messagePtr = &item->MessagePtr();
  4618             CFSMailMessage* messagePtr = &item->MessagePtr();
  4552             if ( messagePtr )
  4619             if ( messagePtr )
  4553                 {
  4620                 {
       
  4621                 TIMESTAMP( "Open email selected from message list" );
  4554                 OpenHighlightedMailL();
  4622                 OpenHighlightedMailL();
  4555                 }
  4623                 }
  4556             }
  4624             }
  4557         // SEPARATOR ITEM; COLLAPSE / EXPAND NODE
  4625         // SEPARATOR ITEM; COLLAPSE / EXPAND NODE
  4558         else if ( item && item->ModelItemType() == ETypeSeparator )
  4626         else if ( item && item->ModelItemType() == ETypeSeparator )
  5328                 // Send flags, local and server
  5396                 // Send flags, local and server
  5329                 msgPtr.ResetFlag( EFSMsgFlag_Read );
  5397                 msgPtr.ResetFlag( EFSMsgFlag_Read );
  5330                 }
  5398                 }
  5331             msgPtr.SaveMessageL();  // Save flag
  5399             msgPtr.SaveMessageL();  // Save flag
  5332 
  5400 
  5333             // Switch icon to correct one
  5401             if ( !iMailOpened )
  5334             UpdateMsgIconAndBoldingL( aIndex );
  5402                 {
       
  5403                 // Switch icon to correct one if mail list is visible
       
  5404                 UpdateMsgIconAndBoldingL( aIndex );
       
  5405                 }
  5335 
  5406 
  5336             if ( iCurrentSortCriteria.iField == EFSMailSortByUnread )
  5407             if ( iCurrentSortCriteria.iField == EFSMailSortByUnread )
  5337                 {
  5408                 {
  5338                 // Attribute affecting the current sorting order has been changed.
  5409                 // Attribute affecting the current sorting order has been changed.
  5339                 // Thus, the list order may now be incorrect.
  5410                 // Thus, the list order may now be incorrect.
  5614     			iTreeItemArray.Remove( idx ); // remove from internal array.
  5685     			iTreeItemArray.Remove( idx ); // remove from internal array.
  5615     	 		iModel->RemoveAndDestroy( idx ); // Remove from model
  5686     	 		iModel->RemoveAndDestroy( idx ); // Remove from model
  5616         	    }
  5687         	    }
  5617     		}
  5688     		}
  5618 	    }
  5689 	    }
       
  5690 	if ( aEntryIds.Count() > 0  )
       
  5691 		{
       
  5692         if ( iMailListUpdater )
       
  5693             {
       
  5694             if ( iMailListUpdater->IsActive() )
       
  5695                 {
       
  5696                 iMailListUpdater->Stop();
       
  5697                 }
       
  5698              iMailListUpdater->StartL();
       
  5699              }
       
  5700 		}
  5619 	if ( iNodesInUse )
  5701 	if ( iNodesInUse )
  5620 		{
  5702 		{
  5621 		RemoveUnnecessaryNodesL();
  5703 		RemoveUnnecessaryNodesL();
  5622 		}
  5704 		}
  5623 
  5705 
  6398 	        CFSMailMessage* confirmedMsgPtr(0);
  6480 	        CFSMailMessage* confirmedMsgPtr(0);
  6399 	        confirmedMsgPtr = iAppUi.GetMailClient()->GetMessageByUidL(iAppUi.GetActiveMailboxId(),
  6481 	        confirmedMsgPtr = iAppUi.GetMailClient()->GetMessageByUidL(iAppUi.GetActiveMailboxId(),
  6400 	                iMailFolder->GetFolderId(), item->MessagePtr().GetMessageId(), EFSMsgDataEnvelope );
  6482 	                iMailFolder->GetFolderId(), item->MessagePtr().GetMessageId(), EFSMsgDataEnvelope );
  6401 	        if ( confirmedMsgPtr )
  6483 	        if ( confirmedMsgPtr )
  6402 	            {
  6484 	            {
       
  6485 	            iMailOpened = ETrue;
       
  6486 	            
  6403 	            ChangeMskCommandL( R_FSE_QTN_MSK_EMPTY );
  6487 	            ChangeMskCommandL( R_FSE_QTN_MSK_EMPTY );
  6404 	            // Pointer confirmed, store Id and delete not needed anymore
  6488 	            // Pointer confirmed, store Id and delete not needed anymore
  6405 	            TFSMailMsgId confirmedId = confirmedMsgPtr->GetMessageId();
  6489 	            TFSMailMsgId confirmedId = confirmedMsgPtr->GetMessageId();
  6406 	      		TBool isCalMessage = confirmedMsgPtr->IsFlagSet( EFSMsgFlag_CalendarMsg );
  6490 	      		TBool isCalMessage = confirmedMsgPtr->IsFlagSet( EFSMsgFlag_CalendarMsg );
  6407 	      		TBool isReadMessage = confirmedMsgPtr->IsFlagSet( EFSMsgFlag_Read );
  6491 	      		TBool isReadMessage = confirmedMsgPtr->IsFlagSet( EFSMsgFlag_Read );
  6487     {
  6571     {
  6488     FUNC_LOG;
  6572     FUNC_LOG;
  6489     iDateChanged = ETrue;
  6573     iDateChanged = ETrue;
  6490     if ( iAppUi.IsForeground() )
  6574     if ( iAppUi.IsForeground() )
  6491         {
  6575         {
  6492         HandleForegroundEventL();
  6576         HandleForegroundEventL(ETrue);
  6493         }
  6577         }
  6494     }
  6578     }
  6495 
  6579 
  6496 // ---------------------------------------------------------------------------
  6580 // ---------------------------------------------------------------------------
  6497 // CreateFolderNameLC
  6581 // CreateFolderNameLC
  6564 	// Irrelevant items for focused mail list item get dimmed at runtime
  6648 	// Irrelevant items for focused mail list item get dimmed at runtime
  6565 
  6649 
  6566 	// Check mail list item's type
  6650 	// Check mail list item's type
  6567 	CFSEmailUiMailListModelItem* item =
  6651 	CFSEmailUiMailListModelItem* item =
  6568 		static_cast<CFSEmailUiMailListModelItem*>( iModel->Item( HighlightedIndex() ) );
  6652 		static_cast<CFSEmailUiMailListModelItem*>( iModel->Item( HighlightedIndex() ) );
  6569 	if ( item && item->ModelItemType() == ETypeMailItem )
  6653 	if ( item )
  6570 		{
  6654 		{
  6571 		// Add mark as read / unread options
  6655 		if ( item->ModelItemType() == ETypeMailItem )
  6572 		iStylusPopUpMenu->SetItemDimmed( EFsEmailUiCmdMarkAsUnread, !IsMarkAsUnreadAvailableL() );
       
  6573 		iStylusPopUpMenu->SetItemDimmed( EFsEmailUiCmdMarkAsRead, !IsMarkAsReadAvailableL() );
       
  6574 
       
  6575 		// Check support for object mail iten moving
       
  6576 		TBool supportsMoving = iAppUi.GetActiveMailbox()->HasCapability( EFSMBoxCapaMoveToFolder );
       
  6577 		iStylusPopUpMenu->SetItemDimmed( EFsEmailUiCmdActionsMoveMessage, !supportsMoving );
       
  6578 
       
  6579 		// Hide / show follow up
       
  6580 		TBool supportsFlag = TFsEmailUiUtility::IsFollowUpSupported( *iAppUi.GetActiveMailbox() );
       
  6581 		iStylusPopUpMenu->SetItemDimmed( EFsEmailUiCmdActionsFlag, !supportsFlag );
       
  6582 
       
  6583 		// Hide mark if applicable
       
  6584 		if ( iMailList->IsMarked( iMailList->FocusedItem() ) )
       
  6585 			{
  6656 			{
  6586 			iStylusPopUpMenu->SetItemDimmed( EFsEmailUiCmdMark, ETrue );
  6657 			// Add mark as read / unread options
  6587 			}
  6658 			iStylusPopUpMenu->SetItemDimmed( EFsEmailUiCmdMarkAsUnread, !IsMarkAsUnreadAvailableL() );
  6588 
  6659 			iStylusPopUpMenu->SetItemDimmed( EFsEmailUiCmdMarkAsRead, !IsMarkAsReadAvailableL() );
  6589 		// Hide collapse / expand all
  6660 	
  6590 		iStylusPopUpMenu->SetItemDimmed( EFsEmailUiCmdActionsCollapseAll, ETrue );
  6661 			// Check support for object mail iten moving
  6591 		iStylusPopUpMenu->SetItemDimmed( EFsEmailUiCmdActionsExpandAll, ETrue );
  6662 			TBool supportsMoving = iAppUi.GetActiveMailbox()->HasCapability( EFSMBoxCapaMoveToFolder );
  6592 		}
  6663 			iStylusPopUpMenu->SetItemDimmed( EFsEmailUiCmdActionsMoveMessage, !supportsMoving );
  6593 	else if ( item->ModelItemType() == ETypeSeparator )
  6664 	
  6594 		{
  6665 			// Hide / show follow up
  6595 		// Hide mark as read / unread options
  6666 			TBool supportsFlag = TFsEmailUiUtility::IsFollowUpSupported( *iAppUi.GetActiveMailbox() );
  6596 		iStylusPopUpMenu->SetItemDimmed( EFsEmailUiCmdMarkAsUnread, ETrue );
  6667 			iStylusPopUpMenu->SetItemDimmed( EFsEmailUiCmdActionsFlag, !supportsFlag );
  6597 		iStylusPopUpMenu->SetItemDimmed( EFsEmailUiCmdMarkAsRead, ETrue );
  6668 	
  6598 
  6669 			// Hide mark if applicable
  6599 		// Hide move & follow up
  6670 			if ( iMailList->IsMarked( iMailList->FocusedItem() ) )
  6600 		iStylusPopUpMenu->SetItemDimmed( EFsEmailUiCmdActionsMoveMessage, ETrue );
  6671 				{
  6601 		iStylusPopUpMenu->SetItemDimmed( EFsEmailUiCmdActionsFlag, ETrue );
  6672 				iStylusPopUpMenu->SetItemDimmed( EFsEmailUiCmdMark, ETrue );
  6602 
  6673 				}
  6603 		// Hide collapse / expand all when applicable
  6674 	
  6604 		if ( iNodesInUse == EListControlSeparatorDisabled || !iModel->Count() )
  6675 			// Hide collapse / expand all
  6605 			{
       
  6606 			iStylusPopUpMenu->SetItemDimmed( EFsEmailUiCmdActionsCollapseAll, ETrue );
  6676 			iStylusPopUpMenu->SetItemDimmed( EFsEmailUiCmdActionsCollapseAll, ETrue );
  6607 			iStylusPopUpMenu->SetItemDimmed( EFsEmailUiCmdActionsExpandAll, ETrue );
  6677 			iStylusPopUpMenu->SetItemDimmed( EFsEmailUiCmdActionsExpandAll, ETrue );
  6608 			}
  6678 			}
  6609 		else
  6679 		else if ( item->ModelItemType() == ETypeSeparator )
  6610 			{
  6680 			{
  6611 			iStylusPopUpMenu->SetItemDimmed( EFsEmailUiCmdActionsCollapseAll, AllNodesCollapsed() );
  6681 			// Hide mark as read / unread options
  6612 			iStylusPopUpMenu->SetItemDimmed( EFsEmailUiCmdActionsExpandAll, AllNodesExpanded() );
  6682 			iStylusPopUpMenu->SetItemDimmed( EFsEmailUiCmdMarkAsUnread, ETrue );
       
  6683 			iStylusPopUpMenu->SetItemDimmed( EFsEmailUiCmdMarkAsRead, ETrue );
       
  6684 	
       
  6685 			// Hide move & follow up
       
  6686 			iStylusPopUpMenu->SetItemDimmed( EFsEmailUiCmdActionsMoveMessage, ETrue );
       
  6687 			iStylusPopUpMenu->SetItemDimmed( EFsEmailUiCmdActionsFlag, ETrue );
       
  6688 	
       
  6689 			// Hide collapse / expand all when applicable
       
  6690 			if ( iNodesInUse == EListControlSeparatorDisabled || !iModel->Count() )
       
  6691 				{
       
  6692 				iStylusPopUpMenu->SetItemDimmed( EFsEmailUiCmdActionsCollapseAll, ETrue );
       
  6693 				iStylusPopUpMenu->SetItemDimmed( EFsEmailUiCmdActionsExpandAll, ETrue );
       
  6694 				}
       
  6695 			else
       
  6696 				{
       
  6697 				iStylusPopUpMenu->SetItemDimmed( EFsEmailUiCmdActionsCollapseAll, AllNodesCollapsed() );
       
  6698 				iStylusPopUpMenu->SetItemDimmed( EFsEmailUiCmdActionsExpandAll, AllNodesExpanded() );
       
  6699 				}
  6613 			}
  6700 			}
  6614 		}
  6701 		}
  6615 
  6702 
  6616 	// Set the position for the popup
  6703 	// Set the position for the popup
  6617 	iStylusPopUpMenu->SetPosition( aPoint );
  6704 	iStylusPopUpMenu->SetPosition( aPoint );
  6849                 // event is not related to the current folder => do nothing
  6936                 // event is not related to the current folder => do nothing
  6850                 }
  6937                 }
  6851 			}
  6938 			}
  6852 		else if ( aEvent == TFSEventMailChanged && iMailFolder ) // Added iMailFolder null safety check
  6939 		else if ( aEvent == TFSEventMailChanged && iMailFolder ) // Added iMailFolder null safety check
  6853 			{
  6940 			{
  6854 			// Change mail item icon or read status
  6941 			if ( !iMailOpened ) // do not handle mail changed while viewer/editor is open. This may cause flickering
  6855 			RArray<TFSMailMsgId>* entries = static_cast<RArray<TFSMailMsgId>*>( aParam1 );
  6942 			    {
  6856 			TFSMailMsgId* parentFolderId = static_cast<TFSMailMsgId*>( aParam2 );
  6943     			// Change mail item icon or read status
  6857 			TFSMailMsgId currentFolderId = iMailFolder->GetFolderId();
  6944     			RArray<TFSMailMsgId>* entries = static_cast<RArray<TFSMailMsgId>*>( aParam1 );
  6858 			if ( *parentFolderId == currentFolderId )
  6945     			TFSMailMsgId* parentFolderId = static_cast<TFSMailMsgId*>( aParam2 );
  6859 				{
  6946     			TFSMailMsgId currentFolderId = iMailFolder->GetFolderId();
  6860  	 			// Refresh mailfolder to get correct actual data
  6947     			if ( *parentFolderId == currentFolderId )
  6861 				/*
  6948     				{
  6862                 iMailListModelUpdater->Cancel();
  6949      	 			// Refresh mailfolder to get correct actual data
  6863                 SafeDelete(iMailFolder);
  6950     				/*
  6864 				iMailFolder = iAppUi.GetMailClient()->GetFolderByUidL( aMailboxId, currentFolderId );
  6951                     iMailListModelUpdater->Cancel();
  6865 				*/
  6952                     SafeDelete(iMailFolder);
  6866 				for ( TInt i=0 ; i<entries->Count() ; i++ )
  6953     				iMailFolder = iAppUi.GetMailClient()->GetFolderByUidL( aMailboxId, currentFolderId );
  6867 					{
  6954     				*/
  6868 					TFSMailMsgId msgId = (*entries)[i];
  6955     				for ( TInt i=0 ; i<entries->Count() ; i++ )
  6869 					TInt idx = ItemIndexFromMessageId( msgId );
  6956     					{
  6870 					if ( idx != KErrNotFound )
  6957     					TFSMailMsgId msgId = (*entries)[i];
  6871 					    {
  6958     					TInt idx = ItemIndexFromMessageId( msgId );
  6872 					    UpdateItemAtIndexL( idx );
  6959     					if ( idx != KErrNotFound )
  6873 					    }
  6960     					    {
  6874 					}
  6961     					    UpdateItemAtIndexL( idx );
  6875 				}
  6962     					    }
       
  6963     					}
       
  6964     				}
       
  6965 			    }
  6876 			}
  6966 			}
  6877    		else if ( aEvent == TFSEventMailboxSyncStateChanged )
  6967    		else if ( aEvent == TFSEventMailboxSyncStateChanged )
  6878    			{
  6968    			{
  6879 	  		TSSMailSyncState* newSyncState = static_cast<TSSMailSyncState*>( aParam1 );
  6969 	  		TSSMailSyncState* newSyncState = static_cast<TSSMailSyncState*>( aParam1 );
  6880     		if ( newSyncState != 0 && *newSyncState != 0 )
  6970     		if ( newSyncState != 0 && *newSyncState != 0 )
  6881     			{
  6971     			{
  6882 	    		switch ( *newSyncState )
  6972 	    		switch ( *newSyncState )
  6883 	    			{
  6973 	    			{
  6884 	    			case StartingSync:
  6974 	    			case StartingSync:
  6885 	   					{
  6975 	   			    {
  6886 	   					//If sync was started by user, show the synchronisation indicator
  6976 	   			    //If sync was started by user, show the synchronisation indicator
  6887 	   					if ( iManualMailBoxSync )
  6977 	   			    if ( iManualMailBoxSync )
  6888 	   						{
  6978 	   			        {
  6889 			   		     	ManualMailBoxSync(EFalse);
  6979 			   		ManualMailBoxSync(EFalse);
  6890 	   						}
  6980 	   				}
  6891 		   				}
  6981 		   		    }
  6892 						break;
  6982 				    break;
       
  6983 						
       
  6984 	    			case SyncCancelled:
       
  6985 	    			    {
       
  6986 	    			    //If sync was started by user, show the synchronisation indicator
       
  6987 	    			    if ( iManualMailBoxSync )
       
  6988 	    			        {
       
  6989 	    			        ManualMailBoxSync(EFalse);
       
  6990 	    			        }
       
  6991 	    			    }
       
  6992 	    			    break;
       
  6993 						
  6893 	    			}
  6994 	    			}
  6894     			}
  6995     			}
  6895 			}
  6996 			}
  6896 		}
  6997 		}
  6897 	}
  6998 	}