emailuis/emailui/src/FreestyleEmailUiMailListVisualiser.cpp
changeset 1 12c456ceeff2
parent 0 8466d47a6819
child 2 5253a20d2a1e
equal deleted inserted replaced
0:8466d47a6819 1:12c456ceeff2
    37 #include "fstreeplainonelinenodevisualizer.h"
    37 #include "fstreeplainonelinenodevisualizer.h"
    38 #include "fstreeplaintwolineitemdata.h"
    38 #include "fstreeplaintwolineitemdata.h"
    39 #include "fstreeplaintwolineitemvisualizer.h"
    39 #include "fstreeplaintwolineitemvisualizer.h"
    40 #include "CFSMailCommon.h"
    40 #include "CFSMailCommon.h"
    41 #include "ceuiemaillisttouchmanager.h"
    41 #include "ceuiemaillisttouchmanager.h"
    42 //</cmail>
       
    43 #include "FSEmailBuildFlags.h"
    42 #include "FSEmailBuildFlags.h"
    44 //<cmail>
       
    45 #include "cfsccontactactionmenu.h"
    43 #include "cfsccontactactionmenu.h"
    46 #include "mfsccontactactionmenumodel.h"
    44 #include "mfsccontactactionmenumodel.h"
    47 //</cmail>
       
    48 
    45 
    49 #include <hlplch.h>
    46 #include <hlplch.h>
    50 #include <AknIconArray.h>
    47 #include <AknIconArray.h>
    51 // <cmail> SF
       
    52 #include <alf/alfdecklayout.h>
    48 #include <alf/alfdecklayout.h>
    53 #include <alf/alfcontrolgroup.h>
    49 #include <alf/alfcontrolgroup.h>
    54 #include <alf/alfframebrush.h>
    50 #include <alf/alfframebrush.h>
    55 #include <alf/alfevent.h>
    51 #include <alf/alfevent.h>
    56 #include <alf/alfstatic.h>
    52 #include <alf/alfstatic.h>
    57 // </cmail>
       
    58 
    53 
    59 #include <aknnotewrappers.h>
    54 #include <aknnotewrappers.h>
    60 #include <msvapi.h>
    55 #include <msvapi.h>
    61 #include <akntitle.h>
    56 #include <akntitle.h>
    62 //<cmail>
    57 //<cmail>
    74 #include <MeetingRequestUids.hrh>
    69 #include <MeetingRequestUids.hrh>
    75 // <cmail>
    70 // <cmail>
    76 #include "cesmricalviewer.h"
    71 #include "cesmricalviewer.h"
    77 //</cmail>
    72 //</cmail>
    78 #include <aknstyluspopupmenu.h>
    73 #include <aknstyluspopupmenu.h>
       
    74 #include <akntoolbar.h>
    79 
    75 
    80 // INTERNAL INCLUDES
    76 // INTERNAL INCLUDES
    81 #include "FreestyleEmailUiUtilities.h"
    77 #include "FreestyleEmailUiUtilities.h"
    82 #include "FreestyleEmailUiLiterals.h"
    78 #include "FreestyleEmailUiLiterals.h"
    83 #include "FreestyleEmailUiLayoutHandler.h"
    79 #include "FreestyleEmailUiLayoutHandler.h"
   101 #include "FSDelayedLoader.h"
    97 #include "FSDelayedLoader.h"
   102 #include "FSEmail.pan"
    98 #include "FSEmail.pan"
   103 
    99 
   104 // CONST VALUES
   100 // CONST VALUES
   105 const TInt KControlBarTransitionTime = 250;
   101 const TInt KControlBarTransitionTime = 250;
   106 //<cmail>
       
   107 //const TInt KFirstButtonStartPosX = 25;
       
   108 //const TInt KControlBarMailboxIconWidth = 20;
       
   109 //const TInt KControlButtonPosY = 3;
       
   110 //const TInt KControlButtonSeparation = 10;
       
   111 //</cmail>
       
   112 const TInt KMaxPreviewPaneLength = 60;
   102 const TInt KMaxPreviewPaneLength = 60;
   113 //const TInt KInitialPreviewUpdate = 5;
       
   114 //const TInt KSyncIconTimerDelay = 18000;
       
   115 const TInt KMsgUpdaterTimerDelay = 2500000; // Time to update list, 2,5sec
   103 const TInt KMsgUpdaterTimerDelay = 2500000; // Time to update list, 2,5sec
   116 static const TInt KMsgDeletionWaitNoteAmount = 5;
   104 static const TInt KMsgDeletionWaitNoteAmount = 5;
   117 _LIT( KMissingPreviewDataMarker, "..." );
   105 _LIT( KMissingPreviewDataMarker, "..." );
   118 
   106 
   119 static const TInt KMaxItemsFethed = 1000;
   107 static const TInt KMaxItemsFethed = 1000;
   249     iMailTreeListVisualizer->SetSelectorPropertiesL( listSelectorBrush, 1.0, CFsTreeVisualizerBase::EFsSelectorMoveSmoothly );
   237     iMailTreeListVisualizer->SetSelectorPropertiesL( listSelectorBrush, 1.0, CFsTreeVisualizerBase::EFsSelectorMoveSmoothly );
   250 
   238 
   251     CAlfBrush* cbSelectorBrush = iAppUi.FsTextureManager()->NewCtrlBarSelectorBrushLC();
   239     CAlfBrush* cbSelectorBrush = iAppUi.FsTextureManager()->NewCtrlBarSelectorBrushLC();
   252     iControlBarControl->SetSelectorImageL( cbSelectorBrush );
   240     iControlBarControl->SetSelectorImageL( cbSelectorBrush );
   253     CleanupStack::Pop( cbSelectorBrush ); // ownership transferred to control bar
   241     CleanupStack::Pop( cbSelectorBrush ); // ownership transferred to control bar
       
   242 
       
   243     iNewEmailText = StringLoader::LoadL( R_COMMAND_AREA_NEW_EMAIL );
   254 
   244 
   255     // Set menu, mark and background icons
   245     // Set menu, mark and background icons
   256     iMailTreeListVisualizer->SetMarkIcon( iAppUi.FsTextureManager()->TextureByIndex( EListControlMarkIcon ) );
   246     iMailTreeListVisualizer->SetMarkIcon( iAppUi.FsTextureManager()->TextureByIndex( EListControlMarkIcon ) );
   257     iMailTreeListVisualizer->SetMenuIcon( iAppUi.FsTextureManager()->TextureByIndex( EListControlMenuIcon ) );
   247     iMailTreeListVisualizer->SetMenuIcon( iAppUi.FsTextureManager()->TextureByIndex( EListControlMenuIcon ) );
   258     //<cmail> s60 skin support
   248     //<cmail> s60 skin support
   297 CFSEmailUiMailListVisualiser::CFSEmailUiMailListVisualiser( CAlfEnv& aEnv,
   287 CFSEmailUiMailListVisualiser::CFSEmailUiMailListVisualiser( CAlfEnv& aEnv,
   298     CFreestyleEmailUiAppUi* aAppUi, CAlfControlGroup& aMailListControlGroup )
   288     CFreestyleEmailUiAppUi* aAppUi, CAlfControlGroup& aMailListControlGroup )
   299     : CFsEmailUiViewBase( aMailListControlGroup, *aAppUi ),
   289     : CFsEmailUiViewBase( aMailListControlGroup, *aAppUi ),
   300     iEnv( aEnv ),
   290     iEnv( aEnv ),
   301     iListMarkItemsState( ETrue ), //Initlly list has no markings
   291     iListMarkItemsState( ETrue ), //Initlly list has no markings
   302 	iMoveToFolderOngoing( EFalse )
   292 	iMoveToFolderOngoing( EFalse ),
       
   293 	iStylusPopUpMenuLaunched( EFalse )
   303 	{
   294 	{
   304     FUNC_LOG;
   295     FUNC_LOG;
   305 	}
   296 	}
   306 
   297 
   307 // ---------------------------------------------------------------------------
   298 // ---------------------------------------------------------------------------
   309 // ---------------------------------------------------------------------------
   300 // ---------------------------------------------------------------------------
   310 //
   301 //
   311 CFSEmailUiMailListVisualiser::~CFSEmailUiMailListVisualiser()
   302 CFSEmailUiMailListVisualiser::~CFSEmailUiMailListVisualiser()
   312     {
   303     {
   313     FUNC_LOG;
   304     FUNC_LOG;
   314     //<cmail>
       
   315     if ( iMailFolder )
   305     if ( iMailFolder )
   316         {
   306         {
   317         delete iMailFolder;
   307         delete iMailFolder;
   318         iMailFolder = NULL;
   308         iMailFolder = NULL;
   319         }
   309         }
   320 
   310 
   321     delete iTouchManager;
   311     delete iTouchManager;
   322     delete iStylusPopUpMenu;
   312     delete iStylusPopUpMenu;
   323     //</cmail>
       
   324     delete iMailList;
   313     delete iMailList;
       
   314     delete iNewEmailText;
   325 
   315 
   326 	// Don't construct this anywhere else than in constructor.
   316 	// Don't construct this anywhere else than in constructor.
   327 	// Don't delete anywhere else thatn here to avoid NULL checks.
   317 	// Don't delete anywhere else thatn here to avoid NULL checks.
   328     delete iModel;
   318     delete iModel;
   329     }
   319     }
   461 //
   451 //
   462 void CFSEmailUiMailListVisualiser::CreateModelItemsL( RPointerArray<CFSMailMessage>& aMessages )
   452 void CFSEmailUiMailListVisualiser::CreateModelItemsL( RPointerArray<CFSMailMessage>& aMessages )
   463 	{
   453 	{
   464     FUNC_LOG;
   454     FUNC_LOG;
   465 	// New Items
   455 	// New Items
   466 	CFSEmailUiMailListModelItem* newItem(NULL);
   456 	CFSEmailUiMailListModelItem* newItem = NULL;
   467 
   457 
   468 	// Draw first separator if there are messages.
   458 	// Draw first separator if there are messages.
   469 	if ( aMessages.Count() && iNodesInUse == EListControlSeparatorEnabled )
   459 	if ( aMessages.Count() && iNodesInUse == EListControlSeparatorEnabled )
   470 		{
   460 		{
   471 	    newItem = CreateSeparatorModelItemLC( *aMessages[0] );
   461 	    newItem = CreateSeparatorModelItemLC( *aMessages[0] );
   949 // ---------------------------------------------------------------------------
   939 // ---------------------------------------------------------------------------
   950 //
   940 //
   951 //
   941 //
   952 // ---------------------------------------------------------------------------
   942 // ---------------------------------------------------------------------------
   953 //
   943 //
   954 // <cmail> Toolbar
       
   955 /*void CFSEmailUiMailListVisualiser::DoActivateL(const TVwsViewId& aPrevViewId,
       
   956                      TUid aCustomMessageId,
       
   957                      const TDesC8& aCustomMessage)*/
       
   958 // </cmail> Toolbar
       
   959 void CFSEmailUiMailListVisualiser::ChildDoActivateL(const TVwsViewId& aPrevViewId,
   944 void CFSEmailUiMailListVisualiser::ChildDoActivateL(const TVwsViewId& aPrevViewId,
   960                      TUid aCustomMessageId,
   945                      TUid aCustomMessageId,
   961                      const TDesC8& aCustomMessage)
   946                      const TDesC8& aCustomMessage)
   962 	{
   947 	{
   963     FUNC_LOG;
   948     FUNC_LOG;
   979 	if ( aCustomMessageId != KStartListReturnToPreviousFolder &&
   964 	if ( aCustomMessageId != KStartListReturnToPreviousFolder &&
   980 	     aCustomMessageId != TUid::Uid(KMailSettingsReturnFromPluginSettings) )
   965 	     aCustomMessageId != TUid::Uid(KMailSettingsReturnFromPluginSettings) )
   981 	    {
   966 	    {
   982 	    ViewEntered( aPrevViewId );
   967 	    ViewEntered( aPrevViewId );
   983 	    forwardNavigation = ETrue;
   968 	    forwardNavigation = ETrue;
       
   969 	    }
       
   970 
       
   971 	if( iAppUi.CurrentFixedToolbar() )
       
   972 	    {
       
   973         iAppUi.CurrentFixedToolbar()->SetToolbarVisibility( EFalse );
   984 	    }
   974 	    }
   985 
   975 
   986     // Set control bar and list layout size always in activation
   976     // Set control bar and list layout size always in activation
   987     TRect clientRect = iAppUi.ClientRect();
   977     TRect clientRect = iAppUi.ClientRect();
   988     iScreenAnchorLayout->SetSize( clientRect.Size() );
   978     iScreenAnchorLayout->SetSize( clientRect.Size() );
  1165     SetBrandedMailBoxIconL();
  1155     SetBrandedMailBoxIconL();
  1166 
  1156 
  1167     // Check sync icon timer and sync status
  1157     // Check sync icon timer and sync status
  1168     ConnectionIconHandling();
  1158     ConnectionIconHandling();
  1169 
  1159 
  1170 // <cmail>
       
  1171     iMailList->HideListL();
  1160     iMailList->HideListL();
  1172     iMailList->ShowListL();
  1161     iMailList->ShowListL();
  1173 // </cmail>
  1162 
  1174     // REBUILD TREE LIST IF NECESSARY
  1163     // REBUILD TREE LIST IF NECESSARY
  1175     if ( refreshNeeded )
  1164     if ( refreshNeeded )
  1176         {
  1165         {
  1177         // Try to maintain previously active item if possible.
  1166         // Try to maintain previously active item if possible.
  1178         // This is of course not possible if folder has changed.
  1167         // This is of course not possible if folder has changed.
  1187 
  1176 
  1188     // THE CORRECT FOLDER IS ALREADY OPEN. CHECK IF SOME PARTIAL UPDATE IS NEEDED.
  1177     // THE CORRECT FOLDER IS ALREADY OPEN. CHECK IF SOME PARTIAL UPDATE IS NEEDED.
  1189     else
  1178     else
  1190         {
  1179         {
  1191         // hide & show list to force it to adept to changed screen size
  1180         // hide & show list to force it to adept to changed screen size
  1192 	// <cmail>
  1181         SetListAndCtrlBarFocusL(); // ShowListL() makes list focused and this may need to be reverted
  1193       /*if ( iCurrentClientRect != clientRect )
       
  1194             {
       
  1195             iMailList->HideListL();
       
  1196             iMailList->ShowListL(); */
       
  1197             SetListAndCtrlBarFocusL(); // ShowListL() makes list focused and this may need to be reverted
       
  1198 //          }
       
  1199 	// </cmail>
       
  1200         UnmarkAllItemsL();
  1182         UnmarkAllItemsL();
  1201 
  1183 
  1202         if ( aCustomMessageId == TUid::Uid(KMailSettingsReturnFromPluginSettings) )
  1184         if ( aCustomMessageId == TUid::Uid(KMailSettingsReturnFromPluginSettings) )
  1203             {
  1185             {
  1204             // Better to refresh launcher grid view because mailbox branding might be changed.
  1186             // Better to refresh launcher grid view because mailbox branding might be changed.
  1219 
  1201 
  1220 	iShiftDepressed = EFalse; // clear state just in case
  1202 	iShiftDepressed = EFalse; // clear state just in case
  1221 
  1203 
  1222 	// Inform MR observer if needed, special MR case, returning from attachment list
  1204 	// Inform MR observer if needed, special MR case, returning from attachment list
  1223 	iAppUi.MailViewer().CompletePendingMrCommand();
  1205 	iAppUi.MailViewer().CompletePendingMrCommand();
  1224 // <cmail>
  1206 
  1225 	//Make sure that correct component is set to focused.
  1207 	//Make sure that correct component is set to focused.
  1226 	if ( iFocusedControl == EMailListComponent )
  1208 	if ( iFocusedControl == EMailListComponent )
       
  1209 	    {
  1227 	    SetTreeListFocusedL();
  1210 	    SetTreeListFocusedL();
       
  1211 	    }
  1228 	else
  1212 	else
       
  1213 	    {
  1229 	    SetControlBarFocusedL();
  1214 	    SetControlBarFocusedL();
  1230 // </cmail>
  1215 	    iControlBarControl->MakeSelectorVisible( iAppUi.IsFocusShown() );
  1231 
  1216 	    }
       
  1217 	UpdateButtonTextsL();
       
  1218 
       
  1219 	FocusVisibilityChange( iAppUi.IsFocusShown() );
  1232 	iAppUi.ShowTitlePaneConnectionStatus();
  1220 	iAppUi.ShowTitlePaneConnectionStatus();
  1233 	}
  1221 	}
  1234 
  1222 
  1235 // ---------------------------------------------------------------------------
  1223 // ---------------------------------------------------------------------------
  1236 // Sets status bar layout
  1224 // Sets status bar layout
  1237 // ---------------------------------------------------------------------------
  1225 // ---------------------------------------------------------------------------
  1238 //
  1226 //
  1239 void CFSEmailUiMailListVisualiser::SetStatusBarLayout()
  1227 void CFSEmailUiMailListVisualiser::SetStatusBarLayout()
  1240 	{
  1228 	{
  1241 	if ( StatusPane()->CurrentLayoutResId() !=  R_AVKON_STATUS_PANE_LAYOUT_IDLE_FLAT )
  1229     TInt res = R_AVKON_STATUS_PANE_LAYOUT_USUAL_FLAT;
       
  1230     if( Layout_Meta_Data::IsLandscapeOrientation() )
       
  1231         {
       
  1232         // landscape must use different layout
       
  1233         res = R_AVKON_STATUS_PANE_LAYOUT_IDLE_FLAT;
       
  1234         }
       
  1235 
       
  1236 	if ( StatusPane()->CurrentLayoutResId() != res )
  1242 		{
  1237 		{
  1243 		TRAP_IGNORE(
  1238 		TRAP_IGNORE(
  1244 			StatusPane()->SwitchLayoutL(  R_AVKON_STATUS_PANE_LAYOUT_IDLE_FLAT ));
  1239 			StatusPane()->SwitchLayoutL( res ));
  1245 		}
  1240 		}
  1246 	}
  1241 	}
  1247 
  1242 
  1248 
  1243 
  1249 // ---------------------------------------------------------------------------
  1244 // ---------------------------------------------------------------------------
  1537 				// move from outbox to drafts is allowed
  1532 				// move from outbox to drafts is allowed
  1538 				aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsMoveToDrafts, EFalse );	// Allow in outbox
  1533 				aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsMoveToDrafts, EFalse );	// Allow in outbox
  1539 				// moving from outbox is not allowed otherwise
  1534 				// moving from outbox is not allowed otherwise
  1540 				aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsMove, ETrue );
  1535 				aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsMove, ETrue );
  1541 				}
  1536 				}
       
  1537 			else if ( currentFolderType == EFSDraftsFolder )
       
  1538 				{
       
  1539 				// move from drafts to drafts is not allowed
       
  1540 				aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsMoveToDrafts, ETrue );
       
  1541 				// moving from drafts folder is not allowed
       
  1542 				aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsMove, ETrue );
       
  1543 				}
       
  1544 
  1542 			// Handle rest of the folders
  1545 			// Handle rest of the folders
  1543 			else
  1546 			else
  1544 				{
  1547 				{
  1545 				aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsMoveToDrafts, ETrue );	// Dim in other folders
  1548 				aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsMoveToDrafts, ETrue );	// Dim in other folders
  1546 				aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsMove, EFalse );
  1549 				aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsMove, EFalse );
  2436     FUNC_LOG;
  2439     FUNC_LOG;
  2437     CFsEmailUiViewBase::HandleDynamicVariantSwitchL( aType );
  2440     CFsEmailUiViewBase::HandleDynamicVariantSwitchL( aType );
  2438 
  2441 
  2439     if ( iFirstStartCompleted ) // Safety
  2442     if ( iFirstStartCompleted ) // Safety
  2440         {
  2443         {
       
  2444         if ( aType == EScreenLayoutChanged )
       
  2445         	{
       
  2446             SetStatusBarLayout();
       
  2447             UpdateButtonTextsL();
       
  2448         	}
       
  2449 
  2441         if ( aType == ESkinChanged )
  2450         if ( aType == ESkinChanged )
  2442             {
  2451             {
  2443             iSkinChanged = ETrue;
  2452             UpdateTheme();
  2444             }
  2453             }
  2445         else
  2454         else
  2446             {
  2455             {
  2447             iMailTreeListVisualizer->HideList();
  2456             iMailTreeListVisualizer->HideList();
  2448             // screen layout changed
  2457             // screen layout changed
  2467 // ---------------------------------------------------------------------------
  2476 // ---------------------------------------------------------------------------
  2468 //
  2477 //
  2469 //
  2478 //
  2470 // ---------------------------------------------------------------------------
  2479 // ---------------------------------------------------------------------------
  2471 //
  2480 //
  2472 void CFSEmailUiMailListVisualiser::HandleDynamicVariantSwitchOnBackgroundL( CFsEmailUiViewBase::TDynamicSwitchType aType )
  2481 void CFSEmailUiMailListVisualiser::HandleDynamicVariantSwitchOnBackgroundL(
       
  2482         CFsEmailUiViewBase::TDynamicSwitchType aType )
  2473     {
  2483     {
  2474     FUNC_LOG;
  2484     FUNC_LOG;
  2475     CFsEmailUiViewBase::HandleDynamicVariantSwitchOnBackgroundL( aType );
  2485     CFsEmailUiViewBase::HandleDynamicVariantSwitchOnBackgroundL( aType );
  2476     if ( aType == ESkinChanged )
  2486     if ( aType == ESkinChanged )
  2477         {
  2487         {
  2478         iSkinChanged = ETrue;
  2488         UpdateTheme();
  2479         }
  2489         }
       
  2490     else if ( aType == EScreenLayoutChanged )
       
  2491         {
       
  2492         UpdateButtonTextsL();
       
  2493         }
       
  2494     }
       
  2495 
       
  2496 // ---------------------------------------------------------------------------
       
  2497 // Update texts for command area buttons
       
  2498 // ---------------------------------------------------------------------------
       
  2499 //
       
  2500 void CFSEmailUiMailListVisualiser::UpdateButtonTextsL()
       
  2501     {
       
  2502     if ( !Layout_Meta_Data::IsLandscapeOrientation() )
       
  2503         {
       
  2504         // No texts in portrait mode
       
  2505         iNewEmailButton->SetTextL( KNullDesC() );
       
  2506         iSortButton->SetTextL( KNullDesC() );
       
  2507         }
       
  2508     else
       
  2509         {
       
  2510         // Set button text if necessary
       
  2511         HBufC* buttonText = GetSortButtonTextLC();
       
  2512         if ( buttonText )
       
  2513             {
       
  2514             iSortButton->SetTextL( *buttonText );
       
  2515             CleanupStack::PopAndDestroy( buttonText );
       
  2516             }
       
  2517 
       
  2518         iNewEmailButton->SetTextL( *iNewEmailText );
       
  2519         }
       
  2520     }
       
  2521 
       
  2522 // ---------------------------------------------------------------------------
       
  2523 //
       
  2524 // ---------------------------------------------------------------------------
       
  2525 //
       
  2526 TBool CFSEmailUiMailListVisualiser::HitTest(
       
  2527         const CAlfControl& aControl, const TPoint& aPoint ) const
       
  2528     {
       
  2529     FUNC_LOG;
       
  2530     TBool contains( EFalse );
       
  2531     const TInt visualCount( aControl.VisualCount() );
       
  2532     for( TInt index( 0 ); index < visualCount && !contains; ++index )
       
  2533         {
       
  2534         TRect rect( aControl.Visual( index ).DisplayRectTarget() );
       
  2535         if( rect.Contains( aPoint ) )
       
  2536             {
       
  2537             contains = ETrue;
       
  2538             }
       
  2539         }
       
  2540     return contains;
       
  2541     }
       
  2542 
       
  2543 // ---------------------------------------------------------------------------
       
  2544 //
       
  2545 //
       
  2546 // ---------------------------------------------------------------------------
       
  2547 //
       
  2548 void CFSEmailUiMailListVisualiser::UpdateTheme()
       
  2549     {
       
  2550     iSkinChanged = ETrue;
       
  2551 
       
  2552     TRgb focusedTextColor = iAppUi.LayoutHandler()->ListFocusedStateTextSkinColor();
       
  2553     TRgb normalTextColor = iAppUi.LayoutHandler()->ListNormalStateTextSkinColor();
       
  2554 
       
  2555     iNewEmailButton->SetNormalTextColor( normalTextColor );
       
  2556     iNewEmailButton->SetFocusedTextColor( focusedTextColor );
       
  2557 
       
  2558     iFolderListButton->SetNormalTextColor( normalTextColor );
       
  2559     iFolderListButton->SetFocusedTextColor( focusedTextColor );
       
  2560 
       
  2561     iSortButton->SetNormalTextColor( normalTextColor );
       
  2562     iSortButton->SetFocusedTextColor( focusedTextColor );
  2480     }
  2563     }
  2481 
  2564 
  2482 // ---------------------------------------------------------------------------
  2565 // ---------------------------------------------------------------------------
  2483 // HandleForegroundEventL
  2566 // HandleForegroundEventL
  2484 // Function checks in foregroundevent that whether settings have changed and
  2567 // Function checks in foregroundevent that whether settings have changed and
  2595    	// Get list of marked or focused items.
  2678    	// Get list of marked or focused items.
  2596     RFsTreeItemIdList actionTargetItems;
  2679     RFsTreeItemIdList actionTargetItems;
  2597     CleanupClosePushL( actionTargetItems );
  2680     CleanupClosePushL( actionTargetItems );
  2598     GetActionsTargetEntriesL( actionTargetItems );
  2681     GetActionsTargetEntriesL( actionTargetItems );
  2599 
  2682 
  2600     switch(aCommand)
  2683     // Check if the focus needs to be removed.
       
  2684     if ( aCommand == KErrCancel || aCommand == EFsEmailUiCmdActionsDelete ||
       
  2685     	 aCommand == EFsEmailUiCmdMarkAsRead ||
       
  2686     	 aCommand == EFsEmailUiCmdMarkAsUnread ||
       
  2687     	 aCommand == EFsEmailUiCmdActionsMove ||
       
  2688     	 aCommand == EFsEmailUiCmdMarkUnmarkToggle )
       
  2689     	{
       
  2690    		// We end up here if the user selects an option from the pop up menu
       
  2691     	// or exits the menu by tapping outside of it's area.
       
  2692     	// Remove the focus from a list item if an item is focused.
       
  2693    		iStylusPopUpMenuLaunched = EFalse;
       
  2694    		FocusVisibilityChange( EFalse );
       
  2695     	}
       
  2696 
       
  2697     switch ( aCommand )
  2601         {
  2698         {
  2602     	case EAknSoftkeyOpen:
  2699     	case EAknSoftkeyOpen:
  2603 		{
  2700 		{
  2604 		if (!iAppUi.IsTimerFocusShown())
  2701 		if( !iAppUi.IsFocusShown() )
  2605 			{
  2702 			{
  2606 			iAppUi.StartFocusRemovalTimer();
  2703 			iAppUi.SetFocusVisibility( ETrue );
  2607 			break;
  2704 			break;
  2608 			}
  2705 			}
  2609 		}
  2706 		}
  2610        	case EAknSoftkeySelect:
  2707        	case EAknSoftkeySelect:
  2611        	    {
  2708        	    {
  2624        	        }
  2721        	        }
  2625        	    }
  2722        	    }
  2626        	    break;
  2723        	    break;
  2627        	case EAknSoftkeyChange:
  2724        	case EAknSoftkeyChange:
  2628        	    {
  2725        	    {
  2629     		if (!iAppUi.IsTimerFocusShown())
  2726     		if( !iAppUi.IsFocusShown() )
  2630     			{
  2727     			{
  2631     			iAppUi.StartFocusRemovalTimer();
  2728     			iAppUi.SetFocusVisibility( ETrue );
  2632     			break;
  2729     			break;
  2633     			}
  2730     			}
  2634        	    if ( iFocusedControl == EControlBarComponent )
  2731        	    if( iFocusedControl == EControlBarComponent )
  2635        	        {
  2732        	        {
  2636        	        TInt focusedButtonId = iControlBarControl->GetFocusedButton()->Id();
  2733        	        TInt focusedButtonId = iControlBarControl->GetFocusedButton()->Id();
  2637        	        if ( focusedButtonId == iFolderListButtonId )
  2734        	        if ( focusedButtonId == iFolderListButtonId )
  2638        	            {
  2735        	            {
  2639                     //<cmail>
  2736                     //<cmail>
  2640                     //Set touchmanager not active for preventing getting events.
  2737                     //Set touchmanager not active for preventing getting events.
  2641                     DisableMailList(ETrue);
  2738                     DisableMailList(ETrue);
  2642                     //</cmail>
  2739                     //</cmail>
  2643        	            iAppUi.ShowFolderListInPopupL( FolderId(), this, iFolderListButton );
  2740        	            iAppUi.ShowFolderListInPopupL( FolderId(), this, iFolderListButton );
  2644        	            }
  2741        	            }
  2645        	        else if ( focusedButtonId == iSortButtonId )
  2742        	        else if( focusedButtonId == iSortButtonId )
  2646        	            {
  2743        	            {
  2647        	            TFSFolderType folderType;
  2744        	            TFSFolderType folderType;
  2648        	            if( iMailFolder )
  2745        	            if( iMailFolder )
  2649        	                {
  2746        	                {
  2650        	                folderType = iMailFolder->GetFolderType();
  2747        	                folderType = iMailFolder->GetFolderType();
  2660                     // </cmail>
  2757                     // </cmail>
  2661                         //<cmail>
  2758                         //<cmail>
  2662                         //Set touchmanager not active for preventing getting events.
  2759                         //Set touchmanager not active for preventing getting events.
  2663                         DisableMailList(ETrue);
  2760                         DisableMailList(ETrue);
  2664                         //</cmail>
  2761                         //</cmail>
  2665                         iAppUi.ShowSortListInPopupL( iCurrentSortCriteria.iField, folderType, this, iSortButton );
  2762                         iAppUi.ShowSortListInPopupL( iCurrentSortCriteria, folderType, this, iSortButton );
  2666                     // <cmail>
  2763                     // <cmail>
  2667                     //    }
  2764                     //    }
  2668                     // </cmail>
  2765                     // </cmail>
  2669        	            }
  2766        	            }
  2670        	        }
  2767        	        }
  2832 
  2929 
  2833 			if ( iFocusedControl == EMailListComponent || markedItems )
  2930 			if ( iFocusedControl == EMailListComponent || markedItems )
  2834 				{
  2931 				{
  2835 				DeleteMessagesL();
  2932 				DeleteMessagesL();
  2836 				}
  2933 				}
  2837 			UnmarkAllItemsL();
       
  2838 			}
  2934 			}
  2839             break;
  2935             break;
  2840 		case EFsEmailUiCmdCompose:
  2936 		case EFsEmailUiCmdCompose:
  2841 			{
  2937 			{
  2842 			CreateNewMsgL();
  2938 			CreateNewMsgL();
  2918        	        {
  3014        	        {
  2919            		ExpandAllNodesL();
  3015            		ExpandAllNodesL();
  2920                 }
  3016                 }
  2921 			break;
  3017 			break;
  2922         case EFsEmailUiCmdCollapse:
  3018         case EFsEmailUiCmdCollapse:
  2923     		if (!iAppUi.IsTimerFocusShown())
  3019     		if( !iAppUi.IsFocusShown() )
  2924     			{
  3020     			{
  2925     			iAppUi.StartFocusRemovalTimer();
  3021     			iAppUi.SetFocusVisibility( ETrue );
  2926     			break;
  3022     			break;
  2927     			}
  3023     			}
  2928             // Safety check, ignore command if the list is empty
  3024             // Safety check, ignore command if the list is empty
  2929             if( iMailList->Count() )
  3025             if( iMailList->Count() )
  2930                 {
  3026                 {
  2931                 ExpandOrCollapseL();
  3027                 ExpandOrCollapseL();
  2932                 }
  3028                 }
  2933             break;
  3029             break;
  2934         case EFsEmailUiCmdExpand:
  3030         case EFsEmailUiCmdExpand:
  2935     		if (!iAppUi.IsTimerFocusShown())
  3031     		if( !iAppUi.IsFocusShown() )
  2936     			{
  3032     			{
  2937     			iAppUi.StartFocusRemovalTimer();
  3033     			iAppUi.SetFocusVisibility( ETrue );
  2938     			break;
  3034     			break;
  2939     			}
  3035     			}
  2940             // Safety check, ignore command if the list is empty
  3036             // Safety check, ignore command if the list is empty
  2941             if( iMailList->Count() )
  3037             if( iMailList->Count() )
  2942                 {
  3038                 {
  3003        		{
  3099        		{
  3004 			TBool supportsSync = iAppUi.GetActiveMailbox()->HasCapability( EFSMBoxCapaSupportsSync );
  3100 			TBool supportsSync = iAppUi.GetActiveMailbox()->HasCapability( EFSMBoxCapaSupportsSync );
  3005 			if ( supportsSync )
  3101 			if ( supportsSync )
  3006 				{
  3102 				{
  3007 	       		iAppUi.StopActiveMailBoxSyncL();
  3103 	       		iAppUi.StopActiveMailBoxSyncL();
  3008 	       		CFSMailBox* mb = iAppUi.GetActiveMailbox();
       
  3009 				TDesC* mbName = &mb->GetName();
       
  3010 				}
  3104 				}
  3011        		}
  3105        		}
  3012        		break;
  3106        		break;
  3013         case EFsEmailUiCmdGoOffline:
  3107         case EFsEmailUiCmdGoOffline:
  3014         	{
  3108         	{
  3016         	}
  3110         	}
  3017         	break;
  3111         	break;
  3018         case EFsEmailUiCmdGoOnline:
  3112         case EFsEmailUiCmdGoOnline:
  3019         	{
  3113         	{
  3020 			CFSMailBox* mb = iAppUi.GetActiveMailbox();
  3114 			CFSMailBox* mb = iAppUi.GetActiveMailbox();
  3021 			TDesC* mbName = &mb->GetName();
       
  3022             iAppUi.ManualMailBoxSync( ETrue );
  3115             iAppUi.ManualMailBoxSync( ETrue );
  3023         	mb->GoOnlineL();
  3116         	mb->GoOnlineL();
  3024         	}
  3117         	}
  3025         	break;
  3118         	break;
  3026        	case EFsEmailUiCmdHelp:
  3119        	case EFsEmailUiCmdHelp:
  3076        	case EFsEmailUiCmdActionsMoveMessage:
  3169        	case EFsEmailUiCmdActionsMoveMessage:
  3077 			{
  3170 			{
  3078 			TFSMailMsgId folderID;
  3171 			TFSMailMsgId folderID;
  3079 			folderID.SetNullId(); // Selection is popped up with NULL
  3172 			folderID.SetNullId(); // Selection is popped up with NULL
  3080 			MoveMsgsToFolderL( folderID );
  3173 			MoveMsgsToFolderL( folderID );
       
  3174 
       
  3175 			TBool supportsSync = iAppUi.GetActiveMailbox()->HasCapability( EFSMBoxCapaSupportsSync );
       
  3176 			if ( supportsSync )
       
  3177 			    {
       
  3178 			    //If synchronizing is ongoing and a new sync is started we ignore it
       
  3179 			    if(!GetLatestSyncState())
       
  3180 			        {
       
  3181 			        iAppUi.SyncActiveMailBoxL();
       
  3182 
       
  3183 			        // Sync the mailbox
       
  3184 			        ManualMailBoxSync(ETrue);
       
  3185 
       
  3186                     iAppUi.ManualMailBoxSync( ETrue );
       
  3187 			        }
       
  3188 			    }
  3081 			}
  3189 			}
  3082 			break;
  3190 			break;
  3083        	case EFsEmailUiCmdActionsMoveToDrafts:
  3191        	case EFsEmailUiCmdActionsMoveToDrafts:
  3084 			{
  3192 			{
  3085 			MoveMessagesToDraftsL();
  3193 			MoveMessagesToDraftsL();
  3113                         }
  3221                         }
  3114                     else
  3222                     else
  3115                         {
  3223                         {
  3116                         HandleCommandL(EFsEmailUiCmdMarkMark);
  3224                         HandleCommandL(EFsEmailUiCmdMarkMark);
  3117                         }
  3225                         }
  3118 				    }
       
  3119 				else if ( item->ModelItemType() == ETypeSeparator )
       
  3120 					{
       
  3121 					// Mark items.
       
  3122 					MarkItemsUnderSeparatorL( ETrue, HighlightedIndex() );
       
  3123 					iListMarkItemsState = ETrue; // Enable mark mode
       
  3124 					}
  3226 					}
  3125                 }
  3227                 }
  3126             }
  3228             }
  3127             break;
  3229             break;
  3128         case EFsEmailUiCmdGoToSwitchFolder:
  3230         case EFsEmailUiCmdGoToSwitchFolder:
  3129             {
  3231             {
  3130             iControlBarControl->SetFocusByIdL( iFolderListButtonId );
  3232             iControlBarControl->SetFocusByIdL( iFolderListButtonId );
       
  3233             iControlBarControl->MakeSelectorVisible( IsFocusShown() );
  3131             iFocusedControl = EControlBarComponent;
  3234             iFocusedControl = EControlBarComponent;
  3132             iMailList->SetFocusedL( EFalse );
  3235             iMailList->SetFocusedL( EFalse );
  3133             }
  3236             }
  3134             break;
  3237             break;
  3135         case EFsEmailUiCmdGoToSwitchSorting:
  3238         case EFsEmailUiCmdGoToSwitchSorting:
  3136             {
  3239             {
  3137             iControlBarControl->SetFocusByIdL( iSortButtonId );
  3240             iControlBarControl->SetFocusByIdL( iSortButtonId );
       
  3241             iControlBarControl->MakeSelectorVisible( IsFocusShown() );
  3138             iFocusedControl = EControlBarComponent;
  3242             iFocusedControl = EControlBarComponent;
  3139            	iMailList->SetFocusedL( EFalse );
  3243            	iMailList->SetFocusedL( EFalse );
  3140             }
  3244             }
  3141             break;
  3245             break;
  3142         case EFsEmailUiCmdCalActionsAccept:
  3246         case EFsEmailUiCmdCalActionsAccept:
  3201  					}
  3305  					}
  3202        			}
  3306        			}
  3203        		}
  3307        		}
  3204 			break;
  3308 			break;
  3205 	    default:
  3309 	    default:
       
  3310 	    	{
       
  3311 	    	// No default action.
       
  3312 	    	}
  3206         	break;
  3313         	break;
  3207         }
  3314         } // switch ( aCommand )
  3208     CleanupStack::PopAndDestroy( &actionTargetItems );
  3315     CleanupStack::PopAndDestroy( &actionTargetItems );
  3209     }
  3316     }
  3210 
  3317 
  3211 // ---------------------------------------------------------------------------
  3318 // ---------------------------------------------------------------------------
  3212 //
  3319 //
  3573     if ( !aEvent.IsKeyEvent() )
  3680     if ( !aEvent.IsKeyEvent() )
  3574         {
  3681         {
  3575         // Only handle key events
  3682         // Only handle key events
  3576         if ( aEvent.IsPointerEvent() )
  3683         if ( aEvent.IsPointerEvent() )
  3577             {
  3684             {
  3578             switch( iFocusedControl )
  3685             if( aEvent.PointerDown() )
  3579                 {
  3686                 {
  3580                 case EMailListComponent:
  3687                 // If pointer down event was made on control bar area
       
  3688                 // focus needs to be changed to control bar control, if it
       
  3689                 // didn't already have focus.
       
  3690                if( HitTest( *iControlBarControl, aEvent.PointerEvent().iPosition ) )
  3581                     {
  3691                     {
  3582                     result = iMailList->TreeControl()->OfferEventL( aEvent );
  3692                     if( iFocusedControl != EControlBarComponent )
  3583                     break;
  3693                         {
       
  3694                         SetControlBarFocusedL();
       
  3695                         }
  3584                     }
  3696                     }
  3585                 case EControlBarComponent:
  3697                 else
  3586                     {
  3698                     {
  3587                     result = static_cast<CAlfControl*>(
  3699                     // if pointer up event was not made on control bar area
  3588                         iControlBarControl )->OfferEventL( aEvent );
  3700                     // then focus need to be set to mail list component if it
  3589                     break;
  3701                     // didn't already have focus.
       
  3702                     if( iFocusedControl != EMailListComponent )
       
  3703                         {
       
  3704                         SetTreeListFocusedL();
       
  3705                         }
  3590                     }
  3706                     }
  3591                 default:
  3707                 }
  3592                     {
  3708 
  3593                     break;
  3709             // Offer event to focused control.
  3594                     }
  3710             if( iFocusedControl == EMailListComponent )
       
  3711                 {
       
  3712                 result = iMailList->TreeControl()->OfferEventL( aEvent );
       
  3713                 }
       
  3714             else // iFocusedControl == EControlBarComponent
       
  3715                 {
       
  3716                 result = static_cast<CAlfControl*>(
       
  3717                     iControlBarControl )->OfferEventL( aEvent );
  3595                 }
  3718                 }
  3596             }
  3719             }
  3597         return result;
  3720         return result;
  3598         }
  3721         }
  3599 
  3722 
  3600     TInt scanCode = aEvent.KeyEvent().iScanCode;
  3723     TInt scanCode = aEvent.KeyEvent().iScanCode;
  3601     // Swap right and left controls in mirrored layout
  3724     // Swap right and left controls in mirrored layout
  3602     if ( AknLayoutUtils::LayoutMirrored() )
  3725     if ( AknLayoutUtils::LayoutMirrored() )
  3603         {
  3726         {
  3604         if ( scanCode == EStdKeyRightArrow ) scanCode = EStdKeyLeftArrow;
  3727         if ( scanCode == EStdKeyRightArrow )
  3605         else if ( scanCode == EStdKeyLeftArrow ) scanCode = EStdKeyRightArrow;
  3728             {
       
  3729             scanCode = EStdKeyLeftArrow;
       
  3730             }
       
  3731         else if ( scanCode == EStdKeyLeftArrow )
       
  3732             {
       
  3733             scanCode = EStdKeyRightArrow;
       
  3734             }
  3606         }
  3735         }
  3607 
  3736 
  3608     // Toggle mark items state when shift key is pressed or released
  3737     // Toggle mark items state when shift key is pressed or released
  3609     if ( iFocusedControl == EMailListComponent &&
  3738     if ( iFocusedControl == EMailListComponent &&
  3610     	 ( scanCode == EStdKeyLeftShift ||
  3739     	 ( scanCode == EStdKeyLeftShift ||
  3703                 || (scanCode == EStdKeyDownArrow)
  3832                 || (scanCode == EStdKeyDownArrow)
  3704                 || (scanCode == EStdKeyEnter)
  3833                 || (scanCode == EStdKeyEnter)
  3705                 || (scanCode == EStdKeyDeviceA)
  3834                 || (scanCode == EStdKeyDeviceA)
  3706                 || (scanCode ==EStdKeyDevice3))
  3835                 || (scanCode ==EStdKeyDevice3))
  3707                 {
  3836                 {
  3708                 TBool wasActive = iAppUi.StartFocusRemovalTimer();
       
  3709 
  3837 
  3710                 // If the focus was not active already, ignore the key press
  3838                 // If the focus was not active already, ignore the key press
  3711                 if( !wasActive )
  3839                 if( !iAppUi.SetFocusVisibility( ETrue ) )
  3712                     {
  3840                     {
  3713                     return ETrue;
  3841                     return ETrue;
  3714                     }
  3842                     }
  3715                 }
  3843                 }
  3716 
  3844 
  3788                                 {
  3916                                 {
  3789                                 //<cmail>
  3917                                 //<cmail>
  3790                                 //Set touchmanager not active for preventing getting events.
  3918                                 //Set touchmanager not active for preventing getting events.
  3791                                 DisableMailList(ETrue);
  3919                                 DisableMailList(ETrue);
  3792                                 //</cmail>
  3920                                 //</cmail>
  3793                                 iAppUi.ShowSortListInPopupL( iCurrentSortCriteria.iField, folderType, this, iSortButton );
  3921                                 iAppUi.ShowSortListInPopupL( iCurrentSortCriteria, folderType, this, iSortButton );
  3794                                 }
  3922                                 }
  3795                             else
  3923                             else
  3796                                 {
  3924                                 {
  3797                                 // hide selector focus if popup is not opened
  3925                                 // hide selector focus if popup is not opened
  3798                                 // and selection was not made via HW-keys
  3926                                 // and selection was not made via HW-keys
  3804                         }
  3932                         }
  3805                     }
  3933                     }
  3806                     break;
  3934                     break;
  3807                 case EStdKeyLeftArrow:
  3935                 case EStdKeyLeftArrow:
  3808                     {
  3936                     {
  3809                     iControlBarControl->MakeSelectorVisible( IsFocusShown() );
       
  3810                     if( iControlBarControl && iFocusedControl == EMailListComponent )
  3937                     if( iControlBarControl && iFocusedControl == EMailListComponent )
  3811                         {
  3938                         {
  3812                         HandleCommandL( EFsEmailUiCmdGoToSwitchSorting );
  3939                         HandleCommandL( EFsEmailUiCmdGoToSwitchSorting );
  3813                         result = ETrue;
  3940                         result = ETrue;
  3814                         }
  3941                         }
  3815                     else if( ( iControlBarControl ) &&
  3942                     else if( ( iControlBarControl ) &&
  3816                              ( iFocusedControl == EControlBarComponent  ) )
  3943                              ( iFocusedControl == EControlBarComponent  ) )
  3817                         {
  3944                         {
  3818 
       
  3819                         TInt focusedButtonId = iControlBarControl->GetFocusedButton()->Id();
  3945                         TInt focusedButtonId = iControlBarControl->GetFocusedButton()->Id();
       
  3946                         iControlBarControl->MakeSelectorVisible( IsFocusShown() );
  3820                         if ( focusedButtonId == iFolderListButtonId )
  3947                         if ( focusedButtonId == iFolderListButtonId )
  3821                             {
  3948                             {
  3822                             if ( iModel->Count() )
  3949                             if ( iModel->Count() )
  3823                                 {
  3950                                 {
  3824                                 iFocusedControl = EMailListComponent;
  3951                                 iFocusedControl = EMailListComponent;
  3844                     SetMskL();
  3971                     SetMskL();
  3845                     }
  3972                     }
  3846                     break;
  3973                     break;
  3847                 case EStdKeyRightArrow:
  3974                 case EStdKeyRightArrow:
  3848                     {
  3975                     {
  3849                     iControlBarControl->MakeSelectorVisible( IsFocusShown() );
       
  3850                     // Show toolbar if there is data on the list
  3976                     // Show toolbar if there is data on the list
  3851                     // <cmail>
  3977                     // <cmail>
  3852                     if ( iFocusedControl == EMailListComponent && iModel->Count() )
  3978                     if ( iFocusedControl == EMailListComponent && iModel->Count() )
  3853                     // </cmail>
  3979                     // </cmail>
  3854                         {
  3980                         {
  3866                         }
  3992                         }
  3867                     else if( ( iControlBarControl ) &&
  3993                     else if( ( iControlBarControl ) &&
  3868                              ( iFocusedControl == EControlBarComponent ) )
  3994                              ( iFocusedControl == EControlBarComponent ) )
  3869                         {
  3995                         {
  3870                         TInt focusedButtonId = iControlBarControl->GetFocusedButton()->Id();
  3996                         TInt focusedButtonId = iControlBarControl->GetFocusedButton()->Id();
       
  3997                         iControlBarControl->MakeSelectorVisible( IsFocusShown() );
  3871                         if ( focusedButtonId == iFolderListButtonId )
  3998                         if ( focusedButtonId == iFolderListButtonId )
  3872                             {
  3999                             {
  3873                             iFocusedControl = EControlBarComponent;
  4000                             iFocusedControl = EControlBarComponent;
  3874                             result = EFalse;
  4001                             result = EFalse;
  3875                             }
  4002                             }
  4135             }
  4262             }
  4136         if ( iModel->Count() )
  4263         if ( iModel->Count() )
  4137             {
  4264             {
  4138             //Set touchmanager not active for preventing getting events.
  4265             //Set touchmanager not active for preventing getting events.
  4139             DisableMailList(ETrue);
  4266             DisableMailList(ETrue);
  4140             iAppUi.ShowSortListInPopupL( iCurrentSortCriteria.iField, folderType, this, iSortButton );
  4267             iAppUi.ShowSortListInPopupL( iCurrentSortCriteria, folderType, this, iSortButton );
  4141             }
  4268             }
  4142         else
  4269         else
  4143             {
  4270             {
  4144             // hide selector focus if popup is not opened and selection was not
  4271             // hide selector focus if popup is not opened and selection was not
  4145             // made via HW-keys
  4272             // made via HW-keys
  4215 
  4342 
  4216 // -----------------------------------------------------------------------------
  4343 // -----------------------------------------------------------------------------
  4217 //  CFSEmailUiMailListVisualiser::HandleTimerFocusStateChange
  4344 //  CFSEmailUiMailListVisualiser::HandleTimerFocusStateChange
  4218 // -----------------------------------------------------------------------------
  4345 // -----------------------------------------------------------------------------
  4219 //
  4346 //
  4220 void CFSEmailUiMailListVisualiser::HandleTimerFocusStateChange( TBool aShow )
  4347 void CFSEmailUiMailListVisualiser::FocusVisibilityChange( TBool aVisible )
  4221     {
  4348     {
  4222     FUNC_LOG;
  4349     FUNC_LOG;
  4223     CFsEmailUiViewBase::HandleTimerFocusStateChange( aShow );
  4350 
       
  4351     CFsEmailUiViewBase::FocusVisibilityChange( aVisible );
       
  4352 
  4224     if( iFocusedControl == EControlBarComponent )
  4353     if( iFocusedControl == EControlBarComponent )
  4225         {
  4354         {
  4226         iControlBarControl->MakeSelectorVisible( aShow );
  4355         iControlBarControl->MakeSelectorVisible( aVisible );
  4227         }
  4356         }
  4228     iMailTreeListVisualizer->SetFocusVisibility( aShow );
  4357 
       
  4358     if ( iStylusPopUpMenuLaunched && !aVisible )
       
  4359     	{
       
  4360     	// Do not allow to remove the focus from a list element if the pop up
       
  4361     	// menu was just launched.
       
  4362     	iStylusPopUpMenuLaunched = EFalse;
       
  4363     	return;
       
  4364     	}
       
  4365 
       
  4366     iMailTreeListVisualizer->SetFocusVisibility( aVisible );
  4229     }
  4367     }
  4230 
  4368 
  4231 // ---------------------------------------------------------------------------
  4369 // ---------------------------------------------------------------------------
  4232 // CFSEmailUiMailListVisualiser::DisableMailList
  4370 // CFSEmailUiMailListVisualiser::DisableMailList
  4233 // ---------------------------------------------------------------------------
  4371 // ---------------------------------------------------------------------------
  4443 // ---------------------------------------------------------------------------
  4581 // ---------------------------------------------------------------------------
  4444 //
  4582 //
  4445 void CFSEmailUiMailListVisualiser::HandleControlBarEvent( TFsControlBarEvent aEvent, TInt aData )
  4583 void CFSEmailUiMailListVisualiser::HandleControlBarEvent( TFsControlBarEvent aEvent, TInt aData )
  4446 	{
  4584 	{
  4447     FUNC_LOG;
  4585     FUNC_LOG;
  4448 	if ( aEvent == EEventFocusLostAtBottom ||
  4586 
  4449 		 aEvent == EEventFocusLostAtSide )
  4587     switch( aEvent )
  4450 		{
  4588         {
  4451        	iFocusedControl = EMailListComponent;
  4589         case EEventFocusLostAtBottom:
  4452         TRAP_IGNORE( iMailList->SetFocusedL( ETrue ) );
  4590         case EEventFocusLostAtSide:
  4453 		}
  4591             {
  4454 	else if ( aEvent == EEventFocusGained )
  4592             iFocusedControl = EMailListComponent;
  4455 		{
  4593             TRAP_IGNORE( iMailList->SetFocusedL( ETrue ) );
  4456 		}
  4594             break;
  4457 	else if ( aEvent == EEventButtonPressed )
  4595             }
  4458 		{
  4596         case EEventFocusGained:
  4459 		// Handle 2 control buttons
  4597             {
  4460 		if ( aData == iFolderListButtonId )
  4598             break;
  4461 			{
  4599             }
  4462 			}
  4600         case EEventButtonPressed:
  4463 		else if ( aData == iSortButtonId )
  4601             {
  4464 			{
  4602             // Handle 2 control buttons
  4465 			}
  4603             if ( aData == iFolderListButtonId )
  4466 		}
  4604                 {
       
  4605                 }
       
  4606             else if ( aData == iSortButtonId )
       
  4607                 {
       
  4608                 }
       
  4609             break;
       
  4610             }
       
  4611         case EEventFocusVisibilityChanged:
       
  4612             {
       
  4613             // Hide focus after button release
       
  4614             iAppUi.SetFocusVisibility( EFalse );
       
  4615             break;
       
  4616             }
       
  4617         default:
       
  4618             {
       
  4619             // No need to handle other events
       
  4620             break;
       
  4621             }
       
  4622         }
  4467 	}
  4623 	}
  4468 
  4624 
  4469 // ---------------------------------------------------------------------------
  4625 // ---------------------------------------------------------------------------
  4470 //
  4626 //
  4471 //
  4627 //
  4472 // ---------------------------------------------------------------------------
  4628 // ---------------------------------------------------------------------------
  4473 //
  4629 //
  4474 void CFSEmailUiMailListVisualiser::CreateControlBarLayoutL()
  4630 void CFSEmailUiMailListVisualiser::CreateControlBarLayoutL()
  4475 	{
  4631 	{
  4476     FUNC_LOG;
  4632     FUNC_LOG;
  4477     TRect screenRect = iAppUi.ClientRect();
  4633     iControlBarControl->SetRectL( iAppUi.LayoutHandler()->GetControlBarRect() );
  4478   	iControlBarControl->SetWidthL( screenRect.Width() );
  4634 
  4479     //<cmail>   ??
  4635     // New email button
  4480     //TInt normalButtonWidth = ( screenRect.Width() - KFirstButtonStartPosX*2 - 10 ) / 2;
  4636     iNewEmailButtonId = iControlBarControl->AddButtonL( ECBTypeOneLineLabelIconA );
  4481     //</cmail>
  4637     iNewEmailButton = iControlBarControl->ButtonById( iNewEmailButtonId );
  4482     // Mailbox icon
  4638     const TRect mailButtonRect( iAppUi.LayoutHandler()->GetControlBarNewEmailButtonRect() );
  4483   	iImageButtonId = iControlBarControl->AddButtonL( ECBTypeIconOnly );
  4639     iNewEmailButton->SetPos( mailButtonRect.iTl );
  4484     iIconButton = iControlBarControl->ButtonById( iImageButtonId );
  4640     iNewEmailButton->SetSize( mailButtonRect.Size() );
  4485 // <cmail> Use layout data instead of hardcoded values
  4641     ControlGroup().AppendL(iNewEmailButton->AsAlfControl());
  4486     const TRect iconButtonRect( iAppUi.LayoutHandler()->GetControlBarMailboxIconRect() );
       
  4487     iIconButton->SetPos( iconButtonRect.iTl );
       
  4488     iIconButton->SetSize( iconButtonRect.Size() );
       
  4489     ControlGroup().AppendL(iIconButton->AsAlfControl());
       
  4490 // </cmail>
       
  4491 
  4642 
  4492     // Folder list button
  4643     // Folder list button
  4493     iFolderListButtonId = iControlBarControl->AddButtonL( ECBTypeOneLineLabelIconB );
  4644     iFolderListButtonId = iControlBarControl->AddButtonL( ECBTypeOneLineLabelIconA );
  4494     iFolderListButton = iControlBarControl->ButtonById( iFolderListButtonId );
  4645     iFolderListButton = iControlBarControl->ButtonById( iFolderListButtonId );
  4495 // <cmail> Use layout data instead of hardcoded values
       
  4496     const TRect folderButtonRect( iAppUi.LayoutHandler()->GetControlBarFolderListButtonRect() );
  4646     const TRect folderButtonRect( iAppUi.LayoutHandler()->GetControlBarFolderListButtonRect() );
  4497     iFolderListButton->SetPos( folderButtonRect.iTl );
  4647     iFolderListButton->SetPos( folderButtonRect.iTl );
  4498     iFolderListButton->SetSize( folderButtonRect.Size() );
  4648     iFolderListButton->SetSize( folderButtonRect.Size() );
  4499     ControlGroup().AppendL(iFolderListButton->AsAlfControl());
  4649     ControlGroup().AppendL(iFolderListButton->AsAlfControl());
  4500 // </cmail>
       
  4501 
  4650 
  4502     // Sort order button
  4651     // Sort order button
  4503     iSortButtonId = iControlBarControl->AddButtonL( ECBTypeOneLineLabelIconB );
  4652     iSortButtonId = iControlBarControl->AddButtonL( ECBTypeOneLineLabelIconA );
  4504     iSortButton = iControlBarControl->ButtonById( iSortButtonId );
  4653     iSortButton = iControlBarControl->ButtonById( iSortButtonId );
  4505 // <cmail> Use layout data instead of hardcoded values
       
  4506     const TRect sortButtonRect( iAppUi.LayoutHandler()->GetControlBarSortButtonRect() );
  4654     const TRect sortButtonRect( iAppUi.LayoutHandler()->GetControlBarSortButtonRect() );
  4507     iSortButton->SetPos( sortButtonRect.iTl );
  4655     iSortButton->SetPos( sortButtonRect.iTl );
  4508     iSortButton->SetSize( sortButtonRect.Size() );
  4656     iSortButton->SetSize( sortButtonRect.Size() );
  4509     ControlGroup().AppendL(iSortButton->AsAlfControl());
  4657     ControlGroup().AppendL(iSortButton->AsAlfControl());
  4510 // </cmail>
  4658 // </cmail>
  4513     TAlfAlignHorizontal horizontalAlign = EAlfAlignHLeft;
  4661     TAlfAlignHorizontal horizontalAlign = EAlfAlignHLeft;
  4514     if ( AknLayoutUtils::LayoutMirrored() )
  4662     if ( AknLayoutUtils::LayoutMirrored() )
  4515         {
  4663         {
  4516         horizontalAlign = EAlfAlignHRight;
  4664         horizontalAlign = EAlfAlignHRight;
  4517         }
  4665         }
       
  4666 
       
  4667     // Icons and sort button text
       
  4668     iFolderListButton->SetIconL( iAppUi.FsTextureManager()->TextureByIndex( EListControlBarMailboxDefaultIcon ) );
       
  4669     iNewEmailButton->SetIconL( iAppUi.FsTextureManager()->TextureByIndex( EListTextureNewEmailDefaultIcon ) );
       
  4670     SetSortButtonTextAndIconL();
       
  4671 
       
  4672     iNewEmailButton->SetElemAlignL(
       
  4673         ECBElemIconA,
       
  4674         EAlfAlignHCenter,
       
  4675         EAlfAlignVCenter );
       
  4676 
  4518     iFolderListButton->SetElemAlignL(
  4677     iFolderListButton->SetElemAlignL(
  4519         ECBElemLabelFirstLine,
  4678         ECBElemLabelFirstLine,
  4520         horizontalAlign,
  4679         horizontalAlign,
  4521         EAlfAlignVCenter );
  4680         EAlfAlignVCenter );
  4522     iSortButton->SetElemAlignL(
  4681     iSortButton->SetElemAlignL(
  4523         ECBElemLabelFirstLine,
  4682         ECBElemLabelFirstLine,
  4524         horizontalAlign,
  4683         horizontalAlign,
  4525         EAlfAlignVCenter );
  4684         EAlfAlignVCenter );
       
  4685     iSortButton->SetElemAlignL(
       
  4686         ECBElemIconA,
       
  4687         EAlfAlignHCenter,
       
  4688         EAlfAlignVCenter );
  4526 
  4689 
  4527 	// Show the buttons
  4690 	// Show the buttons
  4528 	iIconButton->ClearBackgroundColor();
  4691   	iNewEmailButton->ShowButtonL();
  4529   	iIconButton->SetDimmed();
       
  4530     iFolderListButton->ShowButtonL();
  4692     iFolderListButton->ShowButtonL();
  4531     iSortButton->ShowButtonL();
  4693     iSortButton->ShowButtonL();
  4532 
       
  4533     // Button background images
       
  4534 	iFolderListButton->ClearBackgroundColor();
       
  4535  	iSortButton->ClearBackgroundColor();
       
  4536 
       
  4537 	// Icons and sort button text
       
  4538 	iIconButton->SetIconL( iAppUi.FsTextureManager()->TextureByIndex( EListControlBarMailboxDefaultIcon ) );
       
  4539  	SetSortButtonTextAndIconL();
       
  4540 
       
  4541     //iControlBarControl->SetSelectorBorders(-2,-2,-2,-2 ); // CHECKLATER - commented out 'cause fixing things is hard - check later to replace (?) it
       
  4542 	}
  4694 	}
  4543 
  4695 
  4544 // ---------------------------------------------------------------------------
  4696 // ---------------------------------------------------------------------------
  4545 //
  4697 //
  4546 //
  4698 //
  4549 void CFSEmailUiMailListVisualiser::ScaleControlBarL()
  4701 void CFSEmailUiMailListVisualiser::ScaleControlBarL()
  4550 	{
  4702 	{
  4551     FUNC_LOG;
  4703     FUNC_LOG;
  4552     TRect screenRect = iAppUi.ClientRect();
  4704     TRect screenRect = iAppUi.ClientRect();
  4553 
  4705 
  4554 	// First set widht and height
  4706 	// First set pos, widht and height
  4555 	iControlBarControl->SetHeightL( iAppUi.LayoutHandler()->ControlBarHeight() );
  4707   	iControlBarControl->SetRectL( iAppUi.LayoutHandler()->GetControlBarRect() );
  4556   	iControlBarControl->SetWidthL( screenRect.Width() );
  4708 
  4557 
  4709     const TRect newEmailButtonRect( iAppUi.LayoutHandler()->GetControlBarNewEmailButtonRect() );
  4558     const TRect iconButtonRect( iAppUi.LayoutHandler()->GetControlBarMailboxIconRect() );
  4710     iNewEmailButton->SetPos( newEmailButtonRect.iTl );
  4559     iIconButton->SetPos( iconButtonRect.iTl );
  4711     iNewEmailButton->SetSize( newEmailButtonRect.Size() );
  4560     iIconButton->SetSize( iconButtonRect.Size() );
       
  4561 
  4712 
  4562     const TRect folderButtonRect( iAppUi.LayoutHandler()->GetControlBarFolderListButtonRect() );
  4713     const TRect folderButtonRect( iAppUi.LayoutHandler()->GetControlBarFolderListButtonRect() );
  4563   	iFolderListButton->SetPos( folderButtonRect.iTl );
  4714   	iFolderListButton->SetPos( folderButtonRect.iTl );
  4564   	iFolderListButton->SetSize( folderButtonRect.Size() );
  4715   	iFolderListButton->SetSize( folderButtonRect.Size() );
  4565 
  4716 
  4566     const TRect sortButtonRect( iAppUi.LayoutHandler()->GetControlBarSortButtonRect() );
  4717     const TRect sortButtonRect( iAppUi.LayoutHandler()->GetControlBarSortButtonRect() );
  4567    	iSortButton->SetPos( sortButtonRect.iTl );
  4718    	iSortButton->SetPos( sortButtonRect.iTl );
  4568     iSortButton->SetSize( sortButtonRect.Size() );
  4719     iSortButton->SetSize( sortButtonRect.Size() );
  4569 
  4720 
  4570  	// Bar background
       
  4571 	CAlfTexture& barBg = iAppUi.FsTextureManager()->TextureByIndex( EMailListBarBgIcon );
       
  4572 	TSize cbBgSize;
       
  4573 	cbBgSize.SetSize( screenRect.Width(), iAppUi.LayoutHandler()->ControlBarHeight() );
       
  4574 	barBg.Size().SetSize( cbBgSize.iWidth, cbBgSize.iHeight );
       
  4575 	// <cmail> S60 Skin support
       
  4576 	//iControlBarControl->SetBackgroundImageL( barBg );
       
  4577 	//</cmail>
       
  4578 
       
  4579 	// Button background
       
  4580 	CAlfTexture& buttonBg =  iAppUi.FsTextureManager()->TextureByIndex( EListTextureControlButton );
       
  4581 	//<cmail>
       
  4582 	buttonBg.Size().SetSize( iAppUi.LayoutHandler()->GetControlBarFolderListButtonSize().iWidth, iAppUi.LayoutHandler()->GetControlBarFolderListButtonSize().iHeight );
       
  4583         //</cmail>
       
  4584 
       
  4585     // construct main text display window
       
  4586 // <cmail> Use layout data instead of hard-coded values
       
  4587 //    const CFont* font = iEikonEnv->NormalFont();
       
  4588 //    TFontSpec fontSpec = font->FontSpecInTwips();
       
  4589 	//fontSpec.iHeight = iAppUi.LayoutHandler()->ControlBarTextHeight();
       
  4590 
       
  4591 	TInt var = Layout_Meta_Data::IsLandscapeOrientation() ? 1 : 0;
  4721 	TInt var = Layout_Meta_Data::IsLandscapeOrientation() ? 1 : 0;
  4592 	TAknLayoutText textLayout;
  4722 	TAknLayoutText textLayout;
  4593 	textLayout.LayoutText(TRect(0,0,0,0), AknLayoutScalable_Apps::main_sp_fs_ctrlbar_ddmenu_pane_t1(var));
  4723 	textLayout.LayoutText(TRect(0,0,0,0), AknLayoutScalable_Apps::main_sp_fs_ctrlbar_ddmenu_pane_t1(var));
       
  4724 	iNewEmailButton->SetTextFontL( textLayout.Font()->FontSpecInTwips() );
  4594  	iFolderListButton->SetTextFontL( textLayout.Font()->FontSpecInTwips() );
  4725  	iFolderListButton->SetTextFontL( textLayout.Font()->FontSpecInTwips() );
  4595  	iSortButton->SetTextFontL( textLayout.Font()->FontSpecInTwips() );
  4726  	iSortButton->SetTextFontL( textLayout.Font()->FontSpecInTwips() );
  4596 // </cmail>
  4727 
  4597 
  4728  	UpdateTheme();
  4598 	TRgb normalStateButtonTextColor( KRgbBlack );
  4729 
  4599     AknsUtils::GetCachedColor( AknsUtils::SkinInstance(),
  4730 	iNewEmailButton->ShowButtonL();
  4600                      normalStateButtonTextColor, KAknsIIDFsTextColors, EAknsCIFsTextColorsCG6 );
       
  4601 
       
  4602     iFolderListButton->SetNormalTextColor( normalStateButtonTextColor );
       
  4603     iFolderListButton->SetFocusedTextColor( iAppUi.LayoutHandler()->ListFocusedStateTextSkinColor() );
       
  4604 
       
  4605     iSortButton->SetNormalTextColor( normalStateButtonTextColor );
       
  4606     iSortButton->SetFocusedTextColor( iAppUi.LayoutHandler()->ListFocusedStateTextSkinColor() );
       
  4607 
       
  4608     CAlfImageBrush* folderBtnBrush = iAppUi.FsTextureManager()->NewControlBarButtonBgBrushLC();
       
  4609  	iFolderListButton->SetBackgroundImageL( folderBtnBrush );
       
  4610  	CleanupStack::Pop( folderBtnBrush );
       
  4611 
       
  4612  	CAlfImageBrush* sortBtnBrush = iAppUi.FsTextureManager()->NewControlBarButtonBgBrushLC();
       
  4613  	iSortButton->SetBackgroundImageL( sortBtnBrush );
       
  4614  	CleanupStack::Pop( sortBtnBrush );
       
  4615 
       
  4616 	iIconButton->ShowButtonL();
       
  4617   	iFolderListButton->ShowButtonL();
  4731   	iFolderListButton->ShowButtonL();
  4618 	iSortButton->ShowButtonL();
  4732 	iSortButton->ShowButtonL();
  4619 
       
  4620 	iFolderListButton->SetIconL( iAppUi.FsTextureManager()->TextureByIndex( EControlBarDescendingArrowTexture ), ECBElemIconB );
       
  4621 	}
  4733 	}
  4622 
  4734 
  4623 // ---------------------------------------------------------------------------
  4735 // ---------------------------------------------------------------------------
  4624 //
  4736 //
  4625 //
  4737 //
  4626 // ---------------------------------------------------------------------------
  4738 // ---------------------------------------------------------------------------
  4627 //
  4739 //
  4628 void CFSEmailUiMailListVisualiser::SetSortButtonTextAndIconL()
  4740 void CFSEmailUiMailListVisualiser::SetSortButtonTextAndIconL()
  4629 	{
  4741 	{
  4630     FUNC_LOG;
  4742     FUNC_LOG;
  4631 	HBufC* buttonText(0);
  4743 
       
  4744     // Set button text if necessary
       
  4745     HBufC* buttonText = GetSortButtonTextLC();
       
  4746 
       
  4747 	if ( !Layout_Meta_Data::IsLandscapeOrientation() )
       
  4748 		{
       
  4749 		if ( buttonText )
       
  4750 			{
       
  4751 			buttonText->Des().Zero();
       
  4752 			}
       
  4753 		}
       
  4754 
       
  4755 	if ( buttonText )
       
  4756 		{
       
  4757 		iSortButton->SetTextL( *buttonText );
       
  4758 		}
       
  4759 	CleanupStack::PopAndDestroy( buttonText );
       
  4760 
       
  4761 	// Set icon
       
  4762     TFSEmailUiTextures textureIndex( ETextureFirst );
       
  4763 
  4632 	switch ( iCurrentSortCriteria.iField )
  4764 	switch ( iCurrentSortCriteria.iField )
  4633 		{
  4765 		{
  4634 		case EFSMailSortBySubject:
  4766 		case EFSMailSortBySubject:
  4635 			{
  4767 			{
  4636 			buttonText = StringLoader::LoadL( R_FREESTYLE_EMAIL_UI_SORT_BY_SUBJECT );
  4768 			textureIndex = iCurrentSortCriteria.iOrder == EFSMailAscending ?
       
  4769 						   ESortListSubjectDescTexture :
       
  4770 						   ESortListSubjectAscTexture;
  4637 			}
  4771 			}
  4638 			break;
  4772 			break;
  4639 		case EFSMailSortByAttachment:
  4773 		case EFSMailSortByAttachment:
  4640 			{
  4774 			{
  4641 			buttonText = StringLoader::LoadL( R_FREESTYLE_EMAIL_UI_SORT_BY_ATTACHMENT );
  4775 			textureIndex = iCurrentSortCriteria.iOrder == EFSMailAscending ?
       
  4776 						   ESortListAttachmentDescTexture :
       
  4777 						   ESortListAttachmentAscTexture;
  4642 			}
  4778 			}
  4643 			break;
  4779 			break;
  4644 		case EFSMailSortByFlagStatus:
  4780 		case EFSMailSortByFlagStatus:
  4645 			{
  4781 			{
  4646 			buttonText = StringLoader::LoadL( R_FREESTYLE_EMAIL_UI_SORT_BY_FLAG );
  4782 			textureIndex = iCurrentSortCriteria.iOrder == EFSMailAscending ?
       
  4783 						   ESortListFollowDescTexture :
       
  4784 						   ESortListFollowAscTexture;
       
  4785 			}
       
  4786 			break;
       
  4787 		case EFSMailSortByRecipient:
       
  4788 		case EFSMailSortBySender:
       
  4789 			{
       
  4790 			textureIndex = iCurrentSortCriteria.iOrder == EFSMailAscending ?
       
  4791 						   ESortListSenderDescTexture :
       
  4792 						   ESortListSenderAscTexture;
       
  4793 			}
       
  4794 			break;
       
  4795 		case EFSMailSortByPriority:
       
  4796 			{
       
  4797 			textureIndex = iCurrentSortCriteria.iOrder == EFSMailAscending ?
       
  4798 						   ESortListPriorityDescTexture :
       
  4799 						   ESortListPriorityAscTexture;
       
  4800 			}
       
  4801 			break;
       
  4802 		case EFSMailSortByUnread:
       
  4803 			{
       
  4804 			textureIndex = iCurrentSortCriteria.iOrder == EFSMailAscending ?
       
  4805 						   ESortListUnreadDescTexture :
       
  4806 						   ESortListUnreadAscTexture;
       
  4807 			}
       
  4808 			break;
       
  4809 		case EFSMailSortByDate:
       
  4810 		default:
       
  4811 			{
       
  4812 			textureIndex = iCurrentSortCriteria.iOrder == EFSMailAscending ?
       
  4813 						   ESortListDateDescTexture :
       
  4814 						   ESortListDateAscTexture;
       
  4815 			}
       
  4816 			break;
       
  4817 		}
       
  4818 
       
  4819 	iSortButton->SetIconL(
       
  4820 			iAppUi.FsTextureManager()->TextureByIndex( textureIndex ),
       
  4821 			ECBElemIconA );
       
  4822 	}
       
  4823 
       
  4824 // ---------------------------------------------------------------------------
       
  4825 //
       
  4826 //
       
  4827 // ---------------------------------------------------------------------------
       
  4828 //
       
  4829 HBufC* CFSEmailUiMailListVisualiser::GetSortButtonTextLC()
       
  4830 	{
       
  4831     FUNC_LOG;
       
  4832 	HBufC* buttonText( 0 );
       
  4833 
       
  4834 	switch ( iCurrentSortCriteria.iField )
       
  4835 		{
       
  4836 		case EFSMailSortBySubject:
       
  4837 			{
       
  4838 			buttonText = StringLoader::LoadLC( R_FREESTYLE_EMAIL_UI_SORT_BY_SUBJECT );
       
  4839 			}
       
  4840 			break;
       
  4841 		case EFSMailSortByAttachment:
       
  4842 			{
       
  4843 			buttonText = StringLoader::LoadLC( R_FREESTYLE_EMAIL_UI_SORT_BY_ATTACHMENT );
       
  4844 			}
       
  4845 			break;
       
  4846 		case EFSMailSortByFlagStatus:
       
  4847 			{
       
  4848 			buttonText = StringLoader::LoadLC( R_FREESTYLE_EMAIL_UI_SORT_BY_FLAG );
  4647 			}
  4849 			}
  4648 			break;
  4850 			break;
  4649 		case EFSMailSortByRecipient:
  4851 		case EFSMailSortByRecipient:
  4650 		case EFSMailSortBySender:
  4852 		case EFSMailSortBySender:
  4651 			{
  4853 			{
  4658 				{
  4860 				{
  4659 				case EFSSentFolder:
  4861 				case EFSSentFolder:
  4660 				case EFSDraftsFolder:
  4862 				case EFSDraftsFolder:
  4661 				case EFSOutbox:
  4863 				case EFSOutbox:
  4662 					{
  4864 					{
  4663 					buttonText = StringLoader::LoadL( R_FREESTYLE_EMAIL_UI_SORT_BY_RECIPIENT );
  4865 					buttonText = StringLoader::LoadLC( R_FREESTYLE_EMAIL_UI_SORT_BY_RECIPIENT );
  4664 					}
  4866 					}
  4665 					break;
  4867 					break;
  4666 				default:
  4868 				default:
  4667 					buttonText = StringLoader::LoadL( R_FREESTYLE_EMAIL_UI_SORT_BY_SENDER );
  4869 					buttonText = StringLoader::LoadLC( R_FREESTYLE_EMAIL_UI_SORT_BY_SENDER );
  4668 					break;
  4870 					break;
  4669 				}
  4871 				}
  4670 			}
  4872 			}
  4671 			break;
  4873 			break;
  4672 		case EFSMailSortByPriority:
  4874 		case EFSMailSortByPriority:
  4673 			{
  4875 			{
  4674 			buttonText = StringLoader::LoadL( R_FREESTYLE_EMAIL_UI_SORT_BY_PRIORITY );
  4876 			buttonText = StringLoader::LoadLC( R_FREESTYLE_EMAIL_UI_SORT_BY_PRIORITY );
  4675 			}
  4877 			}
  4676 			break;
  4878 			break;
  4677 		case EFSMailSortByUnread:
  4879 		case EFSMailSortByUnread:
  4678 			{
  4880 			{
  4679 			buttonText = StringLoader::LoadL( R_FREESTYLE_EMAIL_UI_SORT_BY_UNREAD );
  4881 			buttonText = StringLoader::LoadLC( R_FREESTYLE_EMAIL_UI_SORT_BY_UNREAD );
  4680 			}
  4882 			}
  4681 			break;
  4883 			break;
  4682 		case EFSMailSortByDate:
  4884 		case EFSMailSortByDate:
  4683 		default:
  4885 		default:
  4684 			{
  4886 			{
  4685 			buttonText = StringLoader::LoadL( R_FREESTYLE_EMAIL_UI_SORT_BY_DATE );
  4887 			buttonText = StringLoader::LoadLC( R_FREESTYLE_EMAIL_UI_SORT_BY_DATE );
  4686 			}
  4888 			}
  4687 			break;
  4889 			break;
  4688 
       
  4689 		}
  4890 		}
  4690 	if ( buttonText )
  4891 	return buttonText;
  4691 		{
       
  4692 		CleanupStack::PushL( buttonText );
       
  4693 		iSortButton->SetTextL( *buttonText );
       
  4694 		CleanupStack::PopAndDestroy( buttonText );
       
  4695 		}
       
  4696 	if ( iCurrentSortCriteria.iOrder == EFSMailAscending )
       
  4697 		{
       
  4698 		iSortButton->SetIconL( iAppUi.FsTextureManager()->TextureByIndex( EControlBarAscendingArrowTexture ), ECBElemIconB );
       
  4699 		}
       
  4700 	else
       
  4701 		{
       
  4702 		iSortButton->SetIconL( iAppUi.FsTextureManager()->TextureByIndex( EControlBarDescendingArrowTexture ), ECBElemIconB );
       
  4703 		}
       
  4704 	}
  4892 	}
  4705 
  4893 
  4706 // ---------------------------------------------------------------------------
  4894 // ---------------------------------------------------------------------------
  4707 //
  4895 //
  4708 //
  4896 //
  5343     FUNC_LOG;
  5531     FUNC_LOG;
  5344     TFSMailMsgId msgId; // constructs null ID
  5532     TFSMailMsgId msgId; // constructs null ID
  5345 
  5533 
  5346     if ( aListId != KFsTreeNoneID )
  5534     if ( aListId != KFsTreeNoneID )
  5347         {
  5535         {
  5348         // Substitute node ID with ID of its first child
       
  5349         if ( iMailList->IsNode( aListId ) && iMailList->CountChildren( aListId ) )
       
  5350             {
       
  5351             aListId = iMailList->Child( aListId, 0 );
       
  5352             }
       
  5353 
       
  5354         // Find corresponding message from the model
  5536         // Find corresponding message from the model
  5355         for ( TInt i=0 ; i<iModel->Count() ; i++ )
  5537         const TInt modelCount( iModel->Count() );
       
  5538         for( TInt i( 0 ) ; i < modelCount ; ++i )
  5356             {
  5539             {
  5357             CFSEmailUiMailListModelItem* item =
  5540             CFSEmailUiMailListModelItem* item =
  5358                 static_cast<CFSEmailUiMailListModelItem*>( iModel->Item(i) );
  5541                 static_cast<CFSEmailUiMailListModelItem*>( iModel->Item( i ) );
  5359             if ( item->ModelItemType() == ETypeMailItem &&
  5542             if ( aListId == item->CorrespondingListId() )
  5360                  aListId == item->CorrespondingListId() )
       
  5361                 {
  5543                 {
  5362                 msgId = item->MessagePtr().GetMessageId();
  5544                 msgId = item->MessagePtr().GetMessageId();
       
  5545                 // if list id points to separator
       
  5546                 // set flag on. This is made for improving focus handling.
       
  5547                 if( item->ModelItemType() == ETypeSeparator )
       
  5548                     {
       
  5549                     msgId.SetSeparator( ETrue );
       
  5550                     }
  5363                 break;
  5551                 break;
  5364                 }
  5552                 }
  5365             }
  5553             }
  5366         }
  5554         }
  5367 
  5555 
  5467 	// point to loop the whole list. There shouldn't be any null id's in
  5655 	// point to loop the whole list. There shouldn't be any null id's in
  5468 	// the model anyway. There is currently also an error in FW's equality
  5656 	// the model anyway. There is currently also an error in FW's equality
  5469 	// operator implementation; it doesn't check the iNullId flag at all.
  5657 	// operator implementation; it doesn't check the iNullId flag at all.
  5470 	if( !aMessageId.IsNullId() )
  5658 	if( !aMessageId.IsNullId() )
  5471 	    {
  5659 	    {
  5472     	for ( TInt i=0; i<iModel->Count() ; i++ )
  5660 	    const TInt modelCount( iModel->Count() );
       
  5661     	for ( TInt i( 0 ); i < modelCount ; ++i )
  5473     		{
  5662     		{
  5474     		CFSEmailUiMailListModelItem* item =
  5663     		CFSEmailUiMailListModelItem* item =
  5475     			static_cast<CFSEmailUiMailListModelItem*>( iModel->Item(i) );
  5664                 static_cast<CFSEmailUiMailListModelItem*>( iModel->Item( i ) );
  5476     		if ( item->ModelItemType() == ETypeMailItem &&
  5665     		if ( aMessageId == item->MessagePtr().GetMessageId() )
  5477     		     aMessageId == item->MessagePtr().GetMessageId() )
       
  5478     			{
  5666     			{
  5479     			idx = i;
  5667     			TModelItemType itemType = item->ModelItemType();
  5480     			break;
  5668     			TBool separator( aMessageId.IsSeparator() );
       
  5669 
       
  5670     			// Because separator and the first message after separator
       
  5671     			// have same message id, we need to separate these cases
       
  5672     			// and that is made with separator flag which is stored to
       
  5673     			// TFSMailMsgId object. If separator flag is on item need to be
       
  5674     			// separator if it is not on item needs to be mail item.
       
  5675     			if( ( separator && itemType == ETypeSeparator ) ||
       
  5676     			    ( !separator && itemType == ETypeMailItem ) )
       
  5677                     {
       
  5678                     idx = i;
       
  5679                     break;
       
  5680                     }
  5481     			}
  5681     			}
  5482     		}
  5682     		}
  5483         }
  5683         }
  5484 	return idx;
  5684 	return idx;
  5485     }
  5685     }
  5608 /* <cmail> Sorting empty list enabled
  5808 /* <cmail> Sorting empty list enabled
  5609                 // Show sort list only if maiil list is not empty
  5809                 // Show sort list only if maiil list is not empty
  5610                 if ( iModel->Count() )
  5810                 if ( iModel->Count() )
  5611 </cmail> */
  5811 </cmail> */
  5612                     {
  5812                     {
  5613                     iAppUi.ShowSortListInPopupL( iCurrentSortCriteria.iField, folderType, this, iSortButton );
  5813                     iAppUi.ShowSortListInPopupL( iCurrentSortCriteria, folderType, this, iSortButton );
  5614                     }
  5814                     }
  5615 				}
  5815 				}
  5616 				return;
  5816 				return;
  5617 			case EFSEmailUiCtrlBarResponseCancel:
  5817 			case EFSEmailUiCtrlBarResponseCancel:
  5618 			    SetMskL();
  5818 			    SetMskL();
  6375 		}
  6575 		}
  6376 
  6576 
  6377 	// Set the position for the popup
  6577 	// Set the position for the popup
  6378 	iStylusPopUpMenu->SetPosition( ActionMenuPosition() );
  6578 	iStylusPopUpMenu->SetPosition( ActionMenuPosition() );
  6379 
  6579 
  6380 	// Display the popup
  6580 	// Display the popup and set the flag to indicate that the menu was
       
  6581 	// launched.
  6381 	iStylusPopUpMenu->ShowMenu();
  6582 	iStylusPopUpMenu->ShowMenu();
       
  6583 	iStylusPopUpMenuLaunched = ETrue;
  6382 	}
  6584 	}
  6383 
  6585 
  6384 // ---------------------------------------------------------------------------
  6586 // ---------------------------------------------------------------------------
  6385 // CreateNewMsgL
  6587 // CreateNewMsgL
  6386 // Launches editor.
  6588 // Launches editor.
  6629 	    			case StartingSync:
  6831 	    			case StartingSync:
  6630 	   					{
  6832 	   					{
  6631 	   					//If sync was started by user, show the synchronisation indicator
  6833 	   					//If sync was started by user, show the synchronisation indicator
  6632 	   					if ( iManualMailBoxSync )
  6834 	   					if ( iManualMailBoxSync )
  6633 	   						{
  6835 	   						{
  6634 							CFSMailBox* mb = iAppUi.GetActiveMailbox();
       
  6635 			   				TDesC* mbName = &mb->GetName();
       
  6636 			   		     	ManualMailBoxSync(EFalse);
  6836 			   		     	ManualMailBoxSync(EFalse);
  6637 	   						}
  6837 	   						}
  6638 		   				}
  6838 		   				}
  6639 						break;
  6839 						break;
  6640 	    			}
  6840 	    			}
  6641     			}
  6841     			}
  6642 			}
  6842 			}
  6643 		}
  6843 		}
  6644 	}
  6844 	}
  6645 
  6845 
  6646 void CFSEmailUiMailListVisualiser::TreeListEventL( const TFsTreeListEvent aEvent, const TFsTreeItemId aId )
  6846 // ---------------------------------------------------------------------------
       
  6847 //
       
  6848 // ---------------------------------------------------------------------------
       
  6849 //
       
  6850 void CFSEmailUiMailListVisualiser::TreeListEventL(
       
  6851     const TFsTreeListEvent aEvent, const TFsTreeItemId aId )
  6647 	{
  6852 	{
  6648     FUNC_LOG;
  6853     FUNC_LOG;
  6649 	if ( aEvent == MFsTreeListObserver::EFsTreeListItemWillGetFocused && aId != KFsTreeNoneID )
  6854     switch( aEvent )
  6650 	    {//EFalse - do not call UpdateItem directly, new text will be drawn when item gets focus
  6855         {
  6651         UpdatePreviewPaneTextIfNecessaryL( aId, EFalse );
  6856         case EFsTreeListItemWillGetFocused:
  6652 	    }
  6857             {
  6653 	else if ( aEvent == MFsTreeListObserver::EFsTreeListItemTouchFocused )
  6858             if( aId != KFsTreeNoneID )
  6654 	    {
  6859                 {
  6655 
  6860                 UpdatePreviewPaneTextIfNecessaryL( aId, EFalse );
  6656 	    }
  6861                 }
       
  6862             break;
       
  6863             }
       
  6864         case EFsTreeListItemTouchFocused:
       
  6865             {
       
  6866             break;
       
  6867             }
       
  6868         case EFsFocusVisibilityChange:
       
  6869             {
       
  6870             iAppUi.SetFocusVisibility( EFalse );
       
  6871             break;
       
  6872             }
       
  6873         default:
       
  6874             {
       
  6875             // Do not handle other events
       
  6876             break;
       
  6877             }
       
  6878 
       
  6879         }
  6657 	}
  6880 	}
  6658 
  6881 
  6659 // ---------------------------------------------------------------------------
  6882 // ---------------------------------------------------------------------------
  6660 // UpdateMailListSettingsL
  6883 // UpdateMailListSettingsL
  6661 // Function reads and updates mail list specific settings from the cen rep
  6884 // Function reads and updates mail list specific settings from the cen rep
  6734 	TRAPD( err, mailBoxIcon = brandManager.GetGraphicL( EFSMailboxIcon,  iAppUi.GetActiveMailboxId() ) );
  6957 	TRAPD( err, mailBoxIcon = brandManager.GetGraphicL( EFSMailboxIcon,  iAppUi.GetActiveMailboxId() ) );
  6735 	if ( err == KErrNone && mailBoxIcon )
  6958 	if ( err == KErrNone && mailBoxIcon )
  6736 		{
  6959 		{
  6737 		CleanupStack::PushL( mailBoxIcon );
  6960 		CleanupStack::PushL( mailBoxIcon );
  6738         //<cmail>
  6961         //<cmail>
  6739 		TSize defaultIconSize(iAppUi.LayoutHandler()->GetControlBarMailboxIconSize());
  6962 		TSize defaultIconSize(iAppUi.LayoutHandler()->GetControlBarMailboxIconRect().Size());
  6740         //</cmail>
  6963         //</cmail>
  6741     	AknIconUtils::SetSize(mailBoxIcon->Bitmap(), defaultIconSize);
  6964     	AknIconUtils::SetSize(mailBoxIcon->Bitmap(), defaultIconSize);
  6742 	    AknIconUtils::SetSize(mailBoxIcon->Mask(), defaultIconSize);
  6965 	    AknIconUtils::SetSize(mailBoxIcon->Mask(), defaultIconSize);
  6743 		// Create texture into TextureManager, If not already existing
  6966 		// Create texture into TextureManager, If not already existing
  6744 	    iAppUi.FsTextureManager()->CreateBrandedMailboxTexture( mailBoxIcon,
  6967 	    iAppUi.FsTextureManager()->CreateBrandedMailboxTexture( mailBoxIcon,
  6747 	    		                                                defaultIconSize );
  6970 	    		                                                defaultIconSize );
  6748 	    // Get branded mailbox icon
  6971 	    // Get branded mailbox icon
  6749 	    iMailBoxIconTexture = &iAppUi.FsTextureManager()->TextureByMailboxIdL( iAppUi.GetActiveMailboxId().PluginId(),
  6972 	    iMailBoxIconTexture = &iAppUi.FsTextureManager()->TextureByMailboxIdL( iAppUi.GetActiveMailboxId().PluginId(),
  6750 	    		                                                               iAppUi.GetActiveMailboxId().Id(),
  6973 	    		                                                               iAppUi.GetActiveMailboxId().Id(),
  6751 	    		                                                               defaultIconSize );
  6974 	    		                                                               defaultIconSize );
  6752 		iIconButton->SetIconL( *iMailBoxIconTexture );
  6975 		iFolderListButton->SetIconL( *iMailBoxIconTexture );
  6753 		CleanupStack::PopAndDestroy( mailBoxIcon );
  6976 		CleanupStack::PopAndDestroy( mailBoxIcon );
  6754 		}
  6977 		}
  6755 	else
  6978 	else
  6756 		{
  6979 		{
  6757 		iIconButton->SetIconL( iAppUi.FsTextureManager()->TextureByIndex( EListControlBarMailboxDefaultIcon ) );
  6980 		iFolderListButton->SetIconL( iAppUi.FsTextureManager()->TextureByIndex( EListControlBarMailboxDefaultIcon ) );
  6758 		}
  6981 		}
  6759 	}
  6982 	}
  6760 
  6983 
  6761 
  6984 
  6762 void CFSEmailUiMailListVisualiser::SetBrandedListWatermarkL()
  6985 void CFSEmailUiMailListVisualiser::SetBrandedListWatermarkL()
  6951 	    iMailTreeListVisualizer->SetFocusedItemL( iTreeItemArray[prevIdx].iListItemId, EFalse );
  7174 	    iMailTreeListVisualizer->SetFocusedItemL( iTreeItemArray[prevIdx].iListItemId, EFalse );
  6952 	    // </cmail>
  7175 	    // </cmail>
  6953 	    ChangeReadStatusOfHighlightedL( ETrue );
  7176 	    ChangeReadStatusOfHighlightedL( ETrue );
  6954         aFoundPreviousMsgId = MsgIdFromIndex( prevIdx );
  7177         aFoundPreviousMsgId = MsgIdFromIndex( prevIdx );
  6955 	    ret = KErrNone;
  7178 	    ret = KErrNone;
  6956 	    }
  7179 	    }	
       
  7180 	
  6957 	if ( ret == KErrNone )
  7181 	if ( ret == KErrNone )
  6958 		{
  7182 		{
  6959 		OpenHighlightedMailL();
  7183 		OpenHighlightedMailL();
  6960 		}
  7184 		}
  6961 	return ret;
  7185 	return ret;
  6962 	}
  7186 	}
  6963 
  7187 
       
  7188 TInt CFSEmailUiMailListVisualiser::MoveToPreviousMsgAfterDeleteL( TFSMailMsgId aFoundPreviousMsgId )
       
  7189 	{
       
  7190 	FUNC_LOG;
       
  7191 	TInt ret(KErrNotFound);	
       
  7192 	
       
  7193 	TInt idx = ItemIndexFromMessageId( aFoundPreviousMsgId );	
       
  7194 	if ( idx >= 0 )
       
  7195 		{		
       
  7196 		// Focus the previous message
       
  7197 		iMailTreeListVisualizer->SetFocusedItemL( iTreeItemArray[idx].iListItemId, EFalse );
       
  7198 		ChangeReadStatusOfHighlightedL( ETrue );
       
  7199 		ret = KErrNone;		
       
  7200 		}
       
  7201 
       
  7202 	if ( ret == KErrNone )
       
  7203 		{
       
  7204 		OpenHighlightedMailL();
       
  7205 		}
       
  7206 	
       
  7207 	return ret;
       
  7208 	}
  6964 
  7209 
  6965 void CFSEmailUiMailListVisualiser::ManualMailBoxSync( TBool aManualMailBoxSync )
  7210 void CFSEmailUiMailListVisualiser::ManualMailBoxSync( TBool aManualMailBoxSync )
  6966 	{
  7211 	{
  6967     FUNC_LOG;
  7212     FUNC_LOG;
  6968 	iManualMailBoxSync = aManualMailBoxSync;
  7213 	iManualMailBoxSync = aManualMailBoxSync;
  7012         iMailList->SetFocusedL( ETrue );
  7257         iMailList->SetFocusedL( ETrue );
  7013         iControlBarControl->SetFocusL( EFalse );
  7258         iControlBarControl->SetFocusL( EFalse );
  7014         }
  7259         }
  7015     else
  7260     else
  7016         {
  7261         {
       
  7262         if ( iStylusPopUpMenuLaunched )
       
  7263         	{
       
  7264         	return;
       
  7265         	}
       
  7266 
  7017         iMailList->SetFocusedL( EFalse );
  7267         iMailList->SetFocusedL( EFalse );
  7018         TInt focusedBtnId = KErrNotFound;
  7268         TInt focusedBtnId = KErrNotFound;
  7019         MFsControlButtonInterface* focusedBtn = iControlBarControl->GetFocusedButton();
  7269         MFsControlButtonInterface* focusedBtn = iControlBarControl->GetFocusedButton();
  7020         if ( focusedBtn )
  7270         if ( focusedBtn )
  7021             {
  7271             {
  7145 	    TInt modelCountBeforeUpdate = iMailListVisualiser->iModel->Count();
  7395 	    TInt modelCountBeforeUpdate = iMailListVisualiser->iModel->Count();
  7146 	    if ( iMailListVisualiser->iModel->Count() )
  7396 	    if ( iMailListVisualiser->iModel->Count() )
  7147 	    	{
  7397 	    	{
  7148 	  		CFSEmailUiMailListModelItem* item =
  7398 	  		CFSEmailUiMailListModelItem* item =
  7149 				static_cast<CFSEmailUiMailListModelItem*>(iMailListVisualiser->iModel->Item( highlightedIndexBeforeUpdate ) );
  7399 				static_cast<CFSEmailUiMailListModelItem*>(iMailListVisualiser->iModel->Item( highlightedIndexBeforeUpdate ) );
  7150 			if ( item->ModelItemType() == ETypeMailItem )
  7400 			if ( item && item->ModelItemType() == ETypeMailItem )
  7151 				{
  7401 				{
  7152 			    msgIdBeforeRefresh = item->MessagePtr().GetMessageId();
  7402 			    msgIdBeforeRefresh = item->MessagePtr().GetMessageId();
  7153 				}
  7403 				}
  7154 	    	}
  7404 	    	}
  7155 
  7405