emailuis/emailui/src/FreestyleEmailUiMailListVisualiser.cpp
branchRCL_3
changeset 80 726fba06891a
parent 73 c8382f7b54ef
equal deleted inserted replaced
73:c8382f7b54ef 80:726fba06891a
   572     CleanupStack::Pop( cbSelectorBrush ); // ownership transferred to control bar
   572     CleanupStack::Pop( cbSelectorBrush ); // ownership transferred to control bar
   573 
   573 
   574     iNewEmailText = StringLoader::LoadL( R_COMMAND_AREA_NEW_EMAIL );
   574     iNewEmailText = StringLoader::LoadL( R_COMMAND_AREA_NEW_EMAIL );
   575 
   575 
   576     // Set menu, mark and background icons
   576     // Set menu, mark and background icons
   577     iMailTreeListVisualizer->SetMarkOnIcon( iAppUi.FsTextureManager()->TextureByIndex( EListControlMarkOnIcon ) );
   577     iMailTreeListVisualizer->SetMarkIcon( iAppUi.FsTextureManager()->TextureByIndex( EListControlMarkIcon ) );
   578     iMailTreeListVisualizer->SetMarkOffIcon( iAppUi.FsTextureManager()->TextureByIndex( EListControlMarkOffIcon ) );
       
   579     iMailTreeListVisualizer->SetMenuIcon( iAppUi.FsTextureManager()->TextureByIndex( EListControlMenuIcon ) );
   578     iMailTreeListVisualizer->SetMenuIcon( iAppUi.FsTextureManager()->TextureByIndex( EListControlMenuIcon ) );
   580     iMailList->AddObserverL( *this );
   579     iMailList->AddObserverL( *this );
   581     iMailList->AddObserverL( *iTouchManager );
   580     iMailList->AddObserverL( *iTouchManager );
   582     // Initializing the default stylus long tap popup menu
   581     // Initializing the default stylus long tap popup menu
   583     if( !iStylusPopUpMenu )
   582     if( !iStylusPopUpMenu )
   756 // ---------------------------------------------------------------------------
   755 // ---------------------------------------------------------------------------
   757 //
   756 //
   758 void CFSEmailUiMailListVisualiser::UpdateProgressL(TFsTreeItemId& aParentId, RPointerArray<CFSMailMessage>& aMessages)
   757 void CFSEmailUiMailListVisualiser::UpdateProgressL(TFsTreeItemId& aParentId, RPointerArray<CFSMailMessage>& aMessages)
   759     {
   758     {
   760     FUNC_LOG;
   759     FUNC_LOG;
   761     
       
   762     const TInt itemsInModel(iModel->Count());
   760     const TInt itemsInModel(iModel->Count());
   763     CreateModelItemsL(aMessages);
   761 
   764     RefreshListItemsL(aParentId, itemsInModel, iModel->Count());
   762     // cleanup items that are already found in model
       
   763     for (TInt i = 0; i < aMessages.Count(); )
       
   764         {
       
   765         if ( iModel->ContainsItem( *aMessages[i] ) )
       
   766             {
       
   767             delete aMessages[i];
       
   768             aMessages.Remove(i);
       
   769             }
       
   770         else
       
   771             {
       
   772             i++;
       
   773             }            
       
   774         }
       
   775 
       
   776     if (aMessages.Count() > 0)
       
   777         {
       
   778         CreateModelItemsL(aMessages);
       
   779         RefreshListItemsL(aParentId, itemsInModel, iModel->Count());
       
   780         }
   765     }
   781     }
   766 
   782 
   767 // ---------------------------------------------------------------------------
   783 // ---------------------------------------------------------------------------
   768 // @see CMailListModelUpdater::MObserver::UpdateCompleteL
   784 // @see CMailListModelUpdater::MObserver::UpdateCompleteL
   769 // ---------------------------------------------------------------------------
   785 // ---------------------------------------------------------------------------
   775     if ( iSortWaitNote )
   791     if ( iSortWaitNote )
   776         {
   792         {
   777         sorting = ETrue;
   793         sorting = ETrue;
   778         }
   794         }
   779     DeleteSortWaitNote();
   795     DeleteSortWaitNote();
   780 
   796     
   781     if ( !iModel->Count() )
   797     if ( !iModel->Count() )
   782         {
   798         {
   783         iFocusedControl = EControlBarComponent;
   799         iFocusedControl = EControlBarComponent;
   784         }
   800         }
   785     else
   801     else
   831 // ---------------------------------------------------------------------------
   847 // ---------------------------------------------------------------------------
   832 //
   848 //
   833 void CFSEmailUiMailListVisualiser::SortMailListModelAsyncL()
   849 void CFSEmailUiMailListVisualiser::SortMailListModelAsyncL()
   834     {
   850     {
   835     FUNC_LOG;
   851     FUNC_LOG;
   836 
   852    
   837     DeleteSortWaitNote();
   853     DeleteSortWaitNote();
   838   
   854   
   839     TBool ret = UpdateMailListModelAsyncL( KCMsgBlockSort );
   855     TBool ret = UpdateMailListModelAsyncL( KCMsgBlockSort );
   840     if ( ret )
   856     if ( ret )
   841         {
   857         {
  1276                 break;
  1292                 break;
  1277                 }
  1293                 }
  1278             case ESortRequested:
  1294             case ESortRequested:
  1279                 {
  1295                 {
  1280                 if( !iNewMailTimer->IsActive() && iNewMailTimer->iStatus != KErrInUse )
  1296                 if( !iNewMailTimer->IsActive() && iNewMailTimer->iStatus != KErrInUse )
  1281         	{
  1297         	        {
  1282                     // Size sorting does not use nodes, so disable those, otherwise check from CR
  1298                     // Size sorting does not use nodes, so disable those, otherwise check from CR
  1283                     iNodesInUse = iAppUi.GetCRHandler()->TitleDividers();
  1299                     iNodesInUse = iAppUi.GetCRHandler()->TitleDividers();
  1284                     SetSortButtonIconL();
  1300                     SetSortButtonTextAndIconL();
  1285 
  1301 
  1286                     iFocusedControl = EControlBarComponent;
  1302                     iFocusedControl = EControlBarComponent;
  1287                     iMailList->SetFocusedL( EFalse );
  1303                     iMailList->SetFocusedL( EFalse );
  1288                     iControlBarControl->SetFocusByIdL( iSortButtonId );
  1304                     iControlBarControl->SetFocusByIdL( iSortButtonId );
  1289 
  1305 
  1326                 }
  1342                 }
  1327             case ESortStartError:
  1343             case ESortStartError:
  1328             case ESortCompleted:
  1344             case ESortCompleted:
  1329                 {
  1345                 {
  1330             	if( !iNewMailTimer->IsActive() )
  1346             	if( !iNewMailTimer->IsActive() )
  1331             	    {
  1347             		{
  1332             	    // refresh the whole mail list if list was sorted
  1348             	    // refresh the whole mail list if list was sorted
  1333             	    if(iSortState != ESortStartError )
  1349             	    if(iSortState != ESortStartError )
  1334             	    	{
  1350             	    	{
  1335             	        RefreshL();
  1351             	        RefreshL();
  1336             	    	}
  1352             	    	}
  1359             }
  1375             }
  1360         }
  1376         }
  1361     
  1377     
  1362     if( aTriggeredTimer == iNewMailTimer )
  1378     if( aTriggeredTimer == iNewMailTimer )
  1363         {
  1379         {
  1364         if ( ! iThisViewActive ) // don't proceed if view is not active 
       
  1365             { 
       
  1366             iNewMailTimer->Stop();
       
  1367             return;
       
  1368             }
       
  1369         
       
  1370         TInt count = Min( KNewMailMaxBatch, iNewMailIds.Count() );
  1380         TInt count = Min( KNewMailMaxBatch, iNewMailIds.Count() );
  1371         CFSMailClient* mailClient = iAppUi.GetMailClient();
  1381         CFSMailClient* mailClient = iAppUi.GetMailClient();
  1372 
  1382 
  1373         // Enter critical section
  1383         // Enter critical section
  1374         // Because CFSMailClient::GetMessageByUidL can use CActiveSchedulerWait
  1384         // Because CFSMailClient::GetMessageByUidL can use CActiveSchedulerWait
  1385                 iNewMailTimer->iStatus = KErrNone;
  1395                 iNewMailTimer->iStatus = KErrNone;
  1386                 iNewMailTimer->Stop();
  1396                 iNewMailTimer->Stop();
  1387                 return; // leave  method
  1397                 return; // leave  method
  1388                 }
  1398                 }
  1389     
  1399     
  1390             CFSMailMessage* msgPtr(NULL);
  1400             CFSMailMessage* msgPtr = mailClient->GetMessageByUidL( iAppUi.GetActiveMailboxId(),
  1391             TRAPD( err, msgPtr = mailClient->GetMessageByUidL( iAppUi.GetActiveMailboxId(),
       
  1392                                                                iMailFolder->GetFolderId(),
  1401                                                                iMailFolder->GetFolderId(),
  1393                                                                iNewMailIds[ 0 ],
  1402                                                                iNewMailIds[ 0 ],
  1394                                                                EFSMsgDataEnvelope ) );
  1403                                                                EFSMsgDataEnvelope );
  1395             if ( KErrNone != err ) 
       
  1396                 {
       
  1397                 iNewMailTimer->iStatus = KErrNone;
       
  1398                 User::Leave(err);
       
  1399                 }
       
  1400             if ( msgPtr != NULL )
  1404             if ( msgPtr != NULL )
  1401  {
  1405                 {
  1402                 __ASSERT_DEBUG( FolderId() == msgPtr->GetFolderId(), User::Invariant() );
  1406                 __ASSERT_DEBUG( FolderId() == msgPtr->GetFolderId(), User::Invariant() );
  1403                 CleanupStack::PushL( msgPtr );
  1407                 CleanupStack::PushL( msgPtr );
  1404                 //first item - show scrollbar
  1408                 //first item - show scrollbar
  1405                 //last item - update scrollbar
  1409                 //last item - update scrollbar
  1406                 TBool allowRefresh = ( i == 0 || i == count - 1 );
  1410                 TBool allowRefresh = ( i == 0 || i == count - 1 );
  1430 // ---------------------------------------------------------------------------
  1434 // ---------------------------------------------------------------------------
  1431 //
  1435 //
  1432 void CFSEmailUiMailListVisualiser::InsertNewMessageL( CFSMailMessage* aNewMessage, const TBool aAllowRefresh )
  1436 void CFSEmailUiMailListVisualiser::InsertNewMessageL( CFSMailMessage* aNewMessage, const TBool aAllowRefresh )
  1433     {
  1437     {
  1434     FUNC_LOG;
  1438     FUNC_LOG;
       
  1439     
       
  1440     // If item is already in model, just delete the pointer and return
       
  1441     if ( iModel->ContainsItem( *aNewMessage ) )
       
  1442         {
       
  1443         delete aNewMessage;
       
  1444         return;
       
  1445         }
       
  1446     
  1435     // Use simple heuristic rule: if the first item is highlighted before the new
  1447     // Use simple heuristic rule: if the first item is highlighted before the new
  1436     // item is added, the highlight is forced to remain on the (possibly new) first
  1448     // item is added, the highlight is forced to remain on the (possibly new) first
  1437     // item. Otherwise the highligh stays on the same item as before.
  1449     // item. Otherwise the highligh stays on the same item as before.
  1438     TBool firstItemWasFocused =
  1450     TBool firstItemWasFocused =
  1439         ( iTreeItemArray.Count() && iTreeItemArray[0].iListItemId == iMailList->FocusedItem() );
  1451         ( iTreeItemArray.Count() && iTreeItemArray[0].iListItemId == iMailList->FocusedItem() );
  1654             TRAP_IGNORE( ExitMarkingModeL() );
  1666             TRAP_IGNORE( ExitMarkingModeL() );
  1655             }
  1667             }
  1656         }
  1668         }
  1657 
  1669 
  1658     iShowReplyAll = EFalse;
  1670     iShowReplyAll = EFalse;
  1659     TBool bDoFirstStartCalled( EFalse );
  1671 
  1660     if ( !iFirstStartCompleted )
  1672 	if ( !iFirstStartCompleted )
  1661         {
  1673 	    {
  1662         DoFirstStartL();
  1674 	    DoFirstStartL();
  1663         bDoFirstStartCalled = ETrue;
  1675 	    }
  1664         }
       
  1665     // set when editor was called so reset is needed i.e. here (Called by DoActivate)
  1676     // set when editor was called so reset is needed i.e. here (Called by DoActivate)
  1666     iMailOpened = EFalse; 
  1677    	iMailOpened = EFalse; 
  1667 
  1678 
  1668     // Make sure that pending popup is not displayd
  1679     // Make sure that pending popup is not displayd
  1669     if ( iAppUi.FolderList().IsPopupShown() )
  1680 	if ( iAppUi.FolderList().IsPopupShown() )
  1670         {
  1681         {
  1671         iAppUi.FolderList().HidePopupL();
  1682         iAppUi.FolderList().HidePopupL();
  1672         }
  1683         }
  1673     DisableMailList( EFalse );
  1684     DisableMailList( EFalse );
  1674 
  1685 
  1675     UpdateFolderAndMarkingModeTextsL();
       
  1676     
       
  1677 	// inform baseView if view entered with forward navigation
  1686 	// inform baseView if view entered with forward navigation
  1678 	TBool forwardNavigation = EFalse;
  1687 	TBool forwardNavigation = EFalse;
  1679 	if ( aCustomMessageId != KStartListReturnToPreviousFolder &&
  1688 	if ( aCustomMessageId != KStartListReturnToPreviousFolder &&
  1680 	     aCustomMessageId != TUid::Uid(KMailSettingsReturnFromPluginSettings) )
  1689 	     aCustomMessageId != TUid::Uid(KMailSettingsReturnFromPluginSettings) )
  1681 	    {
  1690 	    {
  1692     TRect clientRect = iAppUi.ClientRect();
  1701     TRect clientRect = iAppUi.ClientRect();
  1693     iScreenAnchorLayout->SetSize( clientRect.Size() );
  1702     iScreenAnchorLayout->SetSize( clientRect.Size() );
  1694     SetMailListLayoutAnchors();
  1703     SetMailListLayoutAnchors();
  1695     //if the view is already active don't update the icons so they won't "blink" 
  1704     //if the view is already active don't update the icons so they won't "blink" 
  1696     //when the view is activated.
  1705     //when the view is activated.
  1697     if( !iThisViewActive && !iMarkingMode )
  1706     if(!iThisViewActive)
  1698         {     
  1707         {     
       
  1708         ScaleControlBarL();
  1699         
  1709         
  1700         ScaleControlBarL();
  1710         // Set icons on toolbar
  1701         if ( !bDoFirstStartCalled ) // Don't set the icon if set by DoFirstStart()
  1711         iAppUi.FsTextureManager()->ClearTextureByIndex( EListControlBarMailboxDefaultIcon );
  1702             { 
  1712         iFolderListButton->SetIconL( iAppUi.FsTextureManager()->TextureByIndex( EListControlBarMailboxDefaultIcon ) );
  1703             // Set icons on toolbar
  1713         iAppUi.FsTextureManager()->ClearTextureByIndex( EListTextureCreateNewMessageIcon );
  1704             iAppUi.FsTextureManager()->ClearTextureByIndex( EListControlBarMailboxDefaultIcon );
  1714         iNewEmailButton->SetIconL( iAppUi.FsTextureManager()->TextureByIndex( EListTextureCreateNewMessageIcon ) );
  1705             iFolderListButton->SetIconL( iAppUi.FsTextureManager()->TextureByIndex( EListControlBarMailboxDefaultIcon ) );
  1715         iAppUi.FsTextureManager()->ClearTextureByIndex( GetSortButtonTextureIndex() );
  1706             iAppUi.FsTextureManager()->ClearTextureByIndex( EListTextureCreateNewMessageIcon );
  1716         iSortButton->SetIconL( iAppUi.FsTextureManager()->TextureByIndex( GetSortButtonTextureIndex() ) );
  1707             iNewEmailButton->SetIconL( iAppUi.FsTextureManager()->TextureByIndex( EListTextureCreateNewMessageIcon ) );
  1717 
  1708             iAppUi.FsTextureManager()->ClearTextureByIndex( GetSortButtonTextureIndex() );
       
  1709             iSortButton->SetIconL( iAppUi.FsTextureManager()->TextureByIndex( GetSortButtonTextureIndex() ) );
       
  1710             }
       
  1711         SetListAndCtrlBarFocusL();
  1718         SetListAndCtrlBarFocusL();
  1712         }
  1719         }
  1713 
  1720 
  1714 	FadeOut(EFalse); // we can show now CAlfVisuals from CurrentView (to show Folders before updating emails)
  1721 	FadeOut(EFalse); // we can show now CAlfVisuals from CurrentView (to show Folders before updating emails)
  1715     
  1722     
  1874          {
  1881          {
  1875          iForceRefresh = EFalse;
  1882          iForceRefresh = EFalse;
  1876          // Set initial sort criteria when folder is changed
  1883          // Set initial sort criteria when folder is changed
  1877          iCurrentSortCriteria.iField = EFSMailSortByDate;
  1884          iCurrentSortCriteria.iField = EFSMailSortByDate;
  1878          iCurrentSortCriteria.iOrder = EFSMailDescending;
  1885          iCurrentSortCriteria.iOrder = EFSMailDescending;
  1879          SetSortButtonIconL();
  1886          SetSortButtonTextAndIconL();
  1880 
  1887 
  1881          SafeDelete(iMailFolder);
  1888          SafeDelete(iMailFolder);
  1882          TRAP_IGNORE( iMailFolder = iAppUi.GetMailClient()->GetFolderByUidL(
  1889          TRAP_IGNORE( iMailFolder = iAppUi.GetMailClient()->GetFolderByUidL(
  1883                  activationData.iMailBoxId, activationData.iFolderId ) );
  1890                  activationData.iMailBoxId, activationData.iFolderId ) );
  1884          if ( !iMailFolder )
  1891          if ( !iMailFolder )
  1889                  }
  1896                  }
  1890              // Safety, try to revert back to standard folder inbox
  1897              // Safety, try to revert back to standard folder inbox
  1891              TFSMailMsgId inboxId = iAppUi.GetActiveMailbox()->GetStandardFolderId( EFSInbox );
  1898              TFSMailMsgId inboxId = iAppUi.GetActiveMailbox()->GetStandardFolderId( EFSInbox );
  1892              iMailFolder = iAppUi.GetMailClient()->GetFolderByUidL( activationData.iMailBoxId, inboxId );
  1899              iMailFolder = iAppUi.GetMailClient()->GetFolderByUidL( activationData.iMailBoxId, inboxId );
  1893              }
  1900              }
       
  1901          HBufC* newFolderName = CreateFolderNameLC( iMailFolder );
       
  1902          iFolderListButton->SetTextL( *newFolderName );
       
  1903          CleanupStack::PopAndDestroy( newFolderName );
  1894          iMailList->SetFocusedItemL( KFsTreeNoneID );
  1904          iMailList->SetFocusedItemL( KFsTreeNoneID );
  1895          refreshState = EFullRefreshNeeded;
  1905          refreshState = EFullRefreshNeeded;
  1896          }
  1906          }
  1897 
  1907 
  1898     // Set mailbox name to status pane
  1908     // Set mailbox name to status pane
  1989 	else
  1999 	else
  1990 	    {
  2000 	    {
  1991 	    SetControlBarFocusedL();
  2001 	    SetControlBarFocusedL();
  1992 	    iControlBarControl->MakeSelectorVisible( iAppUi.IsFocusShown() );
  2002 	    iControlBarControl->MakeSelectorVisible( iAppUi.IsFocusShown() );
  1993 	    }
  2003 	    }
       
  2004 	UpdateButtonTextsL();
  1994 	FocusVisibilityChange( iAppUi.IsFocusShown() );
  2005 	FocusVisibilityChange( iAppUi.IsFocusShown() );
  1995 	iAppUi.ShowTitlePaneConnectionStatus();
  2006 	iAppUi.ShowTitlePaneConnectionStatus();
  1996 
       
  1997     // if timer stoped when quitting view then restart if more messages available
       
  1998     if ( iNewMailIds.Count() && ( ! iNewMailTimer->IsActive() ) && iSortState == ESortNone )
       
  1999         {
       
  2000         iNewMailTimer->Start( KNewMailTimerDelay );
       
  2001         }
       
  2002 
       
  2003 	TIMESTAMP( "Message list view opened" );
  2007 	TIMESTAMP( "Message list view opened" );
  2004 	}  // CFSEmailUiMailListVisualiser::ChildDoActivateL
  2008 	}
  2005 
  2009 
  2006 // ---------------------------------------------------------------------------
  2010 // ---------------------------------------------------------------------------
  2007 // Sets status bar layout
  2011 // Sets status bar layout
  2008 // ---------------------------------------------------------------------------
  2012 // ---------------------------------------------------------------------------
  2009 //
  2013 //
  2041   	    TRAP_IGNORE( {
  2045   	    TRAP_IGNORE( {
  2042             iMailList->HideListL();
  2046             iMailList->HideListL();
  2043             iMailList->SetFocusedL( EFalse );
  2047             iMailList->SetFocusedL( EFalse );
  2044   	        } );
  2048   	        } );
  2045   	    iMailTreeListVisualizer->NotifyControlVisibilityChange( EFalse );
  2049   	    iMailTreeListVisualizer->NotifyControlVisibilityChange( EFalse );
  2046   	    TRAP_IGNORE( UpdateFolderAndMarkingModeTextsL() );
       
  2047   	    }
  2050   	    }
  2048 	iThisViewActive = EFalse;
  2051 	iThisViewActive = EFalse;
  2049 	}
  2052 	}
  2050 
  2053 
  2051 // ---------------------------------------------------------------------------
  2054 // ---------------------------------------------------------------------------
  2218 	    // "Clear deleted folder" command is available only in Deleted folder
  2221 	    // "Clear deleted folder" command is available only in Deleted folder
  2219 	    if ( currentFolderType != EFSDeleted || !iModel->Count() )
  2222 	    if ( currentFolderType != EFSDeleted || !iModel->Count() )
  2220 	        {
  2223 	        {
  2221 	        aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsEmptyDeleted, ETrue );
  2224 	        aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsEmptyDeleted, ETrue );
  2222 	        }
  2225 	        }
  2223 	    
  2226 		}
  2224 	    CConnectionStatusQueryExtension::TConnectionStatus connetionStatus;
       
  2225         iAppUi.GetConnectionStatusL( connetionStatus );
       
  2226         if ( connetionStatus == CConnectionStatusQueryExtension::ESynchronizing )
       
  2227             {
       
  2228             aMenuPane->SetItemDimmed( EFsEmailUiCmdSync, ETrue );
       
  2229             aMenuPane->SetItemDimmed( EFsEmailUiCmdCancelSync, EFalse );
       
  2230             }
       
  2231         else
       
  2232             {
       
  2233             aMenuPane->SetItemDimmed( EFsEmailUiCmdSync, EFalse );
       
  2234             aMenuPane->SetItemDimmed( EFsEmailUiCmdCancelSync, ETrue );
       
  2235             }
       
  2236 	    }
       
  2237 	
       
  2238     // MAIN MENU ***************************************************************************
  2227     // MAIN MENU ***************************************************************************
  2239 
  2228 
  2240 
  2229 
  2241 	// ACTIONS SUBMENU *********************************************************************
  2230 	// ACTIONS SUBMENU *********************************************************************
  2242 	if ( aResourceId == R_FSEMAILUI_MAILLIST_SUBMENU_MAIL_ACTIONS  )
  2231 	if ( aResourceId == R_FSEMAILUI_MAILLIST_SUBMENU_MAIL_ACTIONS  )
  2538 //
  2527 //
  2539 // ---------------------------------------------------------------------------
  2528 // ---------------------------------------------------------------------------
  2540 //
  2529 //
  2541 void CFSEmailUiMailListVisualiser::ExitMarkingModeL()
  2530 void CFSEmailUiMailListVisualiser::ExitMarkingModeL()
  2542     {
  2531     {
  2543     FUNC_LOG;
  2532     FUNC_LOG;	
  2544     iMarkingMode = EFalse;    
       
  2545     // Hide marking mode text on the place of drop down menus
  2533     // Hide marking mode text on the place of drop down menus
  2546     UpdateFolderAndMarkingModeTextsL();
  2534     RemoveMarkingModeTitleTextL();	
  2547     iMailList->SetMarkingModeL( EFalse );
  2535     iMarkingMode = EFalse;
  2548     UnmarkAllItemsL();
  2536     UnmarkAllItemsL();
  2549     // Change softkeys back to normal
  2537     // Change softkeys back to normal
  2550     SetViewSoftkeysL( R_FREESTYLE_EMAUIL_UI_SK_OPTIONS_BACK );
  2538     SetViewSoftkeysL( R_FREESTYLE_EMAUIL_UI_SK_OPTIONS_BACK );
  2551     // Change options menu back to normal
  2539     // Change options menu back to normal
  2552     CEikMenuBar* menu = iAppUi.CurrentActiveView()->MenuBar();
  2540     CEikMenuBar* menu = iAppUi.CurrentActiveView()->MenuBar();
  2553     menu->StopDisplayingMenuBar();
  2541     menu->StopDisplayingMenuBar();
  2554     menu->SetMenuTitleResourceId(R_FSEMAILUI_MAILLIST_MENUBAR);
  2542     menu->SetMenuTitleResourceId(R_FSEMAILUI_MAILLIST_MENUBAR);
       
  2543     // Change background back to normal
       
  2544     DisplayMarkingModeBgL( EFalse );   
  2555     // Display drop down menu buttons
  2545     // Display drop down menu buttons
  2556     iControlBarControl->SetRectL( iAppUi.LayoutHandler()->GetControlBarRect() );
  2546     iControlBarControl->SetRectL( iAppUi.LayoutHandler()->GetControlBarRect() );
  2557     iNewEmailButton->SetDimmed( EFalse );
  2547     iNewEmailButton->SetDimmed( EFalse );
  2558     iFolderListButton->SetDimmed( EFalse );   
  2548     iFolderListButton->SetDimmed( EFalse );   
  2559     iSortButton->SetDimmed( EFalse );
  2549     iSortButton->SetDimmed( EFalse );
  2560     ScaleControlBarL();
  2550     ScaleControlBarL();
  2561 
       
  2562     iMailTreeListVisualizer->HideList();   
       
  2563     SetMailListLayoutAnchors();
       
  2564     iMailTreeListVisualizer->ShowListL();
       
  2565     }
  2551     }
  2566 
  2552 
  2567 // ---------------------------------------------------------------------------
  2553 // ---------------------------------------------------------------------------
  2568 //
  2554 //
  2569 //
  2555 //
  2571 //
  2557 //
  2572 void CFSEmailUiMailListVisualiser::EnterMarkingModeL()
  2558 void CFSEmailUiMailListVisualiser::EnterMarkingModeL()
  2573     {
  2559     {
  2574     FUNC_LOG;	
  2560     FUNC_LOG;	
  2575     iMarkingMode = ETrue;
  2561     iMarkingMode = ETrue;
  2576     iMailList->SetMarkingModeL( ETrue );
       
  2577 	iListMarkItemsState = ETrue; // shift-scrolling does marking after one item is marked
  2562 	iListMarkItemsState = ETrue; // shift-scrolling does marking after one item is marked
  2578     HandleCommandL( EFsEmailUiCmdActionsExpandAll );
  2563     HandleCommandL( EFsEmailUiCmdActionsExpandAll );
  2579     // Change softkeys for marking mode
  2564     // Change softkeys for marking mode
  2580     SetViewSoftkeysL( R_FREESTYLE_EMAUIL_UI_SK_OPTIONS_CANCEL );
  2565     SetViewSoftkeysL( R_FREESTYLE_EMAUIL_UI_SK_OPTIONS_CANCEL );
  2581     // Change options menu for marking mode
  2566     // Change options menu for marking mode
  2582     CEikMenuBar* menu = iAppUi.CurrentActiveView()->MenuBar();
  2567     CEikMenuBar* menu = iAppUi.CurrentActiveView()->MenuBar();
  2583     menu->StopDisplayingMenuBar();
  2568     menu->StopDisplayingMenuBar();
  2584     menu->SetMenuTitleResourceId(R_FSEMAILUI_MAILLIST_MENUBAR_MARKING_MODE);
  2569     menu->SetMenuTitleResourceId(R_FSEMAILUI_MAILLIST_MENUBAR_MARKING_MODE);
       
  2570     // Change background to marking mode
       
  2571     DisplayMarkingModeBgL( ETrue );       
  2585     // Hide drop down menu buttons
  2572     // Hide drop down menu buttons
  2586     iNewEmailButton->SetDimmed();
  2573     iNewEmailButton->SetDimmed();
  2587     iFolderListButton->SetDimmed();   
  2574     iFolderListButton->SetDimmed();   
  2588     iSortButton->SetDimmed();
  2575     iSortButton->SetDimmed();
  2589     TRect rect(0,0,0,0);
  2576     if( !Layout_Meta_Data::IsLandscapeOrientation() )
  2590     iControlBarControl->SetRectL( rect );
  2577         {
  2591     UpdateFolderAndMarkingModeTextsL();
       
  2592     
       
  2593     iMailTreeListVisualizer->HideList();   
       
  2594     SetMailListLayoutAnchors();
       
  2595     iMailTreeListVisualizer->ShowListL();
       
  2596     }
       
  2597 
       
  2598 // ---------------------------------------------------------------------------
       
  2599 //
       
  2600 //
       
  2601 // ---------------------------------------------------------------------------
       
  2602 //
       
  2603 void CFSEmailUiMailListVisualiser::RefreshMarkingModeL()
       
  2604     {
       
  2605     FUNC_LOG;
       
  2606     if ( iMarkingMode )
       
  2607         {
       
  2608         // Hide drop down menu buttons    
       
  2609         TRect rect(0,0,0,0);
  2578         TRect rect(0,0,0,0);
  2610         iControlBarControl->SetRectL( rect );
  2579         iControlBarControl->SetRectL( rect );
  2611         iNewEmailButton->SetDimmed();
  2580         // Display marking mode text on the place of drop down menus   
  2612         iFolderListButton->SetDimmed();
  2581         DisplayMarkingModeTitleTextL();
  2613         iSortButton->SetDimmed();
  2582         }
  2614         UpdateFolderAndMarkingModeTextsL();
  2583     }
  2615         }
  2584 
  2616     }
  2585 // ---------------------------------------------------------------------------
  2617 
  2586 //
  2618 // ---------------------------------------------------------------------------
  2587 //
  2619 //
  2588 // ---------------------------------------------------------------------------
  2620 //
  2589 //
  2621 // ---------------------------------------------------------------------------
  2590 void CFSEmailUiMailListVisualiser::RefreshMarkingModeL()
  2622 //
  2591     {
  2623 void CFSEmailUiMailListVisualiser::DisplayMarkingModeTextOnButtonsL()
  2592     FUNC_LOG;
       
  2593     if ( iMarkingMode )
       
  2594         {
       
  2595         // Hide drop down menu buttons    
       
  2596         if( !Layout_Meta_Data::IsLandscapeOrientation() )
       
  2597             {
       
  2598             TRect rect(0,0,0,0);
       
  2599             iControlBarControl->SetRectL( rect );
       
  2600             DisplayMarkingModeTitleTextL();
       
  2601             }
       
  2602         else
       
  2603             {
       
  2604             iControlBarControl->SetRectL( iAppUi.LayoutHandler()->GetControlBarRect() );
       
  2605             iNewEmailButton->SetDimmed();
       
  2606             iFolderListButton->SetDimmed();
       
  2607             iSortButton->SetDimmed();
       
  2608             RemoveMarkingModeTitleTextL();
       
  2609             }
       
  2610         }
       
  2611     }
       
  2612 
       
  2613 // ---------------------------------------------------------------------------
       
  2614 //
       
  2615 //
       
  2616 // ---------------------------------------------------------------------------
       
  2617 //
       
  2618 void CFSEmailUiMailListVisualiser::DisplayMarkingModeTitleTextL()
  2624     {
  2619     {
  2625     FUNC_LOG;     
  2620     FUNC_LOG;     
  2626     if (!iMarkingModeTextVisual)
  2621     if (!iMarkingModeTextVisual)
  2627         {
  2622         {
  2628         const TRect sortButtonRect( iAppUi.LayoutHandler()->GetControlBarSortButtonRect() );
  2623         const TRect sortButtonRect( iAppUi.LayoutHandler()->GetControlBarSortButtonRect() );
  2656             }
  2651             }
  2657         else
  2652         else
  2658             {
  2653             {
  2659             iMarkingModeTextVisual->SetTextL( KNullDesC );
  2654             iMarkingModeTextVisual->SetTextL( KNullDesC );
  2660             }
  2655             }
  2661         }
  2656         }        
  2662     }
  2657     }
  2663 
  2658 
  2664 // ---------------------------------------------------------------------------
  2659 // ---------------------------------------------------------------------------
  2665 //
  2660 //
  2666 //
  2661 //
  2667 // ---------------------------------------------------------------------------
  2662 // ---------------------------------------------------------------------------
  2668 //
  2663 //
  2669 void CFSEmailUiMailListVisualiser::RemoveMarkingModeTextOnButtonsL()
  2664 void CFSEmailUiMailListVisualiser::RemoveMarkingModeTitleTextL()
  2670     {
  2665     {
  2671     FUNC_LOG;
  2666     FUNC_LOG;
  2672     if (iMarkingModeTextVisual)
  2667     if (iMarkingModeTextVisual)
  2673         {
  2668         {
  2674         iMarkingModeTextVisual->SetTextL( KNullDesC );
  2669         iMarkingModeTextVisual->SetTextL( KNullDesC );
  2676         iMarkingModeTextVisual = NULL;
  2671         iMarkingModeTextVisual = NULL;
  2677         iMarkingModeTextContentLayout->RemoveAndDestroyAllD();
  2672         iMarkingModeTextContentLayout->RemoveAndDestroyAllD();
  2678         iMarkingModeTextContentLayout = NULL;
  2673         iMarkingModeTextContentLayout = NULL;
  2679         iMarkingModeTextParentLayout->RemoveAndDestroyAllD();
  2674         iMarkingModeTextParentLayout->RemoveAndDestroyAllD();
  2680         iMarkingModeTextParentLayout = NULL;
  2675         iMarkingModeTextParentLayout = NULL;
       
  2676         }
       
  2677     }
       
  2678 
       
  2679 // ---------------------------------------------------------------------------
       
  2680 //
       
  2681 //
       
  2682 // ---------------------------------------------------------------------------
       
  2683 //
       
  2684 void CFSEmailUiMailListVisualiser::DisplayMarkingModeBgL( TBool aDisplay )
       
  2685     {
       
  2686     FUNC_LOG;
       
  2687     if (aDisplay)
       
  2688         {
       
  2689         CAlfBrush* brush = iAppUi.FsTextureManager()->NewMailListMarkingModeBgBrushLC();
       
  2690         iMailTreeListVisualizer->SetBackgroundBrushL( brush );
       
  2691         CleanupStack::Pop( brush );
       
  2692         }
       
  2693     else
       
  2694         {
       
  2695         iMailTreeListVisualizer->ClearBackground();
  2681         }
  2696         }
  2682     }
  2697     }
  2683 
  2698 
  2684 // ---------------------------------------------------------------------------
  2699 // ---------------------------------------------------------------------------
  2685 //
  2700 //
  3351     if ( iFirstStartCompleted ) // Safety
  3366     if ( iFirstStartCompleted ) // Safety
  3352         {
  3367         {
  3353         if ( aType == EScreenLayoutChanged )
  3368         if ( aType == EScreenLayoutChanged )
  3354         	{
  3369         	{
  3355             SetStatusBarLayout();
  3370             SetStatusBarLayout();
       
  3371             UpdateButtonTextsL();
  3356         	}
  3372         	}
  3357 
  3373 
  3358         if ( aType == ESkinChanged )
  3374         if ( aType == ESkinChanged )
  3359             {
  3375             {
  3360             UpdateThemeL();
  3376             UpdateThemeL();
  3387             }
  3403             }
  3388         }
  3404         }
  3389     if (iMarkingMode)
  3405     if (iMarkingMode)
  3390         {
  3406         {
  3391         RefreshMarkingModeL();
  3407         RefreshMarkingModeL();
  3392         }
  3408         }    
  3393     UpdateFolderAndMarkingModeTextsL();
       
  3394 	}
  3409 	}
  3395 
  3410 
  3396 // ---------------------------------------------------------------------------
  3411 // ---------------------------------------------------------------------------
  3397 //
  3412 //
  3398 //
  3413 //
  3404     FUNC_LOG;
  3419     FUNC_LOG;
  3405     CFsEmailUiViewBase::HandleDynamicVariantSwitchOnBackgroundL( aType );
  3420     CFsEmailUiViewBase::HandleDynamicVariantSwitchOnBackgroundL( aType );
  3406     if ( aType == ESkinChanged )
  3421     if ( aType == ESkinChanged )
  3407         {
  3422         {
  3408         UpdateThemeL();
  3423         UpdateThemeL();
       
  3424         }
       
  3425     else if ( aType == EScreenLayoutChanged )
       
  3426         {
       
  3427         UpdateButtonTextsL();
       
  3428         }
       
  3429     }
       
  3430 
       
  3431 // ---------------------------------------------------------------------------
       
  3432 // Update texts for command area buttons
       
  3433 // ---------------------------------------------------------------------------
       
  3434 //
       
  3435 void CFSEmailUiMailListVisualiser::UpdateButtonTextsL()
       
  3436     {
       
  3437     if ( !Layout_Meta_Data::IsLandscapeOrientation() )
       
  3438         {
       
  3439         // No texts in portrait mode
       
  3440         iNewEmailButton->SetTextL( KNullDesC() );
       
  3441         iSortButton->SetTextL( KNullDesC() );
       
  3442         }
       
  3443     else
       
  3444         {
       
  3445         // Set button text if necessary
       
  3446         HBufC* buttonText = GetSortButtonTextLC();
       
  3447         if ( buttonText )
       
  3448             {
       
  3449             iSortButton->SetTextL( *buttonText );
       
  3450             CleanupStack::PopAndDestroy( buttonText );
       
  3451             }
       
  3452 
       
  3453         iNewEmailButton->SetTextL( *iNewEmailText );
  3409         }
  3454         }
  3410     }
  3455     }
  3411 
  3456 
  3412 // ---------------------------------------------------------------------------
  3457 // ---------------------------------------------------------------------------
  3413 //
  3458 //
  3915     	   aCommand == EFsEmailUiCmdMarkAsUnread ||
  3960     	   aCommand == EFsEmailUiCmdMarkAsUnread ||
  3916     	   aCommand == EFsEmailUiCmdActionsMove ||
  3961     	   aCommand == EFsEmailUiCmdActionsMove ||
  3917     	   aCommand == EFsEmailUiCmdActionsMoveMessage ||
  3962     	   aCommand == EFsEmailUiCmdActionsMoveMessage ||
  3918     	   aCommand == EFsEmailUiCmdMarkingModeFromPopUp ||
  3963     	   aCommand == EFsEmailUiCmdMarkingModeFromPopUp ||
  3919     	   aCommand == EFsEmailUiCmdActionsCollapseAll ||
  3964     	   aCommand == EFsEmailUiCmdActionsCollapseAll ||
  3920     	   aCommand == EFsEmailUiCmdActionsExpandAll ||
  3965     	   aCommand == EFsEmailUiCmdActionsExpandAll ) )
  3921            aCommand == EFsEmailUiCmdActionsFlag ) )
       
  3922     	{
  3966     	{
  3923    		// We end up here if the user selects an option from the pop up menu
  3967    		// We end up here if the user selects an option from the pop up menu
  3924     	// or exits the menu by tapping outside of it's area.
  3968     	// or exits the menu by tapping outside of it's area.
  3925     	// Remove the focus from a list item if an item is focused.
  3969     	// Remove the focus from a list item if an item is focused.
  3926     	iStylusPopUpMenuVisible = EFalse;
  3970     	iStylusPopUpMenuVisible = EFalse;
  4382 			    //POP3 synchronise
  4426 			    //POP3 synchronise
  4383 				iAppUi.DoAutoConnectL();
  4427 				iAppUi.DoAutoConnectL();
  4384 				}
  4428 				}
  4385 			}
  4429 			}
  4386 			break;
  4430 			break;
  4387        	case EFsEmailUiCmdCancelSync:
       
  4388        	    {
       
  4389        	    if ( GetLatestSyncState() )
       
  4390        	        {
       
  4391                 iAppUi.StopActiveMailBoxSyncL();
       
  4392        	        }
       
  4393        	    }
       
  4394        	    break;
       
  4395        	case EFsEmailUiCmdGoOffline:
  4431        	case EFsEmailUiCmdGoOffline:
  4396         	{
  4432         	{
  4397     	   	iAppUi.GetActiveMailbox()->GoOfflineL();
  4433     	   	iAppUi.GetActiveMailbox()->GoOfflineL();
  4398         	}
  4434         	}
  4399         	break;
  4435         	break;
  4613             {
  4649             {
  4614             // If destination folder is not set, it needs to be asked messages are moved after callbak
  4650             // If destination folder is not set, it needs to be asked messages are moved after callbak
  4615             if ( aDestinationFolderId.IsNullId() )
  4651             if ( aDestinationFolderId.IsNullId() )
  4616                 {
  4652                 {
  4617                 // Activate folder selection view and handle moving after callback gets destination
  4653                 // Activate folder selection view and handle moving after callback gets destination
       
  4654                 RemoveMarkingModeTitleTextL();    
  4618                 iMoveToFolderOngoing = ETrue;
  4655                 iMoveToFolderOngoing = ETrue;
  4619                 TFolderListActivationData folderListData;
  4656                 TFolderListActivationData folderListData;
  4620                 folderListData.iCallback = this;
  4657                 folderListData.iCallback = this;
  4621                 if(iMailFolder) // Coverity error fix , assuming that inbox is best bet for safe data. 
  4658                 if(iMailFolder) // Coverity error fix , assuming that inbox is best bet for safe data. 
  4622                     {
  4659                     {
  5885     TAlfAlignHorizontal horizontalAlign = EAlfAlignHLeft;
  5922     TAlfAlignHorizontal horizontalAlign = EAlfAlignHLeft;
  5886     if ( AknLayoutUtils::LayoutMirrored() )
  5923     if ( AknLayoutUtils::LayoutMirrored() )
  5887         {
  5924         {
  5888         horizontalAlign = EAlfAlignHRight;
  5925         horizontalAlign = EAlfAlignHRight;
  5889         }
  5926         }
       
  5927 
  5890     // Icons and sort button text
  5928     // Icons and sort button text
  5891     iFolderListButton->SetIconL( iAppUi.FsTextureManager()->TextureByIndex( EListControlBarMailboxDefaultIcon ) );
  5929     iFolderListButton->SetIconL( iAppUi.FsTextureManager()->TextureByIndex( EListControlBarMailboxDefaultIcon ) );
  5892     iNewEmailButton->SetIconL( iAppUi.FsTextureManager()->TextureByIndex( EListTextureCreateNewMessageIcon ) );
  5930     iNewEmailButton->SetIconL( iAppUi.FsTextureManager()->TextureByIndex( EListTextureCreateNewMessageIcon ) );
  5893     SetSortButtonIconL();
  5931     SetSortButtonTextAndIconL();
  5894 
  5932 
  5895     iNewEmailButton->SetElemAlignL(
  5933     iNewEmailButton->SetElemAlignL(
  5896         ECBElemIconA,
  5934         ECBElemIconA,
  5897         EAlfAlignHCenter,
  5935         EAlfAlignHCenter,
  5898         EAlfAlignVCenter );
  5936         EAlfAlignVCenter );
  5909         ECBElemIconA,
  5947         ECBElemIconA,
  5910         EAlfAlignHCenter,
  5948         EAlfAlignHCenter,
  5911         EAlfAlignVCenter );
  5949         EAlfAlignVCenter );
  5912 
  5950 
  5913 	// Show the buttons
  5951 	// Show the buttons
  5914     if( iThisViewActive || iMarkingMode )
  5952   	iNewEmailButton->ShowButtonL();
  5915         {
  5953     iFolderListButton->ShowButtonL();
  5916         iNewEmailButton->ShowButtonL();
  5954     iSortButton->ShowButtonL();
  5917         iFolderListButton->ShowButtonL();
  5955 	}
  5918         iSortButton->ShowButtonL();
       
  5919         }
       
  5920     // else buttons shown later in ChildDoActivete() by ScaleControlBarL()
       
  5921     }
       
  5922 
  5956 
  5923 // ---------------------------------------------------------------------------
  5957 // ---------------------------------------------------------------------------
  5924 //
  5958 //
  5925 //
  5959 //
  5926 // ---------------------------------------------------------------------------
  5960 // ---------------------------------------------------------------------------
  5978 // ---------------------------------------------------------------------------
  6012 // ---------------------------------------------------------------------------
  5979 //
  6013 //
  5980 //
  6014 //
  5981 // ---------------------------------------------------------------------------
  6015 // ---------------------------------------------------------------------------
  5982 //
  6016 //
  5983 void CFSEmailUiMailListVisualiser::SetSortButtonIconL()
  6017 void CFSEmailUiMailListVisualiser::SetSortButtonTextAndIconL()
  5984 	{
  6018 	{
  5985     FUNC_LOG;
  6019     FUNC_LOG;
       
  6020 
       
  6021     // Set button text if necessary
       
  6022     HBufC* buttonText = GetSortButtonTextLC();
       
  6023 
       
  6024 	if ( !Layout_Meta_Data::IsLandscapeOrientation() )
       
  6025 		{
       
  6026 		if ( buttonText )
       
  6027 			{
       
  6028 			buttonText->Des().Zero();
       
  6029 			}
       
  6030 		}
       
  6031 
       
  6032 	if ( buttonText )
       
  6033 		{
       
  6034 		iSortButton->SetTextL( *buttonText );
       
  6035 		}
       
  6036 	CleanupStack::PopAndDestroy( buttonText );
       
  6037 
  5986 	iSortButton->SetIconL(
  6038 	iSortButton->SetIconL(
  5987 			iAppUi.FsTextureManager()->TextureByIndex( GetSortButtonTextureIndex() ),
  6039 			iAppUi.FsTextureManager()->TextureByIndex( GetSortButtonTextureIndex() ),
  5988 			ECBElemIconA );
  6040 			ECBElemIconA );
  5989 
  6041 
  5990 	}
  6042 	}
  5998     {
  6050     {
  5999     FUNC_LOG;
  6051     FUNC_LOG;
  6000     
  6052     
  6001     TFSEmailUiTextures textureIndex( ETextureFirst );
  6053     TFSEmailUiTextures textureIndex( ETextureFirst );
  6002     switch ( iCurrentSortCriteria.iField )
  6054     switch ( iCurrentSortCriteria.iField )
  6003         {
  6055 		{
  6004         case EFSMailSortBySubject:
  6056 		case EFSMailSortBySubject:
  6005             {
  6057 			{
  6006             textureIndex = iCurrentSortCriteria.iOrder == EFSMailAscending ?
  6058 			textureIndex = iCurrentSortCriteria.iOrder == EFSMailAscending ?
  6007                 ESortListSubjectAscTexture : ESortListSubjectDescTexture;
  6059 						   ESortListSubjectDescTexture :
  6008             }
  6060 						   ESortListSubjectAscTexture;
  6009             break;
  6061 			}
  6010         case EFSMailSortByAttachment:
  6062 			break;
  6011             {
  6063 		case EFSMailSortByAttachment:
  6012             textureIndex = iCurrentSortCriteria.iOrder == EFSMailAscending ?
  6064 			{
  6013                 ESortListAttachmentAscTexture : ESortListAttachmentDescTexture;
  6065 			textureIndex = iCurrentSortCriteria.iOrder == EFSMailAscending ?
  6014             }
  6066 						   ESortListAttachmentDescTexture :
  6015             break;
  6067 						   ESortListAttachmentAscTexture;
  6016         case EFSMailSortByFlagStatus:
  6068 			}
  6017             {
  6069 			break;
  6018             textureIndex = iCurrentSortCriteria.iOrder == EFSMailAscending ?
  6070 		case EFSMailSortByFlagStatus:
  6019                 ESortListFollowAscTexture : ESortListFollowDescTexture;
  6071 			{
  6020             }
  6072 			textureIndex = iCurrentSortCriteria.iOrder == EFSMailAscending ?
  6021             break;
  6073 						   ESortListFollowDescTexture :
  6022         case EFSMailSortByRecipient:
  6074 						   ESortListFollowAscTexture;
  6023         case EFSMailSortBySender:
  6075 			}
  6024             {
  6076 			break;
  6025             textureIndex = iCurrentSortCriteria.iOrder == EFSMailAscending ?
  6077 		case EFSMailSortByRecipient:
  6026                 ESortListSenderAscTexture : ESortListSenderDescTexture;
  6078 		case EFSMailSortBySender:
  6027             }
  6079 			{
  6028             break;
  6080 			textureIndex = iCurrentSortCriteria.iOrder == EFSMailAscending ?
  6029         case EFSMailSortByPriority:
  6081 						   ESortListSenderDescTexture :
  6030             {
  6082 						   ESortListSenderAscTexture;
  6031             textureIndex = iCurrentSortCriteria.iOrder == EFSMailAscending ?
  6083 			}
  6032                 ESortListPriorityAscTexture : ESortListPriorityDescTexture;
  6084 			break;
  6033             }
  6085 		case EFSMailSortByPriority:
  6034             break;
  6086 			{
  6035         case EFSMailSortByUnread:
  6087 			textureIndex = iCurrentSortCriteria.iOrder == EFSMailAscending ?
  6036             {
  6088 						   ESortListPriorityDescTexture :
  6037             textureIndex = iCurrentSortCriteria.iOrder == EFSMailAscending ?
  6089 						   ESortListPriorityAscTexture;
  6038                 ESortListUnreadAscTexture : ESortListUnreadDescTexture;
  6090 			}
  6039             }
  6091 			break;
  6040             break;
  6092 		case EFSMailSortByUnread:
  6041         case EFSMailSortByDate:
  6093 			{
  6042         default:
  6094 			textureIndex = iCurrentSortCriteria.iOrder == EFSMailAscending ?
  6043             {
  6095 						   ESortListUnreadDescTexture :
  6044             textureIndex = iCurrentSortCriteria.iOrder == EFSMailAscending ?
  6096 						   ESortListUnreadAscTexture;
  6045                 ESortListDateAscTexture : ESortListDateDescTexture;
  6097 			}
  6046             }
  6098 			break;
  6047             break;
  6099 		case EFSMailSortByDate:
  6048         }
  6100 		default:
       
  6101 			{
       
  6102 			textureIndex = iCurrentSortCriteria.iOrder == EFSMailAscending ?
       
  6103 						   ESortListDateDescTexture :
       
  6104 						   ESortListDateAscTexture;
       
  6105 			}
       
  6106 			break;
       
  6107   		}
  6049     return textureIndex;
  6108     return textureIndex;
  6050 	}
  6109 	}
  6051 
  6110 
  6052 // ---------------------------------------------------------------------------
  6111 // ---------------------------------------------------------------------------
  6053 //
  6112 //
  6135     iScreenAnchorLayout->SetAnchor(EAlfAnchorBottomRight, 0,
  6194     iScreenAnchorLayout->SetAnchor(EAlfAnchorBottomRight, 0,
  6136         EAlfAnchorOriginLeft, EAlfAnchorOriginTop,
  6195         EAlfAnchorOriginLeft, EAlfAnchorOriginTop,
  6137         EAlfAnchorMetricRelativeToSize, EAlfAnchorMetricAbsolute,
  6196         EAlfAnchorMetricRelativeToSize, EAlfAnchorMetricAbsolute,
  6138         TAlfTimedPoint(1, iAppUi.LayoutHandler()->ControlBarHeight() ));
  6197         TAlfTimedPoint(1, iAppUi.LayoutHandler()->ControlBarHeight() ));
  6139 
  6198 
       
  6199     // <cmail> Platform layout changes
  6140     TRect listRect = iAppUi.LayoutHandler()->GetListRect();
  6200     TRect listRect = iAppUi.LayoutHandler()->GetListRect();
  6141 	// Set anchors so that list leaves space for control bar
  6201 	// Set anchors so that list leaves space for control bar
  6142     if( Layout_Meta_Data::IsMirrored() ) 
  6202     if( Layout_Meta_Data::IsMirrored() ) 
  6143         { 
  6203         { 
  6144         TInt tlX = listRect.iTl.iX; 
  6204         TInt tlX = listRect.iTl.iX; 
  6149         } 
  6209         } 
  6150     iScreenAnchorLayout->SetAnchor(EAlfAnchorTopLeft, 1,
  6210     iScreenAnchorLayout->SetAnchor(EAlfAnchorTopLeft, 1,
  6151         EAlfAnchorOriginLeft, EAlfAnchorOriginTop,
  6211         EAlfAnchorOriginLeft, EAlfAnchorOriginTop,
  6152         EAlfAnchorMetricAbsolute, EAlfAnchorMetricAbsolute,
  6212         EAlfAnchorMetricAbsolute, EAlfAnchorMetricAbsolute,
  6153         TAlfTimedPoint(listRect.iTl.iX, listRect.iTl.iY));
  6213         TAlfTimedPoint(listRect.iTl.iX, listRect.iTl.iY));
  6154     
  6214     iScreenAnchorLayout->SetAnchor(EAlfAnchorBottomRight, 1,
  6155     if (iMarkingMode && Layout_Meta_Data::IsLandscapeOrientation())
  6215         EAlfAnchorOriginLeft, EAlfAnchorOriginTop,
  6156         {
  6216         EAlfAnchorMetricAbsolute, EAlfAnchorMetricAbsolute,
  6157         iScreenAnchorLayout->SetAnchor(EAlfAnchorBottomRight, 1,
  6217         TAlfTimedPoint(listRect.iBr.iX, listRect.iBr.iY));
  6158                 EAlfAnchorOriginLeft, EAlfAnchorOriginTop,
  6218     // </cmail> Platform layout changes
  6159                 EAlfAnchorMetricRelativeToSize, EAlfAnchorMetricAbsolute,
       
  6160                 TAlfTimedPoint(1, listRect.iBr.iY));
       
  6161         }
       
  6162     else
       
  6163         {
       
  6164         iScreenAnchorLayout->SetAnchor(EAlfAnchorBottomRight, 1,
       
  6165                 EAlfAnchorOriginLeft, EAlfAnchorOriginTop,
       
  6166                 EAlfAnchorMetricAbsolute, EAlfAnchorMetricAbsolute,
       
  6167                 TAlfTimedPoint(listRect.iBr.iX, listRect.iBr.iY));    
       
  6168         }
       
  6169 
  6219 
  6170  	// Set anchors for connection icon
  6220  	// Set anchors for connection icon
       
  6221 
       
  6222     // <cmail> Platform layout changes
  6171     TRect connectionIconRect( iAppUi.LayoutHandler()->GetControlBarConnectionIconRect() );
  6223     TRect connectionIconRect( iAppUi.LayoutHandler()->GetControlBarConnectionIconRect() );
  6172     const TPoint& tl( connectionIconRect.iTl );
  6224     const TPoint& tl( connectionIconRect.iTl );
  6173  	iScreenAnchorLayout->SetAnchor(EAlfAnchorTopLeft, 2,
  6225  	iScreenAnchorLayout->SetAnchor(EAlfAnchorTopLeft, 2,
  6174         EAlfAnchorOriginLeft, EAlfAnchorOriginTop,
  6226         EAlfAnchorOriginLeft, EAlfAnchorOriginTop,
  6175         EAlfAnchorMetricAbsolute, EAlfAnchorMetricAbsolute,
  6227         EAlfAnchorMetricAbsolute, EAlfAnchorMetricAbsolute,
  6177     const TPoint& br( connectionIconRect.iBr );
  6229     const TPoint& br( connectionIconRect.iBr );
  6178     iScreenAnchorLayout->SetAnchor(EAlfAnchorBottomRight, 2,
  6230     iScreenAnchorLayout->SetAnchor(EAlfAnchorBottomRight, 2,
  6179         EAlfAnchorOriginLeft, EAlfAnchorOriginTop,
  6231         EAlfAnchorOriginLeft, EAlfAnchorOriginTop,
  6180         EAlfAnchorMetricAbsolute, EAlfAnchorMetricAbsolute,
  6232         EAlfAnchorMetricAbsolute, EAlfAnchorMetricAbsolute,
  6181         TAlfTimedPoint( br.iX, br.iY ));
  6233         TAlfTimedPoint( br.iX, br.iY ));
       
  6234     // </cmail> Platform layout changes
  6182 
  6235 
  6183     iScreenAnchorLayout->UpdateChildrenLayout();
  6236     iScreenAnchorLayout->UpdateChildrenLayout();
  6184     }
  6237     }
  6185 
  6238 
  6186 // ---------------------------------------------------------------------------
  6239 // ---------------------------------------------------------------------------
  6315             TRAP_IGNORE( confirmedMsgPtr = iAppUi.GetMailClient()->GetMessageByUidL( iAppUi.GetActiveMailboxId(),
  6368             TRAP_IGNORE( confirmedMsgPtr = iAppUi.GetMailClient()->GetMessageByUidL( iAppUi.GetActiveMailboxId(),
  6316                                                                                      iMailFolder->GetFolderId(),
  6369                                                                                      iMailFolder->GetFolderId(),
  6317                                                                                      modelItem->MessagePtr().GetMessageId() ,
  6370                                                                                      modelItem->MessagePtr().GetMessageId() ,
  6318                                                                                      EFSMsgDataEnvelope ) );
  6371                                                                                      EFSMsgDataEnvelope ) );
  6319             if( aIndex < iTreeItemArray.Count() )
  6372             if( aIndex < iTreeItemArray.Count() )
  6320                 {
  6373             	{
  6321                 if ( confirmedMsgPtr )
  6374                 if ( confirmedMsgPtr )
  6322                     {
  6375                     {
  6323                     const SMailListItem& item = iTreeItemArray[aIndex];
  6376                     const SMailListItem& item = iTreeItemArray[aIndex];
  6324                     // Replace message pointer in model with newly fetched one
  6377                     // Replace message pointer in model with newly fetched one
  6325                     Model()->ReplaceMessagePtr( aIndex, confirmedMsgPtr );
  6378                     Model()->ReplaceMessagePtr( aIndex, confirmedMsgPtr );
  6698     FUNC_LOG;
  6751     FUNC_LOG;
  6699     TFSMailMsgId folderId = FolderId();
  6752     TFSMailMsgId folderId = FolderId();
  6700     TFSMailMsgId mailBox = iAppUi.GetActiveMailboxId();
  6753     TFSMailMsgId mailBox = iAppUi.GetActiveMailboxId();
  6701     RArray<TFSMailMsgId> msgIds;
  6754     RArray<TFSMailMsgId> msgIds;
  6702     CleanupClosePushL( msgIds );
  6755     CleanupClosePushL( msgIds );
  6703     for ( TInt i = aEntries.Count() - 1; i >= 0; i-- )
  6756     for ( TInt i = 0; i < aEntries.Count(); i++ )
  6704         {
  6757         {
  6705         msgIds.AppendL( MsgIdFromListId( aEntries[i] ) );
  6758         msgIds.AppendL( MsgIdFromListId( aEntries[i] ) );
  6706         }
  6759         }
  6707 
       
  6708     // Clear the focused item to avoid repeated selection of a new focused
       
  6709     // item, unnecessary scrolling of the viewport, etc.
       
  6710     iMailTreeListVisualizer->SetFocusedItemL( KFsTreeNoneID );
       
  6711 
       
  6712     iMailList->BeginUpdate();
       
  6713     iAppUi.GetMailClient()->DeleteMessagesByUidL( mailBox, folderId, msgIds );
  6760     iAppUi.GetMailClient()->DeleteMessagesByUidL( mailBox, folderId, msgIds );
  6714     // Remove from mail list if not already removed by mailbox events
  6761     // Remove from mail list if not already removed by mailbox events
  6715     RemoveMsgItemsFromListIfFoundL( msgIds );
  6762     RemoveMsgItemsFromListIfFoundL( msgIds );
  6716     iMailList->EndUpdateL();
       
  6717 
       
  6718     CleanupStack::PopAndDestroy(); // msgIds.Close()
  6763     CleanupStack::PopAndDestroy(); // msgIds.Close()
  6719     }
  6764     }
  6720 
  6765 
  6721 // ---------------------------------------------------------------------------
  6766 // ---------------------------------------------------------------------------
  6722 // ConfirmDeleteL
  6767 // ConfirmDeleteL
  7078 		{
  7123 		{
  7079 		iMoveToFolderOngoing = EFalse;
  7124 		iMoveToFolderOngoing = EFalse;
  7080 		switch ( aResponse )
  7125 		switch ( aResponse )
  7081 			{
  7126 			{
  7082 			case EFSEmailUiCtrlBarResponseCancel:
  7127 			case EFSEmailUiCtrlBarResponseCancel:
       
  7128 			    if ( iMarkingMode )
       
  7129 			        {
       
  7130                     DisplayMarkingModeTitleTextL();
       
  7131 			        }
  7083 			    iMarkingModeWaitingToExit = EFalse;
  7132 			    iMarkingModeWaitingToExit = EFalse;
  7084 			    SetMskL();
  7133 			    SetMskL();
  7085 				return;
  7134 				return;
  7086 			case EFSEmailUiCtrlBarResponseSelect:
  7135 			case EFSEmailUiCtrlBarResponseSelect:
  7087 			    {
  7136 			    {
  7121 				}
  7170 				}
  7122 				return;
  7171 				return;
  7123 			case EFSEmailUiCtrlBarResponseCancel:
  7172 			case EFSEmailUiCtrlBarResponseCancel:
  7124 			    iMarkingModeWaitingToExit = EFalse;
  7173 			    iMarkingModeWaitingToExit = EFalse;
  7125 			    SetMskL();
  7174 			    SetMskL();
       
  7175 			    // <cmail> Touch
  7126                 //Set touchmanager back to active
  7176                 //Set touchmanager back to active
  7127                 DisableMailList(EFalse);
  7177                 DisableMailList(EFalse);
       
  7178                 // </cmail>
  7128 				return;
  7179 				return;
  7129 			case EFSEmailUiCtrlBarResponseSelect:
  7180 			case EFSEmailUiCtrlBarResponseSelect:
  7130 			    SetMskL();
  7181 			    SetMskL();
       
  7182 			    // <cmail> Touch
  7131                 //Set touchmanager back to active
  7183                 //Set touchmanager back to active
  7132                 DisableMailList(EFalse);
  7184                 DisableMailList(EFalse);
       
  7185                 // </cmail>
  7133 			default:
  7186 			default:
  7134 				break;
  7187 				break;
  7135 			}
  7188 			}
  7136 
  7189 
  7137 		if ( !iMailFolder || ( iMailFolder && iMailFolder->GetFolderId() != aSelectedFolderId ) )
  7190 		if ( !iMailFolder || ( iMailFolder && iMailFolder->GetFolderId() != aSelectedFolderId ) )
  7146                 {
  7199                 {
  7147                 // Do nothing if can't get the folder object
  7200                 // Do nothing if can't get the folder object
  7148                 return;
  7201                 return;
  7149                 }
  7202                 }
  7150 
  7203 
  7151             UpdateFolderAndMarkingModeTextsL();
  7204             // Set new text to folder button in control bar
       
  7205             HBufC* newFolderName = CreateFolderNameLC( iMailFolder );
       
  7206             iFolderListButton->SetTextL( *newFolderName );
       
  7207             CleanupStack::PopAndDestroy( newFolderName );
  7152 
  7208 
  7153             // Set initial sort criteria when folder has changed
  7209             // Set initial sort criteria when folder has changed
  7154             iCurrentSortCriteria.iField = EFSMailSortByDate;
  7210             iCurrentSortCriteria.iField = EFSMailSortByDate;
  7155             iCurrentSortCriteria.iOrder = EFSMailDescending;
  7211             iCurrentSortCriteria.iOrder = EFSMailDescending;
  7156             // reload node state because in file sort mode this is disabled even when globally enabled
  7212             // reload node state because in file sort mode this is disabled even when globally enabled
  7157             iNodesInUse = iAppUi.GetCRHandler()->TitleDividers();
  7213             iNodesInUse = iAppUi.GetCRHandler()->TitleDividers();
  7158             SetSortButtonIconL();
  7214             SetSortButtonTextAndIconL();
  7159 
  7215 
  7160             // Update the mail list contents
  7216             // Update the mail list contents
  7161             UpdateMailListModelL();
  7217             UpdateMailListModelL();
  7162             RefreshL();
  7218             RefreshL();
  7163 		    }
  7219 		    }
  7187 	// Set initial sort criteria when folder has changed
  7243 	// Set initial sort criteria when folder has changed
  7188     iCurrentSortCriteria.iField = EFSMailSortByDate;
  7244     iCurrentSortCriteria.iField = EFSMailSortByDate;
  7189     iCurrentSortCriteria.iOrder = EFSMailDescending;
  7245     iCurrentSortCriteria.iOrder = EFSMailDescending;
  7190     // reload node state because in file sort mode this is disabled even when globally enabled
  7246     // reload node state because in file sort mode this is disabled even when globally enabled
  7191     iNodesInUse = iAppUi.GetCRHandler()->TitleDividers();
  7247     iNodesInUse = iAppUi.GetCRHandler()->TitleDividers();
  7192     SetSortButtonIconL();
  7248     SetSortButtonTextAndIconL();
  7193 
  7249 
  7194     // Set folder name to the control bar button
  7250     // Set folder name to the control bar button
  7195     UpdateFolderAndMarkingModeTextsL();
  7251     HBufC* newFolderName = CreateFolderNameLC( iMailFolder );
       
  7252     iFolderListButton->SetTextL( *newFolderName );
       
  7253     CleanupStack::PopAndDestroy( newFolderName );
  7196 
  7254 
  7197     // Set mailbox name and icons
  7255     // Set mailbox name and icons
  7198     SetMailboxNameToStatusPaneL();
  7256     SetMailboxNameToStatusPaneL();
  7199     SetBrandedListWatermarkL();
  7257     SetBrandedListWatermarkL();
  7200     SetBrandedMailBoxIconL();
  7258     SetBrandedMailBoxIconL();
  7286 		}
  7344 		}
  7287 
  7345 
  7288 	iCurrentSortCriteria.iField = aSortField;
  7346 	iCurrentSortCriteria.iField = aSortField;
  7289 	iModel->SetSortCriteria(iCurrentSortCriteria);
  7347 	iModel->SetSortCriteria(iCurrentSortCriteria);
  7290 
  7348 
  7291 	// rest of the code moved to TimerEventL ( iSortTimer part )
  7349         // rest of the code moved to TimerEventL ( iSortTimer part )
  7292 	// used also in DoHandleControlBarOpenL to prevent SortList reopening
  7350 	// used also in DoHandleControlBarOpenL to prevent SortList reopening
  7293 	iSortState = ESortRequested; 
  7351 	iSortState = ESortRequested; 
  7294 	iSortTimer->Start( KSortTimerDelay );	
  7352 	iSortTimer->Start( KSortTimerDelay );	
  7295 	}
  7353 	}
  7296 
  7354 
  7686 						if ( !inboxId.IsNullId() )
  7744 						if ( !inboxId.IsNullId() )
  7687 						    {
  7745 						    {
  7688 						    iMailFolder = iAppUi.GetMailClient()->GetFolderByUidL( aMailboxId, inboxId );
  7746 						    iMailFolder = iAppUi.GetMailClient()->GetFolderByUidL( aMailboxId, inboxId );
  7689 						    UpdateMailListModelL();
  7747 						    UpdateMailListModelL();
  7690 					        RefreshL();
  7748 					        RefreshL();
  7691 						    UpdateFolderAndMarkingModeTextsL();
  7749 							HBufC* newFolderName = CreateFolderNameLC( iMailFolder );
       
  7750 						    iFolderListButton->SetTextL( *newFolderName );
       
  7751 							CleanupStack::PopAndDestroy( newFolderName );
  7692 						    }
  7752 						    }
  7693 						else
  7753 						else
  7694 							{
  7754 							{
  7695 							// No standard folder inbox, go back to grid as a last option
  7755 							// No standard folder inbox, go back to grid as a last option
  7696 							HandleCommandL( EAknSoftkeyBack );
  7756 							HandleCommandL( EAknSoftkeyBack );
  7741 				    {
  7801 				    {
  7742 				    iMailFolder = iAppUi.GetMailClient()->GetFolderByUidL( aMailboxId, inboxId );
  7802 				    iMailFolder = iAppUi.GetMailClient()->GetFolderByUidL( aMailboxId, inboxId );
  7743 				    // Check that mailfolder fetching succeeded
  7803 				    // Check that mailfolder fetching succeeded
  7744 				    if ( iMailFolder )
  7804 				    if ( iMailFolder )
  7745 				    	{
  7805 				    	{
  7746 					    UpdateFolderAndMarkingModeTextsL();
  7806 						HBufC* newFolderName = CreateFolderNameLC( iMailFolder );
       
  7807 					    iFolderListButton->SetTextL( *newFolderName );
       
  7808 						CleanupStack::PopAndDestroy( newFolderName );
  7747 				    	}
  7809 				    	}
  7748 				    }
  7810 				    }
  7749 				}
  7811 				}
  7750 			// Null pointer check is needed here because of special cases such as new mail
  7812 			// Null pointer check is needed here because of special cases such as new mail
  7751 			// creation in POP/IMAP before first sync where folder does not exists
  7813 			// creation in POP/IMAP before first sync where folder does not exists
  8411             }
  8473             }
  8412         }
  8474         }
  8413     return manualSync;
  8475     return manualSync;
  8414     }
  8476     }
  8415 
  8477 
  8416 
       
  8417 void CFSEmailUiMailListVisualiser::UpdateFolderAndMarkingModeTextsL()
       
  8418     {
       
  8419     if ( iAppUi.CurrentActiveView()->Id() == MailListId )
       
  8420         {
       
  8421         HBufC* folder = CreateFolderNameLC( iMailFolder );
       
  8422         if( Layout_Meta_Data::IsLandscapeOrientation() )
       
  8423             {
       
  8424             iFolderListButton->SetTextL( KNullDesC );
       
  8425             if (iMarkingMode)
       
  8426                 {
       
  8427                 RemoveMarkingModeTextOnButtonsL();
       
  8428                 HBufC* txt = StringLoader::LoadLC( R_FREESTYLE_EMAIL_UI_MARKINGMODE );
       
  8429                 iAppUi.SetNaviPaneTextL( *txt );
       
  8430                 CleanupStack::PopAndDestroy( txt );
       
  8431                 }
       
  8432             else
       
  8433                 {
       
  8434                 iAppUi.SetNaviPaneTextL( *folder );
       
  8435                 }
       
  8436             }
       
  8437         else // Portrait orientation
       
  8438             {
       
  8439             iAppUi.SetNaviPaneTextL( KNullDesC );        
       
  8440             if (iMarkingMode)
       
  8441                 {
       
  8442                 DisplayMarkingModeTextOnButtonsL();
       
  8443                 }
       
  8444             else
       
  8445                 {
       
  8446                 RemoveMarkingModeTextOnButtonsL();
       
  8447                 iFolderListButton->SetTextL( *folder );
       
  8448                 }        
       
  8449             }
       
  8450         CleanupStack::PopAndDestroy( folder );
       
  8451         }
       
  8452     else
       
  8453         {
       
  8454         iAppUi.SetNaviPaneTextL( KNullDesC );
       
  8455         RemoveMarkingModeTextOnButtonsL();
       
  8456         }
       
  8457     }
       
  8458 
       
  8459 //////////////////////////////////////////////////////////////////
  8478 //////////////////////////////////////////////////////////////////
  8460 // Class implementation CMailListUpdater
  8479 // Class implementation CMailListUpdater
  8461 ///////////////////////////////////////////////////////////////////
  8480 ///////////////////////////////////////////////////////////////////
  8462 
  8481 
  8463 
  8482