emailuis/emailui/src/FreestyleEmailUiMailListVisualiser.cpp
changeset 2 5253a20d2a1e
parent 1 12c456ceeff2
child 3 a4d6f1ea0416
equal deleted inserted replaced
1:12c456ceeff2 2:5253a20d2a1e
    21 #include <freestyleemailui.mbg>
    21 #include <freestyleemailui.mbg>
    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 //<cmail>
       
    27 #include <featmgr.h>
    26 #include <featmgr.h>
    28 //</cmail>
       
    29 #include "CFSMailClient.h"
    27 #include "CFSMailClient.h"
    30 #include "CFSMailBox.h"
    28 #include "CFSMailBox.h"
    31 #include "CFSMailFolder.h"
    29 #include "CFSMailFolder.h"
    32 #include "fscontrolbar.h"
    30 #include "fscontrolbar.h"
    33 #include "fscontrolbuttoninterface.h"
    31 #include "fscontrolbuttoninterface.h"
    52 #include <alf/alfstatic.h>
    50 #include <alf/alfstatic.h>
    53 
    51 
    54 #include <aknnotewrappers.h>
    52 #include <aknnotewrappers.h>
    55 #include <msvapi.h>
    53 #include <msvapi.h>
    56 #include <akntitle.h>
    54 #include <akntitle.h>
    57 //<cmail>
       
    58 #include "ESMailSettingsPluginUids.hrh"
    55 #include "ESMailSettingsPluginUids.hrh"
    59 #include "ESMailSettingsPlugin.h"
    56 #include "ESMailSettingsPlugin.h"
    60 #include "MFSMailBrandManager.h"
    57 #include "MFSMailBrandManager.h"
    61 //</cmail>
       
    62 #include <AknWaitDialog.h>
    58 #include <AknWaitDialog.h>
    63 // <cmail>
       
    64 #include <aknlayoutscalable_apps.cdl.h>
    59 #include <aknlayoutscalable_apps.cdl.h>
    65 #include <layoutmetadata.cdl.h>
    60 #include <layoutmetadata.cdl.h>
    66 #include <csxhelp/cmail.hlp.hrh>
    61 #include <csxhelp/cmail.hlp.hrh>
    67 // </cmail>
       
    68 // Meeting request
    62 // Meeting request
    69 #include <MeetingRequestUids.hrh>
    63 #include <MeetingRequestUids.hrh>
    70 // <cmail>
       
    71 #include "cesmricalviewer.h"
    64 #include "cesmricalviewer.h"
    72 //</cmail>
       
    73 #include <aknstyluspopupmenu.h>
    65 #include <aknstyluspopupmenu.h>
    74 #include <akntoolbar.h>
    66 #include <akntoolbar.h>
    75 
    67 
    76 // INTERNAL INCLUDES
    68 // INTERNAL INCLUDES
    77 #include "FreestyleEmailUiUtilities.h"
    69 #include "FreestyleEmailUiUtilities.h"
   158 
   150 
   159 	iFirstStartCompleted = EFalse;
   151 	iFirstStartCompleted = EFalse;
   160 
   152 
   161 	iAsyncCallback = new (ELeave) CAsyncCallBack( CActive::EPriorityStandard );
   153 	iAsyncCallback = new (ELeave) CAsyncCallBack( CActive::EPriorityStandard );
   162 	iAsyncRedrawer = new (ELeave) CAsyncCallBack( CActive::EPriorityLow );
   154 	iAsyncRedrawer = new (ELeave) CAsyncCallBack( CActive::EPriorityLow );
       
   155 	iLastFocus = EFalse;
   163  	}
   156  	}
   164 
   157 
   165 // CFSEmailUiMailListVisualiser::DoFirstStartL()
   158 // CFSEmailUiMailListVisualiser::DoFirstStartL()
   166 // Purpose of this function is to do first start things only when list is
   159 // Purpose of this function is to do first start things only when list is
   167 // really needed to be shown. Implemented to make app startuo faster.
   160 // really needed to be shown. Implemented to make app startuo faster.
   259         iStylusPopUpMenu = CAknStylusPopUpMenu::NewL( this , point );
   252         iStylusPopUpMenu = CAknStylusPopUpMenu::NewL( this , point );
   260 		TResourceReader reader;
   253 		TResourceReader reader;
   261 		iCoeEnv->CreateResourceReaderLC( reader,
   254 		iCoeEnv->CreateResourceReaderLC( reader,
   262 				R_STYLUS_POPUP_MENU_MESSAGE_LIST_VIEW );
   255 				R_STYLUS_POPUP_MENU_MESSAGE_LIST_VIEW );
   263 		iStylusPopUpMenu->ConstructFromResourceL( reader );
   256 		iStylusPopUpMenu->ConstructFromResourceL( reader );
   264 		CleanupStack::PopAndDestroy();
   257 		CleanupStack::PopAndDestroy(); // reader
   265         }
   258         }
   266 
   259 
   267     iAppUi.LayoutHandler()->SetListMarqueeBehaviour( iMailList );
   260     iAppUi.LayoutHandler()->SetListMarqueeBehaviour( iMailList );
   268 
   261 
   269     iDateChangeTimer = CDateChangeTimer::NewL( *this );
   262     iDateChangeTimer = CDateChangeTimer::NewL( *this );
   287 CFSEmailUiMailListVisualiser::CFSEmailUiMailListVisualiser( CAlfEnv& aEnv,
   280 CFSEmailUiMailListVisualiser::CFSEmailUiMailListVisualiser( CAlfEnv& aEnv,
   288     CFreestyleEmailUiAppUi* aAppUi, CAlfControlGroup& aMailListControlGroup )
   281     CFreestyleEmailUiAppUi* aAppUi, CAlfControlGroup& aMailListControlGroup )
   289     : CFsEmailUiViewBase( aMailListControlGroup, *aAppUi ),
   282     : CFsEmailUiViewBase( aMailListControlGroup, *aAppUi ),
   290     iEnv( aEnv ),
   283     iEnv( aEnv ),
   291     iListMarkItemsState( ETrue ), //Initlly list has no markings
   284     iListMarkItemsState( ETrue ), //Initlly list has no markings
   292 	iMoveToFolderOngoing( EFalse ),
   285     iConsumeStdKeyYes_KeyUp( EFalse ), // use to prevent Call application execution if call for contact processed
   293 	iStylusPopUpMenuLaunched( EFalse )
   286     iMoveToFolderOngoing( EFalse )
   294 	{
   287 	{
   295     FUNC_LOG;
   288     FUNC_LOG;
   296 	}
   289 	}
   297 
   290 
   298 // ---------------------------------------------------------------------------
   291 // ---------------------------------------------------------------------------
  1202 	iShiftDepressed = EFalse; // clear state just in case
  1195 	iShiftDepressed = EFalse; // clear state just in case
  1203 
  1196 
  1204 	// Inform MR observer if needed, special MR case, returning from attachment list
  1197 	// Inform MR observer if needed, special MR case, returning from attachment list
  1205 	iAppUi.MailViewer().CompletePendingMrCommand();
  1198 	iAppUi.MailViewer().CompletePendingMrCommand();
  1206 
  1199 
  1207 	//Make sure that correct component is set to focused.
  1200 	// Make sure that correct component is set to focused.
  1208 	if ( iFocusedControl == EMailListComponent )
  1201 	if ( iFocusedControl == EMailListComponent )
  1209 	    {
  1202 	    {
  1210 	    SetTreeListFocusedL();
  1203 	    SetTreeListFocusedL();
  1211 	    }
  1204 	    }
  1212 	else
  1205 	else
  1213 	    {
  1206 	    {
  1214 	    SetControlBarFocusedL();
  1207 	    SetControlBarFocusedL();
  1215 	    iControlBarControl->MakeSelectorVisible( iAppUi.IsFocusShown() );
  1208 	    iControlBarControl->MakeSelectorVisible( iAppUi.IsFocusShown() );
  1216 	    }
  1209 	    }
  1217 	UpdateButtonTextsL();
  1210 	UpdateButtonTextsL();
  1218 
       
  1219 	FocusVisibilityChange( iAppUi.IsFocusShown() );
  1211 	FocusVisibilityChange( iAppUi.IsFocusShown() );
  1220 	iAppUi.ShowTitlePaneConnectionStatus();
  1212 	iAppUi.ShowTitlePaneConnectionStatus();
  1221 	}
  1213 	}
  1222 
  1214 
  1223 // ---------------------------------------------------------------------------
  1215 // ---------------------------------------------------------------------------
  1311 	    }
  1303 	    }
  1312 
  1304 
  1313     // MAIN MENU ***************************************************************************
  1305     // MAIN MENU ***************************************************************************
  1314 	if ( aResourceId == R_FSEMAILUI_MAILLIST_MENUPANE )
  1306 	if ( aResourceId == R_FSEMAILUI_MAILLIST_MENUPANE )
  1315 		{
  1307 		{
       
  1308 		// Saves a focus visibility.
       
  1309 		iLastFocus = EFalse;
       
  1310 		if( iFocusedControl == EMailListComponent && IsFocusShown() )
       
  1311 		    {
       
  1312 		    iLastFocus = ETrue;
       
  1313 		    }
  1316 	    if (FeatureManager::FeatureSupported( KFeatureIdFfCmailIntegration ))
  1314 	    if (FeatureManager::FeatureSupported( KFeatureIdFfCmailIntegration ))
  1317 		   {
  1315 		   {
  1318 		   // remove help support in pf5250
  1316 		   // remove help support in pf5250
  1319 		   aMenuPane->SetItemDimmed( EFsEmailUiCmdHelp, ETrue);
  1317 		   aMenuPane->SetItemDimmed( EFsEmailUiCmdHelp, ETrue);
  1320 		   }
  1318 		   }
  1321 
  1319 
  1322 	    // Checks if a device has a keyboard or not.
  1320 	    // Checks if a device has a keyboard or not.
  1323 		if( !iKeyboardFlipOpen )
  1321 		if( !iLastFocus )
  1324     	    {
  1322     	    {
  1325 	        aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsOpen, ETrue );
  1323             // Hide all the normal email message specific actions
       
  1324             aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsReply, ETrue );
       
  1325             aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsReplyAll, ETrue );
       
  1326             aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsForward, ETrue );
  1326             aMenuPane->SetItemDimmed( EFsEmailUiCmdMailActions, ETrue);
  1327             aMenuPane->SetItemDimmed( EFsEmailUiCmdMailActions, ETrue);
  1327 	        aMenuPane->SetItemDimmed( EFsEmailUiCmdReadEmail, ETrue );
  1328 
  1328             }
  1329             TInt markedCount = CountMarkedItemsL();
  1329 
  1330             // Hide mark/unmark all when not applicable
  1330         // OFFLINE/ONLINE MENU SELECTION
  1331             if ( markedCount == EmailsInModelL() ) // Hide mark all
  1331         TFSMailBoxStatus onlineStatus = iAppUi.GetActiveMailbox()->GetMailBoxStatus();
  1332 		       {
  1332         aMenuPane->SetItemDimmed( EFsEmailUiCmdGoOnline, onlineStatus == EFSMailBoxOnline );
  1333 		       aMenuPane->SetItemDimmed( EFsEmailUiCmdSubMenuMark, ETrue );
  1333         aMenuPane->SetItemDimmed( EFsEmailUiCmdGoOffline, onlineStatus == EFSMailBoxOffline );
  1334 		       }
  1334 
  1335             if ( markedCount == 0 ) // Hide unmark all
  1335         // Sync/cancel sync
  1336 		       {
  1336         TBool supportsSync = iAppUi.GetActiveMailbox()->HasCapability( EFSMBoxCapaSupportsSync );
  1337 		       aMenuPane->SetItemDimmed( EFsEmailUiCmdSubMenuUnmark, ETrue );
  1337         if ( !supportsSync )
  1338 		       }
  1338             {
  1339 
  1339             aMenuPane->SetItemDimmed( EFsEmailUiCmdCancelSync, ETrue );
       
  1340             aMenuPane->SetItemDimmed( EFsEmailUiCmdSync, ETrue );
       
  1341             }
       
  1342         else if ( GetLatestSyncState() )
       
  1343             {
       
  1344             aMenuPane->SetItemDimmed( EFsEmailUiCmdSync, ETrue );
       
  1345             }
  1340             }
  1346         else
  1341         else
  1347             {
  1342     	    {
  1348             aMenuPane->SetItemDimmed( EFsEmailUiCmdCancelSync, ETrue );
  1343     		CFSMailMessage* targetMessage = NULL;
  1349             }
  1344             if ( targetEntries.Count() == 1 )
  1350 
  1345                 {
  1351         //MESSAGEREADER MENU SELECTION
  1346                 targetMessage = &MsgPtrFromListIdL( targetEntries[0] );
  1352 		if ( iAppUi.MessageReaderSupportsFreestyle() )
  1347                 }
  1353 			{
  1348 
  1354 			aMenuPane->SetItemDimmed( EFsEmailUiCmdReadEmail, EFalse );
  1349             // Hide the irrelevant reply / reply all / forward commands
  1355 			}
  1350             TInt numRecipients(0);
  1356 		else
  1351             if ( targetMessage )
  1357 			{
  1352                 {
  1358 			aMenuPane->SetItemDimmed( EFsEmailUiCmdReadEmail, ETrue );
  1353                 //Get # of recipients
  1359 			}
  1354                 numRecipients = TFsEmailUiUtility::CountRecipientsSmart( iAppUi, targetMessage );
  1360 		// Disable read in outbox and drafts
  1355                 }
  1361 		if ( currentFolderType == EFSDraftsFolder ||
  1356             // All reply/forward options are hidden when multiple marked messages or folder is outbox or drafts
  1362 		     currentFolderType == EFSOutbox )
  1357             if ( targetEntries.Count() != 1 ||
  1363 			{
  1358                  currentFolderType == EFSOutbox ||
  1364 			aMenuPane->SetItemDimmed( EFsEmailUiCmdReadEmail, ETrue );
  1359                  currentFolderType == EFSDraftsFolder )
  1365 			}
  1360                 {
       
  1361                 aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsReply, ETrue );
       
  1362                 aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsReplyAll, ETrue );
       
  1363                 aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsForward, ETrue );
       
  1364                 }
       
  1365 
       
  1366             // Reply all is hidden also when the single target message has multiple recipients
       
  1367             else if ( !targetMessage || numRecipients <= 1 )
       
  1368                 {
       
  1369                 aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsReplyAll, ETrue );
       
  1370                 }
       
  1371 
       
  1372             aMenuPane->SetItemDimmed( EFsEmailUiCmdSubMenuUnmark, ETrue);
       
  1373             }
  1366 
  1374 
  1367 	    // EMPTY LIST, MOST OPTIONS ARE HIDDEN
  1375 	    // EMPTY LIST, MOST OPTIONS ARE HIDDEN
  1368 	    if ( !iModel->Count() || !iMailFolder )
  1376 	    if ( !iModel->Count() || !iMailFolder )
  1369 	        {
  1377 	        {
  1370 	        aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsOpen, ETrue );
       
  1371 	        aMenuPane->SetItemDimmed( EFsEmailUiCmdMailActions, ETrue );
  1378 	        aMenuPane->SetItemDimmed( EFsEmailUiCmdMailActions, ETrue );
  1372 	        aMenuPane->SetItemDimmed( EFsEmailUiCmdMore, ETrue );
  1379 	        aMenuPane->SetItemDimmed( EFsEmailUiCmdSubMenuMark, ETrue );
       
  1380 	        aMenuPane->SetItemDimmed( EFsEmailUiCmdSubMenuUnmark, ETrue );
  1373 	        aMenuPane->SetItemDimmed( EFsEmailUiCmdSearch, ETrue );
  1381 	        aMenuPane->SetItemDimmed( EFsEmailUiCmdSearch, ETrue );
  1374 	        aMenuPane->SetItemDimmed( EFsEmailUiCmdReadEmail, ETrue );
       
  1375 	        }
  1382 	        }
  1376 
  1383 
  1377 	    // NO TARGET ITEMS, E.G FOCUS ON DIVIDER AND NO MARKED ITEMS, ITEM RELATED OPTIONS ARE HIDDEN
       
  1378 	    else if ( !targetEntries.Count() )
       
  1379 	        {
       
  1380 	        aMenuPane->SetItemDimmed( EFsEmailUiCmdMailActions, ETrue );
       
  1381 	        aMenuPane->SetItemDimmed( EFsEmailUiCmdReadEmail, ETrue );
       
  1382 	        }
       
  1383 
       
  1384 	    // Open command is available only if there's exactly one target item
       
  1385 	    if ( targetEntries.Count() != 1 )
       
  1386 	        {
       
  1387             aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsOpen, ETrue );
       
  1388 	        }
       
  1389 
       
  1390 	    // FOLDER SPECIFIC COMMAND HIDING
  1384 	    // FOLDER SPECIFIC COMMAND HIDING
  1391 	    // In the outbox folder, Open command is inavailable in any case
       
  1392 	    if ( currentFolderType == EFSOutbox )
       
  1393 	        {
       
  1394 	        aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsOpen, ETrue );
       
  1395 	        }
       
  1396 
       
  1397 	    // "Clear deleted folder" command is available only in Deleted folder
  1385 	    // "Clear deleted folder" command is available only in Deleted folder
  1398 	    if ( currentFolderType != EFSDeleted || !iModel->Count() )
  1386 	    if ( currentFolderType != EFSDeleted || !iModel->Count() )
  1399 	        {
  1387 	        {
  1400 	        aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsEmptyDeleted, ETrue );
  1388 	        aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsEmptyDeleted, ETrue );
  1401 	        }
  1389 	        }
  1404 
  1392 
  1405 
  1393 
  1406 	// ACTIONS SUBMENU *********************************************************************
  1394 	// ACTIONS SUBMENU *********************************************************************
  1407 	if ( aResourceId == R_FSEMAILUI_MAILLIST_SUBMENU_MAIL_ACTIONS  )
  1395 	if ( aResourceId == R_FSEMAILUI_MAILLIST_SUBMENU_MAIL_ACTIONS  )
  1408 		{
  1396 		{
  1409 		// Actions menu should never be available when there's no marked or focused item(s)
       
  1410 		__ASSERT_DEBUG( targetEntries.Count(), Panic(EFSEmailUiUnexpectedValue) );
       
  1411 
       
  1412 		CFSMailMessage* targetMessage = NULL;
       
  1413         if ( targetEntries.Count() == 1 )
       
  1414             {
       
  1415             targetMessage = &MsgPtrFromListIdL( targetEntries[0] );
       
  1416             }
       
  1417 
       
  1418 		// Meeting request mode is in use when there's exactly one target item and it's a
       
  1419 		// calendar message and MRUI is available.
       
  1420 		TBool showMrActions = EFalse;
       
  1421 
       
  1422         if ( targetMessage && targetMessage->IsFlagSet( EFSMsgFlag_CalendarMsg ) &&
       
  1423              iAppUi.MrViewerInstanceL() &&
       
  1424              iAppUi.MrViewerInstanceL()->CanViewMessage( *targetMessage ) &&
       
  1425              currentFolderType != EFSOutbox &&
       
  1426 		     currentFolderType != EFSDraftsFolder )
       
  1427 		    {
       
  1428 		    showMrActions = ETrue;
       
  1429 		    }
       
  1430 
       
  1431         // CALENDAR EVENT ACTIONS SUBMENU
       
  1432         if ( showMrActions )
       
  1433             {
       
  1434             // Hide all the normal email message specific actions
       
  1435             aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsReply, ETrue );
       
  1436             aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsReplyAll, ETrue );
       
  1437             aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsForward, ETrue );
       
  1438 
       
  1439             // Hide the irrelevant MR actions
       
  1440             TESMRMeetingRequestMethod mrMethod( EESMRMeetingRequestMethodUnknown );
       
  1441             if ( iAppUi.MrViewerInstanceL() )
       
  1442                 {
       
  1443                 TRAP_IGNORE( mrMethod = iAppUi.MrViewerInstanceL()->ResolveMeetingRequestMethodL( *targetMessage ) );
       
  1444                 }
       
  1445             switch ( mrMethod )
       
  1446                 {
       
  1447                 case EESMRMeetingRequestMethodRequest:
       
  1448                     {
       
  1449                     aMenuPane->SetItemDimmed(EFsEmailUiCmdCalRemoveFromCalendar, ETrue);
       
  1450                     }
       
  1451                     break;
       
  1452                 case EESMRMeetingRequestMethodCancellation:
       
  1453                     {
       
  1454                     aMenuPane->SetItemDimmed(EFsEmailUiCmdCalActionsAccept, ETrue);
       
  1455                     aMenuPane->SetItemDimmed(EFsEmailUiCmdCalActionsTentative, ETrue);
       
  1456                     aMenuPane->SetItemDimmed(EFsEmailUiCmdCalActionsDecline, ETrue);
       
  1457 
       
  1458                     TBool supportsRemove = iAppUi.GetActiveMailbox()->HasCapability( EFSMBoxCapaRemoveFromCalendar );
       
  1459                     if( !supportsRemove )
       
  1460                         {
       
  1461                         aMenuPane->SetItemDimmed(EFsEmailUiCmdCalRemoveFromCalendar, ETrue);
       
  1462                         }
       
  1463                     }
       
  1464                     break;
       
  1465                 case EESMRMeetingRequestMethodResponse:
       
  1466                 case EESMRMeetingRequestMethodUnknown:
       
  1467                     {
       
  1468                     aMenuPane->SetItemDimmed(EFsEmailUiCmdCalRemoveFromCalendar, ETrue);
       
  1469                     aMenuPane->SetItemDimmed(EFsEmailUiCmdCalActionsAccept, ETrue);
       
  1470                     aMenuPane->SetItemDimmed(EFsEmailUiCmdCalActionsTentative, ETrue);
       
  1471                     aMenuPane->SetItemDimmed(EFsEmailUiCmdCalActionsDecline, ETrue);
       
  1472                     }
       
  1473                     break;
       
  1474                 default:
       
  1475                     break;
       
  1476                 }
       
  1477             }
       
  1478 
       
  1479         // MAIL MESSAGE ACTIONS SUBMENU
       
  1480         else
       
  1481             {
       
  1482             // Hide all the calendar event options
       
  1483             aMenuPane->SetItemDimmed( EFsEmailUiCmdCalActionsAccept, ETrue );
       
  1484             aMenuPane->SetItemDimmed( EFsEmailUiCmdCalActionsTentative, ETrue );
       
  1485             aMenuPane->SetItemDimmed( EFsEmailUiCmdCalActionsDecline, ETrue );
       
  1486             aMenuPane->SetItemDimmed( EFsEmailUiCmdCalRemoveFromCalendar, ETrue );
       
  1487 
       
  1488             // Hide the irrelevant reply / reply all / forward commands
       
  1489             TInt numRecipients(0);
       
  1490             if ( targetMessage )
       
  1491                 {
       
  1492                 //Get # of recipients
       
  1493                 numRecipients = TFsEmailUiUtility::CountRecipientsSmart( iAppUi, targetMessage );
       
  1494                 }
       
  1495             // All reply/forward options are hidden when multiple marked messages or folder is outbox or drafts
       
  1496             if ( targetEntries.Count() > 1 ||
       
  1497                  currentFolderType == EFSOutbox ||
       
  1498                  currentFolderType == EFSDraftsFolder )
       
  1499                 {
       
  1500                 aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsReply, ETrue );
       
  1501                 aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsReplyAll, ETrue );
       
  1502                 aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsForward, ETrue );
       
  1503                 }
       
  1504 
       
  1505             // Reply all is hidden also when the single target message has multiple recipients
       
  1506             else if ( !targetMessage || numRecipients <= 1 )
       
  1507                 {
       
  1508                 aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsReplyAll, ETrue );
       
  1509                 }
       
  1510            }
       
  1511 
       
  1512         // COMMON PART OF ACTIONS SUBMENU
  1397         // COMMON PART OF ACTIONS SUBMENU
  1513 		aMenuPane->SetItemDimmed( EFsEmailUiCmdMarkAsRead, !IsMarkAsReadAvailableL() );
  1398 		aMenuPane->SetItemDimmed( EFsEmailUiCmdMarkAsRead, !IsMarkAsReadAvailableL() );
  1514         aMenuPane->SetItemDimmed( EFsEmailUiCmdMarkAsUnread, !IsMarkAsUnreadAvailableL() );
  1399         aMenuPane->SetItemDimmed( EFsEmailUiCmdMarkAsUnread, !IsMarkAsUnreadAvailableL() );
  1515 
  1400 
  1516 		if ( !supportsMoving || !iMailFolder ) // Hide move from actions if not supported
  1401 		if ( !supportsMoving || !iMailFolder ) // Hide move from actions if not supported
  1517 			{
  1402 			{
  1518 			aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsMove, ETrue );
  1403 			aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsMove, ETrue );
  1519 			aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsMoveToDrafts, ETrue );
       
  1520 			}
  1404 			}
  1521 		else
  1405 		else
  1522 			{
  1406 			{
  1523 			// Moving supported, show/hide moving options depending on the current folder
  1407 			// Moving supported, show/hide moving options depending on the current folder
  1524 			// First check deleted items case, IMS does not support deleted sync
  1408 			// Check for outbox case
  1525 			if ( currentFolderType == EFSDeleted )
  1409 			if ( currentFolderType == EFSOutbox )
  1526 				{
  1410 				{
  1527 				aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsMoveToDrafts, ETrue );	// Dim in deleted
       
  1528 				}
       
  1529 			// Then check for outbox case, move to drafts is allowed, other moves not
       
  1530 			else if ( currentFolderType == EFSOutbox )
       
  1531 				{
       
  1532 				// move from outbox to drafts is allowed
       
  1533 				aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsMoveToDrafts, EFalse );	// Allow in outbox
       
  1534 				// moving from outbox is not allowed otherwise
  1411 				// moving from outbox is not allowed otherwise
  1535 				aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsMove, ETrue );
  1412 				aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsMove, ETrue );
  1536 				}
  1413 				}
  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 
       
  1545 			// Handle rest of the folders
  1414 			// Handle rest of the folders
  1546 			else
  1415 			else
  1547 				{
  1416 				{
  1548 				aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsMoveToDrafts, ETrue );	// Dim in other folders
       
  1549 				aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsMove, EFalse );
  1417 				aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsMove, EFalse );
  1550 				}
  1418 				}
  1551 			}
  1419 			}
  1552 		}
  1420 
  1553     // ACTIONS SUBMENU *********************************************************************
       
  1554 
       
  1555 
       
  1556 	// MORE SUBMENU ************************************************************************
       
  1557 	if ( aResourceId == R_FSEMAILUI_MAILLIST_SUBMENU_MORE )
       
  1558 		{
       
  1559 		TInt markedCount = CountMarkedItemsL();
  1421 		TInt markedCount = CountMarkedItemsL();
  1560 
       
  1561 	    // Checks if a device has a keyboard or not.
       
  1562 		if( !iKeyboardFlipOpen )
       
  1563        	    {
       
  1564             aMenuPane->SetItemDimmed( EFsEmailUiCmdMarkMark, ETrue );
       
  1565 		    aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsCallSender, ETrue );
       
  1566 		    aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsAddContact, ETrue );
       
  1567 		    aMenuPane->SetItemDimmed( EFsEmailUiCmdMessageDetails, ETrue );
       
  1568 	        }
       
  1569 
  1422 
  1570 	    // Hide expand/collapse all when not applicable
  1423 	    // Hide expand/collapse all when not applicable
  1571 		if ( iNodesInUse == EListControlSeparatorDisabled || !iModel->Count() )
  1424 		if ( iNodesInUse == EListControlSeparatorDisabled || !iModel->Count() )
  1572 			{
  1425 			{
  1573 			aMenuPane->SetItemDimmed(EFsEmailUiCmdActionsCollapseAll, ETrue);
  1426 			aMenuPane->SetItemDimmed(EFsEmailUiCmdActionsCollapseAll, ETrue);
  1576 		else
  1429 		else
  1577 			{
  1430 			{
  1578 			aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsCollapseAll, AllNodesCollapsed() );
  1431 			aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsCollapseAll, AllNodesCollapsed() );
  1579 			aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsExpandAll, AllNodesExpanded() );
  1432 			aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsExpandAll, AllNodesExpanded() );
  1580 			}
  1433 			}
  1581 
       
  1582 		// Some commands are available only when there's exactly one target message
       
  1583 		if ( targetEntries.Count() != 1 )
       
  1584 			{
       
  1585 			aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsCallSender, ETrue );
       
  1586 			aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsAddContact, ETrue );
       
  1587 			aMenuPane->SetItemDimmed( EFsEmailUiCmdMessageDetails, ETrue );
       
  1588 			}
       
  1589 
       
  1590 		// Hide mark/unmark all when not applicable
       
  1591 		if ( markedCount == EmailsInModelL() ) // Hide mark all
       
  1592 		    {
       
  1593 		    aMenuPane->SetItemDimmed( EFsEmailUiCmdMarkMarkAll, ETrue );
       
  1594 		    //aMenuPane->SetItemDimmed( EFsEmailUiCmdMarkUnmarkAll, EFalse );
       
  1595 		    }
       
  1596 		else if ( !markedCount ) // hide unmark all
       
  1597 		    {
       
  1598 		    //aMenuPane->SetItemDimmed( EFsEmailUiCmdMarkMarkAll, EFalse );
       
  1599 		    aMenuPane->SetItemDimmed( EFsEmailUiCmdMarkUnmarkAll, ETrue );
       
  1600 		    }
       
  1601 
  1434 
  1602 		// Hide followup flagging if not applicable
  1435 		// Hide followup flagging if not applicable
  1603 		if ( !supportsFlag || !targetEntries.Count() )
  1436 		if ( !supportsFlag || !targetEntries.Count() )
  1604 		    {
  1437 		    {
  1605 		    aMenuPane->SetItemDimmed(EFsEmailUiCmdActionsFlag, ETrue);
  1438 		    aMenuPane->SetItemDimmed(EFsEmailUiCmdActionsFlag, ETrue);
  1606 		    }
  1439 		    }
  1607 
  1440 
  1608 		// Hide Download Manager if no downloads present
       
  1609 // <cmail> Prevent Download Manager opening with attachments
       
  1610 //		if ( !iAppUi.DownloadInfoMediator() || !iAppUi.DownloadInfoMediator()->IsAnyAttachmentDownloads() )
       
  1611 //		    {
       
  1612 //		    aMenuPane->SetItemDimmed(EFsEmailUiCmdDownloadManager, ETrue);
       
  1613 //		    }
       
  1614 // </cmail>
       
  1615 
       
  1616 		// Availability of the mark/unmark commands depends only on the focused item
       
  1617 		if ( !iMailList || iMailList->FocusedItem() == KFsTreeNoneID ||
       
  1618 		     iMailList->IsNode( iMailList->FocusedItem() ) )
       
  1619 		    {
       
  1620             aMenuPane->SetItemDimmed( EFsEmailUiCmdMarkMark, ETrue );
       
  1621             aMenuPane->SetItemDimmed( EFsEmailUiCmdMarkUnmark, ETrue );
       
  1622 		    }
       
  1623 		else if ( iMailList->IsMarked( iMailList->FocusedItem() ) ) // Item was already marked
       
  1624 		    {
       
  1625 		    aMenuPane->SetItemDimmed( EFsEmailUiCmdMarkMark, ETrue );
       
  1626 		    }
       
  1627 		else
       
  1628 		    {
       
  1629 		    aMenuPane->SetItemDimmed( EFsEmailUiCmdMarkUnmark, ETrue );
       
  1630 		    }
       
  1631 
       
  1632 	    // Some commands are hidden in the outbox and drafts folders
  1441 	    // Some commands are hidden in the outbox and drafts folders
  1633         if ( currentFolderType == EFSOutbox ||
  1442         if ( currentFolderType == EFSOutbox ||
  1634              currentFolderType == EFSDraftsFolder )
  1443              currentFolderType == EFSDraftsFolder )
  1635             {
  1444             {
  1636             aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsCallSender, ETrue );
       
  1637             aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsAddContact, ETrue );
       
  1638             aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsFlag, ETrue );
  1445             aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsFlag, ETrue );
  1639             }
  1446             }
  1640 		}
  1447 		}
  1641     // MORE SUBMENU ************************************************************************
  1448     // ACTIONS SUBMENU *********************************************************************
  1642 
  1449 
  1643 
  1450 
  1644 	// SETTINGS SUBMENU ********************************************************************
  1451 	// MARK SUBMENU ************************************************************************
  1645 	if ( aResourceId == R_FSEMAILUI_MAILLIST_SUBMENU_MAIL_SETTINGS )
  1452 	// Mark submenu show only when focus is visible
       
  1453 	if ( aResourceId == R_FSEMAILUI_MAILLIST_SUBMENU_MARK)
  1646 		{
  1454 		{
  1647 		TUid pluginUid = iAppUi.GetActiveMailbox()->GetSettingsUid();
  1455 	    // Checks if a device has a keyboard or not.
  1648 
  1456 		if( !iLastFocus )
  1649 		CESMailSettingsPlugin* settingsPlugin =
  1457        	    {
  1650 			static_cast<CESMailSettingsPlugin*>( iAppUi.View( pluginUid ) );
  1458             aMenuPane->SetItemDimmed( EFsEmailUiCmdMarkMark, ETrue );
  1651 
  1459             aMenuPane->SetItemDimmed( EFsEmailUiCmdMarkMarkAll, ETrue );
  1652 		if ( !settingsPlugin )
  1460 	        }
  1653 			{
  1461          else
  1654 			settingsPlugin = CESMailSettingsPlugin::NewL( pluginUid );
  1462        	    {
  1655 			CleanupStack::PushL( settingsPlugin );
  1463             aMenuPane->SetItemDimmed( EFsEmailUiCmdMarkSubAll, ETrue );
  1656 			iAppUi.AddViewL( settingsPlugin );
  1464 	        }
  1657 			CleanupStack::Pop( settingsPlugin ); // ownership transferred
       
  1658 			}
       
  1659 		TInt count( settingsPlugin->MailSettingsSubviewCount() );
       
  1660 		if ( count > 0 )
       
  1661 			{
       
  1662 			TInt index = 0;
       
  1663 			while ( index < count )
       
  1664 				{
       
  1665 				CEikMenuPaneItem::SData newMenuItem;
       
  1666 				newMenuItem.iCommandId = EFsEmailUiCmdSettingsBaseCommandId + index;
       
  1667 				newMenuItem.iCascadeId = 0;
       
  1668 				newMenuItem.iFlags = 0;
       
  1669 				newMenuItem.iText = settingsPlugin->MailSettingsSubviewCaption(
       
  1670 		        		iAppUi.GetActiveMailboxId(),
       
  1671 		        		index,
       
  1672 		        		EFalse
       
  1673 		        		);
       
  1674 		        aMenuPane->InsertMenuItemL(
       
  1675 		        		newMenuItem,
       
  1676 		        		aMenuPane->NumberOfItemsInPane() );
       
  1677 		        ++index;
       
  1678 				}
       
  1679 			}
       
  1680 		else
       
  1681 			{
       
  1682 			// POP/IMAP mailbox settings
       
  1683 			HBufC* ipsText = StringLoader::LoadLC( R_FREESTYLE_EMAIL_UI_SETTINGS_IPS_TEXT );
       
  1684 			CEikMenuPaneItem::SData newMenuItem;
       
  1685 			newMenuItem.iCommandId = EFsEmailUiCmdSettingsBaseCommandId;
       
  1686 			newMenuItem.iCascadeId = 0;
       
  1687 			newMenuItem.iFlags = 0;
       
  1688 			newMenuItem.iText = *ipsText;
       
  1689 	        aMenuPane->InsertMenuItemL(
       
  1690 	        		newMenuItem,
       
  1691 	        		aMenuPane->NumberOfItemsInPane() );
       
  1692 	        CleanupStack::PopAndDestroy( ipsText );
       
  1693 			}
       
  1694 		}
  1465 		}
  1695     // SETTINGS SUBMENU ********************************************************************
  1466 
       
  1467     // MARK SUBMENU ************************************************************************
       
  1468 
       
  1469 
       
  1470 	// UNMARK SUBMENU ************************************************************************
       
  1471 	// Unmark submenu show only when focus is not visible
       
  1472 	if ( aResourceId == R_FSEMAILUI_MAILLIST_SUBMENU_UNMARK)
       
  1473 		{
       
  1474 		// Nothing to do yet
       
  1475 		}
       
  1476     // UNMARK SUBMENU ************************************************************************
       
  1477 
  1696 
  1478 
  1697 	CleanupStack::PopAndDestroy( &targetEntries );
  1479 	CleanupStack::PopAndDestroy( &targetEntries );
  1698 
  1480 
  1699 	// Add shortcut hints
  1481 	// Add shortcut hints
  1700 	iAppUi.ShortcutBinding().AppendShortcutHintsL( *aMenuPane,
  1482 	iAppUi.ShortcutBinding().AppendShortcutHintsL( *aMenuPane,
  1829         if ( aFocusToMessage && !aFocusToMessage->IsNullId() )
  1611         if ( aFocusToMessage && !aFocusToMessage->IsNullId() )
  1830             {
  1612             {
  1831             TInt idx = ItemIndexFromMessageId( *aFocusToMessage );
  1613             TInt idx = ItemIndexFromMessageId( *aFocusToMessage );
  1832             if ( idx >= 0 )
  1614             if ( idx >= 0 )
  1833                 {
  1615                 {
  1834                 iMailList->SetFocusedItemL( iTreeItemArray[idx].iListItemId );
  1616                 TFsTreeItemId itemId = iTreeItemArray[idx].iListItemId;
       
  1617                 iMailList->SetFocusedItemL( itemId );
       
  1618                 // If contorl bar is focused, we need to hide
       
  1619                 // focus then.
       
  1620                 if( iFocusedControl == EControlBarComponent )
       
  1621                     {
       
  1622                     iMailTreeListVisualizer->UpdateItemL( itemId );
       
  1623                     }
  1835                 }
  1624                 }
  1836             }
  1625             }
  1837 	    }
  1626 	    }
  1838 
  1627 
  1839     SetListAndCtrlBarFocusL();
  1628     SetListAndCtrlBarFocusL();
  1914         // SetNullId sets just the null id flag,
  1703         // SetNullId sets just the null id flag,
  1915         // so we need to null the actual id manually
  1704         // so we need to null the actual id manually
  1916         iMsgToFocusAfterRedraw.SetId( 0 );
  1705         iMsgToFocusAfterRedraw.SetId( 0 );
  1917         iMsgToFocusAfterRedraw.SetNullId();
  1706         iMsgToFocusAfterRedraw.SetNullId();
  1918         }
  1707         }
  1919     // <cmail>
  1708 
  1920     if ( iAsyncRedrawer )
  1709     if ( iAsyncRedrawer )
  1921         {
  1710         {
  1922         TCallBack asyncRefresh( DoRefresh, this );
  1711         TCallBack asyncRefresh( DoRefresh, this );
  1923         iAsyncRedrawer->Cancel();
  1712         iAsyncRedrawer->Cancel();
  1924         iAsyncRedrawer->Set( asyncRefresh );
  1713         iAsyncRedrawer->Set( asyncRefresh );
  1925         iAsyncRedrawer->CallBack();
  1714         iAsyncRedrawer->CallBack();
  1926         }
  1715         }
  1927     // </cmail>
       
  1928     }
  1716     }
  1929 
  1717 
  1930 // ---------------------------------------------------------------------------
  1718 // ---------------------------------------------------------------------------
  1931 // Static wrapper function for RefreshL() to enable asynchronous calling
  1719 // Static wrapper function for RefreshL() to enable asynchronous calling
  1932 //
  1720 //
  1950 //
  1738 //
  1951 void CFSEmailUiMailListVisualiser::CompletePendingRefresh()
  1739 void CFSEmailUiMailListVisualiser::CompletePendingRefresh()
  1952     {
  1740     {
  1953     FUNC_LOG;
  1741     FUNC_LOG;
  1954 
  1742 
  1955     if ( iAsyncRedrawer && iAsyncRedrawer->IsActive() ) //<cmail>
  1743     if ( iAsyncRedrawer && iAsyncRedrawer->IsActive() )
  1956         {
  1744         {
  1957         iAsyncRedrawer->Cancel();
  1745         iAsyncRedrawer->Cancel();
  1958         DoRefresh( this );
  1746         DoRefresh( this );
  1959         }
  1747         }
  1960 
  1748 
  2085                                                              TFsTreeItemId aParentNodeId,
  1873                                                              TFsTreeItemId aParentNodeId,
  2086                                                              TInt aChildIdx, /*= KErrNotFound*/
  1874                                                              TInt aChildIdx, /*= KErrNotFound*/
  2087                                                              TBool aAllowRefresh )
  1875                                                              TBool aAllowRefresh )
  2088     {
  1876     {
  2089     FUNC_LOG;
  1877     FUNC_LOG;
  2090     TRect screenRect = iAppUi.ClientRect();
  1878     TRect screenRec( iAppUi.ClientRect() );
  2091     CFsTreePlainTwoLineItemData* itemData(0);
  1879     CFsTreePlainTwoLineItemData* itemData = NULL;
  2092     CFsTreePlainTwoLineItemVisualizer* itemVisualizer(0);
  1880     CFsTreePlainTwoLineItemVisualizer* itemVisualizer = NULL;
  2093     TRgb focusedColor = iAppUi.LayoutHandler()->ListFocusedStateTextSkinColor();
  1881     TRgb focusedColor = iAppUi.LayoutHandler()->ListFocusedStateTextSkinColor();
  2094     TRgb normalColor = iAppUi.LayoutHandler()->ListNormalStateTextSkinColor();
  1882     TRgb normalColor = iAppUi.LayoutHandler()->ListNormalStateTextSkinColor();
  2095 
  1883 
  2096     CFSEmailUiMailListModelItem* item =
  1884     CFSEmailUiMailListModelItem* item =
  2097         static_cast<CFSEmailUiMailListModelItem*>( iModel->Item(aModelIndex) );
  1885         static_cast<CFSEmailUiMailListModelItem*>( iModel->Item(aModelIndex) );
  2105 
  1893 
  2106     // Set placeholder for body preview
  1894     // Set placeholder for body preview
  2107     itemData->SetPreviewPaneDataL( KMissingPreviewDataMarker );
  1895     itemData->SetPreviewPaneDataL( KMissingPreviewDataMarker );
  2108 
  1896 
  2109     // Create item visualiser
  1897     // Create item visualiser
  2110     itemVisualizer = CFsTreePlainTwoLineItemVisualizer::NewL(*iMailList->TreeControl());
  1898     itemVisualizer = CFsTreePlainTwoLineItemVisualizer::NewL(
       
  1899             *iMailList->TreeControl() );
  2111     CleanupStack::PushL( itemVisualizer );
  1900     CleanupStack::PushL( itemVisualizer );
  2112 
       
  2113     // Enable menu icon
       
  2114     itemVisualizer->SetFlags( itemVisualizer->Flags() | KFsTreeListItemHasMenu );
       
  2115 
  1901 
  2116    	itemVisualizer->SetTextAlign( EAlfAlignHLocale );
  1902    	itemVisualizer->SetTextAlign( EAlfAlignHLocale );
  2117 
  1903 
  2118    	TBool previewOn = ( iListMode == EListControlTypeDoubleLinePreviewOn ||
  1904    	TBool previewOn = ( iListMode == EListControlTypeDoubleLinePreviewOn ||
  2119                         iListMode == EListControlTypeSingleLinePreviewOn );
  1905                         iListMode == EListControlTypeSingleLinePreviewOn );
  2432 // ---------------------------------------------------------------------------
  2218 // ---------------------------------------------------------------------------
  2433 //
  2219 //
  2434 //
  2220 //
  2435 // ---------------------------------------------------------------------------
  2221 // ---------------------------------------------------------------------------
  2436 //
  2222 //
  2437 void CFSEmailUiMailListVisualiser::HandleDynamicVariantSwitchL( CFsEmailUiViewBase::TDynamicSwitchType aType )
  2223 void CFSEmailUiMailListVisualiser::HandleDynamicVariantSwitchL(
       
  2224     CFsEmailUiViewBase::TDynamicSwitchType aType )
  2438 	{
  2225 	{
  2439     FUNC_LOG;
  2226     FUNC_LOG;
  2440     CFsEmailUiViewBase::HandleDynamicVariantSwitchL( aType );
  2227     CFsEmailUiViewBase::HandleDynamicVariantSwitchL( aType );
  2441 
  2228 
  2442     if ( iFirstStartCompleted ) // Safety
  2229     if ( iFirstStartCompleted ) // Safety
  2540     return contains;
  2327     return contains;
  2541     }
  2328     }
  2542 
  2329 
  2543 // ---------------------------------------------------------------------------
  2330 // ---------------------------------------------------------------------------
  2544 //
  2331 //
       
  2332 // ---------------------------------------------------------------------------
       
  2333 //
       
  2334 TBool CFSEmailUiMailListVisualiser::HandleArrowEventInPortraitL(
       
  2335         const TInt aScancode,
       
  2336         const TAlfEvent& aEvent,
       
  2337         const TBool aShiftState )
       
  2338     {
       
  2339     FUNC_LOG;
       
  2340     TBool result( EFalse );
       
  2341 
       
  2342     if( aScancode == EStdKeyLeftArrow )
       
  2343         {
       
  2344         if( ( iControlBarControl ) &&
       
  2345             ( iFocusedControl == EMailListComponent ) )
       
  2346             {
       
  2347             // Move focus to control bar (focused button is
       
  2348             // sort button).
       
  2349             HandleCommandL( EFsEmailUiCmdGoToSwitchSorting );
       
  2350             result = ETrue;
       
  2351             }
       
  2352         else if( ( iControlBarControl ) &&
       
  2353                  ( iFocusedControl == EControlBarComponent  ) )
       
  2354             {
       
  2355             TInt focusedButtonId( iControlBarControl->GetFocusedButton()->Id() );
       
  2356             if ( focusedButtonId == iNewEmailButtonId )
       
  2357                 {
       
  2358                 // Change focus to mail list if there are any
       
  2359                 // emails in it.
       
  2360                 if( iModel->Count() )
       
  2361                     {
       
  2362                     iFocusedControl = EMailListComponent;
       
  2363                     result = EFalse;
       
  2364                     }
       
  2365                 // Leave focus to control bar because there are no
       
  2366                 // mails in mail list.
       
  2367                 else
       
  2368                     {
       
  2369                     iControlBarControl->MakeSelectorVisible( IsFocusShown() );
       
  2370                     iFocusedControl = EControlBarComponent;
       
  2371                     result = ETrue; // Do not set focus to empty list
       
  2372                     }
       
  2373                 }
       
  2374             else
       
  2375                 {
       
  2376                 iControlBarControl->MakeSelectorVisible( IsFocusShown() );
       
  2377                 iFocusedControl = EControlBarComponent;
       
  2378                 result = EFalse;
       
  2379                 }
       
  2380             }
       
  2381         else
       
  2382             {
       
  2383             iFocusedControl = EMailListComponent;
       
  2384             result = EFalse;
       
  2385             }
       
  2386         SetMskL();
       
  2387         }
       
  2388     else if( aScancode == EStdKeyRightArrow )
       
  2389         {
       
  2390         // Show toolbar if there is data on the list
       
  2391         const TInt modelCount( iModel->Count() );
       
  2392         TBool focusShown( IsFocusShown() );
       
  2393 
       
  2394         // If control bar is focused.
       
  2395         if( ( iControlBarControl ) &&
       
  2396             ( iFocusedControl == EControlBarComponent ) )
       
  2397             {
       
  2398             TInt focusedButtonId( iControlBarControl->GetFocusedButton()->Id() );
       
  2399 
       
  2400             // If sort button is focused and there are mails in mail
       
  2401             // list then focus is moved to mail list, otherwise
       
  2402             // leave focus to control bar
       
  2403             if( focusedButtonId == iSortButtonId )
       
  2404                 {
       
  2405                 if ( modelCount > 0 ) // Check for empty folder
       
  2406                     {
       
  2407                     iFocusedControl = EMailListComponent;
       
  2408                     result = EFalse;
       
  2409                     }
       
  2410                 else
       
  2411                     {
       
  2412                     iFocusedControl = EControlBarComponent;
       
  2413                     iControlBarControl->MakeSelectorVisible( focusShown );
       
  2414                     result = ETrue; // Do not set focus to empty list
       
  2415                     }
       
  2416                 }
       
  2417             else
       
  2418                 {
       
  2419                 iFocusedControl = EControlBarComponent;
       
  2420                 iControlBarControl->MakeSelectorVisible( focusShown );
       
  2421                 result = EFalse;
       
  2422                 }
       
  2423             }
       
  2424         else if( ( iControlBarControl ) &&
       
  2425                  ( iFocusedControl == EMailListComponent ) )
       
  2426             {
       
  2427             HandleCommandL( EFsEmailUiCmdGoToSwitchNewEmail );
       
  2428             result = ETrue;
       
  2429             }
       
  2430         else
       
  2431             {
       
  2432             iFocusedControl = EMailListComponent;
       
  2433             result = EFalse;
       
  2434             }
       
  2435         SetMskL();
       
  2436         }
       
  2437     else if( aScancode ==  EStdKeyDownArrow )
       
  2438         {
       
  2439         const TInt itemCount( iModel->Count() );
       
  2440         if ( iFocusedControl == EMailListComponent )
       
  2441             {
       
  2442             result = iMailList->TreeControl()->OfferEventL( aEvent );
       
  2443             if ( aShiftState )
       
  2444                 {
       
  2445                 DoScrollMarkUnmarkL(); // marking is done after moving the cursor
       
  2446                 }
       
  2447             }
       
  2448         else if( ( iFocusedControl == EControlBarComponent ) &&
       
  2449                  ( itemCount == 0 ) )
       
  2450             {
       
  2451             result = ETrue; // Do not set focus to empty list
       
  2452             }
       
  2453         else if( ( iFocusedControl == EControlBarComponent ) &&
       
  2454                  ( itemCount > 0 ) )
       
  2455             {
       
  2456             iFocusedControl = EMailListComponent;
       
  2457 
       
  2458             result = iMailList->TreeControl()->OfferEventL(aEvent);
       
  2459             if ( aShiftState )
       
  2460                 {
       
  2461                 DoScrollMarkUnmarkL(); // marking is done after moving the cursor
       
  2462                 }
       
  2463             }
       
  2464         else
       
  2465             {
       
  2466             result = EFalse;
       
  2467             }
       
  2468         SetMskL();
       
  2469         }
       
  2470     else if( aScancode == EStdKeyUpArrow )
       
  2471         {
       
  2472         iControlBarControl->MakeSelectorVisible( IsFocusShown() );
       
  2473         if ( iFocusedControl == EMailListComponent )
       
  2474             {
       
  2475             if ( HighlightedIndex() == 0 )
       
  2476                 {
       
  2477                 HandleCommandL( EFsEmailUiCmdGoToSwitchFolder );
       
  2478                 result = ETrue;
       
  2479                 }
       
  2480             else
       
  2481                 {
       
  2482                 result = iMailList->TreeControl()->OfferEventL( aEvent );
       
  2483                 if ( aShiftState )
       
  2484                     {
       
  2485                     // marking is done after moving the cursor
       
  2486                     DoScrollMarkUnmarkL();
       
  2487                     }
       
  2488                 SetMskL();
       
  2489                 }
       
  2490             }
       
  2491         else if( iFocusedControl == EControlBarComponent )
       
  2492             {
       
  2493             result = ETrue;
       
  2494             }
       
  2495         else
       
  2496             {
       
  2497             result = EFalse;
       
  2498             }
       
  2499         }
       
  2500 
       
  2501     return result;
       
  2502     }
       
  2503 
       
  2504 // ---------------------------------------------------------------------------
       
  2505 //
       
  2506 // ---------------------------------------------------------------------------
       
  2507 //
       
  2508 TBool CFSEmailUiMailListVisualiser::HandleArrowEventInLandscapeL(
       
  2509         const TInt aScancode,
       
  2510         const TAlfEvent& aEvent,
       
  2511         const TBool aShiftState )
       
  2512     {
       
  2513     FUNC_LOG;
       
  2514     TBool result( EFalse );
       
  2515     if( aScancode == EStdKeyRightArrow )
       
  2516         {
       
  2517         if ( iFocusedControl == EMailListComponent )
       
  2518             {
       
  2519             HandleCommandL( EFsEmailUiCmdGoToSwitchFolder );
       
  2520             result = ETrue;
       
  2521             }
       
  2522         else if( iFocusedControl == EControlBarComponent )
       
  2523             {
       
  2524             iControlBarControl->MakeSelectorVisible( IsFocusShown() );
       
  2525             result = ETrue;
       
  2526             }
       
  2527         }
       
  2528     else if( aScancode == EStdKeyLeftArrow )
       
  2529         {
       
  2530         if ( iFocusedControl == EControlBarComponent )
       
  2531             {
       
  2532             const TInt modelCount( iModel->Count() );
       
  2533             if( modelCount > 0 )
       
  2534                 {
       
  2535                 iFocusedControl = EMailListComponent;
       
  2536                 result = iMailList->TreeControl()->OfferEventL( aEvent );
       
  2537                 if( aShiftState )
       
  2538                     {
       
  2539                     // marking is done after moving the cursor
       
  2540                     DoScrollMarkUnmarkL();
       
  2541                     }
       
  2542                 }
       
  2543             else
       
  2544                 {
       
  2545                 iControlBarControl->MakeSelectorVisible( IsFocusShown() );
       
  2546                 // Do not set focus to empty list
       
  2547                 result = ETrue;
       
  2548                 }
       
  2549             }
       
  2550         else if( iFocusedControl == EMailListComponent )
       
  2551             {
       
  2552             result = iMailList->TreeControl()->OfferEventL( aEvent );
       
  2553             if ( aShiftState )
       
  2554                 {
       
  2555                 // marking is done after moving the cursor
       
  2556                 DoScrollMarkUnmarkL();
       
  2557                 }
       
  2558            }
       
  2559         SetMskL();
       
  2560         }
       
  2561     if( aScancode == EStdKeyUpArrow )
       
  2562         {
       
  2563         if( iFocusedControl == EMailListComponent )
       
  2564             {
       
  2565             result = iMailList->TreeControl()->OfferEventL( aEvent );
       
  2566             if ( aShiftState )
       
  2567                 {
       
  2568                 // marking is done after moving the cursor
       
  2569                 DoScrollMarkUnmarkL();
       
  2570                 }
       
  2571             }
       
  2572         else if( iFocusedControl == EControlBarComponent )
       
  2573             {
       
  2574             TInt focusedButtonId( iControlBarControl->GetFocusedButton()->Id() );
       
  2575             if ( focusedButtonId == iNewEmailButtonId )
       
  2576                 {
       
  2577                 // Change focus to mail list if there are any
       
  2578                 // mails in it.
       
  2579                 if( iModel->Count() > 0 )
       
  2580                     {
       
  2581                     iFocusedControl = EMailListComponent;
       
  2582                     result = EFalse;
       
  2583                     }
       
  2584                 // Leave focus to control bar because there are no
       
  2585                 // mails in mail list.
       
  2586                 else
       
  2587                     {
       
  2588                     // Do not set focus to empty list
       
  2589                     iControlBarControl->MakeSelectorVisible( IsFocusShown() );
       
  2590                     result = ETrue;
       
  2591                     }
       
  2592                 }
       
  2593             else
       
  2594                 {
       
  2595                 iControlBarControl->MakeSelectorVisible( IsFocusShown() );
       
  2596                 result = static_cast<CAlfControl*>( iControlBarControl )->OfferEventL( aEvent );
       
  2597                 }
       
  2598             }
       
  2599         SetMskL();
       
  2600         }
       
  2601     else if( aScancode == EStdKeyDownArrow )
       
  2602         {
       
  2603         if( iFocusedControl == EMailListComponent )
       
  2604             {
       
  2605             result = iMailList->TreeControl()->OfferEventL( aEvent );
       
  2606             if( aShiftState )
       
  2607                 {
       
  2608                 // marking is done after moving the cursor
       
  2609                 DoScrollMarkUnmarkL();
       
  2610                 }
       
  2611             }
       
  2612         else if( iFocusedControl == EControlBarComponent )
       
  2613             {
       
  2614             const TInt modelCount( iModel->Count() );
       
  2615             TInt focusedButtonId( iControlBarControl->GetFocusedButton()->Id() );
       
  2616             // If sort button is focused and there are mails in mail
       
  2617             // list then focus is moved to mail list, otherwise
       
  2618             // leave focus to control bar
       
  2619             if( focusedButtonId == iSortButtonId )
       
  2620                 {
       
  2621                 if ( modelCount > 0 ) // Check for empty folder
       
  2622                     {
       
  2623                     iFocusedControl = EMailListComponent;
       
  2624                     result = EFalse;
       
  2625                     }
       
  2626                 else
       
  2627                     {
       
  2628                     iControlBarControl->MakeSelectorVisible( IsFocusShown() );
       
  2629                     result = ETrue; // Do not set focus to empty list
       
  2630                     }
       
  2631                 }
       
  2632             else
       
  2633                 {
       
  2634                 iControlBarControl->MakeSelectorVisible( IsFocusShown() );
       
  2635                 result = static_cast<CAlfControl*>( iControlBarControl )->OfferEventL( aEvent );
       
  2636                 }
       
  2637             }
       
  2638         SetMskL();
       
  2639         }
       
  2640 
       
  2641     return result;
       
  2642     }
       
  2643 
       
  2644 // ---------------------------------------------------------------------------
  2545 //
  2645 //
  2546 // ---------------------------------------------------------------------------
  2646 // ---------------------------------------------------------------------------
  2547 //
  2647 //
  2548 void CFSEmailUiMailListVisualiser::UpdateTheme()
  2648 void CFSEmailUiMailListVisualiser::UpdateTheme()
  2549     {
  2649     {
  2679     RFsTreeItemIdList actionTargetItems;
  2779     RFsTreeItemIdList actionTargetItems;
  2680     CleanupClosePushL( actionTargetItems );
  2780     CleanupClosePushL( actionTargetItems );
  2681     GetActionsTargetEntriesL( actionTargetItems );
  2781     GetActionsTargetEntriesL( actionTargetItems );
  2682 
  2782 
  2683     // Check if the focus needs to be removed.
  2783     // Check if the focus needs to be removed.
  2684     if ( aCommand == KErrCancel || aCommand == EFsEmailUiCmdActionsDelete ||
  2784     if ( ( iStylusPopUpMenuVisible ) &&
  2685     	 aCommand == EFsEmailUiCmdMarkAsRead ||
  2785          ( aCommand == KErrCancel ||
  2686     	 aCommand == EFsEmailUiCmdMarkAsUnread ||
  2786            aCommand == EFsEmailUiCmdActionsDelete ||
  2687     	 aCommand == EFsEmailUiCmdActionsMove ||
  2787     	   aCommand == EFsEmailUiCmdMarkAsRead ||
  2688     	 aCommand == EFsEmailUiCmdMarkUnmarkToggle )
  2788     	   aCommand == EFsEmailUiCmdMarkAsUnread ||
       
  2789     	   aCommand == EFsEmailUiCmdActionsMove ||
       
  2790     	   aCommand == EFsEmailUiCmdActionsMoveMessage ||
       
  2791     	   aCommand == EFsEmailUiCmdMarkUnmarkToggle ||
       
  2792     	   aCommand == EFsEmailUiCmdActionsCollapseAll ||
       
  2793     	   aCommand == EFsEmailUiCmdActionsExpandAll ) )
  2689     	{
  2794     	{
  2690    		// We end up here if the user selects an option from the pop up menu
  2795    		// 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.
  2796     	// or exits the menu by tapping outside of it's area.
  2692     	// Remove the focus from a list item if an item is focused.
  2797     	// Remove the focus from a list item if an item is focused.
  2693    		iStylusPopUpMenuLaunched = EFalse;
  2798     	iStylusPopUpMenuVisible = EFalse;
  2694    		FocusVisibilityChange( EFalse );
  2799     	iAppUi.SetFocusVisibility( EFalse );
  2695     	}
  2800     	}
  2696 
  2801 
  2697     switch ( aCommand )
  2802     switch( aCommand )
  2698         {
  2803         {
  2699     	case EAknSoftkeyOpen:
  2804     	case EAknSoftkeyOpen:
  2700 		{
  2805             {
  2701 		if( !iAppUi.IsFocusShown() )
  2806             if( !iAppUi.IsFocusShown() )
  2702 			{
  2807                 {
  2703 			iAppUi.SetFocusVisibility( ETrue );
  2808                 iAppUi.SetFocusVisibility( ETrue );
  2704 			break;
  2809                 break;
  2705 			}
  2810                 }
  2706 		}
  2811             }
  2707        	case EAknSoftkeySelect:
  2812        	case EAknSoftkeySelect:
  2708        	    {
  2813        	    {
  2709        	    if ( iFocusedControl == EMailListComponent )
  2814        	    if ( iFocusedControl == EMailListComponent )
  2710        	        {
  2815        	        {
  2711        	        CFSEmailUiMailListModelItem* item = dynamic_cast<CFSEmailUiMailListModelItem*>(iModel->Item(HighlightedIndex()));
  2816        	        CFSEmailUiMailListModelItem* item = dynamic_cast<CFSEmailUiMailListModelItem*>(iModel->Item(HighlightedIndex()));
  3072 		case EFsEmailUiCmdMarkUnmarkAll:
  3177 		case EFsEmailUiCmdMarkUnmarkAll:
  3073 			{
  3178 			{
  3074 			UnmarkAllItemsL();
  3179 			UnmarkAllItemsL();
  3075 			}
  3180 			}
  3076 			break;
  3181 			break;
       
  3182 
       
  3183 		case EFsEmailUiCmdMarkSubAll:
       
  3184 			{
       
  3185 			MarkAllItemsL();
       
  3186 			}
       
  3187 			break;
       
  3188 		case EFsEmailUiCmdUnmarkSubAll:
       
  3189 			{
       
  3190 			UnmarkAllItemsL();
       
  3191 			}
       
  3192 			break;
  3077 		case EFsEmailUiCmdReadEmail:
  3193 		case EFsEmailUiCmdReadEmail:
  3078 			{
  3194 			{
  3079 			iAppUi.StartReadingEmailsL();
  3195 			iAppUi.StartReadingEmailsL();
  3080 			}
  3196 			}
  3081 			break;
  3197 			break;
  3222                     else
  3338                     else
  3223                         {
  3339                         {
  3224                         HandleCommandL(EFsEmailUiCmdMarkMark);
  3340                         HandleCommandL(EFsEmailUiCmdMarkMark);
  3225                         }
  3341                         }
  3226 					}
  3342 					}
       
  3343 				else if ( item && item->ModelItemType() == ETypeSeparator )
       
  3344 					{
       
  3345 					// Currently only mark is done since mark should activate
       
  3346 					// marking mode for messages. Unmark can be done via message long tap menu.
       
  3347 					TInt index = HighlightedIndex();
       
  3348 					MarkItemsUnderSeparatorL( ETrue, index );
       
  3349 					}
  3227                 }
  3350                 }
  3228             }
  3351             }
  3229             break;
  3352             break;
  3230         case EFsEmailUiCmdGoToSwitchFolder:
  3353         case EFsEmailUiCmdGoToSwitchFolder:
  3231             {
  3354             {
  3241             iControlBarControl->MakeSelectorVisible( IsFocusShown() );
  3364             iControlBarControl->MakeSelectorVisible( IsFocusShown() );
  3242             iFocusedControl = EControlBarComponent;
  3365             iFocusedControl = EControlBarComponent;
  3243            	iMailList->SetFocusedL( EFalse );
  3366            	iMailList->SetFocusedL( EFalse );
  3244             }
  3367             }
  3245             break;
  3368             break;
       
  3369         case EFsEmailUiCmdGoToSwitchNewEmail:
       
  3370             {
       
  3371             iControlBarControl->SetFocusByIdL( iNewEmailButtonId );
       
  3372             iControlBarControl->MakeSelectorVisible( IsFocusShown() );
       
  3373             iFocusedControl = EControlBarComponent;
       
  3374             iMailList->SetFocusedL( EFalse );
       
  3375             break;
       
  3376             }
  3246         case EFsEmailUiCmdCalActionsAccept:
  3377         case EFsEmailUiCmdCalActionsAccept:
  3247         case EFsEmailUiCmdCalActionsTentative:
  3378         case EFsEmailUiCmdCalActionsTentative:
  3248         case EFsEmailUiCmdCalActionsDecline:
  3379         case EFsEmailUiCmdCalActionsDecline:
  3249         case EFsEmailUiCmdCalRemoveFromCalendar:
  3380         case EFsEmailUiCmdCalRemoveFromCalendar:
  3250 			{
  3381 			{
  3304 					CleanupStack::PopAndDestroy( &msgIds );
  3435 					CleanupStack::PopAndDestroy( &msgIds );
  3305  					}
  3436  					}
  3306        			}
  3437        			}
  3307        		}
  3438        		}
  3308 			break;
  3439 			break;
       
  3440         case EFsEmailUiCmdSettings:
       
  3441             {
       
  3442             TInt tmp = 0;
       
  3443             const TPckgBuf<TInt> pkgBuf( tmp );
       
  3444             iAppUi.EnterFsEmailViewL( SettingsViewId,
       
  3445                                       TUid::Uid(KMailSettingsOpenMainList), pkgBuf );
       
  3446             }
       
  3447             break;
       
  3448 
       
  3449 
  3309 	    default:
  3450 	    default:
  3310 	    	{
       
  3311 	    	// No default action.
       
  3312 	    	}
       
  3313         	break;
  3451         	break;
  3314         } // switch ( aCommand )
  3452         } // switch ( aCommand )
  3315     CleanupStack::PopAndDestroy( &actionTargetItems );
  3453     CleanupStack::PopAndDestroy( &actionTargetItems );
  3316     }
  3454     }
  3317 
  3455 
  3426 //
  3564 //
  3427 void CFSEmailUiMailListVisualiser::CollapseAllNodesL()
  3565 void CFSEmailUiMailListVisualiser::CollapseAllNodesL()
  3428 	{
  3566 	{
  3429     FUNC_LOG;
  3567     FUNC_LOG;
  3430     // Safety check, ignore command if the list is empty
  3568     // Safety check, ignore command if the list is empty
  3431     if ( iMailList->Count() )
  3569     if ( iMailList->Count() > 0 )
  3432         {
  3570         {
  3433     	iMailTreeListVisualizer->CollapseAllL();
  3571     	iMailTreeListVisualizer->CollapseAllL();
  3434         }
  3572         }
  3435     }
  3573     }
  3436 
  3574 
  3437 // ---------------------------------------------------------------------------
  3575 // ---------------------------------------------------------------------------
  3438 //
  3576 //
  3439 //
       
  3440 // ---------------------------------------------------------------------------
  3577 // ---------------------------------------------------------------------------
  3441 //
  3578 //
  3442 void CFSEmailUiMailListVisualiser::ExpandAllNodesL()
  3579 void CFSEmailUiMailListVisualiser::ExpandAllNodesL()
  3443 	{
  3580 	{
  3444     FUNC_LOG;
  3581     FUNC_LOG;
  3445     // Safety check, ignore command if the list is empty
  3582     // Safety check, ignore command if the list is empty
  3446 	if ( iMailList->Count() )
  3583 	if ( iMailList->Count() > 0 )
  3447 	    {
  3584 	    {
  3448     	TFsTreeItemId prevId = iMailList->FocusedItem();
  3585     	TFsTreeItemId prevId = iMailList->FocusedItem();
  3449     	iMailTreeListVisualizer->ExpandAllL();
  3586     	iMailTreeListVisualizer->ExpandAllL();
  3450     	iMailTreeListVisualizer->SetFocusedItemL( prevId );
  3587     	iMailTreeListVisualizer->SetFocusedItemL( prevId );
  3451         }
  3588         }
  3452 	}
  3589 	}
  3453 
  3590 
       
  3591 // ---------------------------------------------------------------------------
       
  3592 //
       
  3593 // ---------------------------------------------------------------------------
       
  3594 //
  3454 void CFSEmailUiMailListVisualiser::ExpandOrCollapseL()
  3595 void CFSEmailUiMailListVisualiser::ExpandOrCollapseL()
  3455     {
  3596     {
  3456     FUNC_LOG;
  3597     FUNC_LOG;
  3457     CFSEmailUiMailListModelItem* item =
  3598     CFSEmailUiMailListModelItem* item =
  3458         dynamic_cast<CFSEmailUiMailListModelItem*>( iModel->Item( HighlightedIndex() ) );
  3599         dynamic_cast<CFSEmailUiMailListModelItem*>( iModel->Item( HighlightedIndex() ) );
  3588         listCount = iMailList->Count();
  3729         listCount = iMailList->Count();
  3589         }
  3730         }
  3590 
  3731 
  3591     if ( iFocusedControl == EControlBarComponent )
  3732     if ( iFocusedControl == EControlBarComponent )
  3592         {
  3733         {
  3593 /* <cmail> Sorting enabled also for empty list
  3734         ChangeMskCommandL( R_FSE_QTN_MSK_CHANGE );
  3594         // Sort menu can't be opened if mail list is empty. Hide MSK label in that case.
       
  3595         if ( !listCount && iControlBarControl->GetFocusedButton() == iSortButton )
       
  3596             {
       
  3597             ChangeMskCommandL( R_FSE_QTN_MSK_EMPTY );
       
  3598             }
       
  3599         else
       
  3600 </cmail> */
       
  3601             {
       
  3602             ChangeMskCommandL( R_FSE_QTN_MSK_CHANGE );
       
  3603             }
       
  3604         }
  3735         }
  3605     else  if ( iFocusedControl == EMailListComponent )
  3736     else  if ( iFocusedControl == EMailListComponent )
  3606         {
  3737         {
  3607         if ( listCount ) // Safety check
  3738         if ( listCount ) // Safety check
  3608             {
  3739             {
  3670 // ---------------------------------------------------------------------------
  3801 // ---------------------------------------------------------------------------
  3671 //
  3802 //
  3672 //
  3803 //
  3673 // ---------------------------------------------------------------------------
  3804 // ---------------------------------------------------------------------------
  3674 //
  3805 //
  3675 TBool CFSEmailUiMailListVisualiser::OfferEventL(const TAlfEvent& aEvent)
  3806 TBool CFSEmailUiMailListVisualiser::OfferEventL( const TAlfEvent& aEvent )
  3676     {
  3807     {
  3677     FUNC_LOG;
  3808     FUNC_LOG;
  3678     TBool result( EFalse );
  3809     TBool result( EFalse );
  3679 
  3810 
  3680     if ( !aEvent.IsKeyEvent() )
  3811     if ( !aEvent.IsKeyEvent() )
  3694                         SetControlBarFocusedL();
  3825                         SetControlBarFocusedL();
  3695                         }
  3826                         }
  3696                     }
  3827                     }
  3697                 else
  3828                 else
  3698                     {
  3829                     {
  3699                     // if pointer up event was not made on control bar area
  3830                     // If pointer down event was not made on control bar area
  3700                     // then focus need to be set to mail list component if it
  3831                     // then focus need to be set to mail list component, if it
  3701                     // didn't already have focus.
  3832                     // didn't already have focus. If mail list is empty, then
  3702                     if( iFocusedControl != EMailListComponent )
  3833                     // focus is hidden and control bar stays as a focused item.
       
  3834                     if( ( iFocusedControl != EMailListComponent ) &&
       
  3835                         ( iMailList->Count() > 0 ) )
  3703                         {
  3836                         {
  3704                         SetTreeListFocusedL();
  3837                         SetTreeListFocusedL();
       
  3838                         }
       
  3839                     else
       
  3840                         {
       
  3841                         iAppUi.SetFocusVisibility( EFalse );
  3705                         }
  3842                         }
  3706                     }
  3843                     }
  3707                 }
  3844                 }
  3708 
  3845 
  3709             // Offer event to focused control.
  3846             // Offer event to focused control.
  3767         iOtherKeyPressedWhileShiftDepressed = ETrue;
  3904         iOtherKeyPressedWhileShiftDepressed = ETrue;
  3768         }
  3905         }
  3769 
  3906 
  3770     // MSK label can now be updated when shift key has been handled
  3907     // MSK label can now be updated when shift key has been handled
  3771     SetMskL();
  3908     SetMskL();
       
  3909     // On KeyUp of EStdKeyYes usually Call application is called - prevent it
       
  3910     if ( iConsumeStdKeyYes_KeyUp && (aEvent.Code() == EEventKeyUp )) 
       
  3911 		{
       
  3912 		iConsumeStdKeyYes_KeyUp = EFalse; // in case call button was consumed elsewhere first key up enables calling Call application
       
  3913 		if ( EStdKeyYes == scanCode) 
       
  3914 			{
       
  3915 			  result = ETrue; // consume not to switch to Call application when call to contact was processed
       
  3916 			  return result;
       
  3917 			}
       
  3918 		}
  3772 
  3919 
  3773     if ( aEvent.IsKeyEvent() && aEvent.Code() == EEventKey )
  3920     if ( aEvent.IsKeyEvent() && aEvent.Code() == EEventKey )
  3774         {
  3921         {
  3775         TBool shiftState = (aEvent.KeyEvent().iModifiers & EModifierShift );
  3922         TBool shiftState = ( aEvent.KeyEvent().iModifiers & EModifierShift );
  3776 
  3923 
  3777         // Do the (un)marking if in shift state and suitable key is received
  3924         // Do the (un)marking if in shift state and suitable key is received
  3778         if ( shiftState )
  3925         if ( shiftState )
  3779             {
  3926             {
  3780             switch ( aEvent.KeyEvent().iScanCode )
  3927             switch ( aEvent.KeyEvent().iScanCode )
  3824 
  3971 
  3825         // If event not handled by now
  3972         // If event not handled by now
  3826         if ( !result )
  3973         if ( !result )
  3827             {
  3974             {
  3828             // Handle possible focus visibility change
  3975             // Handle possible focus visibility change
  3829             if ((scanCode == EStdKeyRightArrow)
  3976             if ( ( scanCode == EStdKeyRightArrow ) ||
  3830                 || (scanCode == EStdKeyLeftArrow)
  3977                  ( scanCode == EStdKeyLeftArrow ) ||
  3831                 || (scanCode == EStdKeyUpArrow)
  3978                  ( scanCode == EStdKeyUpArrow ) ||
  3832                 || (scanCode == EStdKeyDownArrow)
  3979                  ( scanCode == EStdKeyDownArrow ) ||
  3833                 || (scanCode == EStdKeyEnter)
  3980                  ( scanCode == EStdKeyEnter ) ||
  3834                 || (scanCode == EStdKeyDeviceA)
  3981                  ( scanCode == EStdKeyDeviceA ) ||
  3835                 || (scanCode ==EStdKeyDevice3))
  3982                  ( scanCode ==EStdKeyDevice3 ) )
  3836                 {
  3983                 {
  3837 
       
  3838                 // If the focus was not active already, ignore the key press
  3984                 // If the focus was not active already, ignore the key press
  3839                 if( !iAppUi.SetFocusVisibility( ETrue ) )
  3985                 if( !iAppUi.SetFocusVisibility( ETrue ) )
  3840                     {
  3986                     {
  3841                     return ETrue;
  3987                     return ETrue;
  3842                     }
  3988                     }
  3850                 case EAknSoftkeySelect:
  3996                 case EAknSoftkeySelect:
  3851                     {
  3997                     {
  3852                     SetMskL();
  3998                     SetMskL();
  3853                     if ( iFocusedControl == EMailListComponent )
  3999                     if ( iFocusedControl == EMailListComponent )
  3854                         {
  4000                         {
  3855                         TInt modelCount(0);
  4001                         TInt modelCount( modelCount = iModel->Count() );
  3856                         // <cmail>
       
  3857                         modelCount = iModel->Count();
       
  3858                         // </cmail>
       
  3859                         if ( modelCount ) // Safety check
  4002                         if ( modelCount ) // Safety check
  3860                             {
  4003                             {
  3861                             CFSEmailUiMailListModelItem* item =
  4004                             CFSEmailUiMailListModelItem* item =
  3862                                 dynamic_cast<CFSEmailUiMailListModelItem*>( iModel->Item( HighlightedIndex() ) );
  4005                                 dynamic_cast<CFSEmailUiMailListModelItem*>( iModel->Item( HighlightedIndex() ) );
  3863                             // MAIL ITEM; OPEN MAIL
  4006                             // MAIL ITEM; OPEN MAIL
  3885                                 }
  4028                                 }
  3886                             }
  4029                             }
  3887                         }
  4030                         }
  3888                     else
  4031                     else
  3889                         {
  4032                         {
  3890                         TInt focusedButtonId = iControlBarControl->GetFocusedButton()->Id();
  4033                         TInt focusedButtonId( iControlBarControl->GetFocusedButton()->Id() );
  3891                         if ( focusedButtonId == iNewEmailButtonId )
  4034                         if ( focusedButtonId == iNewEmailButtonId )
  3892                             {
  4035                             {
  3893                             HandleCommandL(EFsEmailUiCmdCompose);
  4036                             HandleCommandL(EFsEmailUiCmdCompose);
  3894                             }
  4037                             }
  3895                         else if ( focusedButtonId == iFolderListButtonId )
  4038                         else if ( focusedButtonId == iFolderListButtonId )
  3896                             {
  4039                             {
  3897                             //<cmail>
  4040                             // Set touchmanager not active for preventing getting events.
  3898                             //Set touchmanager not active for preventing getting events.
  4041                             DisableMailList( ETrue );
  3899                             DisableMailList(ETrue);
       
  3900                             //</cmail>
       
  3901                             iAppUi.ShowFolderListInPopupL( FolderId(), this, iFolderListButton );
  4042                             iAppUi.ShowFolderListInPopupL( FolderId(), this, iFolderListButton );
  3902                             }
  4043                             }
  3903                         else if ( focusedButtonId == iSortButtonId )
  4044                         else if ( focusedButtonId == iSortButtonId )
  3904                             {
  4045                             {
  3905                             TFSFolderType folderType;
  4046                             TFSFolderType folderType;
  3912                                 folderType = EFSInbox;
  4053                                 folderType = EFSInbox;
  3913                                 }
  4054                                 }
  3914                             // Show sort if model has data.
  4055                             // Show sort if model has data.
  3915                             if ( iModel->Count() )
  4056                             if ( iModel->Count() )
  3916                                 {
  4057                                 {
  3917                                 //<cmail>
  4058                                 // Set touchmanager not active for preventing getting events.
  3918                                 //Set touchmanager not active for preventing getting events.
       
  3919                                 DisableMailList(ETrue);
  4059                                 DisableMailList(ETrue);
  3920                                 //</cmail>
       
  3921                                 iAppUi.ShowSortListInPopupL( iCurrentSortCriteria, folderType, this, iSortButton );
  4060                                 iAppUi.ShowSortListInPopupL( iCurrentSortCriteria, folderType, this, iSortButton );
  3922                                 }
  4061                                 }
  3923                             else
  4062                             else
  3924                                 {
  4063                                 {
  3925                                 // hide selector focus if popup is not opened
  4064                                 // hide selector focus if popup is not opened
  3926                                 // and selection was not made via HW-keys
  4065                                 // and selection was not made via HW-keys
  3927                                 iControlBarControl->MakeSelectorVisible(
  4066                                 iControlBarControl->MakeSelectorVisible(
  3928                                     IsFocusShown() );
  4067                                     IsFocusShown() );
  3929                                 }
  4068                                 }
  3930                             }
  4069                             }
  3931                         return ETrue;//iControlBar->OfferEventL( aEvent );
  4070                         return ETrue; // iControlBar->OfferEventL( aEvent );
  3932                         }
  4071                         }
  3933                     }
  4072                     }
  3934                     break;
  4073                     break;
  3935                 case EStdKeyLeftArrow:
  4074                 case EStdKeyLeftArrow:
       
  4075                 case EStdKeyRightArrow:
       
  4076                 case EStdKeyDownArrow:
       
  4077                 case EStdKeyUpArrow:
  3936                     {
  4078                     {
  3937                     if( iControlBarControl && iFocusedControl == EMailListComponent )
  4079                     if( Layout_Meta_Data::IsLandscapeOrientation() )
  3938                         {
  4080                         {
  3939                         HandleCommandL( EFsEmailUiCmdGoToSwitchSorting );
  4081                         result = HandleArrowEventInLandscapeL( scanCode,
  3940                         result = ETrue;
  4082                                     aEvent, shiftState );
  3941                         }
       
  3942                     else if( ( iControlBarControl ) &&
       
  3943                              ( iFocusedControl == EControlBarComponent  ) )
       
  3944                         {
       
  3945                         TInt focusedButtonId = iControlBarControl->GetFocusedButton()->Id();
       
  3946                         iControlBarControl->MakeSelectorVisible( IsFocusShown() );
       
  3947                         if ( focusedButtonId == iFolderListButtonId )
       
  3948                             {
       
  3949                             if ( iModel->Count() )
       
  3950                                 {
       
  3951                                 iFocusedControl = EMailListComponent;
       
  3952                                 result = EFalse;
       
  3953                                 }
       
  3954                             else
       
  3955                                 {
       
  3956                                 iFocusedControl = EControlBarComponent;
       
  3957                                 result = ETrue; // Do not set focus to empty list
       
  3958                                 }
       
  3959                             }
       
  3960                         else
       
  3961                             {
       
  3962                             iFocusedControl = EControlBarComponent;
       
  3963                             result = EFalse;
       
  3964                             }
       
  3965                         }
  4083                         }
  3966                     else
  4084                     else
  3967                         {
  4085                         {
  3968                         iFocusedControl = EMailListComponent;
  4086                         result = HandleArrowEventInPortraitL( scanCode,
  3969                         result = EFalse;
  4087                                     aEvent, shiftState );
  3970                         }
  4088                         }
  3971                     SetMskL();
  4089                     break;
  3972                     }
  4090                     }
  3973                     break;
       
  3974                 case EStdKeyRightArrow:
       
  3975                     {
       
  3976                     // Show toolbar if there is data on the list
       
  3977                     // <cmail>
       
  3978                     if ( iFocusedControl == EMailListComponent && iModel->Count() )
       
  3979                     // </cmail>
       
  3980                         {
       
  3981                         RFsTreeItemIdList targetEntries;
       
  3982                         CleanupClosePushL( targetEntries );
       
  3983                         GetActionsTargetEntriesL( targetEntries );
       
  3984                         TInt targetCount = targetEntries.Count();
       
  3985                         CleanupStack::PopAndDestroy( &targetEntries );
       
  3986 
       
  3987                         if ( targetCount )
       
  3988                             {
       
  3989                             LaunchStylusPopupMenuL();
       
  3990                             result = ETrue;
       
  3991                             }
       
  3992                         }
       
  3993                     else if( ( iControlBarControl ) &&
       
  3994                              ( iFocusedControl == EControlBarComponent ) )
       
  3995                         {
       
  3996                         TInt focusedButtonId = iControlBarControl->GetFocusedButton()->Id();
       
  3997                         iControlBarControl->MakeSelectorVisible( IsFocusShown() );
       
  3998                         if ( focusedButtonId == iFolderListButtonId )
       
  3999                             {
       
  4000                             iFocusedControl = EControlBarComponent;
       
  4001                             result = EFalse;
       
  4002                             }
       
  4003                         else
       
  4004                             {
       
  4005                             if ( iModel->Count() ) // Check for empty folder
       
  4006                                 {
       
  4007                                 iFocusedControl = EMailListComponent;
       
  4008                                 result = EFalse;
       
  4009                                 }
       
  4010                             else
       
  4011                                 {
       
  4012                                 iFocusedControl = EControlBarComponent;
       
  4013                                 result = ETrue; // Do not set focus to empty list
       
  4014                                 }
       
  4015                             }    					                                   ;
       
  4016                         }
       
  4017                     else
       
  4018                         {
       
  4019                         iFocusedControl = EMailListComponent;
       
  4020                         result = EFalse;
       
  4021                         }
       
  4022                     SetMskL();
       
  4023                     }
       
  4024                     break;
       
  4025                 case EStdKeyDownArrow:
       
  4026                     {
       
  4027                     if ( iFocusedControl == EMailListComponent )
       
  4028                         {
       
  4029                         result = iMailList->TreeControl()->OfferEventL(aEvent);
       
  4030                         if ( shiftState )
       
  4031                             {
       
  4032                             DoScrollMarkUnmarkL(); // marking is done after moving the cursor
       
  4033                             }
       
  4034                         }
       
  4035                     // <cmail>
       
  4036                     else if ( iFocusedControl == EControlBarComponent && iModel->Count() == 0 )
       
  4037                         {
       
  4038                         iControlBarControl->MakeSelectorVisible( IsFocusShown() );
       
  4039                         result = ETrue; // Do not set focus to empty list
       
  4040                         }
       
  4041                     else if ( iFocusedControl == EControlBarComponent && iModel->Count() != 0 )
       
  4042                     // </cmail>
       
  4043                         {
       
  4044                         iFocusedControl = EMailListComponent;
       
  4045 
       
  4046                         result = iMailList->TreeControl()->OfferEventL(aEvent);
       
  4047                         if ( shiftState )
       
  4048                             {
       
  4049                             DoScrollMarkUnmarkL(); // marking is done after moving the cursor
       
  4050                             }
       
  4051                         }
       
  4052                     else
       
  4053                         {
       
  4054                         result = EFalse;
       
  4055                         }
       
  4056                     SetMskL();
       
  4057                     }
       
  4058                     break;
       
  4059                 case EStdKeyUpArrow:
       
  4060                     {
       
  4061                     iControlBarControl->MakeSelectorVisible( IsFocusShown() );
       
  4062                     if ( iFocusedControl == EMailListComponent )
       
  4063                         {
       
  4064                         if ( HighlightedIndex() == 0 )
       
  4065                             {
       
  4066                             HandleCommandL( EFsEmailUiCmdGoToSwitchFolder );
       
  4067                             result = ETrue;
       
  4068                             }
       
  4069                         else
       
  4070                             {
       
  4071                             result = iMailList->TreeControl()->OfferEventL(aEvent);
       
  4072                             if ( shiftState )
       
  4073                                 {
       
  4074                                 DoScrollMarkUnmarkL(); // marking is done after moving the cursor
       
  4075                                 }
       
  4076                             SetMskL();
       
  4077                             }
       
  4078                         }
       
  4079                     else if (iFocusedControl == EControlBarComponent)
       
  4080                         {
       
  4081                         result = ETrue;
       
  4082                         }
       
  4083                     else
       
  4084                         {
       
  4085                         result = EFalse;
       
  4086                         }
       
  4087                     }
       
  4088                     break;
       
  4089                 case EStdKeyYes:
  4091                 case EStdKeyYes:
  4090                     {
  4092                     {
  4091                     if ( !iAppUi.ViewSwitchingOngoing() )
  4093                     if ( !iAppUi.ViewSwitchingOngoing() )
  4092                         {
  4094                         {
  4093                         if ( iMailFolder && iMailFolder->GetFolderType() != EFSOutbox &&
  4095                         if ( iMailFolder && iMailFolder->GetFolderType() != EFSOutbox &&
  4116                                         else
  4118                                         else
  4117                                             {
  4119                                             {
  4118                                             CFsDelayedLoader::InstanceL()->GetContactHandlerL()->FindAndCallToContactByEmailL(
  4120                                             CFsDelayedLoader::InstanceL()->GetContactHandlerL()->FindAndCallToContactByEmailL(
  4119                                                     *mailAddress, iAppUi.GetActiveMailbox(), this, ETrue );
  4121                                                     *mailAddress, iAppUi.GetActiveMailbox(), this, ETrue );
  4120                                             }
  4122                                             }
       
  4123 // consume following KyUp event to prevent execution of Call application when call to contact processing
       
  4124                                         iConsumeStdKeyYes_KeyUp = result = ETrue;
  4121                                         }
  4125                                         }
  4122                                     }
  4126                                     }
  4123                                 }
  4127                                 }
  4124                             }
  4128                             }
  4125                         }
  4129                         }
  4131                     // to react to those until the in the key up event. There hash key works as mark/unmark shortcut only
  4135                     // to react to those until the in the key up event. There hash key works as mark/unmark shortcut only
  4132                     // if it hasn't been used as shift modifier.
  4136                     // if it hasn't been used as shift modifier.
  4133                     result = ETrue;
  4137                     result = ETrue;
  4134                     }
  4138                     }
  4135                     break;
  4139                     break;
  4136                //<cmail>
       
  4137                // Backspace (C key) must be handled on Key-Down instead of Key-Up
  4140                // Backspace (C key) must be handled on Key-Down instead of Key-Up
  4138                // ( this was the reason that deleted two emails from opened mail in viewer )
  4141                // ( this was the reason that deleted two emails from opened mail in viewer )
  4139                case EStdKeyBackspace:
  4142                case EStdKeyBackspace:
  4140                    {
  4143                    {
  4141                    TInt shortcutCommand = iAppUi.ShortcutBinding().CommandForShortcutKey( aEvent.KeyEvent(),
  4144                    TInt shortcutCommand = iAppUi.ShortcutBinding().CommandForShortcutKey( aEvent.KeyEvent(),
  4147                        result = ETrue;
  4150                        result = ETrue;
  4148                        }
  4151                        }
  4149                    else result = EFalse;
  4152                    else result = EFalse;
  4150                    }
  4153                    }
  4151                    break;
  4154                    break;
  4152                 //</cmail>
       
  4153                 default:
  4155                 default:
  4154                     {
  4156                     {
  4155                     if ( iFocusedControl == EMailListComponent )
  4157                     if ( iFocusedControl == EMailListComponent )
  4156                         {
  4158                         {
  4157                         result = iMailList->TreeControl()->OfferEventL(aEvent);
  4159                         result = iMailList->TreeControl()->OfferEventL(aEvent);
  4171         // because half-QWERTY keyboad has shortcuts also on shift and chr keys which do
  4173         // because half-QWERTY keyboad has shortcuts also on shift and chr keys which do
  4172         // no send any key events, only key down and key up.
  4174         // no send any key events, only key down and key up.
  4173         TInt shortcutCommand =
  4175         TInt shortcutCommand =
  4174             iAppUi.ShortcutBinding().CommandForShortcutKey( aEvent.KeyEvent(),
  4176             iAppUi.ShortcutBinding().CommandForShortcutKey( aEvent.KeyEvent(),
  4175                 CFSEmailUiShortcutBinding::EContextMailList );
  4177                 CFSEmailUiShortcutBinding::EContextMailList );
       
  4178 
  4176         // Hash/shift key of ITU-T and half-QWERTY keyboards is an exception case to other
  4179         // Hash/shift key of ITU-T and half-QWERTY keyboards is an exception case to other
  4177         // shortcuts: it is handled only if it hasn't been used as shift modifier
  4180         // shortcuts: it is handled only if it hasn't been used as shift modifier
  4178         if ( (scanCode == EStdKeyHash || scanCode == EStdKeyLeftShift || scanCode == EStdKeyRightShift) &&
  4181         if ( (scanCode == EStdKeyHash || scanCode == EStdKeyLeftShift || scanCode == EStdKeyRightShift) &&
  4179              iOtherKeyPressedWhileShiftDepressed )
  4182              iOtherKeyPressedWhileShiftDepressed )
  4180             {
  4183             {
  4181             shortcutCommand = KErrNotFound;
  4184             shortcutCommand = KErrNotFound;
  4182             }
  4185             }
  4183 
  4186 
  4184         //<cmail>  // block Backspace (C key) handle on Key-Up
  4187         // block Backspace (C key) handle on Key-Up
  4185         if ( scanCode == EStdKeyBackspace) shortcutCommand = KErrNotFound; // handled on Key-Down, see above
  4188         if ( scanCode == EStdKeyBackspace )
  4186         //</cmail>
  4189             {
       
  4190             shortcutCommand = KErrNotFound; // handled on Key-Down, see above
       
  4191             }
  4187 
  4192 
  4188         if ( shortcutCommand != KErrNotFound )
  4193         if ( shortcutCommand != KErrNotFound )
  4189             {
  4194             {
  4190             HandleCommandL( shortcutCommand );
  4195             HandleCommandL( shortcutCommand );
  4191             result = ETrue;
  4196             result = ETrue;
  4197         }
  4202         }
  4198 
  4203 
  4199     return result;
  4204     return result;
  4200     }
  4205     }
  4201 
  4206 
  4202 //<cmail>
       
  4203 // ---------------------------------------------------------------------------
  4207 // ---------------------------------------------------------------------------
  4204 // CFSEmailUiMailListVisualiser::DoHandleListItemOpenL
  4208 // CFSEmailUiMailListVisualiser::DoHandleListItemOpenL
  4205 // ---------------------------------------------------------------------------
  4209 // ---------------------------------------------------------------------------
  4206 //
  4210 //
  4207 void CFSEmailUiMailListVisualiser::DoHandleListItemOpenL()
  4211 void CFSEmailUiMailListVisualiser::DoHandleListItemOpenL()
  4277 
  4281 
  4278 // ---------------------------------------------------------------------------
  4282 // ---------------------------------------------------------------------------
  4279 // CFSEmailUiMailListVisualiser::DoHandleListItemLongTapL
  4283 // CFSEmailUiMailListVisualiser::DoHandleListItemLongTapL
  4280 // ---------------------------------------------------------------------------
  4284 // ---------------------------------------------------------------------------
  4281 //
  4285 //
  4282 void CFSEmailUiMailListVisualiser::DoHandleListItemLongTapL()
  4286 void CFSEmailUiMailListVisualiser::DoHandleListItemLongTapL( const TPoint& aPoint )
  4283     {
  4287     {
  4284     FUNC_LOG;
  4288     FUNC_LOG;
  4285 
  4289 
  4286     if ( 0 < iModel->Count() ) // Safety check
  4290     if ( 0 < iModel->Count() ) // Safety check
  4287         {
  4291         {
  4288         RFsTreeItemIdList markedEntries;
  4292         RFsTreeItemIdList markedEntries;
  4289         iMailList->GetMarkedItemsL( markedEntries );
  4293         iMailList->GetMarkedItemsL( markedEntries );
  4290         if ( markedEntries.Count() >= 0 )
  4294         if ( markedEntries.Count() >= 0 )
  4291             {
  4295             {
  4292             LaunchStylusPopupMenuL();
  4296             LaunchStylusPopupMenuL( aPoint );
  4293             }
  4297             }
  4294         }
  4298         }
  4295     }
  4299     }
  4296 
  4300 
  4297 // ---------------------------------------------------------------------------
  4301 // ---------------------------------------------------------------------------
  4353     if( iFocusedControl == EControlBarComponent )
  4357     if( iFocusedControl == EControlBarComponent )
  4354         {
  4358         {
  4355         iControlBarControl->MakeSelectorVisible( aVisible );
  4359         iControlBarControl->MakeSelectorVisible( aVisible );
  4356         }
  4360         }
  4357 
  4361 
  4358     if ( iStylusPopUpMenuLaunched && !aVisible )
  4362     if ( iStylusPopUpMenuVisible && !aVisible )
  4359     	{
  4363     	{
  4360     	// Do not allow to remove the focus from a list element if the pop up
  4364     	// Do not allow to remove the focus from a list element if the pop up
  4361     	// menu was just launched.
  4365     	// menu was just launched.
  4362     	iStylusPopUpMenuLaunched = EFalse;
       
  4363     	return;
  4366     	return;
  4364     	}
  4367     	}
  4365 
  4368 
  4366     iMailTreeListVisualizer->SetFocusVisibility( aVisible );
  4369     iMailTreeListVisualizer->SetFocusVisibility( aVisible );
  4367     }
  4370     }
  5348 				TFSMailMsgId mailBox = iAppUi.GetActiveMailbox()->GetId();
  5351 				TFSMailMsgId mailBox = iAppUi.GetActiveMailbox()->GetId();
  5349 				iAppUi.GetMailClient()->DeleteMessagesByUidL( mailBox, folderId, msgIds );
  5352 				iAppUi.GetMailClient()->DeleteMessagesByUidL( mailBox, folderId, msgIds );
  5350                 RemoveMsgItemsFromListIfFoundL( msgIds );
  5353                 RemoveMsgItemsFromListIfFoundL( msgIds );
  5351                 CleanupStack::PopAndDestroy( &msgIds );
  5354                 CleanupStack::PopAndDestroy( &msgIds );
  5352 				}
  5355 				}
       
  5356 			else
       
  5357 				{
       
  5358 				UnmarkAllItemsL();
       
  5359 				}
  5353 			}
  5360 			}
  5354 		}
  5361 		}
  5355 	}
  5362 	}
  5356 
  5363 
  5357 // ---------------------------------------------------------------------------
  5364 // ---------------------------------------------------------------------------
  5413             iAsyncCallback->Set( TCallBack(DoDeleteMarkedMessages, this) );
  5420             iAsyncCallback->Set( TCallBack(DoDeleteMarkedMessages, this) );
  5414             iAsyncCallback->CallBack();
  5421             iAsyncCallback->CallBack();
  5415             }
  5422             }
  5416         // </cmail>
  5423         // </cmail>
  5417         }
  5424         }
       
  5425     else
       
  5426     	{
       
  5427 		UnmarkAllItemsL();
       
  5428     	}
  5418 
  5429 
  5419     CleanupStack::PopAndDestroy( &markedEntries );
  5430     CleanupStack::PopAndDestroy( &markedEntries );
  5420 	}
  5431 	}
  5421 
  5432 
  5422 // ---------------------------------------------------------------------------
  5433 // ---------------------------------------------------------------------------
  5803 					{
  5814 					{
  5804 					folderType = EFSInbox;
  5815 					folderType = EFSInbox;
  5805 					}
  5816 					}
  5806 			    iControlBarControl->SetFocusByIdL( iSortButtonId );
  5817 			    iControlBarControl->SetFocusByIdL( iSortButtonId );
  5807 			    iControlBarControl->MakeSelectorVisible( IsFocusShown() );
  5818 			    iControlBarControl->MakeSelectorVisible( IsFocusShown() );
  5808 /* <cmail> Sorting empty list enabled
  5819 
  5809                 // Show sort list only if maiil list is not empty
  5820 			    // Sorting empty mail list disabled
       
  5821                 // Show sort list only if mail list is not empty
  5810                 if ( iModel->Count() )
  5822                 if ( iModel->Count() )
  5811 </cmail> */
       
  5812                     {
  5823                     {
  5813                     iAppUi.ShowSortListInPopupL( iCurrentSortCriteria, folderType, this, iSortButton );
  5824                     iAppUi.ShowSortListInPopupL( iCurrentSortCriteria, folderType, this, iSortButton );
  5814                     }
  5825                     }
  5815 				}
  5826 				}
  5816 				return;
  5827 				return;
  6208 		}
  6219 		}
  6209 	return ret;
  6220 	return ret;
  6210 	}
  6221 	}
  6211 
  6222 
  6212 // ---------------------------------------------------------------------------
  6223 // ---------------------------------------------------------------------------
  6213 // LaunchActionMenuL
       
  6214 // Function launches action menu based on the highlighted or marked messages
       
  6215 // ---------------------------------------------------------------------------
       
  6216 //
       
  6217 void CFSEmailUiMailListVisualiser::LaunchActionMenuL()
       
  6218 	{
       
  6219     FUNC_LOG;
       
  6220 	// Get marked entries
       
  6221 	RFsTreeItemIdList markedEntries;
       
  6222 	CleanupClosePushL( markedEntries );
       
  6223 	iMailList->GetMarkedItemsL( markedEntries );
       
  6224 	TInt markedCount = markedEntries.Count();
       
  6225 
       
  6226 	// Remove old items from action menu
       
  6227     CFSEmailUiActionMenu::RemoveAllL();
       
  6228 	// Construct item list
       
  6229     RFsEActionMenuIdList itemList;
       
  6230     CleanupClosePushL( itemList );
       
  6231 	// Check support for object mail iten moving
       
  6232 	TBool supportsMoving = iAppUi.GetActiveMailbox()->HasCapability( EFSMBoxCapaMoveToFolder );
       
  6233 
       
  6234 	if ( markedCount == 0 || markedCount == 1 ) // Action menu for a single item
       
  6235 		{
       
  6236 		// Get pointer to the single message we are dealing with
       
  6237 	    TFsTreeItemId listItemId;
       
  6238 	    if ( markedCount == 0 )
       
  6239 	        {
       
  6240 	        listItemId = iMailList->FocusedItem();
       
  6241 	        }
       
  6242 	    else // ( markedCount == 1)
       
  6243 	        {
       
  6244 	        listItemId = markedEntries[0];
       
  6245 	        }
       
  6246 	    CFSMailMessage* msgPtr = &MsgPtrFromListIdL( listItemId );
       
  6247 
       
  6248 	    if ( iMailFolder->GetFolderType() == EFSOutbox )
       
  6249 			{
       
  6250 			if ( supportsMoving )
       
  6251 				{
       
  6252 			    itemList.AppendL( FsEActionMenuMoveToDrafts );
       
  6253 				}
       
  6254 			}
       
  6255 		else if( iMailFolder->GetFolderType() == EFSDraftsFolder )
       
  6256 			{
       
  6257 			// Create mark unread / mark read flag
       
  6258 			if ( msgPtr->IsFlagSet( EFSMsgFlag_Read ) )
       
  6259 				{
       
  6260 			    itemList.AppendL( FsEActionMenuMarkUnread );
       
  6261 				}
       
  6262 			else
       
  6263 				{
       
  6264 			    itemList.AppendL( FsEActionMenuMarkRead );
       
  6265 				}
       
  6266 			// Add Move message item if applicable
       
  6267 			if ( supportsMoving )
       
  6268 				{
       
  6269 				itemList.AppendL( FsEActionMenuMove );
       
  6270 				}
       
  6271 			}
       
  6272 		else
       
  6273 			{
       
  6274 			// Construct menu for calendar message based on resolved mr object
       
  6275 			// and whether the MRUI object is available
       
  6276 			if ( msgPtr->IsFlagSet( EFSMsgFlag_CalendarMsg ) &&  iAppUi.MrViewerInstanceL() )
       
  6277 				{
       
  6278 			    TESMRMeetingRequestMethod mrMethod( EESMRMeetingRequestMethodUnknown );
       
  6279 			    TRAP_IGNORE( mrMethod = iAppUi.MrViewerInstanceL()->ResolveMeetingRequestMethodL( *msgPtr ) );
       
  6280 			    switch ( mrMethod )
       
  6281 					{
       
  6282 					case EESMRMeetingRequestMethodRequest:
       
  6283 						{
       
  6284 						if ( iMailFolder && iMailFolder->GetFolderType() != EFSOutbox &&
       
  6285 							 iMailFolder->GetFolderType() != EFSDraftsFolder )
       
  6286 							{
       
  6287 							// No choices in outbox in outbox or drafts
       
  6288 							itemList.AppendL( FsEActionMenuAccept );
       
  6289 						    itemList.AppendL( FsEActionMenuTentative );
       
  6290 						    itemList.AppendL( FsEActionMenuDecline );
       
  6291 							}
       
  6292 						}
       
  6293 						break;
       
  6294 					case EESMRMeetingRequestMethodCancellation:
       
  6295 						{
       
  6296 						// No "remove from calendar" in outbox or drafts
       
  6297 						if ( iMailFolder && iMailFolder->GetFolderType() != EFSOutbox &&
       
  6298 							 iMailFolder->GetFolderType() != EFSDraftsFolder )
       
  6299 							{
       
  6300 							TBool supportsRemove = iAppUi.GetActiveMailbox()->HasCapability( EFSMBoxCapaRemoveFromCalendar );
       
  6301 							if( supportsRemove )
       
  6302 							    {
       
  6303 							    itemList.AppendL( FsEActionMenuRemoveFormCal );
       
  6304 							    }
       
  6305 							}
       
  6306 						}
       
  6307 						break;
       
  6308                     case EESMRMeetingRequestMethodUnknown:
       
  6309                     case EESMRMeetingRequestMethodResponse:
       
  6310 					default:
       
  6311 					    {
       
  6312 					    // Only "Open" options is available for responses and when MR method
       
  6313 					    // cannot be resolved without opening the message (this is the case with IMAP)
       
  6314 	                    itemList.AppendL( FsEActionMenuOpenCalendarEvent );
       
  6315 					    }
       
  6316 						break;
       
  6317 					}
       
  6318 				}
       
  6319 			// No mrui object or message is typical mail
       
  6320 			// Append normal menu commands
       
  6321 			else
       
  6322 				{
       
  6323 			    itemList.AppendL( FsEActionMenuReply );
       
  6324 			    // Show ReplyAll if more than 1 recepient
       
  6325 			    TInt numRecipients(0);
       
  6326                 if ( msgPtr )
       
  6327                     {
       
  6328                     //Get # of recipients
       
  6329                     numRecipients =TFsEmailUiUtility::CountRecepients( msgPtr );
       
  6330                     if ( numRecipients == 1 )
       
  6331                         {
       
  6332                         //check if the malbox ownmailaddress is same as the recipients email address. If not, then assume that the
       
  6333                         //email is a distribution list and we need to inc num of Recipients so that "Reply ALL" option appears in UI.
       
  6334                         if ( msgPtr->GetToRecipients().Count() )
       
  6335                             {
       
  6336                                 if( iAppUi.GetActiveMailbox()->OwnMailAddress().GetEmailAddress().Compare(msgPtr->GetToRecipients()[0]->GetEmailAddress()) )
       
  6337                                     {
       
  6338                                     numRecipients++;
       
  6339                                     }
       
  6340                             }
       
  6341                         if ( msgPtr->GetCCRecipients().Count() )
       
  6342                             {
       
  6343                                 if ( iAppUi.GetActiveMailbox()->OwnMailAddress().GetEmailAddress().Compare(msgPtr->GetCCRecipients()[0]->GetEmailAddress()) )
       
  6344                                     {
       
  6345                                     numRecipients++;
       
  6346                                     }
       
  6347                             }
       
  6348                         if( msgPtr->GetBCCRecipients().Count() )
       
  6349                             {
       
  6350                                 if ( iAppUi.GetActiveMailbox()->OwnMailAddress().GetEmailAddress().Compare(msgPtr->GetBCCRecipients()[0]->GetEmailAddress()) )
       
  6351                                     {
       
  6352                                     numRecipients++;
       
  6353                                     }
       
  6354                             }
       
  6355                         }
       
  6356                     }
       
  6357 
       
  6358 			    if ( numRecipients > 1 )
       
  6359 			        {
       
  6360 	                itemList.AppendL( FsEActionMenuReplyAll );
       
  6361 			        }
       
  6362 			    itemList.AppendL( FsEActionMenuForward );
       
  6363 				}
       
  6364 
       
  6365 			// Add mark as read/unread options
       
  6366 			if ( IsMarkAsUnreadAvailableL() )
       
  6367 				{
       
  6368 			    itemList.AppendL( FsEActionMenuMarkUnread );
       
  6369 				}
       
  6370 			if ( IsMarkAsReadAvailableL() )
       
  6371 				{
       
  6372 			    itemList.AppendL( FsEActionMenuMarkRead );
       
  6373 				}
       
  6374 
       
  6375 			// Add Move message item if applicable
       
  6376 			if ( supportsMoving )
       
  6377 				{
       
  6378 				itemList.AppendL( FsEActionMenuMove );
       
  6379 				}
       
  6380 			}
       
  6381 	    itemList.AppendL( FsEActionMenuDelete );
       
  6382 
       
  6383 		// Execute action list and handle the menu command
       
  6384 		TFSMailMsgId oldMsgId = msgPtr->GetMessageId();
       
  6385 
       
  6386 // <cmail> Touch
       
  6387 		TActionMenuCustomItemId itemId = CFSEmailUiActionMenu::ExecuteL( itemList, EFscCustom, 0, this );
       
  6388 // </cmail>
       
  6389 
       
  6390 		// Make sure that focus or marking is still on the same item as when Action menu was launched.
       
  6391 		// This is beacause message added/deleted event migh have occured and deleted the original meessage or
       
  6392 	   	// resulted in complete redraw of the message list.
       
  6393         TInt newItemIdx = ItemIndexFromMessageId( oldMsgId );
       
  6394         if ( newItemIdx >= 0 ) // items still exists
       
  6395             {
       
  6396             TFsTreeItemId newItemListId = iTreeItemArray[ newItemIdx ].iListItemId;
       
  6397             if ( markedCount )
       
  6398                 {
       
  6399                 // Item was marked. Make sure it's marked now.
       
  6400                 iMailList->MarkItemL( newItemListId, ETrue );
       
  6401                 }
       
  6402             else
       
  6403                 {
       
  6404                 // No items were marked. Make sure the focus is on the same item as before.
       
  6405                 if ( iMailList->FocusedItem() != newItemListId )
       
  6406                     {
       
  6407                     iMailList->SetFocusedItemL( newItemListId );
       
  6408                     }
       
  6409                 }
       
  6410             HandleActionMenuCommandL( itemId );
       
  6411             }
       
  6412 		}
       
  6413 	else // Multiple items marked
       
  6414 		{
       
  6415         // Add mark as read/unread options
       
  6416         if ( IsMarkAsUnreadAvailableL() )
       
  6417             {
       
  6418             itemList.AppendL( FsEActionMenuMarkUnread );
       
  6419             }
       
  6420         if ( IsMarkAsReadAvailableL() )
       
  6421             {
       
  6422             itemList.AppendL( FsEActionMenuMarkRead );
       
  6423             }
       
  6424 
       
  6425 		if ( iMailFolder->GetFolderType() == EFSOutbox ) // Append move to drafts in outbox
       
  6426 			{
       
  6427 			if ( supportsMoving )
       
  6428 				{
       
  6429 			    itemList.AppendL( FsEActionMenuMoveToDrafts );
       
  6430 				}
       
  6431 			}
       
  6432 		else 	// Append move in any other cases dirtectly if supported
       
  6433 			{
       
  6434 			if ( supportsMoving )
       
  6435 				{
       
  6436 			    itemList.AppendL( FsEActionMenuMove );
       
  6437 				}
       
  6438 			}
       
  6439 	    itemList.AppendL( FsEActionMenuDelete );
       
  6440 	   	TActionMenuCustomItemId itemId = CFSEmailUiActionMenu::ExecuteL( itemList );
       
  6441 		iMailList->GetMarkedItemsL( markedEntries );
       
  6442 		if ( markedEntries.Count() ) // Safety check
       
  6443 			{
       
  6444 			HandleActionMenuCommandL( itemId );
       
  6445 			}
       
  6446 		}
       
  6447 	CleanupStack::PopAndDestroy( &itemList );
       
  6448 	CleanupStack::PopAndDestroy( &markedEntries );
       
  6449 	}
       
  6450 
       
  6451 // ---------------------------------------------------------------------------
       
  6452 // HandleActionMenuCommandL
       
  6453 // Action menu command callback handler
       
  6454 // ---------------------------------------------------------------------------
       
  6455 //
       
  6456 void CFSEmailUiMailListVisualiser::HandleActionMenuCommandL( TActionMenuCustomItemId itemId )
       
  6457 	{
       
  6458     FUNC_LOG;
       
  6459 	// Map each Action Menu ID to correcponding command ID.
       
  6460 	TInt commandId = KErrNotFound;
       
  6461 
       
  6462 	switch( itemId )
       
  6463 		{
       
  6464 		case FsEActionMenuOpenCalendarEvent:
       
  6465 		case FsEActionMenuOpen:
       
  6466 		    commandId = EFsEmailUiCmdOpen;
       
  6467 		    break;
       
  6468 		case FsEActionMenuAccept:
       
  6469 		    commandId = EFsEmailUiCmdCalActionsAccept;
       
  6470 		    break;
       
  6471 		case FsEActionMenuTentative:
       
  6472 		    commandId = EFsEmailUiCmdCalActionsTentative;
       
  6473 		    break;
       
  6474 		case FsEActionMenuDecline:
       
  6475 		    commandId = EFsEmailUiCmdCalActionsDecline;
       
  6476 		    break;
       
  6477 		case FsEActionMenuRemoveFormCal:
       
  6478 		    commandId = EFsEmailUiCmdCalRemoveFromCalendar;
       
  6479 		    break;
       
  6480 		case FsEActionMenuMarkRead:
       
  6481 		    commandId = EFsEmailUiCmdMarkAsRead;
       
  6482 		    break;
       
  6483 		case FsEActionMenuMarkUnread:
       
  6484 		    commandId = EFsEmailUiCmdMarkAsUnread;
       
  6485 			break;
       
  6486 		case FsEActionMenuDelete:
       
  6487 		    commandId = EFsEmailUiCmdActionsDelete;
       
  6488 			break;
       
  6489 		case FsEActionMenuReply:
       
  6490 		    commandId = EFsEmailUiCmdActionsReply;
       
  6491 			break;
       
  6492 		case FsEActionMenuReplyAll:
       
  6493             commandId = EFsEmailUiCmdActionsReplyAll;
       
  6494 			break;
       
  6495 		case FsEActionMenuForward:
       
  6496             commandId = EFsEmailUiCmdActionsForward;
       
  6497 			break;
       
  6498 		case FsEActionMenuMove:
       
  6499 		    commandId = EFsEmailUiCmdActionsMoveMessage;
       
  6500 			break;
       
  6501 		case FsEActionMenuMoveToDrafts:
       
  6502             commandId = EFsEmailUiCmdActionsMoveToDrafts;
       
  6503 			break;
       
  6504 		case FsEActionMenuDismissed:
       
  6505 		    commandId = KErrCancel;
       
  6506 		    break;
       
  6507 		default:
       
  6508 		    __ASSERT_DEBUG( EFalse, Panic(EFSEmailUiUnexpectedValue) );
       
  6509 		    break;
       
  6510 		}
       
  6511 
       
  6512 	if ( commandId >= 0 )
       
  6513 	    {
       
  6514 	    HandleCommandL( commandId );
       
  6515 	    }
       
  6516 	}
       
  6517 
       
  6518 // ---------------------------------------------------------------------------
       
  6519 // LaunchStylusPopupMenuL
  6224 // LaunchStylusPopupMenuL
  6520 // Function launches avkon stylus popup menu based on the selected message item/items
  6225 // Function launches avkon stylus popup menu based on the selected message item/items
  6521 // ---------------------------------------------------------------------------
  6226 // ---------------------------------------------------------------------------
  6522 //
  6227 //
  6523 void CFSEmailUiMailListVisualiser::LaunchStylusPopupMenuL()
  6228 void CFSEmailUiMailListVisualiser::LaunchStylusPopupMenuL( const TPoint& aPoint )
  6524 	{
  6229 	{
  6525 	// Irrelevant items for focused mail list item get dimmed at runtime
  6230 	// Irrelevant items for focused mail list item get dimmed at runtime
  6526 
  6231 
  6527 	// Check mail list item's type
  6232 	// Check mail list item's type
  6528 	CFSEmailUiMailListModelItem* item =
  6233 	CFSEmailUiMailListModelItem* item =
  6573 			iStylusPopUpMenu->SetItemDimmed( EFsEmailUiCmdActionsExpandAll, AllNodesExpanded() );
  6278 			iStylusPopUpMenu->SetItemDimmed( EFsEmailUiCmdActionsExpandAll, AllNodesExpanded() );
  6574 			}
  6279 			}
  6575 		}
  6280 		}
  6576 
  6281 
  6577 	// Set the position for the popup
  6282 	// Set the position for the popup
  6578 	iStylusPopUpMenu->SetPosition( ActionMenuPosition() );
  6283 	iStylusPopUpMenu->SetPosition( aPoint );
  6579 
  6284 
  6580 	// Display the popup and set the flag to indicate that the menu was
  6285 	// Display the popup and set the flag to indicate that the menu was
  6581 	// launched.
  6286 	// launched.
  6582 	iStylusPopUpMenu->ShowMenu();
  6287 	iStylusPopUpMenu->ShowMenu();
  6583 	iStylusPopUpMenuLaunched = ETrue;
  6288 	iStylusPopUpMenuVisible = ETrue;
  6584 	}
  6289 	}
  6585 
  6290 
  6586 // ---------------------------------------------------------------------------
  6291 // ---------------------------------------------------------------------------
  6587 // CreateNewMsgL
  6292 // CreateNewMsgL
  6588 // Launches editor.
  6293 // Launches editor.
  6845 
  6550 
  6846 // ---------------------------------------------------------------------------
  6551 // ---------------------------------------------------------------------------
  6847 //
  6552 //
  6848 // ---------------------------------------------------------------------------
  6553 // ---------------------------------------------------------------------------
  6849 //
  6554 //
  6850 void CFSEmailUiMailListVisualiser::TreeListEventL(
  6555 void CFSEmailUiMailListVisualiser::TreeListEventL( const TFsTreeListEvent aEvent,
  6851     const TFsTreeListEvent aEvent, const TFsTreeItemId aId )
  6556                                                    const TFsTreeItemId aId,
       
  6557                                                    const TPoint& /*aPoint*/ )
  6852 	{
  6558 	{
  6853     FUNC_LOG;
  6559     FUNC_LOG;
  6854     switch( aEvent )
  6560     switch( aEvent )
  6855         {
  6561         {
  6856         case EFsTreeListItemWillGetFocused:
  6562         case EFsTreeListItemWillGetFocused:
  7174 	    iMailTreeListVisualizer->SetFocusedItemL( iTreeItemArray[prevIdx].iListItemId, EFalse );
  6880 	    iMailTreeListVisualizer->SetFocusedItemL( iTreeItemArray[prevIdx].iListItemId, EFalse );
  7175 	    // </cmail>
  6881 	    // </cmail>
  7176 	    ChangeReadStatusOfHighlightedL( ETrue );
  6882 	    ChangeReadStatusOfHighlightedL( ETrue );
  7177         aFoundPreviousMsgId = MsgIdFromIndex( prevIdx );
  6883         aFoundPreviousMsgId = MsgIdFromIndex( prevIdx );
  7178 	    ret = KErrNone;
  6884 	    ret = KErrNone;
  7179 	    }	
  6885 	    }
  7180 	
  6886 
  7181 	if ( ret == KErrNone )
  6887 	if ( ret == KErrNone )
  7182 		{
  6888 		{
  7183 		OpenHighlightedMailL();
  6889 		OpenHighlightedMailL();
  7184 		}
  6890 		}
  7185 	return ret;
  6891 	return ret;
  7186 	}
  6892 	}
  7187 
  6893 
  7188 TInt CFSEmailUiMailListVisualiser::MoveToPreviousMsgAfterDeleteL( TFSMailMsgId aFoundPreviousMsgId )
  6894 TInt CFSEmailUiMailListVisualiser::MoveToPreviousMsgAfterDeleteL( TFSMailMsgId aFoundPreviousMsgId )
  7189 	{
  6895 	{
  7190 	FUNC_LOG;
  6896 	FUNC_LOG;
  7191 	TInt ret(KErrNotFound);	
  6897 	TInt ret(KErrNotFound);
  7192 	
  6898 
  7193 	TInt idx = ItemIndexFromMessageId( aFoundPreviousMsgId );	
  6899 	TInt idx = ItemIndexFromMessageId( aFoundPreviousMsgId );
  7194 	if ( idx >= 0 )
  6900 	if ( idx >= 0 )
  7195 		{		
  6901 		{
  7196 		// Focus the previous message
  6902 		// Focus the previous message
  7197 		iMailTreeListVisualizer->SetFocusedItemL( iTreeItemArray[idx].iListItemId, EFalse );
  6903 		iMailTreeListVisualizer->SetFocusedItemL( iTreeItemArray[idx].iListItemId, EFalse );
  7198 		ChangeReadStatusOfHighlightedL( ETrue );
  6904 		ChangeReadStatusOfHighlightedL( ETrue );
  7199 		ret = KErrNone;		
  6905 		ret = KErrNone;
  7200 		}
  6906 		}
  7201 
  6907 
  7202 	if ( ret == KErrNone )
  6908 	if ( ret == KErrNone )
  7203 		{
  6909 		{
  7204 		OpenHighlightedMailL();
  6910 		OpenHighlightedMailL();
  7205 		}
  6911 		}
  7206 	
  6912 
  7207 	return ret;
  6913 	return ret;
  7208 	}
  6914 	}
  7209 
  6915 
  7210 void CFSEmailUiMailListVisualiser::ManualMailBoxSync( TBool aManualMailBoxSync )
  6916 void CFSEmailUiMailListVisualiser::ManualMailBoxSync( TBool aManualMailBoxSync )
  7211 	{
  6917 	{
  7257         iMailList->SetFocusedL( ETrue );
  6963         iMailList->SetFocusedL( ETrue );
  7258         iControlBarControl->SetFocusL( EFalse );
  6964         iControlBarControl->SetFocusL( EFalse );
  7259         }
  6965         }
  7260     else
  6966     else
  7261         {
  6967         {
  7262         if ( iStylusPopUpMenuLaunched )
  6968         if( iStylusPopUpMenuVisible )
  7263         	{
  6969         	{
  7264         	return;
  6970         	return;
  7265         	}
  6971         	}
  7266 
  6972 
  7267         iMailList->SetFocusedL( EFalse );
  6973         iMailList->SetFocusedL( EFalse );
  7269         MFsControlButtonInterface* focusedBtn = iControlBarControl->GetFocusedButton();
  6975         MFsControlButtonInterface* focusedBtn = iControlBarControl->GetFocusedButton();
  7270         if ( focusedBtn )
  6976         if ( focusedBtn )
  7271             {
  6977             {
  7272             focusedBtnId = focusedBtn->Id();
  6978             focusedBtnId = focusedBtn->Id();
  7273             }
  6979             }
  7274         iControlBarControl->MakeSelectorVisible( IsFocusShown() );
       
  7275         iControlBarControl->SetFocusL( ETrue );
  6980         iControlBarControl->SetFocusL( ETrue );
  7276         if ( focusedBtnId != KErrNotFound )
  6981         if ( focusedBtnId != KErrNotFound )
  7277             {
  6982             {
  7278             iControlBarControl->SetFocusByIdL( focusedBtnId );
  6983             iControlBarControl->SetFocusByIdL( focusedBtnId );
  7279             }
  6984             }
  7280         }
  6985         iControlBarControl->MakeSelectorVisible( IsFocusShown() );
  7281     }
  6986         }
  7282 
  6987     }
  7283 // <cmail>
       
  7284 // ---------------------------------------------------------------------------
       
  7285 // ActionMenuPosition
       
  7286 // ---------------------------------------------------------------------------
       
  7287 //
       
  7288 TPoint CFSEmailUiMailListVisualiser::ActionMenuPosition()
       
  7289     {
       
  7290     RFsTreeItemIdList markedEntries;
       
  7291     TRAP_IGNORE(iMailList->GetMarkedItemsL( markedEntries ));
       
  7292     TInt markedCount = markedEntries.Count();
       
  7293     TFsTreeItemId listItemId;
       
  7294     if ( markedCount == 0 )
       
  7295         {
       
  7296         listItemId = iMailList->FocusedItem();
       
  7297         }
       
  7298     else // ( markedCount == 1)
       
  7299         {
       
  7300         listItemId = markedEntries[0];
       
  7301         }
       
  7302     TAlfRealRect focusRect;
       
  7303     iMailList->GetItemDisplayRectTarget(listItemId, focusRect);
       
  7304     markedEntries.Close();
       
  7305     return focusRect.iTl;
       
  7306     }
       
  7307 // </cmail>
       
  7308 
  6988 
  7309 void CFSEmailUiMailListVisualiser::GetParentLayoutsL( RPointerArray<CAlfVisual>& aLayoutArray ) const
  6989 void CFSEmailUiMailListVisualiser::GetParentLayoutsL( RPointerArray<CAlfVisual>& aLayoutArray ) const
  7310     {
  6990     {
  7311     aLayoutArray.AppendL( iScreenAnchorLayout );
  6991     aLayoutArray.AppendL( iScreenAnchorLayout );
  7312     aLayoutArray.AppendL( iControlBarControl->Visual() );
  6992     aLayoutArray.AppendL( iControlBarControl->Visual() );
  7633 // -----------------------------------------------------------------------------
  7313 // -----------------------------------------------------------------------------
  7634 //
  7314 //
  7635 void CDateChangeTimer::RunL()
  7315 void CDateChangeTimer::RunL()
  7636     {
  7316     {
  7637     FUNC_LOG;
  7317     FUNC_LOG;
  7638     // Update mail list and reissue the request for timer event
  7318     if ( KErrCancel == iStatus.Int() )
  7639     iMailListVisualiser.NotifyDateChangedL();
  7319         {
  7640     Start();
  7320         ;
  7641     }
  7321         }
       
  7322     // System time changed?
       
  7323     else if ( KErrAbort == iStatus.Int() )
       
  7324         {
       
  7325         Start();
       
  7326         }
       
  7327     // Interval is over
       
  7328     else
       
  7329         {
       
  7330         // Update mail list and reissue the request for timer event
       
  7331         TRAP_IGNORE( iMailListVisualiser.NotifyDateChangedL() );
       
  7332         Start();
       
  7333         }
       
  7334     }