emailuis/emailui/src/FreestyleEmailUiFolderListVisualiser.cpp
changeset 0 8466d47a6819
child 1 12c456ceeff2
equal deleted inserted replaced
-1:000000000000 0:8466d47a6819
       
     1 /*
       
     2 * Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  FreestyleEmailUi folder list view implementation
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // SYSTEM INCLUDES
       
    20 #include "emailtrace.h"
       
    21 #include <AknUtils.h>
       
    22 #include <StringLoader.h>
       
    23 #include <AknBidiTextUtils.h>
       
    24 #include <gulicon.h>
       
    25 #include <aknlayoutscalable_apps.cdl.h>
       
    26 #include <aknlayoutscalable_avkon.cdl.h>
       
    27 #include <layoutmetadata.cdl.h>
       
    28 #include <AknStatuspaneUtils.h>
       
    29 #include <akntoolbar.h>
       
    30 #include <eikcolib.h>
       
    31 #include <alf/alfdecklayout.h>
       
    32 #include <alf/alftextvisual.h>
       
    33 #include <alf/alfcontrolgroup.h>
       
    34 #include <alf/alfbrusharray.h>
       
    35 #include <alf/alfevent.h>
       
    36 #include <alf/alfframebrush.h>
       
    37 #include <alf/alfstatic.h>
       
    38 
       
    39 // GENERIC LIST COMPONENT INCLUDES
       
    40 #include "fstreelist.h"
       
    41 #include "fstreevisualizerbase.h"
       
    42 #include "fstreeplainonelineitemdata.h"
       
    43 #include "fstreeplainonelineitemvisualizer.h"
       
    44 #include "fstreeplaintwolineitemdata.h"
       
    45 #include "fstreeplaintwolineitemvisualizer.h"
       
    46 #include "fstreeplainonelinenodedata.h"
       
    47 #include "fstreeplainonelinenodevisualizer.h"
       
    48 #include "fscontrolbuttoninterface.h"
       
    49 #include "fsseparatordata.h"
       
    50 #include "fsseparatorvisualizer.h"
       
    51 
       
    52 // FREESTYLE EMAIL FRAMEWORK INCLUDES
       
    53 #include "CFSMailCommon.h"
       
    54 #include "CFSMailClient.h"
       
    55 #include "CFSMailBox.h"
       
    56 #include "CFSMailFolder.h"
       
    57 #include <csxhelp/cmail.hlp.hrh>
       
    58 #include <featmgr.h>
       
    59 
       
    60 // INTERNAL INCLUDES
       
    61 #include <freestyleemailui.mbg>
       
    62 #include <FreestyleEmailUi.rsg>
       
    63 
       
    64 #include "FreestyleEmailUiAppui.h"
       
    65 #include "FreestyleEmailUiFolderListControl.h"
       
    66 #include "FreestyleEmailUiFolderListModel.h"
       
    67 #include "FreestyleEmailUiFolderListVisualiser.h"
       
    68 #include "FreestyleEmailUi.hrh"
       
    69 #include "FreestyleEmailUiLayoutHandler.h"
       
    70 #include "FreestyleEmailUiTextureManager.h"
       
    71 #include "FreestyleEmailUiControlBarCallback.h"
       
    72 #include "FreestyleEmailUiUtilities.h"
       
    73 #include "FreestyleEmailUiLayoutData.h"
       
    74 #include "FreestyleEmailUiShortcutBinding.h"
       
    75 #include "ESMailSettingsPlugin.h"
       
    76 #include "FreestyleEmailUiStatusIndicator.h"
       
    77 
       
    78 // REMOVE WHEN DONE TESTING:
       
    79 //#include "CSimpleAOTest.h"
       
    80 
       
    81 // Defines the order of the folders in UI
       
    82 enum TFSEmailUiFolderListPriorities
       
    83 	{
       
    84     EFolderListPriorityInbox = 1,
       
    85     EFolderListPriorityDrafts,
       
    86     EFolderListPrioritySent,
       
    87     EFolderListPriorityOutbox,
       
    88     EFolderListPriorityDeleted,
       
    89     EFolderListPriorityOtherFolder
       
    90 	};
       
    91 
       
    92 // Defines the order of the list icons in the icon array
       
    93 enum TFsEmailUiFolderListIcons
       
    94 	{
       
    95     EFolderListIconInbox = 0,
       
    96     EFolderListIconInboxSubfolders,
       
    97     EFolderListIconOutbox,
       
    98     EFolderListIconDrafts,
       
    99     EFolderListIconSent,
       
   100     EFolderListIconDeleted,
       
   101     EFolderListIconServerFolders,
       
   102 	EFolderListIconMoreFolders,
       
   103     EFolderListIconEmailAccount
       
   104 	};
       
   105 
       
   106 // List level for the root folders
       
   107 static const TInt KListRootLevel( 1 );
       
   108 // List supports three levels, so basically root folder + two levels of subfolders
       
   109 static const TInt KListLastBasicLevel( KListRootLevel + 2 );
       
   110 
       
   111 // Constants for drawing header text
       
   112 const TReal KFSHeaderTextBackgroundOpacity = 0.3f;
       
   113 const TAlfTimedValue KFSVisible( 1 );
       
   114 const TAlfTimedValue KFSInvisible( 0 );
       
   115 // Considering that there are 99999 unread emails + ( + ) + SPACE size should be 5+1+1+1 =8
       
   116 static const TInt KFmtUnRdCntMaxLength( 8 );
       
   117 _LIT(KFormatUnreadCnt, " (%d)");
       
   118 
       
   119 // ---------------------------------------------------------------------------
       
   120 // NewL
       
   121 // ---------------------------------------------------------------------------
       
   122 //
       
   123 CFSEmailUiFolderListVisualiser* CFSEmailUiFolderListVisualiser::NewL( CAlfEnv& aEnv,
       
   124                                                  CAlfControlGroup& aControlGroup,
       
   125                                                  CFreestyleEmailUiAppUi& aAppUi )
       
   126     {
       
   127     FUNC_LOG;
       
   128     CFSEmailUiFolderListVisualiser* self = CFSEmailUiFolderListVisualiser::NewLC(aEnv, aControlGroup, aAppUi );
       
   129     CleanupStack::Pop(self);
       
   130     return self;
       
   131     }
       
   132 
       
   133 // ---------------------------------------------------------------------------
       
   134 // NewLC
       
   135 // ---------------------------------------------------------------------------
       
   136 //
       
   137 CFSEmailUiFolderListVisualiser* CFSEmailUiFolderListVisualiser::NewLC( CAlfEnv& aEnv,
       
   138                                                  CAlfControlGroup& aControlGroup,
       
   139                                                  CFreestyleEmailUiAppUi& aAppUi )
       
   140 	{
       
   141     FUNC_LOG;
       
   142     CFSEmailUiFolderListVisualiser* self = new (ELeave) CFSEmailUiFolderListVisualiser( aEnv, aAppUi, aControlGroup );
       
   143     CleanupStack::PushL(self);
       
   144     self->ConstructL();
       
   145     return self;
       
   146 	}
       
   147 
       
   148 // ---------------------------------------------------------------------------
       
   149 // Constructor
       
   150 // ---------------------------------------------------------------------------
       
   151 //
       
   152 CFSEmailUiFolderListVisualiser::CFSEmailUiFolderListVisualiser( CAlfEnv& aEnv, 
       
   153                                                                 CFreestyleEmailUiAppUi& aAppUi, 
       
   154                                                                 CAlfControlGroup& aControlGroup )
       
   155     : CFsEmailUiViewBase( aControlGroup, aAppUi ),
       
   156       iEnv( aEnv ),
       
   157       iFullScreen( ETrue ),
       
   158       iPreviousListLevel( KListRootLevel ),
       
   159       iMoveOrCopyInitiated(EFalse),
       
   160       iWaitingToGoOnline(EFalse),
       
   161       iNoConnectNeeded(ETrue)
       
   162 	{
       
   163     FUNC_LOG;
       
   164 	}
       
   165 	
       
   166 // ---------------------------------------------------------------------------
       
   167 // Destructor
       
   168 // ---------------------------------------------------------------------------
       
   169 //
       
   170 CFSEmailUiFolderListVisualiser::~CFSEmailUiFolderListVisualiser()
       
   171 	{
       
   172     FUNC_LOG;
       
   173 	delete iModel;
       
   174 	iModel = NULL;
       
   175 
       
   176 	delete iBackgroundBrush;
       
   177 	iBackgroundBrush = NULL;
       
   178 
       
   179 	// No need for ResetAndDestroy because list items are owned by generic list
       
   180 	iListItemVisulizers.Close();
       
   181 	
       
   182     //delete iNotifierTest;
       
   183     
       
   184     delete iTreeList;
       
   185     iTreeList = NULL;
       
   186     
       
   187     iIconArray.Close();
       
   188     
       
   189     if ( iAsyncCallback )
       
   190         {
       
   191         iAsyncCallback->Cancel();
       
   192         delete iAsyncCallback;
       
   193         }
       
   194 
       
   195     iListItemDatas.Close();
       
   196 	}
       
   197 
       
   198 // ---------------------------------------------------------------------------
       
   199 // Second phase constructor
       
   200 // ---------------------------------------------------------------------------
       
   201 //
       
   202 void CFSEmailUiFolderListVisualiser::ConstructL()
       
   203 	{
       
   204     FUNC_LOG;
       
   205 
       
   206     BaseConstructL( R_FSEMAILUI_FOLDER_LIST_VIEW );
       
   207     iFirstStartCompleted = EFalse;
       
   208 	}
       
   209 
       
   210 // ---------------------------------------------------------------------------
       
   211 // CFSEmailUiFolderListVisualiser::DoFirstStartL
       
   212 // Purpose of this function is to do first start things only when list is
       
   213 // really needed to be shown. Implemented to make app startuo faster.
       
   214 // ---------------------------------------------------------------------------
       
   215 //
       
   216 void CFSEmailUiFolderListVisualiser::DoFirstStartL()
       
   217     {
       
   218     FUNC_LOG;
       
   219     iControl = CFSEmailUiFolderListControl::NewL( iEnv, *this );
       
   220     iModel = new (ELeave) CFSEmailUiFolderListModel();
       
   221      
       
   222     UpdateListSizeAttributes();
       
   223     //LoadIconsL();
       
   224    
       
   225     TRect mainPaneRect;
       
   226     AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, mainPaneRect);
       
   227     iFaderLayout = CAlfDeckLayout::AddNewL( *iControl );
       
   228     iFaderLayout->SetRect( mainPaneRect );
       
   229     
       
   230     iParentLayout = CAlfAnchorLayout::AddNewL( *iControl );
       
   231     iParentLayout->SetRect( iScreenRect );
       
   232     iParentLayout->SetFlags( EAlfVisualFlagManualLayout );
       
   233     
       
   234     iParentLayout->EnableBrushesL();
       
   235     SetAnchors();
       
   236 
       
   237     iFaderVisual = CAlfImageVisual::AddNewL( *iControl, iParentLayout );
       
   238 
       
   239     iHeaderLayout = CAlfDeckLayout::AddNewL( *iControl, iParentLayout );
       
   240     iHeaderLayout->SetFlags( EAlfVisualFlagAutomaticLocaleMirroringEnabled );
       
   241      
       
   242     iHeaderTextVisual = CAlfTextVisual::AddNewL( *iControl, iHeaderLayout );
       
   243     iHeaderTextVisual->SetWrapping( CAlfTextVisual::ELineWrapTruncate );
       
   244     iHeaderTextVisual->SetTextL( KNullDesC );
       
   245      
       
   246     TRgb headerTextColor( KRgbBlack );
       
   247     AknsUtils::GetCachedColor( AknsUtils::SkinInstance(), 
       
   248                                headerTextColor, KAknsIIDFsTextColors, EAknsCIFsTextColorsCG10 );
       
   249     iHeaderTextVisual->SetColor( headerTextColor );
       
   250     iHeaderTextVisual->SetTextStyle( iAppUi.LayoutHandler()->
       
   251         FSTextStyleFromLayoutL( AknLayoutScalable_Apps::main_sp_fs_ctrlbar_pane_t1( 0 ) ).Id() );
       
   252 
       
   253     if ( AknLayoutUtils::LayoutMirrored() )
       
   254         {
       
   255         iHeaderTextVisual->SetAlign( EAlfAlignHRight, EAlfAlignVCenter );
       
   256         }
       
   257     else
       
   258         {
       
   259         iHeaderTextVisual->SetAlign( EAlfAlignHLeft, EAlfAlignVCenter );
       
   260         }
       
   261 
       
   262 	iHeaderTextVisual->SetOpacity( KFSInvisible );
       
   263 	iHeaderLayout->SetOpacity( KFSInvisible );
       
   264 	
       
   265     iListLayout = CAlfDeckLayout::AddNewL( *iControl, iParentLayout );
       
   266     iListLayout->SetFlags(EAlfVisualFlagLayoutUpdateNotification|EAlfVisualFlagAutomaticLocaleMirroringEnabled);
       
   267 
       
   268     iTreeVisualizer = CFsTreeVisualizerBase::NewL(iControl, *iListLayout);
       
   269     iTreeVisualizer->SetItemExpansionDelay( iAppUi.LayoutHandler()->ListItemExpansionDelay() );
       
   270     iTreeVisualizer->SetScrollTime( iAppUi.LayoutHandler()->ListScrollingTime() );
       
   271     iTreeVisualizer->SetFadeInEffectTime( iAppUi.LayoutHandler()->CtrlBarListFadeEffectTime() );
       
   272     iTreeVisualizer->SetFadeOutEffectTime( iAppUi.LayoutHandler()->CtrlBarListFadeEffectTime() );
       
   273     iTreeVisualizer->SetItemSeparatorSize( TSize(0, 0) );
       
   274     iTreeVisualizer->SetExpandCollapseAllOnLongTap( EFalse );
       
   275      
       
   276     iTreeList = CFsTreeList::NewL( *iTreeVisualizer, iEnv );
       
   277     
       
   278     // Compared to S60 3.2.3 in S60 5.0 Alf offers the key events in
       
   279     // opposite order.
       
   280     ControlGroup().AppendL( iControl );
       
   281     ControlGroup().AppendL( iTreeList->TreeControl() ); 
       
   282     
       
   283     iTreeList->AddObserverL(*this);
       
   284 
       
   285     iTreeList->SetLoopingType( EFsTreeListLoopingJumpToFirstLast );
       
   286     iTreeList->SetScrollbarVisibilityL( EFsScrollbarAuto );
       
   287     iAppUi.LayoutHandler()->SetListMarqueeBehaviour( iTreeList );
       
   288     iTreeList->HideListL();
       
   289 
       
   290     // Set page up and page down keys
       
   291     iTreeVisualizer->AddCustomPageUpKey( EStdKeyPageUp );
       
   292     iTreeVisualizer->AddCustomPageDownKey( EStdKeyPageDown );
       
   293     iTreeVisualizer->SetIndentationL(
       
   294             iAppUi.LayoutHandler()->FolderListIndentation(iScreenRect) );
       
   295 
       
   296     iTreeVisualizer->SetSelectorPropertiesL(
       
   297             iAppUi.FsTextureManager()->NewListSelectorBrushL(), 1.0,
       
   298             CFsTreeVisualizerBase::EFsSelectorMoveSmoothly );
       
   299     
       
   300     iAsyncCallback = new (ELeave) CAsyncCallBack( CActive::EPriorityStandard );
       
   301     
       
   302     //iNotifierTest = CSimpleAOTest::NewL();
       
   303     iFirstStartCompleted = ETrue;
       
   304     }
       
   305 
       
   306 
       
   307 // ---------------------------------------------------------------------------
       
   308 // CFSEmailUiFolderListVisualiser::Id
       
   309 // ---------------------------------------------------------------------------
       
   310 //
       
   311 TUid CFSEmailUiFolderListVisualiser::Id() const
       
   312 	{
       
   313     FUNC_LOG;
       
   314 	return FolderListId;
       
   315 	}			   
       
   316 
       
   317 // ---------------------------------------------------------------------------
       
   318 // CFSEmailUiFolderListVisualiser::PrepareFolderListL
       
   319 // ---------------------------------------------------------------------------
       
   320 //
       
   321 void CFSEmailUiFolderListVisualiser::PrepareFolderListL()
       
   322     {
       
   323     FUNC_LOG;
       
   324     iTreeList->RemoveAllL();
       
   325     iListItemVisulizers.Reset();
       
   326     iModel->RemoveAll();
       
   327     iMoreFoldersItemId = KFsTreeNoneID;
       
   328 
       
   329     // SetRect need to be called twice for the parent layout (before and after
       
   330     // list construction), otherwise the layout is incorrect in some cases.
       
   331     UpdateListSizeAttributes();
       
   332     iParentLayout->SetRect( iScreenRect );
       
   333     SetAnchors();
       
   334     ResizeListIcons();
       
   335 
       
   336     // Show empty screen when offline
       
   337     CEikButtonGroupContainer* cba = CEikButtonGroupContainer::Current();
       
   338             
       
   339     if( iModel->Count() == 0 )
       
   340         {
       
   341         cba->SetCommandSetL( R_FREESTYLE_EMAUIL_UI_SK_OPTIONS_BACK );
       
   342         }
       
   343         
       
   344     if( iMoveOrCopyInitiated )
       
   345         {
       
   346         iTreeVisualizer->SetEmptyListTextL( KNullDesC );    
       
   347         iTreeVisualizer->RefreshListViewL();    
       
   348         }
       
   349 	}
       
   350 
       
   351 // ---------------------------------------------------------------------------
       
   352 // CFSEmailUiFolderListVisualiser::PopulateFolderListL
       
   353 // ---------------------------------------------------------------------------
       
   354 //
       
   355 void CFSEmailUiFolderListVisualiser::PopulateFolderListL()
       
   356     {
       
   357     FUNC_LOG;
       
   358     if ( !iFullScreen && iSortListCallback )
       
   359         {
       
   360         UpdateSortListL();
       
   361         SetFocusToCurrentSortItemL();
       
   362         }
       
   363   	else
       
   364         {
       
   365         UpdateFolderListL();
       
   366         if( !iFullScreen )
       
   367             {
       
   368             SetFocusToCurrentFolderL();
       
   369             }
       
   370         }
       
   371 
       
   372     if( !iFullScreen )
       
   373         {
       
   374         AdaptScreenRectToListContent();
       
   375         }
       
   376 
       
   377   	iParentLayout->SetRect(iScreenRect);
       
   378 
       
   379     CEikButtonGroupContainer* cba = CEikButtonGroupContainer::Current();
       
   380     
       
   381   	if( iModel->Count() > 0 )
       
   382   	    {
       
   383         cba->SetCommandSetL( R_FREESTYLE_EMAUIL_UI_SK_OPTIONS_BACK__SELECT );
       
   384   	    }
       
   385   	    
       
   386     if( iMoveOrCopyInitiated )
       
   387         {
       
   388         HBufC* emptyListText = StringLoader::LoadLC( 
       
   389                R_FREESTYLE_EMAIL_UI_FOLDER_LIST_NO_FOLDERS_AVAILABLE );
       
   390         iTreeVisualizer->SetEmptyListTextL( *emptyListText );
       
   391         CleanupStack::PopAndDestroy( emptyListText );
       
   392     
       
   393         iTreeVisualizer->RefreshListViewL();
       
   394         }
       
   395 	}
       
   396 
       
   397 // ---------------------------------------------------------------------------
       
   398 // CFSEmailUiFolderListVisualiser::PopulateFolderListDeferred
       
   399 // ---------------------------------------------------------------------------
       
   400 //
       
   401 void CFSEmailUiFolderListVisualiser::PopulateFolderListDeferred()
       
   402     {
       
   403     FUNC_LOG;
       
   404     if ( iAsyncCallback )
       
   405         {
       
   406         iAsyncCallback->Cancel();
       
   407         iAsyncCallback->Set( TCallBack( DoPopulateFolderList, this ) );
       
   408         iAsyncCallback->CallBack();
       
   409         }
       
   410     }
       
   411 
       
   412 // ---------------------------------------------------------------------------
       
   413 // CFSEmailUiFolderListVisualiser::DoPopulateFolderList
       
   414 // ---------------------------------------------------------------------------
       
   415 //
       
   416 TInt CFSEmailUiFolderListVisualiser::DoPopulateFolderList( TAny* aSelfPtr )
       
   417     {
       
   418     FUNC_LOG;
       
   419     CFSEmailUiFolderListVisualiser* self =
       
   420         static_cast< CFSEmailUiFolderListVisualiser* >( aSelfPtr );
       
   421     TRAPD( err, 
       
   422         self->PopulateFolderListL();
       
   423         if ( self->iCustomMessageId == KFolderListMoveMessage ||
       
   424              self->iCustomMessageId == KFolderListMoveMessages ||
       
   425              self->iCustomMessageId == KFolderListCopyMessage ||
       
   426              self->iCustomMessageId == KFolderListCopyMessages )
       
   427             {
       
   428             self->SetFocusToLatestMovedFolderL();
       
   429             }
       
   430         self->iTreeList->SetFocusedL( ETrue );
       
   431         );
       
   432     return err;
       
   433     }
       
   434 
       
   435 // ---------------------------------------------------------------------------
       
   436 // CFSEmailUiFolderListVisualiser::IsPopupShown
       
   437 // ---------------------------------------------------------------------------
       
   438 //
       
   439 TBool CFSEmailUiFolderListVisualiser::IsPopupShown()
       
   440     {
       
   441     return iPopupListShown;
       
   442     }
       
   443 
       
   444 // ---------------------------------------------------------------------------
       
   445 // CFSEmailUiFolderListVisualiser::HidePopupL
       
   446 // ---------------------------------------------------------------------------
       
   447 //
       
   448 void CFSEmailUiFolderListVisualiser::HidePopupL()
       
   449 	{
       
   450     FUNC_LOG;
       
   451     
       
   452     iParentLayout->SetRect( iCtrlButtonRect, iAppUi.LayoutHandler()->CtrlBarListFadeEffectTime() );
       
   453 
       
   454     TAlfTimedValue bgOpacity;
       
   455 
       
   456 	// Hiding delay was removed to get rid of flickering if changing between
       
   457 	// folderlist / sortlist popups. If delay is used in SetTarget,
       
   458 	// folderlistview would be quickly drawn as fullscreen after HideListL
       
   459 	// call, effecting ugly flickering
       
   460     bgOpacity.SetTarget( 0, 0 );
       
   461     iParentLayout->SetOpacity( bgOpacity );
       
   462 	iTreeList->HideListL();
       
   463 	iTreeList->DisableKineticScrolling( EFalse );
       
   464 	ClearPopupSoftkeys();
       
   465 	iPopupListShown = EFalse;
       
   466 	}
       
   467 
       
   468 // ---------------------------------------------------------------------------
       
   469 // CFSEmailUiFolderListVisualiser::SetPopupSoftkeysL
       
   470 // ---------------------------------------------------------------------------
       
   471 //
       
   472 void CFSEmailUiFolderListVisualiser::SetPopupSoftkeysL()
       
   473 	{
       
   474     FUNC_LOG;
       
   475     CEikButtonGroupContainer* cba = CEikButtonGroupContainer::Current();
       
   476     cba->AddCommandSetToStackL( R_AVKON_SOFTKEYS_SELECT_CANCEL__SELECT);
       
   477     cba->UpdateCommandObserverL( cba->PositionById( EAknSoftkeySelect ), *this );
       
   478     cba->UpdateCommandObserverL( cba->PositionById( EEikBidCancel ), *this );
       
   479     cba->DrawNow();
       
   480 	}
       
   481 
       
   482 // ---------------------------------------------------------------------------
       
   483 // CFSEmailUiFolderListVisualiser::ClearPopupSoftkeys
       
   484 // ---------------------------------------------------------------------------
       
   485 //
       
   486 void CFSEmailUiFolderListVisualiser::ClearPopupSoftkeys()
       
   487 	{
       
   488     FUNC_LOG;
       
   489     CEikButtonGroupContainer* cba = CEikButtonGroupContainer::Current();
       
   490 
       
   491     if (cba->UpdatedCommandObserverExists(CEikButtonGroupContainer::ELeftSoftkeyPosition))
       
   492         {
       
   493         cba->RemoveCommandObserver( cba->PositionById( EAknSoftkeySelect ) );
       
   494         }
       
   495     if (cba->UpdatedCommandObserverExists(CEikButtonGroupContainer::ERightSoftkeyPosition))
       
   496         {
       
   497         cba->RemoveCommandObserver( cba->PositionById( EEikBidCancel ) );
       
   498         }
       
   499     TInt pos = -1;
       
   500     if ((pos = cba->PositionById( EAknSoftkeySelect )) >= 0)
       
   501         {
       
   502         cba->RemoveCommandFromStack( pos, EAknSoftkeySelect );
       
   503         }
       
   504     if ((pos = cba->PositionById( EEikBidCancel )) >= 0)
       
   505         {
       
   506         cba->RemoveCommandFromStack( pos, EEikBidCancel );
       
   507         }
       
   508 	}
       
   509 
       
   510 // ---------------------------------------------------------------------------
       
   511 // CFSEmailUiFolderListVisualiser::DoShowInPopupL
       
   512 // ---------------------------------------------------------------------------
       
   513 //
       
   514 /*void CFSEmailUiFolderListVisualiser::DoShowInPopupL()*/
       
   515 void CFSEmailUiFolderListVisualiser::DoShowInPopupL(
       
   516         MFsControlButtonInterface* aButton,
       
   517         MFSEmailUiFolderListCallback* aFolderCallback,
       
   518         MFSEmailUiSortListCallback* aSortCallback )
       
   519 	{
       
   520     FUNC_LOG;
       
   521         
       
   522     if ( ( aFolderCallback == NULL && aSortCallback == NULL ) ||
       
   523             aButton == NULL )
       
   524         {
       
   525         return;
       
   526         }
       
   527     
       
   528     // In case of popup we are not moving or copying messages,
       
   529     // so there's no need to connect the mailbox
       
   530     iNoConnectNeeded = ETrue;
       
   531     
       
   532     iCallback = aFolderCallback;
       
   533     iSortListCallback = aSortCallback;
       
   534     const TPoint buttonPos( aButton->Pos().Target() );
       
   535     const TSize buttonSize( aButton->Size().Target().AsSize() );
       
   536 
       
   537     // TRect from where to start the transformation effect
       
   538     iCtrlButtonRect.SetRect( buttonPos, buttonSize );
       
   539 
       
   540     iFullScreen = EFalse;
       
   541 
       
   542     LoadIconsL();
       
   543     
       
   544     if ( !iFirstStartCompleted )
       
   545         {
       
   546         DoFirstStartL();
       
   547         }
       
   548 
       
   549 	// Make parent layout invisible to avoid any flashes in display
       
   550 	// during the construction of the list. Hide header also, not used.
       
   551 	TAlfTimedValue opacity;
       
   552 	opacity.SetValueNow( 0 );
       
   553 	iHeaderLayout->SetOpacity( opacity );
       
   554     iParentLayout->SetOpacity( opacity );
       
   555 
       
   556 	if( iListBgImageVisual )
       
   557 		{
       
   558 		iListBgImageVisual->SetOpacity( opacity );
       
   559 		}
       
   560 
       
   561 	PrepareFolderListL();
       
   562     PopulateFolderListL();
       
   563 
       
   564     const TInt paddingValue( 
       
   565             iAppUi.LayoutHandler()->DropDownMenuListPadding() );
       
   566     const TAlfMetric paddingMetric( paddingValue );
       
   567     iParentLayout->SetPadding( paddingMetric );
       
   568 
       
   569 	// Set list background
       
   570 	if ( !iBackgroundBrush )
       
   571 		{
       
   572 		iBackgroundBrush =
       
   573             CAlfFrameBrush::NewL( iEnv, KAknsIIDQsnFrPopup, 1, 1 );
       
   574         TRect outerRect( iScreenRect );
       
   575         outerRect.Shrink( paddingValue, paddingValue );
       
   576         iBackgroundBrush->SetFrameRectsL( outerRect, iScreenRect );
       
   577 		}
       
   578 
       
   579 	// Append brush if it's not yet appended. Currently this is our only
       
   580 	// brush so if brush count is more than zero, this brush is already
       
   581 	// appended. If other brush(es) are added later, this implementation
       
   582 	// need to be changed.
       
   583     if ( iParentLayout->Brushes()->Count() == 0 )
       
   584         {
       
   585     	// Keep the ownership of the brush to avoid unneeded object
       
   586     	// deletion / reconstruction
       
   587     	iParentLayout->Brushes()->AppendL( iBackgroundBrush, EAlfDoesNotHaveOwnership );
       
   588         }
       
   589 	
       
   590 	SetPopupSoftkeysL();
       
   591 	// SetRect need to be called also here, otherwise the list layout might
       
   592 	// be wrong in mirrored layout
       
   593     //iParentLayout->SetRect( iScreenRect );
       
   594     iParentLayout->SetRect( iCtrlButtonRect );
       
   595     
       
   596     opacity.SetValueNow( 1 );
       
   597     //opacity.SetTarget( 1, iAppUi.LayoutHandler()->CtrlBarListFadeEffectTime() );
       
   598     iParentLayout->SetOpacity( opacity );
       
   599     iParentLayout->SetRect( iScreenRect, iAppUi.LayoutHandler()->CtrlBarListFadeEffectTime() );
       
   600     iParentLayout->UpdateChildrenLayout();
       
   601     iTreeList->DisableKineticScrolling( ETrue );
       
   602     iTreeList->ShowListL( ETrue );
       
   603     iTreeList->SetFocusedL( ETrue );
       
   604     iPopupListShown = ETrue;
       
   605 	}
       
   606 
       
   607 // ---------------------------------------------------------------------------
       
   608 // CFSEmailUiFolderListVisualiser::ShowInPopupL
       
   609 // ---------------------------------------------------------------------------
       
   610 //
       
   611 void CFSEmailUiFolderListVisualiser::ShowInPopupL(
       
   612     const TFSMailMsgId aFolderId,
       
   613 	MFSEmailUiFolderListCallback* aCallback,
       
   614 	MFsControlButtonInterface* aButton )
       
   615 	{
       
   616     FUNC_LOG;
       
   617     iCustomMessageId = KFolderListSelectFolder;
       
   618     iCurrentFolderId = aFolderId;
       
   619     DoShowInPopupL( aButton, aCallback, NULL );
       
   620     }
       
   621 
       
   622 // ---------------------------------------------------------------------------
       
   623 // CFSEmailUiFolderListVisualiser::ShowSortListPopupL
       
   624 // ---------------------------------------------------------------------------
       
   625 //
       
   626 void CFSEmailUiFolderListVisualiser::ShowSortListPopupL(
       
   627     const TFSMailSortField aCurrentSortOrder,
       
   628 	const TFSFolderType aFolderType,
       
   629 	MFSEmailUiSortListCallback* aCallback,
       
   630 	MFsControlButtonInterface* aButton )
       
   631 	{
       
   632     FUNC_LOG;
       
   633     iCurrentSortOrder = aCurrentSortOrder;
       
   634     iCurrentFolderType = aFolderType;
       
   635     DoShowInPopupL( aButton, NULL, aCallback );
       
   636 	}
       
   637 
       
   638 // ---------------------------------------------------------------------------
       
   639 // Activate this view
       
   640 // ---------------------------------------------------------------------------
       
   641 //
       
   642 void CFSEmailUiFolderListVisualiser::ChildDoActivateL(const TVwsViewId& /*aPrevViewId*/,
       
   643 	                 TUid aCustomMessageId,
       
   644 	                 const TDesC8& aCustomMessage)
       
   645 	{
       
   646     FUNC_LOG;
       
   647     iFullScreen = ETrue;
       
   648 
       
   649     LoadIconsL();
       
   650     
       
   651     if ( !iFirstStartCompleted )
       
   652 	    {
       
   653 	    DoFirstStartL();
       
   654 	    }
       
   655 
       
   656 	// Set title pane text
       
   657 	iAppUi.SetActiveMailboxNameToStatusPaneL();
       
   658     
       
   659     // Different effect is used when opening folder selection list
       
   660     iAnimateNextActivation = ( aCustomMessageId == KFolderListSelectFolder );
       
   661 
       
   662     // Create header image visual if not yet created
       
   663     if( !iHeaderImageVisual )
       
   664         {
       
   665         iHeaderImageVisual = CAlfImageVisual::AddNewL( *iControl, iHeaderLayout );
       
   666         CAlfTexture& headerBgTexture = iAppUi.FsTextureManager()->TextureByIndex( EMailListBarBgIcon );
       
   667         headerBgTexture.Size().SetSize( iScreenRect.Width(), iListHeaderHeight );
       
   668         iHeaderImageVisual->SetImage( TAlfImage( headerBgTexture ) );
       
   669 
       
   670         TAlfTimedValue headerImageOpacity;
       
   671         headerImageOpacity.SetValueNow( 0 );
       
   672         iHeaderImageVisual->SetOpacity( headerImageOpacity );
       
   673 
       
   674         // Make header text visible by moving it on front of the header background image
       
   675         iHeaderTextVisual->MoveToFront();
       
   676         }
       
   677 
       
   678     // Create list background image if not yet created
       
   679     if( !iListBgImageVisual )
       
   680         {
       
   681         iListBgImageVisual = CAlfImageVisual::AddNewL( *iControl, iListLayout );
       
   682 
       
   683         TAlfTimedValue bgImageVisualOpacity;
       
   684         bgImageVisualOpacity.SetValueNow( 0 );
       
   685         iListBgImageVisual->SetOpacity( bgImageVisualOpacity );
       
   686         // Move to background to make the list visible
       
   687         iListLayout->MoveVisualToBack( *iListBgImageVisual );
       
   688         }
       
   689 
       
   690     // Returning from the settings view needs to handled as special case where
       
   691     // the previous state of the folder list is preserved.
       
   692     if ( aCustomMessageId.iUid == KMailSettingsReturnFromPluginSettings )
       
   693         {
       
   694         iTreeList->HideListL();
       
   695 
       
   696         // Then just refresh the list as in dynamic variant switch,
       
   697         // because screen orientation might have changed
       
   698         HandleDynamicVariantSwitchL( EScreenLayoutChanged );
       
   699 
       
   700         // Set flag for moving or copying
       
   701         iMoveOrCopyInitiated = (iCustomMessageId == KFolderListMoveMessage ||
       
   702                                 iCustomMessageId == KFolderListMoveMessages ||
       
   703                                 iCustomMessageId == KFolderListCopyMessage ||
       
   704                                 iCustomMessageId == KFolderListCopyMessages);
       
   705         // Update toolbar button statuses.
       
   706         UpdateToolbarButtons();
       
   707         }
       
   708 
       
   709     // Normal case of entering the folder list. Set the header text and callback function
       
   710     // according the view activation parameters.
       
   711     else
       
   712         {
       
   713         iCustomMessageId = aCustomMessageId;
       
   714         iTitleCaptionVisible = ETrue;
       
   715 
       
   716         // No header in folders list if not moving or copying messages
       
   717         if( aCustomMessageId == KFolderListMoveMessage )
       
   718             {
       
   719             SetHeaderTextByResourceIdL( R_FREESTYLE_EMAIL_UI_FOLDER_LIST_MOVE_ONE_HEADING );
       
   720             }
       
   721         else if( aCustomMessageId == KFolderListMoveMessages )
       
   722             {
       
   723             SetHeaderTextByResourceIdL( R_FREESTYLE_EMAIL_UI_FOLDER_LIST_MOVE_MORE_HEADING );
       
   724             }
       
   725         else if( aCustomMessageId == KFolderListCopyMessage )
       
   726             {
       
   727             SetHeaderTextByResourceIdL( R_FREESTYLE_EMAIL_UI_FOLDER_LIST_COPY_ONE_HEADING );
       
   728             }
       
   729         else if( aCustomMessageId == KFolderListCopyMessages )
       
   730             {
       
   731             SetHeaderTextByResourceIdL( R_FREESTYLE_EMAIL_UI_FOLDER_LIST_COPY_MORE_HEADING );
       
   732             }
       
   733         else
       
   734             {
       
   735             // Hide text visual
       
   736             iTitleCaptionVisible = EFalse;
       
   737             iHeaderTextVisual->SetOpacity( KFSInvisible );
       
   738             }
       
   739     
       
   740         // Set flag for moving or copying
       
   741         iMoveOrCopyInitiated = (aCustomMessageId == KFolderListMoveMessage ||
       
   742                                 aCustomMessageId == KFolderListMoveMessages ||
       
   743                                 aCustomMessageId == KFolderListCopyMessage ||
       
   744                                 aCustomMessageId == KFolderListCopyMessages);
       
   745 
       
   746         // Set callback function
       
   747         TFolderListActivationData subView;
       
   748         TPckgBuf<TFolderListActivationData> viewData( subView );
       
   749         viewData.Copy( aCustomMessage );
       
   750         iCallback = viewData().iCallback;
       
   751         iCurrentFolderType = viewData().iSourceFolderType;
       
   752     
       
   753        	iTreeList->HideListL();
       
   754     
       
   755     	// Clear padding when shown in full screen
       
   756        	const TAlfMetric padding( 0 );
       
   757     	iParentLayout->SetPadding( padding );
       
   758     	iListLayout->SetPadding( padding );
       
   759     
       
   760         PrepareFolderListL();
       
   761     
       
   762         // Remove need to be called for all brushes before Reset, otherwise the
       
   763         // brush resources are not completely freed from server side -> brushes
       
   764         // keep "hanging" there and make future drawing slower.
       
   765         while( iParentLayout->Brushes()->Count() > 0 )
       
   766             {
       
   767             iParentLayout->Brushes()->Remove( 0 );
       
   768             }
       
   769     	iParentLayout->Brushes()->Reset();
       
   770     	
       
   771     	TAlfTimedValue layoutOpacity = iHeaderLayout->Opacity();
       
   772     	layoutOpacity.SetTarget( 1, iAppUi.LayoutHandler()->CtrlBarListFadeEffectTime()/2 );
       
   773     	iHeaderLayout->SetOpacity( layoutOpacity );
       
   774     	
       
   775     	TAlfTimedValue bgImageOpacity = iListBgImageVisual->Opacity();
       
   776     	bgImageOpacity.SetTarget( 1, iAppUi.LayoutHandler()->CtrlBarListFadeEffectTime()/2 );
       
   777     	iListBgImageVisual->SetOpacity( bgImageOpacity );
       
   778     
       
   779     	// Reset the variables used in horizontal scrolling
       
   780     	iPreviousListRect = iListLayout->DisplayRectTarget();
       
   781         iPreviousListLevel = KListRootLevel;
       
   782     
       
   783         iParentLayout->SetRect( iScreenRect );
       
   784         iTreeList->ShowListL();
       
   785 
       
   786         TAlfTimedValue opacity;
       
   787         opacity.SetValueNow( 1 );
       
   788         iParentLayout->SetOpacity( opacity );
       
   789         }
       
   790 
       
   791     // See if we are already connected
       
   792     CFSMailBox* mb = iAppUi.GetActiveMailbox();
       
   793     // Just in case, shouldn't happen
       
   794     User::LeaveIfNull( mb );
       
   795     
       
   796     TFSMailBoxStatus onlineStatus = mb->GetMailBoxStatus();
       
   797 
       
   798     // If we are not moving or copying messages, there's no need to connect
       
   799     // the mailbox. In case of move/copy we need to check the mailbox
       
   800     // capability to see if we need to connect the mailbox before showing the
       
   801     // folder list.
       
   802     iNoConnectNeeded = ETrue;
       
   803     if( iMoveOrCopyInitiated )
       
   804         {
       
   805         iNoConnectNeeded = mb->HasCapability( EFSMBoxCapaMoveMessageNoConnectNeeded );
       
   806         }
       
   807 
       
   808     iWaitingToGoOnline = EFalse;
       
   809     // If we are already online or we don't need to be online for
       
   810     // this operation, then we can show the list immediately
       
   811     if( onlineStatus == EFSMailBoxOnline || iNoConnectNeeded )
       
   812         {
       
   813         if( aCustomMessageId.iUid != KMailSettingsReturnFromPluginSettings )
       
   814             {
       
   815             // Populate list after it has been made visible. List should not
       
   816             // be focused before it's fully populated to prevent jumping of the
       
   817             // highlight.
       
   818             iTreeList->SetFocusedL( EFalse );
       
   819             PopulateFolderListDeferred();
       
   820             }
       
   821         }
       
   822     else
       
   823         {
       
   824         // If we come here it means that the mailbox is offline but connection
       
   825         // is needed for this operation, so we need to connect first
       
   826         ConnectToMailboxL();
       
   827         }
       
   828 	}
       
   829 
       
   830 // ---------------------------------------------------------------------------
       
   831 // CFSEmailUiFolderListVisualiser::OfferToolbarEventL
       
   832 // ---------------------------------------------------------------------------
       
   833 //
       
   834 void CFSEmailUiFolderListVisualiser::OfferToolbarEventL( TInt aCommand )
       
   835     {
       
   836     switch( aCommand )
       
   837         {
       
   838         case EFsEmailUiTbCmdSelect:
       
   839             HandleCommandL( EFsEmailUiCmdSelect );
       
   840             break;
       
   841         case EFsEmailUiTbCmdCollapseAll:
       
   842             HandleCommandL( EFsEmailUiCmdActionsCollapseAll );
       
   843             break;
       
   844         case EFsEmailUiTbCmdExpandAll:
       
   845             HandleCommandL( EFsEmailUiCmdActionsExpandAll );
       
   846             break;
       
   847 
       
   848         default:
       
   849             break;
       
   850         }
       
   851     }
       
   852 
       
   853 // ---------------------------------------------------------------------------
       
   854 // CFSEmailUiFolderListVisualiser::ToolbarResourceId
       
   855 // ---------------------------------------------------------------------------
       
   856 //
       
   857 TInt CFSEmailUiFolderListVisualiser::ToolbarResourceId() const
       
   858     {
       
   859     return R_FREESTYLE_EMAIL_UI_TOOLBAR_FOLDER_LIST;
       
   860     }
       
   861 	
       
   862 // ---------------------------------------------------------------------------
       
   863 // Deactivate this view
       
   864 // ---------------------------------------------------------------------------
       
   865 //
       
   866 void CFSEmailUiFolderListVisualiser::ChildDoDeactivate()
       
   867 	{
       
   868     FUNC_LOG;
       
   869     iMoveOrCopyInitiated = EFalse;
       
   870     iWaitingToGoOnline = EFalse;
       
   871     if ( !iAppUi.AppUiExitOngoing() )
       
   872         {
       
   873         iTreeVisualizer->NotifyControlVisibilityChange( EFalse );
       
   874         }
       
   875 	}
       
   876 
       
   877 // ---------------------------------------------------------------------------
       
   878 // In case of sort list, this function sets focus to current sort item
       
   879 // ---------------------------------------------------------------------------
       
   880 //
       
   881 void CFSEmailUiFolderListVisualiser::SetFocusToCurrentSortItemL()
       
   882     {
       
   883     FUNC_LOG;
       
   884     if ( iFirstStartCompleted ) // Safety
       
   885         {
       
   886         for ( TInt i=0; i < iModel->Count() ; i++ )
       
   887             {
       
   888             CFSEmailUiFolderListItem* modelItem = iModel->ItemByIndex( i );
       
   889             if ( modelItem && ( modelItem->iSortField == iCurrentSortOrder ) )
       
   890                 {
       
   891                 iTreeVisualizer->SetFocusedItemL( modelItem->iListId, EFalse );
       
   892                 break;          
       
   893                 }
       
   894             }
       
   895         }
       
   896     }
       
   897 
       
   898 // ---------------------------------------------------------------------------
       
   899 // In case of folder list popup, this function sets focus to current folder,
       
   900 // if that folder can be found from the list. If current folder is not found
       
   901 // from the list, then move focus to "More folders" item.
       
   902 // ---------------------------------------------------------------------------
       
   903 //
       
   904 void CFSEmailUiFolderListVisualiser::SetFocusToCurrentFolderL()
       
   905     {
       
   906     FUNC_LOG;
       
   907     if ( iFirstStartCompleted ) // Safety
       
   908         {
       
   909         TFsTreeItemId itemToFocus = iMoreFoldersItemId;
       
   910         for ( TInt i=0; i < iModel->Count() ; i++ )
       
   911             {
       
   912             CFSEmailUiFolderListItem* modelItem = iModel->ItemByIndex( i );
       
   913             if ( modelItem && ( modelItem->iFolderId == iCurrentFolderId ) )
       
   914                 {
       
   915                 itemToFocus = modelItem->iListId;
       
   916                 break;          
       
   917                 }
       
   918             }
       
   919         iTreeVisualizer->SetFocusedItemL( itemToFocus, EFalse );
       
   920         }
       
   921     }
       
   922 
       
   923 // ---------------------------------------------------------------------------
       
   924 // In case of move, this function sets focus to latest selected item
       
   925 // ---------------------------------------------------------------------------
       
   926 //
       
   927 void CFSEmailUiFolderListVisualiser::SetFocusToLatestMovedFolderL()
       
   928 	{
       
   929     FUNC_LOG;
       
   930 	if ( iFirstStartCompleted ) // Safety
       
   931 	    {
       
   932 	    TBool match( EFalse );
       
   933 	    for ( TInt i=0; i < iModel->Count() ; i++ )
       
   934 	         {
       
   935 	         CFSEmailUiFolderListItem* modelItem = iModel->ItemByIndex( i );
       
   936 	         if ( modelItem && // Safety check
       
   937 	              !modelItem->iFolderId.IsNullId() && // Filter mailbox and sort items
       
   938 	              modelItem->iFolderId == iLatestSelectedMoveFolderId )
       
   939 	             {
       
   940 	             match = ETrue;
       
   941 	             iTreeVisualizer->SetFocusedItemL( modelItem->iListId );
       
   942 	             break;          
       
   943 	             }
       
   944 	         }
       
   945 
       
   946 	     if ( match )
       
   947 	         {
       
   948              // Make sure that the horizontal position is recalculated
       
   949              DoHorizontalScrollL( ETrue );
       
   950 	         }
       
   951 	     else
       
   952 	         {
       
   953              iLatestSelectedMoveFolderId.SetId( 0 );
       
   954              iLatestSelectedMoveFolderId.SetNullId();
       
   955 	         }
       
   956 	    }
       
   957 	}
       
   958 
       
   959 // ---------------------------------------------------------------------------
       
   960 // Handle events
       
   961 // ---------------------------------------------------------------------------
       
   962 //
       
   963 TBool CFSEmailUiFolderListVisualiser::OfferEventL(const TAlfEvent& aEvent)
       
   964     {
       
   965     FUNC_LOG;
       
   966     TBool result( EFalse ); 
       
   967     if ( aEvent.IsKeyEvent() && aEvent.Code() == EEventKey )
       
   968         {
       
   969         // Swap left and right with mirrored layout
       
   970         TInt scanCode = aEvent.KeyEvent().iScanCode;
       
   971         if ( AknLayoutUtils::LayoutMirrored() )
       
   972             {
       
   973             if ( scanCode == EStdKeyLeftArrow ) scanCode = EStdKeyRightArrow;
       
   974             else if ( scanCode == EStdKeyRightArrow ) scanCode = EStdKeyLeftArrow;
       
   975             }
       
   976         
       
   977         switch ( scanCode )
       
   978             {
       
   979             case EStdKeyDevice3:	// CENTER CLICK
       
   980             case EStdKeyEnter:		// ENTER
       
   981             	{
       
   982             	// Handle center click and enter as selection
       
   983             	HandleCommandL( EAknSoftkeySelect );
       
   984             	result = ETrue;
       
   985             	}
       
   986             	break;
       
   987 
       
   988             case EStdKeyLeftArrow:
       
   989             	{
       
   990             	// Check is the folder list open
       
   991             	if( !iFullScreen && iCallback )
       
   992             		{
       
   993             		HandleSelectionL( EFSEmailUiCtrlBarResponseCancel );
       
   994             		}
       
   995             	// Check is the sort list open
       
   996             	else if( !iFullScreen && iSortListCallback )
       
   997             		{
       
   998             		HandleSelectionL( EFSEmailUiCtrlBarResponseSwitchList );
       
   999             		}
       
  1000  	           	}            
       
  1001                 break;
       
  1002 
       
  1003 	        case EStdKeyRightArrow:
       
  1004             	{
       
  1005             	// Check is the folder list open
       
  1006             	if( !iFullScreen && iCallback )
       
  1007             		{
       
  1008             		HandleSelectionL( EFSEmailUiCtrlBarResponseSwitchList );
       
  1009             		}
       
  1010             	// Check is the sort list open
       
  1011             	else if( !iFullScreen && iSortListCallback )
       
  1012             		{
       
  1013             		HandleSelectionL( EFSEmailUiCtrlBarResponseCancel );
       
  1014             		}
       
  1015             	}
       
  1016 				break;
       
  1017 
       
  1018              default:
       
  1019 	       	    // Check keyboard shortcuts.
       
  1020 	       	    TInt shortcutCommand = 
       
  1021 	       	        iAppUi.ShortcutBinding().CommandForShortcutKey( aEvent.KeyEvent(),
       
  1022 	       	                                                         CFSEmailUiShortcutBinding::EContextFolderList );
       
  1023 	       	    if ( shortcutCommand != KErrNotFound )
       
  1024 	       	        {
       
  1025        	            HandleCommandL( shortcutCommand );
       
  1026 	       	        result = ETrue;
       
  1027 	       	        }
       
  1028                 break;
       
  1029             }
       
  1030         }      
       
  1031     return result;
       
  1032     }
       
  1033 
       
  1034 // ---------------------------------------------------------------------------
       
  1035 // CFSEmailUiFolderListVisualiser::HandlePointerEventL
       
  1036 // ---------------------------------------------------------------------------
       
  1037 //      
       
  1038 TBool CFSEmailUiFolderListVisualiser::HandlePointerEventL(const TAlfEvent& aEvent)
       
  1039     {
       
  1040     // Handle pointer events to fadervisual. If the list is shown in popup, then
       
  1041     // the popup will be closed.
       
  1042     if ((aEvent.Visual() == iFaderVisual || aEvent.Visual() == iFaderLayout) && aEvent.PointerEvent().iType == TPointerEvent::EButton1Down && iPopupListShown)
       
  1043         {
       
  1044         HandleSelectionL( EFSEmailUiCtrlBarResponseCancel );
       
  1045         }
       
  1046     else
       
  1047         {
       
  1048         return iTreeList->TreeControl()->OfferEventL(aEvent);
       
  1049         }
       
  1050     return ETrue;     
       
  1051     }
       
  1052 
       
  1053 // ---------------------------------------------------------------------------
       
  1054 // CFSEmailUiFolderListVisualiser::DynInitMenuPaneL
       
  1055 // ---------------------------------------------------------------------------
       
  1056 //
       
  1057 void CFSEmailUiFolderListVisualiser::DynInitMenuPaneL(TInt aResourceId, CEikMenuPane* aMenuPane)
       
  1058 	{
       
  1059     FUNC_LOG;
       
  1060     if ( iFirstStartCompleted ) // Safety
       
  1061         {
       
  1062         // Hide expand/collapse all if not needed
       
  1063         if ( aResourceId == R_FSEMAILUI_FOLDERLIST_MENUPANE )
       
  1064             {
       
  1065             if ( FeatureManager::FeatureSupported( KFeatureIdFfCmailIntegration ) )
       
  1066         	   {
       
  1067         	   // remove help support in pf5250
       
  1068         	   aMenuPane->SetItemDimmed( EFsEmailUiCmdHelp, ETrue);      
       
  1069         	   }
       
  1070             
       
  1071             // OFFLINE/ONLINE MENU SELECTION
       
  1072             if( iMoveOrCopyInitiated )
       
  1073                 {
       
  1074                 TFSMailBoxStatus onlineStatus = iAppUi.GetActiveMailbox()->GetMailBoxStatus();
       
  1075                 aMenuPane->SetItemDimmed( EFsEmailUiCmdGoOnline, onlineStatus == EFSMailBoxOnline );                            
       
  1076                 aMenuPane->SetItemDimmed( EFsEmailUiCmdGoOffline, onlineStatus == EFSMailBoxOffline );      
       
  1077                 }
       
  1078             else
       
  1079                 {
       
  1080                 aMenuPane->SetItemDimmed( EFsEmailUiCmdGoOnline, ETrue );                            
       
  1081                 aMenuPane->SetItemDimmed( EFsEmailUiCmdGoOffline, ETrue );      
       
  1082                 }
       
  1083 
       
  1084             // select option
       
  1085             aMenuPane->SetItemDimmed( EFsEmailUiCmdSelect, iModel->Count() == 0 );
       
  1086 
       
  1087             aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsCollapseAll, AllNodesCollapsed() );
       
  1088             aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsExpandAll, AllNodesExpanded() );
       
  1089             }
       
  1090          
       
  1091         // Add shortcut hints
       
  1092         iAppUi.ShortcutBinding().AppendShortcutHintsL( *aMenuPane, 
       
  1093                                     CFSEmailUiShortcutBinding::EContextFolderList );
       
  1094         }
       
  1095 	}
       
  1096 
       
  1097 
       
  1098 // ---------------------------------------------------------------------------
       
  1099 // 
       
  1100 // ---------------------------------------------------------------------------
       
  1101 //
       
  1102 void CFSEmailUiFolderListVisualiser::HandleSelectionL( TFSEmailUiCtrlBarResponse aSelection )
       
  1103     {
       
  1104     FUNC_LOG;
       
  1105     // If popup is not open or the view is not active, then do nothing
       
  1106     if ( !(iPopupListShown || IsViewActive()) )
       
  1107         {
       
  1108         return;
       
  1109         }
       
  1110     
       
  1111     TBool popupHiddenAlready(EFalse);
       
  1112     switch( aSelection )
       
  1113         {
       
  1114         case EFSEmailUiCtrlBarResponseSelect:
       
  1115             {
       
  1116             TFsTreeItemId focusedItem = iTreeList->FocusedItem();
       
  1117             if (focusedItem != KFsTreeNoneID)
       
  1118                 {
       
  1119                 if ( !iFullScreen && iTreeList->ItemData(focusedItem).Type() != KFsSeparatorDataType)
       
  1120                     {
       
  1121                     HidePopupL();
       
  1122                     popupHiddenAlready = ETrue;
       
  1123                     }
       
  1124                 }
       
  1125             if( !HandleCallbackL() )
       
  1126                 {
       
  1127                 break;
       
  1128                 }
       
  1129             }
       
  1130             // fall through
       
  1131         case EFSEmailUiCtrlBarResponseSwitchList:
       
  1132         case EFSEmailUiCtrlBarResponseCancel:
       
  1133             {
       
  1134             if ( IsFullScreen() )
       
  1135                 {
       
  1136                 iAppUi.ReturnToPreviousViewL();
       
  1137                 }
       
  1138             else
       
  1139                 {
       
  1140                 if ( !popupHiddenAlready )
       
  1141                     {
       
  1142                     HidePopupL();
       
  1143                     }
       
  1144 
       
  1145                 iAppUi.FolderPopupClosed();
       
  1146                 }
       
  1147                 
       
  1148             if ( !iFullScreen && iSortListCallback )
       
  1149                 {
       
  1150                 iSortListCallback->SortOrderChangedL( EFSMailDontCare, aSelection );
       
  1151                 iSortListCallback = NULL;
       
  1152                 }
       
  1153             else if ( iCallback )
       
  1154                 {
       
  1155                 iCallback->FolderSelectedL( TFSMailMsgId(), aSelection );
       
  1156                 iCallback = NULL;
       
  1157                 }
       
  1158             }
       
  1159             break;
       
  1160 
       
  1161         default:
       
  1162             break;
       
  1163         }
       
  1164     }
       
  1165 
       
  1166 // ---------------------------------------------------------------------------
       
  1167 // Recursive function to get the root parent of given item
       
  1168 // ---------------------------------------------------------------------------
       
  1169 //
       
  1170 TFsTreeItemId CFSEmailUiFolderListVisualiser::GetRootParent( const TFsTreeItemId aItemId ) const
       
  1171 	{
       
  1172     FUNC_LOG;
       
  1173 	TFsTreeItemId parentId = iTreeList->Parent( aItemId );
       
  1174 	// If current item's parent is KFsTreeRootID, return its id
       
  1175 	if( parentId == KFsTreeRootID || parentId == KFsTreeNoneID )
       
  1176 		{
       
  1177 		return aItemId;
       
  1178 		}
       
  1179 	else
       
  1180 		{
       
  1181 		// Get the root parent recursively
       
  1182 		return GetRootParent( parentId );
       
  1183 		}
       
  1184 	}
       
  1185 
       
  1186 // ---------------------------------------------------------------------------
       
  1187 // Override the default transition effect in case full screen mode is launched 
       
  1188 // from popup mode.
       
  1189 // ---------------------------------------------------------------------------
       
  1190 //
       
  1191 void CFSEmailUiFolderListVisualiser::DoTransitionEffect( TBool aDirectionOut )
       
  1192     {
       
  1193     FUNC_LOG;
       
  1194     if ( !aDirectionOut && IsFullScreen() && iAnimateNextActivation )
       
  1195         {
       
  1196         TInt rectTransitionTime = iAppUi.LayoutHandler()->CtrlBarListFadeEffectTime();
       
  1197         TInt opacityTransitionTime = iAppUi.LayoutHandler()->CtrlBarListFadeEffectTime() / 2;
       
  1198         
       
  1199         TAlfTimedValue opacity;
       
  1200         opacity.SetValueNow( 0 );
       
  1201         opacity.SetTarget( 1, opacityTransitionTime );
       
  1202         iParentLayout->SetOpacity( opacity );
       
  1203         
       
  1204         // Do animated enlargening from popup window rect to full screen rect
       
  1205         iParentLayout->SetRect( FolderListRectInThisResolution() );
       
  1206         iParentLayout->SetRect( iScreenRect, rectTransitionTime );
       
  1207         }
       
  1208     else
       
  1209         {
       
  1210         // Use generic transition effect in all other cases
       
  1211         CFsEmailUiViewBase::DoTransitionEffect( aDirectionOut );
       
  1212         }
       
  1213     }
       
  1214 
       
  1215 // ---------------------------------------------------------------------------
       
  1216 // Gets the parent layout holding all the visials of this view
       
  1217 // ---------------------------------------------------------------------------
       
  1218 //
       
  1219 void CFSEmailUiFolderListVisualiser::GetParentLayoutsL(
       
  1220         RPointerArray<CAlfVisual>& aLayoutArray ) const
       
  1221     {
       
  1222     FUNC_LOG;
       
  1223     aLayoutArray.AppendL( iParentLayout );
       
  1224     }
       
  1225 
       
  1226 // ---------------------------------------------------------------------------
       
  1227 // Handle commands
       
  1228 // ---------------------------------------------------------------------------
       
  1229 //
       
  1230 void CFSEmailUiFolderListVisualiser::HandleCommandL( TInt aCommand )
       
  1231     {
       
  1232     FUNC_LOG;
       
  1233     if ( iFirstStartCompleted ) // Safety
       
  1234          {
       
  1235          switch(aCommand)
       
  1236               {
       
  1237               // Key presses
       
  1238               case EAknSoftkeySelect:
       
  1239               case EAknSoftkeyOpen:
       
  1240               case EFsEmailUiCmdOpen:
       
  1241               case EFsEmailUiCmdSelect:
       
  1242                   {
       
  1243                   HandleSelectionL( EFSEmailUiCtrlBarResponseSelect );
       
  1244                   }
       
  1245                   break;
       
  1246                   
       
  1247               case EAknSoftkeyBack:
       
  1248               case EEikBidCancel:
       
  1249                   {
       
  1250                   HandleSelectionL( EFSEmailUiCtrlBarResponseCancel );
       
  1251                   }
       
  1252                   break;
       
  1253 
       
  1254               // Options menu commands
       
  1255               case EFsEmailUiCmdGoOnline:
       
  1256                   {
       
  1257                   if( iMoveOrCopyInitiated )
       
  1258                       {
       
  1259       			      ConnectToMailboxL();
       
  1260                       }
       
  1261                   }
       
  1262             	  break;
       
  1263               case EFsEmailUiCmdGoOffline:
       
  1264                   {
       
  1265                   if( iMoveOrCopyInitiated )
       
  1266                       {
       
  1267                       DisconnectFromMailboxL();
       
  1268                       }
       
  1269                   }
       
  1270                   break;
       
  1271               case EFsEmailUiCmdActionsCollapseAll:
       
  1272                   {
       
  1273                   TFsTreeItemId prevId = iTreeList->FocusedItem();
       
  1274                   prevId = GetRootParent( prevId );
       
  1275                   iTreeVisualizer->CollapseAllL();
       
  1276                   if ( prevId != KFsTreeRootID && prevId != KFsTreeNoneID )
       
  1277                       {
       
  1278                       iTreeVisualizer->SetFocusedItemL( prevId );
       
  1279                       }
       
  1280                   }
       
  1281                   break;
       
  1282 
       
  1283               case EFsEmailUiCmdActionsExpandAll:
       
  1284                   {
       
  1285                   TFsTreeItemId prevId = iTreeList->FocusedItem();    
       
  1286                   iTreeVisualizer->ExpandAllL();
       
  1287                   if ( prevId != KFsTreeRootID && prevId != KFsTreeNoneID )
       
  1288                       {
       
  1289                       iTreeVisualizer->SetFocusedItemL( prevId );
       
  1290                       }
       
  1291                   }
       
  1292                   break;
       
  1293 
       
  1294               case EFsEmailUiCmdSettings:
       
  1295                   {
       
  1296                   CESMailSettingsPlugin::TSubViewActivationData activationData;
       
  1297                   activationData.iAccount = iAppUi.GetActiveMailbox()->GetId();
       
  1298                   activationData.iSubviewId = 1;
       
  1299                   activationData.iLaunchFolderSettings = ETrue;
       
  1300                   
       
  1301                   TUid pluginUid = iAppUi.GetActiveMailbox()->GetSettingsUid();
       
  1302                   // register plugin view if not exists so that activation can be made
       
  1303                   if ( !iAppUi.View( pluginUid ) )
       
  1304                       {
       
  1305                       CESMailSettingsPlugin* plugin = CESMailSettingsPlugin::NewL( pluginUid );
       
  1306                       CleanupStack::PushL( plugin );
       
  1307                       iAppUi.AddViewL( plugin );
       
  1308                       CleanupStack::Pop( plugin );        
       
  1309                       }
       
  1310                   TUid messageId = TUid::Uid( CESMailSettingsPlugin::EActivateMailSettingsSubview );
       
  1311                   const TPckgBuf<CESMailSettingsPlugin::TSubViewActivationData> pluginMessagePkg( activationData );
       
  1312                   iAppUi.EnterPluginSettingsViewL( pluginUid, messageId, pluginMessagePkg );
       
  1313                   
       
  1314                   // Hide list to avoid it flashing when returning back
       
  1315                   iTreeList->HideListL();
       
  1316                   }
       
  1317                   break;
       
  1318 
       
  1319               case EFsEmailUiCmdHelp:
       
  1320                   {
       
  1321                   TFsEmailUiUtility::LaunchHelpL( KFSE_HLP_LAUNCHER_GRID );
       
  1322                   }
       
  1323                   break;
       
  1324 
       
  1325               case EFsEmailUiCmdExit:
       
  1326                   {
       
  1327                   iAppUi.Exit();      
       
  1328                   }
       
  1329                   break;
       
  1330 
       
  1331               case EFsEmailUiCmdGoToTop:
       
  1332                   {
       
  1333                   GoToTopL();
       
  1334                   }
       
  1335                   break;
       
  1336                   
       
  1337               case EFsEmailUiCmdGoToBottom:
       
  1338                   {
       
  1339                   GoToBottomL();
       
  1340                   }
       
  1341                   break;
       
  1342               
       
  1343               case EFsEmailUiCmdPageUp:
       
  1344                   {
       
  1345                   TKeyEvent simEvent = { EKeyPageUp, EStdKeyPageUp, 0, 0 };
       
  1346                   iCoeEnv->SimulateKeyEventL( simEvent, EEventKey );
       
  1347                   }
       
  1348                   break;
       
  1349                   
       
  1350               case EFsEmailUiCmdPageDown:
       
  1351                   {
       
  1352                   TKeyEvent simEvent = { EKeyPageDown, EStdKeyPageDown, 0, 0 };
       
  1353                   iCoeEnv->SimulateKeyEventL( simEvent, EEventKey );
       
  1354                   }
       
  1355                   break;
       
  1356 
       
  1357               case EFsEmailUiCmdActionsCollapseExpandAllToggle:
       
  1358                   {
       
  1359                   if ( !AllNodesCollapsed() )
       
  1360                       {
       
  1361                       HandleCommandL( EFsEmailUiCmdActionsCollapseAll );
       
  1362                       }
       
  1363                   else
       
  1364                       {       
       
  1365                       HandleCommandL( EFsEmailUiCmdActionsExpandAll );
       
  1366                       }
       
  1367                   }
       
  1368                   break;
       
  1369                   
       
  1370               default:
       
  1371                   break;
       
  1372               }        
       
  1373          }
       
  1374     }
       
  1375 
       
  1376 // ---------------------------------------------------------------------------
       
  1377 // Handle call to callback function
       
  1378 // ---------------------------------------------------------------------------
       
  1379 //
       
  1380 TBool CFSEmailUiFolderListVisualiser::HandleCallbackL()
       
  1381 	{
       
  1382     FUNC_LOG;
       
  1383     TFsTreeItemId focusedItem = iTreeList->FocusedItem();
       
  1384 
       
  1385     if( focusedItem == KFsTreeNoneID )
       
  1386     	{
       
  1387     	return ETrue;
       
  1388     	}
       
  1389     
       
  1390     if( focusedItem == iMoreFoldersItemId )
       
  1391     	{
       
  1392         //HidePopupL();
       
  1393         iFullScreen = ETrue;
       
  1394 
       
  1395 		TFolderListActivationData tmp;	
       
  1396 	    tmp.iCallback = iCallback;
       
  1397 		const TPckgBuf<TFolderListActivationData> pkgOut( tmp );
       
  1398 
       
  1399 		iAppUi.EnterFsEmailViewL( FolderListId, KFolderListSelectFolder, pkgOut );
       
  1400 		
       
  1401         return EFalse;
       
  1402     	}
       
  1403 
       
  1404     CFSEmailUiFolderListItem* modelItem = iModel->ItemByListId( focusedItem );
       
  1405 	if( !modelItem ) // Safety check, shouldn't be possible
       
  1406 		{
       
  1407 		return EFalse;
       
  1408 		}
       
  1409 		
       
  1410 	if( iCallback )
       
  1411 		{
       
  1412 		const TFSMailMsgId& selectedFolderId = modelItem->iFolderId;
       
  1413 		const TFSMailMsgId& selectedMailboxId = modelItem->iMailboxId;
       
  1414         if( !selectedFolderId.IsNullId() )
       
  1415         	{
       
  1416     		if ( iCustomMessageId == KFolderListMoveMessage || 
       
  1417     			 iCustomMessageId == KFolderListMoveMessages ||
       
  1418     		     iCustomMessageId == KFolderListCopyMessage ||
       
  1419     		     iCustomMessageId == KFolderListCopyMessages )
       
  1420     			{
       
  1421     			iLatestSelectedMoveFolderId = selectedFolderId;
       
  1422     			}		        	
       
  1423   	       	iCallback->FolderSelectedL( selectedFolderId, EFSEmailUiCtrlBarResponseSelect );
       
  1424         	}
       
  1425         else if( !selectedMailboxId.IsNullId() )
       
  1426         	{
       
  1427         	iCallback->MailboxSelectedL( selectedMailboxId );
       
  1428         	}
       
  1429         // Set callback to NULL after callback is called so that the
       
  1430         // same callback is not reused unintentionally.
       
  1431         iCallback = NULL;
       
  1432 		}
       
  1433 	else if( iSortListCallback )
       
  1434 		{
       
  1435         iSortListCallback->SortOrderChangedL( modelItem->iSortField, EFSEmailUiCtrlBarResponseSelect );
       
  1436         // Set callback to NULL after callback is called so that the
       
  1437         // same callback is not reused unintentionally.
       
  1438         iSortListCallback = NULL;
       
  1439 		}
       
  1440 		
       
  1441     return ETrue;
       
  1442 	}
       
  1443 
       
  1444 
       
  1445 // ---------------------------------------------------------------------------
       
  1446 // Append node to list by getting the item data from resource
       
  1447 // ---------------------------------------------------------------------------
       
  1448 //
       
  1449 void CFSEmailUiFolderListVisualiser::SetHeaderTextByResourceIdL( 
       
  1450         TInt aResourceId )
       
  1451 	{
       
  1452     FUNC_LOG;
       
  1453     if ( iFirstStartCompleted ) // Safety
       
  1454         {	
       
  1455         HBufC* headingText = StringLoader::LoadLC( aResourceId );
       
  1456         SetHeaderTextAttributesL();
       
  1457         iHeaderTextVisual->SetTextL( *headingText );
       
  1458         CleanupStack::PopAndDestroy( headingText );
       
  1459         }
       
  1460     }
       
  1461 
       
  1462 // ---------------------------------------------------------------------------
       
  1463 // CFSEmailUiFolderListVisualiser::SetHeaderTextAttributesL()
       
  1464 //
       
  1465 // Apply header text attributes
       
  1466 // This creates "Move message to:" title caption and background graphics
       
  1467 // ---------------------------------------------------------------------------
       
  1468 //
       
  1469 void CFSEmailUiFolderListVisualiser::SetHeaderTextAttributesL()
       
  1470     {
       
  1471     iHeaderTextVisual->SetOpacity( KFSVisible );
       
  1472     CAlfTextStyle* textStyle = iAppUi.LayoutHandler()->FSTextStyleFromIdL( 
       
  1473             EFSFontTypeNormalBold );
       
  1474     iHeaderTextVisual->SetTextStyle ( textStyle->Id() );
       
  1475     iHeaderTextVisual->SetColor( iAppUi.LayoutHandler()->
       
  1476             ListNormalStateTextSkinColor() );
       
  1477     iHeaderTextVisual->SetPadding( 
       
  1478             iAppUi.LayoutHandler()->TitleCaptionPadding() );
       
  1479 
       
  1480     if( iHeaderTextVisual->Brushes() )
       
  1481         {
       
  1482         iHeaderTextVisual->Brushes()->Reset();
       
  1483         }
       
  1484     iHeaderTextVisual->EnableBrushesL();
       
  1485     CAlfBrush* selectorBrush = iAppUi.FsTextureManager()->
       
  1486                    NewCtrlBarSelectorBrushLC();
       
  1487     selectorBrush->SetOpacity( KFSHeaderTextBackgroundOpacity );
       
  1488     iHeaderTextVisual->Brushes()->AppendL( selectorBrush, EAlfHasOwnership );
       
  1489     CleanupStack::Pop( selectorBrush );
       
  1490     }
       
  1491 
       
  1492 
       
  1493 // ---------------------------------------------------------------------------
       
  1494 // CFSEmailUiFolderListVisualiser::ConnectMailbox
       
  1495 // ---------------------------------------------------------------------------
       
  1496 //
       
  1497 void CFSEmailUiFolderListVisualiser::ConnectToMailboxL()
       
  1498     {
       
  1499 	CFSMailBox* mb = iAppUi.GetActiveMailbox();	
       
  1500 	TDesC* mbName = &mb->GetName();
       
  1501     
       
  1502     iWaitingToGoOnline = ETrue;
       
  1503 		
       
  1504     mb->GoOnlineL();
       
  1505     }
       
  1506 
       
  1507 
       
  1508 // ---------------------------------------------------------------------------
       
  1509 // CFSEmailUiFolderListVisualiser::DisconnectMailbox
       
  1510 // ---------------------------------------------------------------------------
       
  1511 //
       
  1512 void CFSEmailUiFolderListVisualiser::DisconnectFromMailboxL()
       
  1513     {
       
  1514     iAppUi.GetActiveMailbox()->GoOfflineL();
       
  1515     
       
  1516     iWaitingToGoOnline = EFalse;
       
  1517     }
       
  1518 
       
  1519 
       
  1520 // ---------------------------------------------------------------------------
       
  1521 // Construct folder list data
       
  1522 // ---------------------------------------------------------------------------
       
  1523 //
       
  1524 void CFSEmailUiFolderListVisualiser::UpdateFolderListL()
       
  1525 	{
       
  1526     FUNC_LOG;
       
  1527     if ( iFirstStartCompleted ) // Safety
       
  1528         {
       
  1529 		// <cmail>
       
  1530         iListItemDatas.Reset();
       
  1531 		// </cmail>
       
  1532         if( iFullScreen )
       
  1533             {
       
  1534             // Append lines to the model
       
  1535             AppendActiveMailboxFoldersL();
       
  1536             
       
  1537             // Update toolbar button statuses.
       
  1538             UpdateToolbarButtons();
       
  1539             }
       
  1540         else
       
  1541             {    
       
  1542             //Mailboxes needed to be at the top followed by seperator
       
  1543             AppendMailboxesL();   
       
  1544             
       
  1545             // Append lines to the model followed by seperator
       
  1546             AppendActiveMailboxFoldersL();
       
  1547             AppendSeparatorLineL();
       
  1548             
       
  1549             // Append the folder list view selector            
       
  1550             AppendMoreFoldersL();            
       
  1551             }	        
       
  1552         }
       
  1553   	}
       
  1554 
       
  1555 // ---------------------------------------------------------------------------
       
  1556 // Construct sort list data
       
  1557 // ---------------------------------------------------------------------------
       
  1558 //
       
  1559 void CFSEmailUiFolderListVisualiser::UpdateSortListL()
       
  1560 	{
       
  1561     FUNC_LOG;
       
  1562     if ( iFirstStartCompleted ) // Safety
       
  1563         {
       
  1564         iListItemDatas.Reset();
       
  1565         iTreeList->RemoveAllL();
       
  1566         iListItemVisulizers.Reset();
       
  1567         iModel->RemoveAll();
       
  1568         iMoreFoldersItemId = KFsTreeNoneID;
       
  1569         // Append lines to the model
       
  1570         AppendSortListItemsL();	        
       
  1571         }
       
  1572 	}
       
  1573 
       
  1574 // ---------------------------------------------------------------------------
       
  1575 // Append active mailbox's folders
       
  1576 // ---------------------------------------------------------------------------
       
  1577 //
       
  1578 void CFSEmailUiFolderListVisualiser::AppendActiveMailboxFoldersL()
       
  1579 	{
       
  1580     FUNC_LOG;
       
  1581     if ( iFirstStartCompleted ) // Safety
       
  1582         {
       
  1583         iActiveMailbox = iAppUi.GetActiveMailbox();
       
  1584         if( iActiveMailbox )
       
  1585             {
       
  1586             AppendSubfoldersL( TFSMailMsgId(), KFsTreeRootID, ETrue );
       
  1587             }     
       
  1588         }
       
  1589 	}
       
  1590 
       
  1591 // ---------------------------------------------------------------------------
       
  1592 // Compare two mail folders, used in sorting done with TLinearOrder
       
  1593 // ---------------------------------------------------------------------------
       
  1594 //
       
  1595 TInt CFSEmailUiFolderListVisualiser::CompareFolders( const CFSMailFolder& aFirst, const CFSMailFolder& aSecond )
       
  1596 	{
       
  1597     FUNC_LOG;
       
  1598 	TInt priorityOfFirst = GetFolderPriorityByType( aFirst );
       
  1599 	TInt priorityOfSecond = GetFolderPriorityByType( aSecond );
       
  1600 
       
  1601 	// First sort the folders by folder type priority.
       
  1602 	// If priority is same, sort alphabetically by folder name.
       
  1603 	if( priorityOfFirst != priorityOfSecond )
       
  1604 		{
       
  1605 		return priorityOfFirst - priorityOfSecond;
       
  1606 		}
       
  1607 	else
       
  1608 		{
       
  1609 		TDesC& nameOfFirst = aFirst.GetFolderName();
       
  1610 		TDesC& nameOfSecond = aSecond.GetFolderName();
       
  1611 		
       
  1612 		return nameOfFirst.CompareC( nameOfSecond );
       
  1613 		}
       
  1614 	}
       
  1615 
       
  1616 // ---------------------------------------------------------------------------
       
  1617 // Compare two mail folders, used in sorting done with TLinearOrder
       
  1618 // ---------------------------------------------------------------------------
       
  1619 //
       
  1620 TInt CFSEmailUiFolderListVisualiser::GetFolderPriorityByType( const CFSMailFolder& aFolder )
       
  1621 	{
       
  1622     FUNC_LOG;
       
  1623 	TInt folderType = aFolder.GetFolderType();
       
  1624 	switch( folderType )
       
  1625 		{
       
  1626 		case EFSInbox:
       
  1627 			return EFolderListPriorityInbox;
       
  1628 
       
  1629 		case EFSOutbox:
       
  1630 			return EFolderListPriorityOutbox;
       
  1631 
       
  1632 		case EFSDraftsFolder:
       
  1633 			return EFolderListPriorityDrafts;
       
  1634 
       
  1635 		case EFSSentFolder:
       
  1636 			return EFolderListPrioritySent;
       
  1637 
       
  1638 		case EFSDeleted:
       
  1639 			return EFolderListPriorityDeleted;
       
  1640 
       
  1641 		default:
       
  1642 			return EFolderListPriorityOtherFolder;
       
  1643 		}
       
  1644 	}
       
  1645 
       
  1646 void CFSEmailUiFolderListVisualiser::AppendSortListItemsL()
       
  1647 	{
       
  1648     FUNC_LOG;
       
  1649 	TFsTreeItemId itemId = AppendItemToListFromResourceL( R_FREESTYLE_EMAIL_UI_SORT_BY_DATE, KFsTreeRootID, NULL, EFalse );
       
  1650 	iModel->AppendL( itemId, EFSMailSortByDate );
       
  1651 	
       
  1652 	switch( iCurrentFolderType )
       
  1653 		{
       
  1654 		case EFSSentFolder:
       
  1655 		case EFSDraftsFolder:
       
  1656 		case EFSOutbox:
       
  1657 			{
       
  1658 			itemId = AppendItemToListFromResourceL( R_FREESTYLE_EMAIL_UI_SORT_BY_RECIPIENT, KFsTreeRootID, NULL, EFalse );
       
  1659 			iModel->AppendL( itemId, EFSMailSortByRecipient );
       
  1660 			}
       
  1661 			break;
       
  1662 			
       
  1663 		default:
       
  1664 			{
       
  1665 			itemId = AppendItemToListFromResourceL( R_FREESTYLE_EMAIL_UI_SORT_BY_SENDER, KFsTreeRootID, NULL, EFalse );
       
  1666 			iModel->AppendL( itemId, EFSMailSortBySender );
       
  1667 			}
       
  1668 			break;
       
  1669 		}
       
  1670 
       
  1671 	itemId = AppendItemToListFromResourceL( R_FREESTYLE_EMAIL_UI_SORT_BY_SUBJECT, KFsTreeRootID, NULL, EFalse );
       
  1672 	iModel->AppendL( itemId, EFSMailSortBySubject );
       
  1673 
       
  1674 	if ( TFsEmailUiUtility::IsFollowUpSupported( *iAppUi.GetActiveMailbox() ) )
       
  1675 		{
       
  1676 		itemId = AppendItemToListFromResourceL( R_FREESTYLE_EMAIL_UI_SORT_BY_FLAG, KFsTreeRootID, NULL, EFalse );
       
  1677 		iModel->AppendL( itemId, EFSMailSortByFlagStatus );
       
  1678 		}
       
  1679 
       
  1680 	itemId = AppendItemToListFromResourceL( R_FREESTYLE_EMAIL_UI_SORT_BY_PRIORITY, KFsTreeRootID, NULL, EFalse );
       
  1681 	iModel->AppendL( itemId, EFSMailSortByPriority );
       
  1682 
       
  1683 	if ( iCurrentFolderType != EFSSentFolder &&
       
  1684 		 iCurrentFolderType != EFSDraftsFolder &&
       
  1685 		 iCurrentFolderType != EFSOutbox )
       
  1686 		{
       
  1687 		itemId = AppendItemToListFromResourceL( R_FREESTYLE_EMAIL_UI_SORT_BY_UNREAD, KFsTreeRootID, NULL, EFalse );
       
  1688 		iModel->AppendL( itemId, EFSMailSortByUnread );
       
  1689 		}
       
  1690 
       
  1691 	// Allow scroll bar refresh only for the last item
       
  1692 	itemId = AppendItemToListFromResourceL( R_FREESTYLE_EMAIL_UI_SORT_BY_ATTACHMENT, KFsTreeRootID, NULL, ETrue );
       
  1693 	iModel->AppendL( itemId, EFSMailSortByAttachment );
       
  1694 	}
       
  1695 
       
  1696 // ---------------------------------------------------------------------------
       
  1697 // Recursive function to get the folder's subfolder data
       
  1698 // ---------------------------------------------------------------------------
       
  1699 //
       
  1700 void CFSEmailUiFolderListVisualiser::AppendSubfoldersL(
       
  1701 	TFSMailMsgId aFolder, TFsTreeItemId aParentNode, TBool aRefreshLastItem )
       
  1702 	{
       
  1703     FUNC_LOG;
       
  1704 	RPointerArray<CFSMailFolder> folders;
       
  1705     CleanupResetAndDestroyClosePushL( folders );
       
  1706 
       
  1707 	iActiveMailbox->ListFolders( aFolder, folders );
       
  1708 	
       
  1709 	TLinearOrder<CFSMailFolder> order(
       
  1710 		CFSEmailUiFolderListVisualiser::CompareFolders );
       
  1711 	folders.Sort( order );
       
  1712 
       
  1713 	// First check which folders are not shown, and remove those from the list.
       
  1714 	// This is done in separate loop to be able to check in next loop which
       
  1715 	// folder is last one to be added. This information is needed to enhance
       
  1716 	// list performance by allowing scroll bar refresh only for the last item.
       
  1717 	for( TInt i = folders.Count() - 1; i >= 0; i-- )
       
  1718 	    {
       
  1719         if( !ShowThisTypeOfFolderL( folders[i] ) )
       
  1720             {
       
  1721             // Skip this folder
       
  1722             delete folders[i];
       
  1723             folders.Remove(i);
       
  1724             }
       
  1725 	    }
       
  1726 	
       
  1727 	TBool allowItemRefresh = EFalse;
       
  1728 	while( folders.Count() > 0 )
       
  1729 		{
       
  1730 		// If last item of this level is to be refreshed, and we are in the
       
  1731 		// last item, allow the refresh. If this last item is leaf folder,
       
  1732 		// then list is refreshed during it's drawn. If this last item is
       
  1733 		// node (it has some subfolders), then we don't refresh it, but
       
  1734 		// instead we forward the info to next level with next
       
  1735 		// AppendSubfoldersL function call.
       
  1736 		if( aRefreshLastItem && folders.Count() == 1 )
       
  1737 		    {
       
  1738 		    allowItemRefresh = ETrue;
       
  1739 		    }
       
  1740 
       
  1741 		// Performance optimisations concerning FS Generic scroll bar update
       
  1742 		// logic are implemented so that they assume that all leaf folders
       
  1743 		// are added to list as leaf items, not nodes
       
  1744 		if( iFullScreen && folders[0]->GetSubFolderCount() > 0 )
       
  1745 			{
       
  1746 			TFsTreeItemId nodeId = AppendNodeFolderL( folders[0], aParentNode );
       
  1747             // If the returned item id is KFsTreeNoneID, it means that
       
  1748             // the current folder was not added to folder list, so we
       
  1749             // should not append it to model either
       
  1750 			if( nodeId != KFsTreeNoneID )
       
  1751 				{
       
  1752                 // Note that ownership of the folder object is NOT transferred
       
  1753                 // to model anymore, so we need to delete it here in all cases
       
  1754 				iModel->AppendL( nodeId, folders[0] );
       
  1755 
       
  1756 				AppendSubfoldersL( folders[0]->GetFolderId(), nodeId, allowItemRefresh );
       
  1757 				}
       
  1758             delete folders[0];
       
  1759             folders.Remove(0);
       
  1760             }
       
  1761 		else
       
  1762 			{
       
  1763 			TFsTreeItemId leafId = AppendLeafFolderL( folders[0], aParentNode, allowItemRefresh );
       
  1764             // If the returned item id is KFsTreeNoneID, it means that
       
  1765             // the current folder was not added to folder list, so we
       
  1766             // should not append it to model either
       
  1767 			if( leafId != KFsTreeNoneID )
       
  1768 				{
       
  1769                 // Note that ownership of the folder object is NOT transferred
       
  1770                 // to model anymore, so we need to delete it here in all cases
       
  1771 				iModel->AppendL( leafId, folders[0] );
       
  1772 				}
       
  1773 			delete folders[0];
       
  1774             folders.Remove(0);
       
  1775 			}
       
  1776 		}
       
  1777 
       
  1778     CleanupStack::PopAndDestroy( &folders );
       
  1779 	}
       
  1780 
       
  1781 // ---------------------------------------------------------------------------
       
  1782 // Get "standard" folder's resource id (for name) and icon by folder type
       
  1783 // Returns ETrue if folder type is one of the "standard" folders
       
  1784 // ---------------------------------------------------------------------------
       
  1785 //
       
  1786 TBool CFSEmailUiFolderListVisualiser::GetStandardFolderResouceIdAndIconL( const TInt aFolderType, TInt &aResourceId, CAlfTexture* &aIcon ) const
       
  1787 	{
       
  1788     FUNC_LOG;
       
  1789 	TBool found(EFalse);
       
  1790 	if( aFolderType == EFSInbox )
       
  1791 		{
       
  1792 		if( iFullScreen )
       
  1793 			{
       
  1794 			aResourceId = R_FREESTYLE_EMAIL_UI_FOLDER_LIST_INBOX;
       
  1795 			aIcon = iIconArray[EFolderListIconInbox];
       
  1796 			}
       
  1797 		else
       
  1798 			{
       
  1799 			aResourceId = R_FREESTYLE_EMAIL_UI_DROPDOWN_LIST_INBOX;								
       
  1800 			// Get branded mailbox icon
       
  1801 			aIcon = &iAppUi.FsTextureManager()->TextureByMailboxIdL( iActiveMailbox->GetId().PluginId(),
       
  1802 																	 iActiveMailbox->GetId().Id(),
       
  1803 																     iListIconSize);	
       
  1804 			}		
       
  1805 		found = ETrue;
       
  1806 		}
       
  1807 	else if( aFolderType == EFSOutbox )
       
  1808 		{
       
  1809 		if( iFullScreen )
       
  1810 			{
       
  1811 			aResourceId = R_FREESTYLE_EMAIL_UI_FOLDER_LIST_OUTBOX;
       
  1812 			aIcon = iIconArray[EFolderListIconOutbox];
       
  1813 			}
       
  1814 		else
       
  1815 			{
       
  1816 			aResourceId = R_FREESTYLE_EMAIL_UI_DROPDOWN_LIST_OUTBOX;
       
  1817 			}		
       
  1818 		found = ETrue;
       
  1819 		}
       
  1820 	else if( aFolderType == EFSDraftsFolder )
       
  1821 		{
       
  1822 		if( iFullScreen )
       
  1823 			{
       
  1824 			aResourceId = R_FREESTYLE_EMAIL_UI_FOLDER_LIST_DRAFTS;
       
  1825 			aIcon = iIconArray[EFolderListIconDrafts];
       
  1826 			}
       
  1827 		else
       
  1828 			{
       
  1829 			aResourceId = R_FREESTYLE_EMAIL_UI_DROPDOWN_LIST_DRAFTS;
       
  1830 			}		
       
  1831 		found = ETrue;
       
  1832 		}
       
  1833 	else if( aFolderType == EFSSentFolder )
       
  1834 		{
       
  1835 		if( iFullScreen )
       
  1836 			{
       
  1837 			aResourceId = R_FREESTYLE_EMAIL_UI_FOLDER_LIST_SENT;
       
  1838 			aIcon = iIconArray[EFolderListIconSent];
       
  1839 			}
       
  1840 		else
       
  1841 			{
       
  1842 			aResourceId = R_FREESTYLE_EMAIL_UI_DROPDOWN_LIST_SENT;
       
  1843 			}		
       
  1844 		found = ETrue;
       
  1845 		}
       
  1846 	else if( aFolderType == EFSDeleted )
       
  1847 		{
       
  1848 		if( iFullScreen )
       
  1849 			{
       
  1850 			aResourceId = R_FREESTYLE_EMAIL_UI_FOLDER_LIST_DELETED;
       
  1851 			aIcon = iIconArray[EFolderListIconDeleted];
       
  1852 			}
       
  1853 		else
       
  1854 			{
       
  1855 			aResourceId = R_FREESTYLE_EMAIL_UI_DROPDOWN_LIST_DELETED;
       
  1856 			}		
       
  1857 		found = ETrue;
       
  1858 		}
       
  1859 	return found;
       
  1860 	}
       
  1861 
       
  1862 // ---------------------------------------------------------------------------
       
  1863 // Returns true if the specified folder type should be shown in current view
       
  1864 // ---------------------------------------------------------------------------
       
  1865 //
       
  1866 TBool CFSEmailUiFolderListVisualiser::ShowThisTypeOfFolderL(
       
  1867 	CFSMailFolder* aFolder ) const
       
  1868 	{
       
  1869     FUNC_LOG;
       
  1870 	if( iCustomMessageId == KFolderListMoveMessage || 
       
  1871     	iCustomMessageId == KFolderListMoveMessages )
       
  1872 		{
       
  1873 		// When moving or copying message(s), hide Outbox from list
       
  1874 		if( aFolder->GetFolderType() == EFSOutbox )
       
  1875 			{
       
  1876 			return EFalse;
       
  1877 			}
       
  1878 		// In case of other folders, ask from the folder itself
       
  1879 		else
       
  1880 			{
       
  1881 			return aFolder->SupportsMoveFromL( iCurrentFolderType );
       
  1882 			}
       
  1883 		}
       
  1884 	else if( iCustomMessageId == KFolderListCopyMessage ||
       
  1885 			 iCustomMessageId == KFolderListCopyMessages )
       
  1886 		{
       
  1887 		// When moving or copying message(s), hide Outbox from list
       
  1888 		if( aFolder->GetFolderType() == EFSOutbox )
       
  1889 			{
       
  1890 			return EFalse;
       
  1891 			}
       
  1892 		// In case of other folders, ask from the folder itself
       
  1893 		else
       
  1894 			{
       
  1895 			return aFolder->SupportsCopyFromL( iCurrentFolderType );
       
  1896 			}
       
  1897 		}
       
  1898 
       
  1899 	// In case of folder selection list, show all types of folders. In case of
       
  1900 	// control bar list, subfolders are filtered AppendNode/LeafFolderL().
       
  1901 	return ETrue;
       
  1902 	}
       
  1903 
       
  1904 // ---------------------------------------------------------------------------
       
  1905 // Append the folder to list as node
       
  1906 // ---------------------------------------------------------------------------
       
  1907 //
       
  1908 TFsTreeItemId CFSEmailUiFolderListVisualiser::AppendNodeFolderL(
       
  1909 	CFSMailFolder* aFolder, TFsTreeItemId aParentNode )
       
  1910 	{
       
  1911     FUNC_LOG;
       
  1912 	TInt folderType = aFolder->GetFolderType();
       
  1913 	TInt resourceId( 0 );
       
  1914 	CAlfTexture* icon( NULL );
       
  1915 	TFsTreeItemId nodeId( KFsTreeNoneID );
       
  1916 
       
  1917 	// Check if the folder is one of the "standard" folders
       
  1918 	if ( GetStandardFolderResouceIdAndIconL( folderType, resourceId, icon ) )
       
  1919 		{
       
  1920 		// For "standard" folders use the (localised) name from the resource
       
  1921 		nodeId = AppendNodeToListFromResourceL( resourceId, aParentNode, icon, aFolder->GetUnreadCount() );
       
  1922 		}
       
  1923 	else
       
  1924 		{
       
  1925 		// Append non-standard folders only if in Fullscreen
       
  1926 		if( iFullScreen )
       
  1927 			{
       
  1928 			// For other folders get the name from the folder object
       
  1929 			
       
  1930 			nodeId = AppendNodeToListL(
       
  1931 			        &aFolder->GetFolderName(),
       
  1932 			        aParentNode,
       
  1933 			        iIconArray[EFolderListIconInboxSubfolders],
       
  1934 			        aFolder->GetUnreadCount());
       
  1935 			}
       
  1936 		}
       
  1937 	return nodeId;
       
  1938 	}
       
  1939 
       
  1940 // ---------------------------------------------------------------------------
       
  1941 // Append the folder to list as leaf
       
  1942 // ---------------------------------------------------------------------------
       
  1943 //
       
  1944 TFsTreeItemId CFSEmailUiFolderListVisualiser::AppendLeafFolderL(
       
  1945 	CFSMailFolder* aFolder, TFsTreeItemId aParentNode, TBool aAllowRefresh )
       
  1946 	{
       
  1947     FUNC_LOG;
       
  1948 	TInt folderType = aFolder->GetFolderType();
       
  1949 	TInt resourceId( 0 );
       
  1950 	CAlfTexture* icon( NULL );
       
  1951 	TFsTreeItemId itemId( KFsTreeNoneID );
       
  1952 
       
  1953 	// Check if the folder is one of the "standard" folders
       
  1954 	if ( GetStandardFolderResouceIdAndIconL( folderType, resourceId, icon ) )
       
  1955 		{
       
  1956 		itemId = AppendItemToListFromResourceL( resourceId, aParentNode, icon, aAllowRefresh, aFolder->GetUnreadCount() );
       
  1957 		}
       
  1958 	else
       
  1959 		{
       
  1960 		// Append non-standard folders only if in Fullscreen
       
  1961 		if ( iFullScreen )
       
  1962 			{
       
  1963 			// For other folders get the name from the folder object
       
  1964 			itemId = AppendItemToListL(
       
  1965 			        &aFolder->GetFolderName(),
       
  1966 			        aParentNode,
       
  1967 			        iIconArray[EFolderListIconInboxSubfolders],
       
  1968 			        aAllowRefresh,
       
  1969 			        aFolder->GetUnreadCount());
       
  1970 			}
       
  1971 		}
       
  1972 	return itemId;
       
  1973 	}
       
  1974 
       
  1975 // ---------------------------------------------------------------------------
       
  1976 // Append mailbox data
       
  1977 // ---------------------------------------------------------------------------
       
  1978 //
       
  1979 void CFSEmailUiFolderListVisualiser::AppendMailboxesL()
       
  1980 	{
       
  1981     FUNC_LOG;
       
  1982 	RPointerArray<CFSMailBox> mailboxes;
       
  1983     CleanupResetAndDestroyClosePushL( mailboxes );
       
  1984 	TFSMailMsgId id;
       
  1985     iAppUi.GetMailClient()->ListMailBoxes( id, mailboxes );
       
  1986     
       
  1987     TInt count = mailboxes.Count();
       
  1988 
       
  1989 	while( mailboxes.Count() > 0 )
       
  1990 		{		
       
  1991 		if( !( mailboxes[0]->GetId() == iAppUi.GetActiveMailboxId() ) )
       
  1992 			{
       
  1993 			MFSMailBrandManager& brandManager = iAppUi.GetMailClient()->GetBrandManagerL();
       
  1994 			
       
  1995 			CAlfTexture* mailBoxTexture;
       
  1996 			CGulIcon* mailboxIcon( NULL );
       
  1997 			TRAPD( err, mailboxIcon = brandManager.GetGraphicL( EFSMailboxIcon, mailboxes[0]->GetId() ) ); 
       
  1998 			if ( err == KErrNone && mailboxIcon )
       
  1999 				{
       
  2000 				CleanupStack::PushL( mailboxIcon );
       
  2001 				AknIconUtils::SetSize(mailboxIcon->Bitmap(), iListIconSize);
       
  2002 			    AknIconUtils::SetSize(mailboxIcon->Mask(), iListIconSize);				
       
  2003 			    
       
  2004 			    // Create texture into TextureManager, If not already existing			    
       
  2005 			    iAppUi.FsTextureManager()->CreateBrandedMailboxTexture( mailboxIcon,
       
  2006 			    		                                                mailboxes[0]->GetId().PluginId(),
       
  2007 			    		                                                mailboxes[0]->GetId().Id(),
       
  2008 			    		                                                iListIconSize);
       
  2009 			    // Get branded mailbox icon
       
  2010 			    mailBoxTexture = &iAppUi.FsTextureManager()->TextureByMailboxIdL( mailboxes[0]->GetId().PluginId(),
       
  2011 			    		                                                          mailboxes[0]->GetId().Id(),
       
  2012 			    		                                                          iListIconSize);	
       
  2013 			    
       
  2014 				CleanupStack::PopAndDestroy( mailboxIcon );
       
  2015 				}
       
  2016 			else
       
  2017 				{
       
  2018 				mailBoxTexture = iIconArray[EFolderListIconEmailAccount];
       
  2019 				}
       
  2020 
       
  2021 			// Branded mailbox name is nowadays set in new mailbox event
       
  2022 			// handling, so we don't need to use brand manager here anymore.
       
  2023 			// Mailboxes are the first items in the list, and there probably
       
  2024 			// aren't that much of those, so let's allow scroll bar refresh
       
  2025 			// for all of them.
       
  2026 			TFsTreeItemId itemId = AppendItemToListL( &mailboxes[0]->GetName(),
       
  2027 													  KFsTreeRootID,
       
  2028 													  mailBoxTexture,
       
  2029 													  ETrue );
       
  2030 
       
  2031 			// If the returned item id is KFsTreeNoneID, it means that
       
  2032             // the current mailbox was not added to mailbox list, so we
       
  2033 			// should not append it to model either
       
  2034             if( itemId != KFsTreeNoneID )
       
  2035                 {
       
  2036                 // Note that ownership of the mailbox object is NOT transferred
       
  2037                 // to model anymore, so we need to delete it here in all cases
       
  2038                 iModel->AppendL( itemId, mailboxes[0] );
       
  2039                 }
       
  2040 				
       
  2041 			}
       
  2042 		
       
  2043 		delete mailboxes[0];
       
  2044         mailboxes.Remove(0);
       
  2045 		}
       
  2046 	//There is more then 1 mailbox so we add the seperator at the end
       
  2047 	if( count > 1 )
       
  2048 		{
       
  2049 		AppendSeparatorLineL();
       
  2050 		}		
       
  2051 	
       
  2052     CleanupStack::PopAndDestroy( &mailboxes );
       
  2053 	}
       
  2054 
       
  2055 
       
  2056 // ---------------------------------------------------------------------------
       
  2057 // Append separator between active mailbox's folders and other mailboxes
       
  2058 // ---------------------------------------------------------------------------
       
  2059 //
       
  2060 void CFSEmailUiFolderListVisualiser::AppendSeparatorLineL()
       
  2061 	{
       
  2062     FUNC_LOG;
       
  2063 	CFsSeparatorData* data = CFsSeparatorData::NewL();
       
  2064 
       
  2065 	CFsSeparatorVisualizer* visualizer( NULL );
       
  2066     visualizer = CFsSeparatorVisualizer::NewL(*iTreeList->TreeControl());
       
  2067     
       
  2068     // We use the default size of the separator, but we need to save it
       
  2069     // here to have it available later when calculating the list height
       
  2070     iListSeparatorHeight = visualizer->Size().iHeight;
       
  2071     
       
  2072     // This should never be the last item in the list, so disable the refresh
       
  2073     iTreeList->InsertItemL( *data, *visualizer, KFsTreeRootID, KErrNotFound, EFalse);
       
  2074     
       
  2075     iModel->IncreaseSeparatorCount();
       
  2076 	}
       
  2077 
       
  2078 // ---------------------------------------------------------------------------
       
  2079 // Append separator between active mailbox's folders and other mailboxes
       
  2080 // ---------------------------------------------------------------------------
       
  2081 //
       
  2082 void CFSEmailUiFolderListVisualiser::AppendMoreFoldersL()
       
  2083 	{
       
  2084     FUNC_LOG;
       
  2085 	TInt resourceId = R_FREESTYLE_EMAIL_UI_DROPDOWN_LIST_MORE_FOLDERS;
       
  2086 	CAlfTexture* icon = iIconArray[EFolderListIconMoreFolders];
       
  2087 
       
  2088 	// This might be the last item in the list, so allow scroll bar refresh
       
  2089 	iMoreFoldersItemId = AppendItemToListFromResourceL( resourceId, KFsTreeRootID, icon, ETrue );
       
  2090 	}
       
  2091 
       
  2092 // ---------------------------------------------------------------------------
       
  2093 // Append node to list by getting the item data from resource
       
  2094 // ---------------------------------------------------------------------------
       
  2095 //
       
  2096 TFsTreeItemId CFSEmailUiFolderListVisualiser::AppendNodeToListFromResourceL( TInt aResourceId, TFsTreeItemId aParentNode, CAlfTexture* aIcon, TUint aUnreadCnt )
       
  2097 	{
       
  2098     FUNC_LOG;
       
  2099  	HBufC* headingText = StringLoader::LoadLC( aResourceId );
       
  2100 
       
  2101 	TFsTreeItemId nodeId = AppendNodeToListL( headingText, aParentNode, aIcon, aUnreadCnt);
       
  2102 
       
  2103    	CleanupStack::PopAndDestroy(headingText);
       
  2104 
       
  2105    	return nodeId;
       
  2106 	}
       
  2107 
       
  2108 // ---------------------------------------------------------------------------
       
  2109 // Append node to list
       
  2110 // ---------------------------------------------------------------------------
       
  2111 //
       
  2112 TFsTreeItemId CFSEmailUiFolderListVisualiser::AppendNodeToListL( TDesC* aItemData, TFsTreeItemId aParentNode, CAlfTexture* aIcon, TUint aUnreadCnt )
       
  2113 	{
       
  2114     FUNC_LOG;
       
  2115     CFsTreePlainOneLineNodeData* plainItemData;
       
  2116     CFsTreePlainOneLineNodeVisualizer* plainNodeVisualizer;
       
  2117     
       
  2118     HBufC* itemDispName = HBufC::NewLC(aItemData->Length() + KFmtUnRdCntMaxLength);
       
  2119     itemDispName->Des().Copy(*aItemData);
       
  2120     if( aUnreadCnt > 0 )
       
  2121         {
       
  2122         itemDispName->Des().AppendFormat(KFormatUnreadCnt, aUnreadCnt);
       
  2123         }
       
  2124 	CreatePlainNodeLC2( itemDispName, plainItemData, plainNodeVisualizer, aIcon );
       
  2125 	
       
  2126 	// We assume that node can never be the last item to be drawn, there will
       
  2127 	// always be leaf folder under it. So we can always deny scroll bar update.
       
  2128     TFsTreeItemId nodeId = iTreeList->InsertNodeL( *plainItemData, *plainNodeVisualizer, aParentNode, KErrNotFound, EFalse);
       
  2129     CleanupStack::Pop( 2 ); // plainItemData & plainNodeVisualizer
       
  2130 	CleanupStack::PopAndDestroy( itemDispName );
       
  2131 	if( nodeId != KFsTreeNoneID )
       
  2132 		{
       
  2133 	    iTreeList->ExpandNodeL(nodeId);
       
  2134 		iListItemVisulizers.Append( plainNodeVisualizer );
       
  2135 		}
       
  2136 
       
  2137    	return nodeId;
       
  2138 	}
       
  2139 
       
  2140 // ---------------------------------------------------------------------------
       
  2141 // Append leaf to list by getting the item data from resource
       
  2142 // ---------------------------------------------------------------------------
       
  2143 //
       
  2144 TFsTreeItemId CFSEmailUiFolderListVisualiser::AppendItemToListFromResourceL( TInt aResourceId, 
       
  2145 																			 TFsTreeItemId aParentNode,
       
  2146 																			 CAlfTexture* aIcon,
       
  2147 																			 TBool aAllowRefresh,
       
  2148 																			 TUint aUnreadCnt)
       
  2149 	{
       
  2150     FUNC_LOG;
       
  2151  	HBufC* headingText = StringLoader::LoadLC( aResourceId );
       
  2152 
       
  2153 	TFsTreeItemId itemId = AppendItemToListL( headingText, aParentNode, aIcon, aAllowRefresh,  aUnreadCnt);
       
  2154 
       
  2155    	CleanupStack::PopAndDestroy( headingText );
       
  2156 
       
  2157    	return itemId;
       
  2158 	}
       
  2159 
       
  2160 // ---------------------------------------------------------------------------
       
  2161 // Append leaf to list
       
  2162 // ---------------------------------------------------------------------------
       
  2163 //
       
  2164 TFsTreeItemId CFSEmailUiFolderListVisualiser::AppendItemToListL( TDesC* aItemData, 
       
  2165 																 TFsTreeItemId aParentNode,
       
  2166 																 CAlfTexture* aIcon,
       
  2167                                                                  TBool aAllowRefresh,
       
  2168                                                                  TUint aUnreadCnt)
       
  2169 	{
       
  2170     FUNC_LOG;
       
  2171     CFsTreePlainOneLineItemData* plainItemData;
       
  2172     CFsTreePlainOneLineItemVisualizer* plainItemVisualizer;
       
  2173     
       
  2174     HBufC* itemDispName = HBufC::NewLC(aItemData->Length() + KFmtUnRdCntMaxLength);
       
  2175     itemDispName->Des().Copy(*aItemData);
       
  2176     if( aUnreadCnt > 0 )
       
  2177         {
       
  2178         itemDispName->Des().AppendFormat(KFormatUnreadCnt, aUnreadCnt);
       
  2179         }
       
  2180     CreatePlainItemLC2( itemDispName, plainItemData, plainItemVisualizer, aIcon );
       
  2181     
       
  2182     
       
  2183     TFsTreeItemId itemId = iTreeList->InsertItemL( *plainItemData, *plainItemVisualizer, aParentNode, KErrNotFound, aAllowRefresh);
       
  2184     CleanupStack::Pop( 2 ); // plainItemData & plainItemVisualizer
       
  2185 	CleanupStack::PopAndDestroy( itemDispName );
       
  2186 	if( itemId != KFsTreeNoneID )
       
  2187 		{
       
  2188 		iListItemVisulizers.Append( plainItemVisualizer );
       
  2189 		}
       
  2190     
       
  2191 	return itemId;
       
  2192 	}
       
  2193 
       
  2194 // ---------------------------------------------------------------------------
       
  2195 // Create plain leaf item
       
  2196 // ---------------------------------------------------------------------------
       
  2197 //
       
  2198 void CFSEmailUiFolderListVisualiser::CreatePlainItemLC2( const TDesC* aItemDataBuff,
       
  2199                                                          CFsTreePlainOneLineItemData* &aItemData,
       
  2200                                                          CFsTreePlainOneLineItemVisualizer* &aItemVisualizer,
       
  2201                                                          CAlfTexture* aIcon )
       
  2202 	{
       
  2203     FUNC_LOG;
       
  2204     aItemData = CFsTreePlainOneLineItemData::NewL();
       
  2205     CleanupStack::PushL( aItemData );
       
  2206     
       
  2207     aItemData->SetDataL( *aItemDataBuff );
       
  2208     if( aIcon )
       
  2209     	{
       
  2210 		aItemData->SetIcon( *aIcon );
       
  2211     	}
       
  2212 
       
  2213     aItemVisualizer = CFsTreePlainOneLineItemVisualizer::NewL( *iTreeList->TreeControl() );
       
  2214     CleanupStack::PushL( aItemVisualizer );
       
  2215     iListItemDatas.AppendL( aItemData );
       
  2216     // Set folder view specific layouts to be used
       
  2217     if ( iFullScreen )
       
  2218         {
       
  2219         aItemVisualizer->SetLayoutHints( CFsTreeItemVisualizerBase::EFolderLayout );
       
  2220         }
       
  2221     else
       
  2222         {
       
  2223         aItemVisualizer->SetLayoutHints( CFsTreeItemVisualizerBase::EPopupLayout );        
       
  2224         }
       
  2225     SetItemVisualizerPropertiesL( aItemVisualizer );
       
  2226 	}
       
  2227 
       
  2228 // ---------------------------------------------------------------------------
       
  2229 // Create plain node itme
       
  2230 // ---------------------------------------------------------------------------
       
  2231 //
       
  2232 void CFSEmailUiFolderListVisualiser::CreatePlainNodeLC2( TDesC* aItemDataBuff,
       
  2233                                                          CFsTreePlainOneLineNodeData* &aItemData,
       
  2234                                                          CFsTreePlainOneLineNodeVisualizer* &aNodeVisualizer,
       
  2235                                                          CAlfTexture* aIcon )
       
  2236 	{
       
  2237     FUNC_LOG;
       
  2238     aItemData = CFsTreePlainOneLineNodeData::NewL();
       
  2239     CleanupStack::PushL( aItemData );
       
  2240     
       
  2241     aItemData->SetDataL( *aItemDataBuff );
       
  2242     if( aIcon )
       
  2243     	{
       
  2244 		aItemData->SetIconExpanded( *aIcon );
       
  2245 		aItemData->SetIconCollapsed( *aIcon );
       
  2246     	}
       
  2247 	
       
  2248     aNodeVisualizer = CFsTreePlainOneLineNodeVisualizer::NewL( *iTreeList->TreeControl() );
       
  2249     CleanupStack::PushL( aNodeVisualizer );
       
  2250      
       
  2251     // Set folder view specific layouts to be used
       
  2252     if ( iFullScreen )
       
  2253         {
       
  2254         aNodeVisualizer->SetLayoutHints( CFsTreeItemVisualizerBase::EFolderLayout );
       
  2255         }
       
  2256     else
       
  2257         {
       
  2258         aNodeVisualizer->SetLayoutHints( CFsTreeItemVisualizerBase::EPopupLayout );        
       
  2259         }
       
  2260     SetItemVisualizerPropertiesL( aNodeVisualizer );
       
  2261 	}
       
  2262     
       
  2263 void CFSEmailUiFolderListVisualiser::SetItemVisualizerPropertiesL( MFsTreeItemVisualizer* aItemVisualizer )
       
  2264 	{
       
  2265     FUNC_LOG;
       
  2266 	aItemVisualizer->SetFlags(aItemVisualizer->Flags() & ~KFsTreeListItemManagedLayout);
       
  2267 
       
  2268 	if (iFullScreen)
       
  2269 		{
       
  2270 	    aItemVisualizer->SetSize( iAppUi.LayoutHandler()->FolderListItemSizeInThisResolution( iScreenRect ) );
       
  2271 		}
       
  2272 	else
       
  2273 	    {
       
  2274 	    aItemVisualizer->SetSize(TSize(iScreenRect.Width(), iListItemHeight));
       
  2275         }
       
  2276 
       
  2277     aItemVisualizer->SetExtendable( EFalse );
       
  2278 
       
  2279   	// Set correct skin text colors for the list items  
       
  2280    	TRgb focusedColor = iAppUi.LayoutHandler()->ListFocusedStateTextSkinColor();
       
  2281 	// If list is in full screen, it has general list background, so we use
       
  2282 	// general list text color. If it's not in full screen, we use dropdown
       
  2283 	// menu specific text color.
       
  2284 	TRgb normalColor = KRgbBlack;
       
  2285 	if( iFullScreen )
       
  2286 		{
       
  2287 		normalColor = iAppUi.LayoutHandler()->ListNormalStateTextSkinColor();
       
  2288 		}
       
  2289 	else
       
  2290 		{
       
  2291 		normalColor = iAppUi.LayoutHandler()->DropdownMenuTextColor();
       
  2292 		}
       
  2293 	
       
  2294     aItemVisualizer->SetFocusedStateTextColor( focusedColor );
       
  2295     aItemVisualizer->SetNormalStateTextColor( normalColor );
       
  2296 	
       
  2297 	// Set font size
       
  2298     aItemVisualizer->SetFontHeight( iAppUi.LayoutHandler()->ListItemFontHeightInTwips( !iFullScreen ) );
       
  2299 	// Set node bolded
       
  2300 	aItemVisualizer->SetTextBold( EFalse );
       
  2301 	}
       
  2302 
       
  2303 // ---------------------------------------------------------------------------
       
  2304 // If event is pointer event and popup is showing, close popup and return
       
  2305 // ETrue to tell the caller that event was consumed. If the popup is not
       
  2306 // showing but pointer up event haven't been received since the popup was
       
  2307 // closed, then consume event.
       
  2308 // ---------------------------------------------------------------------------
       
  2309 //
       
  2310 TBool CFSEmailUiFolderListVisualiser::HandleWsEventL( const TWsEvent& aEvent )
       
  2311     {
       
  2312     FUNC_LOG;
       
  2313     TBool eventHandled( EFalse );
       
  2314     if ( aEvent.Type() == EEventPointer )
       
  2315         {
       
  2316         const TPointerEvent* pointerEvent( aEvent.Pointer() );
       
  2317         if ( iPopupListShown )
       
  2318             {
       
  2319             const TPoint& position( pointerEvent->iParentPosition );
       
  2320             if ( !CbaButtonPressed( position ) && pointerEvent->iType == TPointerEvent::EButton1Down )
       
  2321                 {
       
  2322                 // get popup rect in local coordinates
       
  2323                 TRect popupRect( iScreenRect );
       
  2324                 // translate to screen coorinates
       
  2325                 popupRect.Move( iEnv.PrimaryDisplay().VisibleArea().iTl );
       
  2326                 // check if the event happened outside of the popup   
       
  2327                 if ( !popupRect.Contains( position ) )
       
  2328                     {
       
  2329                     HandleSelectionL( EFSEmailUiCtrlBarResponseCancel );
       
  2330                     iConsumeUntilNextUpEvent = eventHandled = ETrue;
       
  2331                     }
       
  2332                 }
       
  2333             }
       
  2334         else if ( iConsumeUntilNextUpEvent )
       
  2335             {
       
  2336             if ( pointerEvent->iType == TPointerEvent::EButton1Up )
       
  2337                 {
       
  2338                 iConsumeUntilNextUpEvent = EFalse;
       
  2339                 }
       
  2340             eventHandled = ETrue;
       
  2341             }
       
  2342         }    
       
  2343     return eventHandled;
       
  2344     }
       
  2345 
       
  2346 // Handle foreground event (called by FreestyleEmailUiMailListVisualiser)
       
  2347 void CFSEmailUiFolderListVisualiser::HandleForegroundEventL()
       
  2348     {
       
  2349     FUNC_LOG;
       
  2350     if ( iFirstStartCompleted && iCallback != NULL || iSortListCallback != NULL )
       
  2351         {
       
  2352         ResizeListIcons();
       
  2353         ResizeListItemsL();
       
  2354         iParentLayout->SetRect( iScreenRect );
       
  2355         SetAnchors();
       
  2356         }
       
  2357     }
       
  2358 
       
  2359 // ---------------------------------------------------------------------------
       
  2360 // Handle dynamic switch
       
  2361 // ---------------------------------------------------------------------------
       
  2362 //
       
  2363 void CFSEmailUiFolderListVisualiser::HandleDynamicVariantSwitchL( CFsEmailUiViewBase::TDynamicSwitchType /*aType*/ )
       
  2364 	{
       
  2365     FUNC_LOG;
       
  2366     if (IsPopupShown() || IsFullScreen())
       
  2367         {
       
  2368         if ( iFirstStartCompleted ) // Safety
       
  2369             {
       
  2370             // Resize fader layout
       
  2371             TRect mainPaneRect;
       
  2372             AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane, mainPaneRect );
       
  2373             iFaderLayout->SetRect( mainPaneRect );
       
  2374 
       
  2375             iTreeList->HideListL( EFalse );
       
  2376             UpdateListSizeAttributes();
       
  2377             ResizeListIcons();
       
  2378             ResizeListItemsL();
       
  2379             SetAnchors();
       
  2380             if( !iFullScreen )
       
  2381                 {
       
  2382                 AdaptScreenRectToListContent();
       
  2383                 TAlfMetric padding(
       
  2384                         iAppUi.LayoutHandler()->DropDownMenuListPadding() );
       
  2385                 iParentLayout->SetPadding( padding );
       
  2386                 }
       
  2387             else
       
  2388                 {
       
  2389                 TAlfMetric padding( 0 );
       
  2390                 iParentLayout->SetPadding( padding );
       
  2391                 if ( iHeaderTextVisual->Opacity().ValueNow() )
       
  2392                     {
       
  2393                     // Update text caption colors only if visible
       
  2394                     SetHeaderTextAttributesL();
       
  2395                     }
       
  2396                 }
       
  2397             iParentLayout->SetRect( iScreenRect );
       
  2398 
       
  2399             // Make sure that the horizontal position is recalculated
       
  2400             DoHorizontalScrollL( ETrue );
       
  2401 
       
  2402             // RefreshListViewL not working correctly
       
  2403             //iTreeVisualizer->RefreshListViewL();
       
  2404 
       
  2405             iTreeList->ShowListL();
       
  2406             }
       
  2407         }
       
  2408 	}
       
  2409 
       
  2410 // ---------------------------------------------------------------------------
       
  2411 // Expand/collapse the focused list item
       
  2412 // ---------------------------------------------------------------------------
       
  2413 //
       
  2414 void CFSEmailUiFolderListVisualiser::ExpandOrCollapseL(
       
  2415         const TExpandCollapseType& aType )
       
  2416 	{
       
  2417     FUNC_LOG;
       
  2418 	TFsTreeItemId focusedItem = iTreeList->FocusedItem();
       
  2419 
       
  2420 	if( focusedItem != KFsTreeNoneID && iTreeList->IsNode( focusedItem ) )
       
  2421 		{
       
  2422 		if( aType == EFolderListCollapse ||
       
  2423 		    ( aType == EFolderListAutomatic && iTreeList->IsExpanded( focusedItem ) ) )
       
  2424 			{
       
  2425 			iTreeList->CollapseNodeL( focusedItem );
       
  2426 			}
       
  2427 		else
       
  2428 			{
       
  2429 			iTreeList->ExpandNodeL( focusedItem );
       
  2430 			}
       
  2431 		}
       
  2432 	}
       
  2433 
       
  2434 // ---------------------------------------------------------------------------
       
  2435 // ETrue if in full screen mode, otherwise EFalse
       
  2436 // ---------------------------------------------------------------------------
       
  2437 //
       
  2438 TBool CFSEmailUiFolderListVisualiser::IsFullScreen() const
       
  2439 	{
       
  2440     FUNC_LOG;
       
  2441 	return iFullScreen;
       
  2442 	}
       
  2443 
       
  2444 // ---------------------------------------------------------------------------
       
  2445 // Update list size members variables
       
  2446 // ---------------------------------------------------------------------------
       
  2447 //
       
  2448 void CFSEmailUiFolderListVisualiser::UpdateListSizeAttributes()
       
  2449 	{
       
  2450     FUNC_LOG;
       
  2451     iListItemHeight = iAppUi.LayoutHandler()->OneLineListItemHeight();
       
  2452 
       
  2453 	if( iFullScreen )
       
  2454 		{
       
  2455 	 	AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane, iScreenRect );
       
  2456 	 	iScreenRect.SetRect( 0, 0, iScreenRect.Width(), iScreenRect.Height() );
       
  2457         }
       
  2458 	else
       
  2459 		{
       
  2460 		if( iCallback )
       
  2461 			{
       
  2462 			iCtrlButtonRect = iCallback->FolderButtonRect();
       
  2463 			iScreenRect = FolderListRectInThisResolution();
       
  2464 			}
       
  2465 		else if ( iSortListCallback )
       
  2466 			{
       
  2467             iCtrlButtonRect = iSortListCallback->SortButtonRect();
       
  2468 			iScreenRect = SortListRectInThisResolution();
       
  2469 			}
       
  2470 		else
       
  2471 		    {
       
  2472 		    // Do nothing. This happens if HandleDynamicVariantSwitch() is called while the popup list is not visible. 
       
  2473 		    }
       
  2474 		}
       
  2475 	iListIconSize = iAppUi.LayoutHandler()->FolderListIconSize( !iFullScreen );
       
  2476 	}
       
  2477 
       
  2478 TRect CFSEmailUiFolderListVisualiser::FolderListRectInThisResolution()
       
  2479 	{
       
  2480     FUNC_LOG;
       
  2481     return LeftListRectInThisResolution();
       
  2482 	}
       
  2483 
       
  2484 TRect CFSEmailUiFolderListVisualiser::SortListRectInThisResolution()
       
  2485 	{
       
  2486     FUNC_LOG;
       
  2487     return RightListRectInThisResolution();
       
  2488     }
       
  2489 
       
  2490 TRect CFSEmailUiFolderListVisualiser::LeftListRectInThisResolution()
       
  2491 	{
       
  2492     FUNC_LOG;
       
  2493     return iAppUi.LayoutHandler()->DropDownMenuListRect(
       
  2494             CFSEmailUiLayoutHandler::ELeft );
       
  2495 	}
       
  2496 
       
  2497 TRect CFSEmailUiFolderListVisualiser::RightListRectInThisResolution()
       
  2498 	{
       
  2499     FUNC_LOG;
       
  2500     return iAppUi.LayoutHandler()->DropDownMenuListRect(
       
  2501             CFSEmailUiLayoutHandler::ERight );
       
  2502 	}
       
  2503 
       
  2504 
       
  2505 // ---------------------------------------------------------------------------
       
  2506 // Load the needed icons
       
  2507 // ---------------------------------------------------------------------------
       
  2508 //
       
  2509 void CFSEmailUiFolderListVisualiser::LoadIconsL()
       
  2510 	{
       
  2511     FUNC_LOG;
       
  2512 	iIconArray.Reset();
       
  2513 	if ( iFullScreen )
       
  2514 	    {	
       
  2515         // NOTE: Must be appended same order as are in TFsEmailUiFolderListIcons!	
       
  2516         iIconArray.AppendL( &iAppUi.FsTextureManager()->TextureByIndex( EFolderListInboxTexture ) );   			// EFolderListIconInbox
       
  2517         iIconArray.AppendL( &iAppUi.FsTextureManager()->TextureByIndex( EFolderListInboxSubfoldersTexture ) );	// EFolderListIconInboxSubfolders
       
  2518         iIconArray.AppendL( &iAppUi.FsTextureManager()->TextureByIndex( EFolderListOutboxTexture ) );  			// EFolderListIconOutbox
       
  2519         iIconArray.AppendL( &iAppUi.FsTextureManager()->TextureByIndex( EFolderListDraftsTexture ) );  			// EFolderListIconDrafts
       
  2520         iIconArray.AppendL( &iAppUi.FsTextureManager()->TextureByIndex( EFolderListSentTexture ) );    			// EFolderListIconSent
       
  2521         iIconArray.AppendL( &iAppUi.FsTextureManager()->TextureByIndex( EFolderListDeletedItemsTexture ) ); 	// EFolderListIconDeleted
       
  2522         iIconArray.AppendL( &iAppUi.FsTextureManager()->TextureByIndex( EFolderListServerFoldersTexture ) ); 	// EFolderListIconServerFolders
       
  2523         iIconArray.AppendL( &iAppUi.FsTextureManager()->TextureByIndex( EFolderListMoreFoldersTexture ) ); 		// EFolderListIconMoreFolders
       
  2524         iIconArray.AppendL( &iAppUi.FsTextureManager()->TextureByIndex( EFolderListEmailAccountTexture ) ); 	// EFolderListIconEmailAccount
       
  2525 	    }
       
  2526 	else
       
  2527 	    {
       
  2528         // NOTE: Must be appended same order as are in TFsEmailUiFolderListIcons!   
       
  2529         iIconArray.AppendL( &iAppUi.FsTextureManager()->TextureByIndex( EFolderListInboxTexturePopup ) );            // EFolderListIconInbox
       
  2530         iIconArray.AppendL( &iAppUi.FsTextureManager()->TextureByIndex( EFolderListInboxSubfoldersTexturePopup ) );  // EFolderListIconInboxSubfolders
       
  2531         iIconArray.AppendL( &iAppUi.FsTextureManager()->TextureByIndex( EFolderListOutboxTexturePopup ) );           // EFolderListIconOutbox
       
  2532         iIconArray.AppendL( &iAppUi.FsTextureManager()->TextureByIndex( EFolderListDraftsTexturePopup ) );           // EFolderListIconDrafts
       
  2533         iIconArray.AppendL( &iAppUi.FsTextureManager()->TextureByIndex( EFolderListSentTexturePopup ) );             // EFolderListIconSent
       
  2534         iIconArray.AppendL( &iAppUi.FsTextureManager()->TextureByIndex( EFolderListDeletedItemsTexturePopup ) );     // EFolderListIconDeleted
       
  2535         iIconArray.AppendL( &iAppUi.FsTextureManager()->TextureByIndex( EFolderListServerFoldersTexturePopup ) );    // EFolderListIconServerFolders
       
  2536         iIconArray.AppendL( &iAppUi.FsTextureManager()->TextureByIndex( EFolderListMoreFoldersTexturePopup ) );      // EFolderListIconMoreFolders
       
  2537         iIconArray.AppendL( &iAppUi.FsTextureManager()->TextureByIndex( EFolderListEmailAccountTexturePopup ) );     // EFolderListIconEmailAccount	    
       
  2538 	    }
       
  2539 	}
       
  2540 
       
  2541 void CFSEmailUiFolderListVisualiser::ResizeListIcons()
       
  2542 	{
       
  2543     FUNC_LOG;
       
  2544 	// Resize icons only if the size has changed since previous resize operation
       
  2545 	if( iListIconSize != iPreviousListIconSize )
       
  2546 		{
       
  2547 		iPreviousListIconSize = iListIconSize;
       
  2548 
       
  2549 		//       Resize of textures is not working anymore in Alfred, instead
       
  2550 		//       we should resize the visuals. But that's not possible with
       
  2551 		//       with the current implementation of generic list.
       
  2552 		// First resize "standard" list icons
       
  2553 		TInt arraySize = iIconArray.Count();
       
  2554 		for( TInt i = 0 ; i < arraySize ; i++ )
       
  2555 			{
       
  2556 			iIconArray[i]->Size().SetSize( iListIconSize.iWidth, iListIconSize.iHeight );
       
  2557 			}
       
  2558 
       
  2559 		// Then resize used branded mailbox icons
       
  2560 		//       Branded mailbox icons are not stored anymore in our own
       
  2561 		//       array, instead those are owned by texture manager. So
       
  2562 		//       those should be resized by other means. But currently
       
  2563 		//       there is no way to do it (see above comment).
       
  2564 		}
       
  2565 	}
       
  2566 
       
  2567 // ---------------------------------------------------------------------------
       
  2568 // Resizes the list items without recreating all items
       
  2569 // ---------------------------------------------------------------------------
       
  2570 //
       
  2571 void CFSEmailUiFolderListVisualiser::ResizeListItemsL()
       
  2572 	{
       
  2573     FUNC_LOG;
       
  2574 	TInt arraySize = iListItemVisulizers.Count();
       
  2575 	for( TInt i = 0 ; i < arraySize ; i++ )
       
  2576 		{
       
  2577 		SetItemVisualizerPropertiesL( iListItemVisulizers[i] );
       
  2578 		}
       
  2579 	}
       
  2580 
       
  2581 // ---------------------------------------------------------------------------
       
  2582 // Optimises the screen rect by the list content
       
  2583 // ---------------------------------------------------------------------------
       
  2584 //
       
  2585 void CFSEmailUiFolderListVisualiser::AdaptScreenRectToListContent()
       
  2586 	{
       
  2587     FUNC_LOG;
       
  2588     const TInt popupHeight( iScreenRect.Height() );
       
  2589     const TInt separatorHeight( iListSeparatorHeight * 
       
  2590             iModel->SeparatorCount() );
       
  2591     const TInt itemCount( iTreeList->Count() - iModel->SeparatorCount() );    
       
  2592     TInt visibleItemCount( ( popupHeight - separatorHeight ) / 
       
  2593             iListItemHeight );    
       
  2594     visibleItemCount = Min( visibleItemCount, itemCount );   
       
  2595     iScreenRect.SetHeight( visibleItemCount * iListItemHeight + 
       
  2596             separatorHeight + 
       
  2597             iAppUi.LayoutHandler()->DropDownMenuListPadding() * 2 + 
       
  2598             iAppUi.LayoutHandler()->ControlBarListPadding().iY );
       
  2599 	AdjustWidthByContent( iScreenRect );
       
  2600 	}
       
  2601 
       
  2602 // ---------------------------------------------------------------------------
       
  2603 // Adjusts list width according to content.
       
  2604 // ---------------------------------------------------------------------------
       
  2605 //
       
  2606 void CFSEmailUiFolderListVisualiser::AdjustWidthByContent( TRect& aRect ) const
       
  2607     {
       
  2608     const TInt buttonWidth( iCtrlButtonRect.Width() );
       
  2609     const TInt currentWidth( aRect.Width() );
       
  2610 
       
  2611     // only do adjusting if the buttonWidth is smaller than current popup width
       
  2612     if ( buttonWidth < currentWidth )
       
  2613         {
       
  2614         TAknLayoutRect scrollPane;
       
  2615         scrollPane.LayoutRect( aRect,
       
  2616                 AknLayoutScalable_Apps::sp_fs_scroll_pane_cp01( 6 ) );
       
  2617         const TInt scrollPaneWidth( scrollPane.Rect().Width() );
       
  2618         
       
  2619         TAknLayoutText textLayout;
       
  2620         textLayout.LayoutText( aRect,
       
  2621                 AknLayoutScalable_Apps::list_single_dyc_row_text_pane_t1( 0 ) );
       
  2622         const CFont& font( *(textLayout.Font()) );
       
  2623         const TInt padding(
       
  2624                 iAppUi.LayoutHandler()->DropDownMenuListPadding() * 2 );
       
  2625         if ( iListItemDatas.Count() > 0 )
       
  2626             {
       
  2627             TInt width( 0 );
       
  2628             for ( TInt i = 0; i < iListItemDatas.Count(); i++ )
       
  2629                 {
       
  2630                 TInt totalWidth( scrollPaneWidth );
       
  2631                 const CFsTreePlainOneLineItemData& data( *iListItemDatas[i] );
       
  2632                 totalWidth += font.TextWidthInPixels( data.Data() );
       
  2633                 totalWidth += padding;
       
  2634                 if ( data.IsIconSet() )
       
  2635                     {
       
  2636                     TAknLayoutRect iconPane;
       
  2637                     iconPane.LayoutRect( aRect,
       
  2638                             AknLayoutScalable_Apps::list_single_dyc_row_pane_g1( 0 ) );
       
  2639                     totalWidth += iconPane.Rect().Width();
       
  2640                     }
       
  2641                 if (totalWidth > width)
       
  2642                     {
       
  2643                     width = totalWidth;
       
  2644                     }
       
  2645                 }
       
  2646             if ( currentWidth > width )
       
  2647                 {
       
  2648                 if ( width < buttonWidth )
       
  2649                     {
       
  2650                     width = buttonWidth;
       
  2651                     }
       
  2652                 aRect.SetWidth( width );
       
  2653                 if ( AknLayoutUtils::LayoutMirrored() )
       
  2654                     {
       
  2655                     if ( iCallback )
       
  2656                         {
       
  2657                         const TInt targetX( iCtrlButtonRect.iBr.iX - width );
       
  2658                         aRect.Move( -aRect.iTl.iX + targetX, 0 );
       
  2659                         }
       
  2660                     else
       
  2661                         {
       
  2662                         aRect.Move( -aRect.iTl.iX + iCtrlButtonRect.iTl.iX, 0 );
       
  2663                         }
       
  2664                     }
       
  2665                 else
       
  2666                     {
       
  2667                     if ( !iCallback )
       
  2668                         {
       
  2669                         const TInt targetX( iCtrlButtonRect.iBr.iX - width );
       
  2670                         aRect.Move( -aRect.iTl.iX + targetX, 0 );
       
  2671                         }
       
  2672                     else
       
  2673                         {
       
  2674                         aRect.Move( -aRect.iTl.iX + iCtrlButtonRect.iTl.iX, 0 );
       
  2675                         }
       
  2676                     }
       
  2677                 }
       
  2678             }
       
  2679         }
       
  2680     else
       
  2681         {
       
  2682         aRect.SetWidth( buttonWidth );
       
  2683         if ( !iCallback ) // is sort menu?
       
  2684             {
       
  2685             aRect.Move( currentWidth - buttonWidth, 0 );
       
  2686             }
       
  2687         }
       
  2688     }
       
  2689 
       
  2690 void CFSEmailUiFolderListVisualiser::SetAnchors()
       
  2691 	{
       
  2692     FUNC_LOG;
       
  2693     if ( iFullScreen && iTitleCaptionVisible )
       
  2694         {
       
  2695         iListHeaderHeight = iAppUi.LayoutHandler()->ControlBarHeight();
       
  2696         }
       
  2697     else
       
  2698         {
       
  2699         iListHeaderHeight = 0;
       
  2700         }
       
  2701     
       
  2702     TSize mainPaneSize;
       
  2703     AknLayoutUtils::LayoutMetricsSize(AknLayoutUtils::EMainPane, mainPaneSize);
       
  2704     
       
  2705     // Set anchor for background visual
       
  2706     iParentLayout->SetAnchor(EAlfAnchorTopLeft,
       
  2707                     0,
       
  2708                     EAlfAnchorOriginLeft,
       
  2709                     EAlfAnchorOriginTop,
       
  2710                     EAlfAnchorMetricAbsolute,
       
  2711                     EAlfAnchorMetricAbsolute,
       
  2712                     TAlfTimedPoint(0, 0));
       
  2713     iParentLayout->SetAnchor(EAlfAnchorBottomRight,
       
  2714                     0,
       
  2715                     EAlfAnchorOriginRight,
       
  2716                     EAlfAnchorOriginTop,
       
  2717                     EAlfAnchorMetricAbsolute,
       
  2718                     EAlfAnchorMetricAbsolute,
       
  2719                     TAlfTimedPoint(mainPaneSize.iWidth,mainPaneSize.iHeight));
       
  2720     
       
  2721 	// Set anchor for header text visual
       
  2722 	iParentLayout->SetAnchor(EAlfAnchorTopLeft,
       
  2723 					1,
       
  2724 					EAlfAnchorOriginLeft,
       
  2725 					EAlfAnchorOriginTop,
       
  2726 					EAlfAnchorMetricRelativeToSize,
       
  2727 					EAlfAnchorMetricRelativeToSize,
       
  2728 					TAlfTimedPoint(0, 0));
       
  2729 	iParentLayout->SetAnchor(EAlfAnchorBottomRight,
       
  2730 					1,
       
  2731 					EAlfAnchorOriginRight,
       
  2732 					EAlfAnchorOriginTop,
       
  2733 					EAlfAnchorMetricRelativeToSize,
       
  2734 					EAlfAnchorMetricAbsolute,
       
  2735 					TAlfTimedPoint(0,iListHeaderHeight));
       
  2736 
       
  2737 	// Set anchor for list's parent layout
       
  2738 	iParentLayout->SetAnchor(EAlfAnchorTopLeft,
       
  2739 					2,
       
  2740 					EAlfAnchorOriginLeft,
       
  2741 					EAlfAnchorOriginTop,
       
  2742 					//EAlfAnchorMetricRelativeToSize,
       
  2743 					EAlfAnchorMetricAbsolute,
       
  2744                     EAlfAnchorMetricAbsolute,
       
  2745 					TAlfTimedPoint(0, iListHeaderHeight));
       
  2746 	iParentLayout->SetAnchor(EAlfAnchorBottomRight,
       
  2747 					2,
       
  2748 					EAlfAnchorOriginRight,
       
  2749 					EAlfAnchorOriginBottom,
       
  2750 					//EAlfAnchorMetricRelativeToSize,
       
  2751                     EAlfAnchorMetricAbsolute,
       
  2752                     EAlfAnchorMetricAbsolute,
       
  2753 					TAlfTimedPoint(0, 0));
       
  2754 	}
       
  2755 
       
  2756 // ---------------------------------------------------------------------------
       
  2757 // Moves the focus to the topmost item
       
  2758 // ---------------------------------------------------------------------------
       
  2759 //
       
  2760 void CFSEmailUiFolderListVisualiser::GoToTopL()
       
  2761     {
       
  2762     FUNC_LOG;
       
  2763     TInt topLevelCount = iTreeList->CountChildren( KFsTreeRootID );
       
  2764     if ( topLevelCount )
       
  2765         {
       
  2766         TFsTreeItemId topId = iTreeList->Child(KFsTreeRootID, 0);
       
  2767         iTreeVisualizer->SetFocusedItemL( topId );            
       
  2768         }
       
  2769     }
       
  2770 
       
  2771 // ---------------------------------------------------------------------------
       
  2772 // Moves the focus to the bottommost item
       
  2773 // ---------------------------------------------------------------------------
       
  2774 //
       
  2775 void CFSEmailUiFolderListVisualiser::GoToBottomL()
       
  2776     {
       
  2777     FUNC_LOG;
       
  2778     // There may be arbitrary number of nested sub folders. Make sure we focus
       
  2779     // the bottommost visible subfolder.
       
  2780     TFsTreeItemId bottomId = KFsTreeRootID;
       
  2781     
       
  2782     while ( iTreeList->IsNode(bottomId) && 
       
  2783             iTreeList->IsExpanded(bottomId) &&
       
  2784             iTreeList->CountChildren(bottomId) )
       
  2785         {
       
  2786         bottomId = iTreeList->Child( bottomId, iTreeList->CountChildren(bottomId)-1 );
       
  2787         }
       
  2788     
       
  2789     if ( bottomId != KFsTreeRootID )
       
  2790         {
       
  2791         iTreeVisualizer->SetFocusedItemL( bottomId );            
       
  2792         }
       
  2793     }
       
  2794 
       
  2795 // ---------------------------------------------------------------------------
       
  2796 // Updates the toolbar buttons (sets the dimmed status of the collapse
       
  2797 // all/expand all buttons).
       
  2798 // ---------------------------------------------------------------------------
       
  2799 //
       
  2800 void CFSEmailUiFolderListVisualiser::UpdateToolbarButtons()
       
  2801     {
       
  2802     FUNC_LOG;
       
  2803     Toolbar()->SetItemDimmed( EFsEmailUiTbCmdExpandAll, AllNodesExpanded(), ETrue );
       
  2804     Toolbar()->SetItemDimmed( EFsEmailUiTbCmdCollapseAll, AllNodesCollapsed(), ETrue );
       
  2805     }
       
  2806 
       
  2807 // ---------------------------------------------------------------------------
       
  2808 // Tells if all expandable nodes are collapsed
       
  2809 // ---------------------------------------------------------------------------
       
  2810 //
       
  2811 TBool CFSEmailUiFolderListVisualiser::AllNodesCollapsed() const
       
  2812     {
       
  2813     FUNC_LOG;
       
  2814     TFsTreeItemId itemId = KFsTreeNoneID;
       
  2815     TInt count = iTreeList->CountChildren(KFsTreeRootID);
       
  2816 	
       
  2817 	// If top level is collapsed, then everything is collapsed. There's no need
       
  2818 	// to crawl any deeper in the tree hierarchy.
       
  2819 	for ( TInt i=0 ; i<count ; ++i )
       
  2820 	    {
       
  2821 	    itemId = iTreeList->Child( KFsTreeRootID, i );
       
  2822 	    if ( iTreeList->IsNode(itemId) &&
       
  2823 	         iTreeList->IsExpanded(itemId) )
       
  2824 	        {
       
  2825 	        return EFalse;
       
  2826 	        }
       
  2827 	    }
       
  2828 	
       
  2829 	return ETrue;
       
  2830     }
       
  2831 
       
  2832 // ---------------------------------------------------------------------------
       
  2833 // Tells if all expandable nodes are expanded
       
  2834 // ---------------------------------------------------------------------------
       
  2835 //
       
  2836 TBool CFSEmailUiFolderListVisualiser::AllNodesExpanded( TFsTreeItemId aParentNodeId ) const
       
  2837     {
       
  2838     FUNC_LOG;
       
  2839     // We must crawl through the whole tree to see, if there are any collapsed nodes
       
  2840     // at any level. We do this with recursive depth-first-search.
       
  2841     
       
  2842     TFsTreeItemId itemId = KFsTreeNoneID;
       
  2843     TInt count = iTreeList->CountChildren(aParentNodeId);
       
  2844     
       
  2845     for ( TInt i=0 ; i<count ; ++i )
       
  2846         {
       
  2847         itemId = iTreeList->Child( aParentNodeId, i );
       
  2848         if ( iTreeList->IsNode(itemId) )
       
  2849             {
       
  2850             if ( !iTreeList->IsExpanded(itemId) ||
       
  2851                  !AllNodesExpanded(itemId) )
       
  2852                 {
       
  2853                 return EFalse;
       
  2854                 }
       
  2855             }
       
  2856         }
       
  2857 	
       
  2858 	return ETrue;
       
  2859     }
       
  2860 
       
  2861 // ---------------------------------------------------------------------------
       
  2862 // Does a horizontal scrolling for the list by resizing and moving the list
       
  2863 // layout rect out of the screen from the left side.
       
  2864 // ---------------------------------------------------------------------------
       
  2865 //
       
  2866 void CFSEmailUiFolderListVisualiser::DoHorizontalScrollL( TBool aForceRecalculation )
       
  2867     {
       
  2868     FUNC_LOG;
       
  2869     // Horizontal scrolling needed only in full screen list,
       
  2870     // because popup list doesn't contain any subfolders
       
  2871     if( iFirstStartCompleted && iFullScreen )
       
  2872         {
       
  2873         TFsTreeItemId focusedId = iTreeList->FocusedItem();
       
  2874         if ( focusedId > KFsTreeRootID )
       
  2875             {
       
  2876             // Get the list level
       
  2877             TUint level = iTreeList->Level( focusedId );
       
  2878             
       
  2879             // Little optimisation, handle all levels up to KListLastBasicLevel
       
  2880             // as root level because horizontal scroll amount is same for all
       
  2881             if( level <= KListLastBasicLevel )
       
  2882                 {
       
  2883                 level = KListRootLevel;
       
  2884                 }
       
  2885             
       
  2886             // Recalculate the list rect only if level has changed or if
       
  2887             // recalculation is forced by parameter (e.g. in case of
       
  2888             // dynamic variant switch)
       
  2889             if( ( level != iPreviousListLevel ) || aForceRecalculation )
       
  2890                 {
       
  2891                 TRect listRect = iListLayout->DisplayRectTarget();
       
  2892                 
       
  2893                 // Calulate list rect by taking x-coordinates from iScreenRect
       
  2894                 // and y-coordinates from list layouts target rect (to take
       
  2895                 // into account the list header)
       
  2896                 listRect.SetRect( iScreenRect.iTl.iX, listRect.iTl.iY,
       
  2897                                   iScreenRect.iBr.iX, listRect.iBr.iY );
       
  2898                 
       
  2899                 if( level > KListLastBasicLevel )
       
  2900                     {
       
  2901                     // Calculate rect according to current level
       
  2902                     TInt rectChange = (level - KListLastBasicLevel) * iTreeList->Indentation();
       
  2903                     listRect.SetWidth( iScreenRect.Width() + rectChange );
       
  2904                     listRect.Move( -rectChange, 0 );
       
  2905                     }
       
  2906     
       
  2907                 // Set the list rect only if it has changed from previous
       
  2908                 // (because list refresh causes a little twitch)
       
  2909                 if( listRect != iPreviousListRect )
       
  2910                     {
       
  2911                     iListLayout->SetRect( listRect, iAppUi.LayoutHandler()->CtrlBarListFadeEffectTime() );
       
  2912                     iTreeVisualizer->RefreshListViewL();
       
  2913                     iPreviousListRect = listRect;
       
  2914                     }
       
  2915                 
       
  2916                 iPreviousListLevel = level;
       
  2917                 }
       
  2918             }
       
  2919         }
       
  2920     }
       
  2921 
       
  2922 // ---------------------------------------------------------------------------
       
  2923 // Process a treelist event
       
  2924 // ---------------------------------------------------------------------------
       
  2925 //
       
  2926 void CFSEmailUiFolderListVisualiser::TreeListEventL( const TFsTreeListEvent aEvent,
       
  2927                                     const TFsTreeItemId /*aId*/ )
       
  2928     {
       
  2929     switch (aEvent)
       
  2930         {
       
  2931         case EFsTreeListItemTouchAction:
       
  2932             {
       
  2933             HandleSelectionL( EFSEmailUiCtrlBarResponseSelect );
       
  2934             break;
       
  2935             }
       
  2936 
       
  2937         // Note that in the handling of the following collapse/expand
       
  2938         // events, we assume that if we have received a collapse (expand)
       
  2939         // event then there must now be something to expand (collapse).
       
  2940         // I.e. we assume that if there is no nesting in the tree list then
       
  2941         // we never get any collapse/expand events.
       
  2942         case EFsTreeListItemCollapsed:
       
  2943             {
       
  2944             Toolbar()->SetItemDimmed( EFsEmailUiTbCmdExpandAll, EFalse, ETrue );
       
  2945             // Check whether or not everything is now collapsed: if so,
       
  2946             // disable collapsing.
       
  2947             if ( AllNodesCollapsed() )
       
  2948                 {
       
  2949                 Toolbar()->SetItemDimmed( EFsEmailUiTbCmdCollapseAll, ETrue, ETrue );
       
  2950                 }
       
  2951             break;
       
  2952             }
       
  2953         case EFsTreeListItemExpanded:
       
  2954             {
       
  2955             Toolbar()->SetItemDimmed( EFsEmailUiTbCmdCollapseAll, EFalse, ETrue );
       
  2956             // Check whether or not everything is now expanded: if so,
       
  2957             // disable expanding.
       
  2958             if ( AllNodesExpanded() )
       
  2959                 {
       
  2960                 Toolbar()->SetItemDimmed( EFsEmailUiTbCmdExpandAll, ETrue, ETrue );
       
  2961                 }
       
  2962             break;
       
  2963             }
       
  2964         case EFsTreeListCollapsedAll:
       
  2965             {
       
  2966             // Everything has been collapsed, so disable collapsing and
       
  2967             // enable expanding.
       
  2968             Toolbar()->SetItemDimmed( EFsEmailUiTbCmdCollapseAll, ETrue, ETrue );
       
  2969             Toolbar()->SetItemDimmed( EFsEmailUiTbCmdExpandAll, EFalse, ETrue );
       
  2970             break;
       
  2971             }
       
  2972         case EFsTreeListExpandedAll:
       
  2973             {
       
  2974             // Everything has been expanded, so disable expanding and
       
  2975             // enable collapsing.
       
  2976             Toolbar()->SetItemDimmed( EFsEmailUiTbCmdCollapseAll, EFalse, ETrue );
       
  2977             Toolbar()->SetItemDimmed( EFsEmailUiTbCmdExpandAll, ETrue, ETrue );
       
  2978             break;
       
  2979             }
       
  2980         }
       
  2981     }
       
  2982 
       
  2983 // ---------------------------------------------------------------------------
       
  2984 // HandleMailBoxEventL
       
  2985 // Mailbox event handler, responds to events sent by the plugin.
       
  2986 // ---------------------------------------------------------------------------
       
  2987 //
       
  2988 void CFSEmailUiFolderListVisualiser::HandleMailBoxEventL( TFSMailEvent aEvent,
       
  2989     TFSMailMsgId aMailboxId, TAny* /*aParam1*/, TAny* /*aParam2*/, TAny* /*aParam3*/ )
       
  2990     {
       
  2991     FUNC_LOG;
       
  2992     
       
  2993     // Handle the event
       
  2994     if ( iMoveOrCopyInitiated && 
       
  2995          iFirstStartCompleted && 
       
  2996          aMailboxId == iAppUi.GetActiveMailboxId() &&
       
  2997          iAppUi.CurrentActiveView() == this ) 
       
  2998         {
       
  2999 		if ( aEvent == TFSEventMailboxOnline ) 
       
  3000 			{
       
  3001             if( iWaitingToGoOnline )
       
  3002                 {
       
  3003                 PrepareFolderListL();
       
  3004                 PopulateFolderListL();
       
  3005                 
       
  3006                 if ( iModel->Count() )
       
  3007                     {
       
  3008                     SetFocusToLatestMovedFolderL(); 
       
  3009                     }
       
  3010                 }
       
  3011 			}
       
  3012    		else if ( aEvent == TFSEventMailboxOffline )
       
  3013    			{
       
  3014             // Empty the list when disconnected if connection is needed for
       
  3015    			// the current operation
       
  3016    			if( !iNoConnectNeeded )
       
  3017    			    {
       
  3018    	            PrepareFolderListL();
       
  3019    			    }
       
  3020 			}
       
  3021         }
       
  3022     }
       
  3023 
       
  3024 // ---------------------------------------------------------------------------
       
  3025 // CbaButtonPressed
       
  3026 // Check if aPosition is on CBA touch area
       
  3027 // ---------------------------------------------------------------------------
       
  3028 //
       
  3029 TBool CFSEmailUiFolderListVisualiser::CbaButtonPressed( TPoint aPosition )
       
  3030     {
       
  3031     TBool cbaPressed( EFalse );
       
  3032     
       
  3033     TRect leftCbaRect = TRect();
       
  3034     TRect rightCbaRect = TRect();
       
  3035     GetCbaRects( leftCbaRect, rightCbaRect );
       
  3036     if ( leftCbaRect.Contains( aPosition ) ||
       
  3037          rightCbaRect.Contains( aPosition ))
       
  3038         {
       
  3039         cbaPressed = ETrue;
       
  3040         }
       
  3041 
       
  3042     return cbaPressed;
       
  3043     }
       
  3044 
       
  3045 // ---------------------------------------------------------------------------
       
  3046 // GetCbaRects
       
  3047 // Resolve CBA touch areas from layouts
       
  3048 // ---------------------------------------------------------------------------
       
  3049 //
       
  3050 void CFSEmailUiFolderListVisualiser::GetCbaRects( TRect& aLeftCbaRect, TRect& aRightCbaRect )
       
  3051     {
       
  3052     TBool rightPaneActive( IsAreaSideRightPaneActive() );    
       
  3053     TBool bskLandscape( Layout_Meta_Data::IsLandscapeOrientation() &&
       
  3054                         !rightPaneActive );
       
  3055     TRect screen;
       
  3056     AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EScreen, screen );
       
  3057     if ( rightPaneActive )
       
  3058         {
       
  3059         TAknWindowComponentLayout rightAreaLayout(
       
  3060             AknLayoutScalable_Avkon::area_side_right_pane( 0 ) );
       
  3061             
       
  3062         TAknLayoutRect layoutRect;
       
  3063         // Read right (top in landscape) softkey layout.      
       
  3064         layoutRect.LayoutRect(
       
  3065                 screen,
       
  3066                 TAknWindowComponentLayout::Compose(
       
  3067                 rightAreaLayout,
       
  3068                 AknLayoutScalable_Avkon::sctrl_sk_bottom_pane() ).LayoutLine() );
       
  3069         TRect bottomSKRect( layoutRect.Rect() );
       
  3070 
       
  3071         // Read left (bottom in landscape) softkey layout.       
       
  3072         layoutRect.LayoutRect(
       
  3073                 screen,
       
  3074                 TAknWindowComponentLayout::Compose(
       
  3075                 rightAreaLayout,
       
  3076                 AknLayoutScalable_Avkon::sctrl_sk_top_pane() ).LayoutLine() );
       
  3077         TRect topSKRect( layoutRect.Rect() );
       
  3078 
       
  3079         layoutRect.LayoutRect(
       
  3080             bottomSKRect,
       
  3081             AknLayoutScalable_Avkon::aid_touch_sctrl_bottom().LayoutLine() );
       
  3082         aLeftCbaRect = layoutRect.Rect();
       
  3083 
       
  3084         layoutRect.LayoutRect(
       
  3085             topSKRect,
       
  3086             AknLayoutScalable_Avkon::aid_touch_sctrl_top().LayoutLine() );
       
  3087         aRightCbaRect = layoutRect.Rect();        
       
  3088         }
       
  3089     else
       
  3090         {          
       
  3091         TAknWindowComponentLayout applicationWindow(
       
  3092             AknLayoutScalable_Avkon::application_window( 0 ) );
       
  3093         TAknLayoutRect cbarect;
       
  3094         cbarect.LayoutRect(
       
  3095             screen,
       
  3096             TAknWindowComponentLayout::Compose(
       
  3097                 applicationWindow,
       
  3098                 TAknWindowComponentLayout::Compose(
       
  3099                     AknLayoutScalable_Avkon::area_bottom_pane( bskLandscape ? 2 : 1 ),
       
  3100                     AknLayoutScalable_Avkon::control_pane() ) ).LayoutLine() );
       
  3101         aLeftCbaRect = cbarect.Rect();
       
  3102         }    
       
  3103     }
       
  3104 
       
  3105 // ---------------------------------------------------------------------------
       
  3106 // IsAreaSideRightPaneActive
       
  3107 // Checks if right side pane is active.
       
  3108 // ---------------------------------------------------------------------------
       
  3109 //
       
  3110 TBool CFSEmailUiFolderListVisualiser::IsAreaSideRightPaneActive()
       
  3111     {
       
  3112     // Currently the widescreen status pane layout is in use only
       
  3113     // when pen input (touch) is enabled.
       
  3114     TBool result = EFalse;
       
  3115     
       
  3116     if ( Layout_Meta_Data::IsLandscapeOrientation() && 
       
  3117          Layout_Meta_Data::IsPenEnabled() )
       
  3118         {
       
  3119         if ( iAvkonEnv->StatusPaneResIdForCurrentLayout(
       
  3120                  AknStatuspaneUtils::CurrentStatusPaneLayoutResId() ) ==
       
  3121                      R_AVKON_WIDESCREEN_PANE_LAYOUT_IDLE_FLAT_NO_SOFTKEYS )
       
  3122             {
       
  3123             result = EFalse;
       
  3124             }
       
  3125         else
       
  3126             {
       
  3127             result = ETrue;
       
  3128             }
       
  3129         }
       
  3130 
       
  3131     return result;
       
  3132     }
       
  3133 
       
  3134 // ---------------------------------------------------------------------------
       
  3135 // Only for testing
       
  3136 // ---------------------------------------------------------------------------
       
  3137 //
       
  3138 //void CFSEmailUiFolderListVisualiser::CancelNotifierTestL()
       
  3139 //	{
       
  3140 //	iNotifierTest->Cancel();
       
  3141 //	}
       
  3142