messagingappbase/mce/src/MceBitmapResolver.cpp
changeset 79 2981cb3aa489
equal deleted inserted replaced
25:84d9eb65b26f 79:2981cb3aa489
       
     1 /*
       
     2 * Copyright (c) 2002 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:  
       
    15 *     Handles different mce bitmaps.
       
    16 *     First collects all the bitmaps from different mtm's and also local
       
    17 *     folder's bitmaps to icon array.
       
    18 *
       
    19 */
       
    20 
       
    21 
       
    22 
       
    23 // INCLUDE FILES
       
    24 #include <mtudcbas.h>       // cbasemtmuidata
       
    25 #include "MtmRegistryObserver.h" // mmtmuidataregistryobserver
       
    26 #include <msvuids.h>
       
    27 #include <msvids.h>         // fixed entry ids
       
    28 #include <MTMStore.h>       // cmtmstore
       
    29 #include <miutset.h>
       
    30 #include <gulicon.h>        // CGulIcon
       
    31 #include <AknIconArray.h>   // cakniconarray
       
    32 #include <fbs.h>            // CFbsFont
       
    33 #include <muiu.mbg>         // bitmap enums
       
    34 #include <avkon.mbg>        // bitmap enums
       
    35 #include <mtud.hrh>         // EMtudEntryStateOpen
       
    36 #include <SenduiMtmUids.h>  // mtm uids
       
    37 #include <bldvariant.hrh>
       
    38 #include <featmgr.h>
       
    39 #include "MceUtils.h"
       
    40 #include "MceListItem.h"
       
    41 #include "MceBitmapResolver.h"
       
    42 #include "MceIds.h"         //kmcedocumentsentryid
       
    43 #include <mceextraicons.mbg>
       
    44 // security data caging
       
    45 #include <data_caging_path_literals.hrh>
       
    46 #include <AknIconUtils.h>
       
    47 
       
    48 
       
    49 // LOCAL CONSTANTS AND MACROS
       
    50 
       
    51 _LIT( KMceDirAndFileMuiu,"muiu.mbm" );
       
    52 
       
    53 const TInt KMceIconArrayGranularity = 10;
       
    54 
       
    55 // ================= MEMBER FUNCTIONS =======================
       
    56 
       
    57 CMceBitmapResolver* CMceBitmapResolver::NewL(
       
    58     CMsvSessionPtr aSession,
       
    59     MMtmUiDataRegistryObserver& aRegObserver,
       
    60     TBool aLargeIcons )
       
    61     { // static
       
    62     CMceBitmapResolver* self=new(ELeave) CMceBitmapResolver(
       
    63         aSession, aRegObserver, aLargeIcons );
       
    64     CleanupStack::PushL(self);
       
    65     self->ConstructL();
       
    66     CleanupStack::Pop( self );
       
    67     return self;
       
    68     }
       
    69 
       
    70 CMceBitmapResolver::CMceBitmapResolver(
       
    71     CMsvSessionPtr aSession,
       
    72     MMtmUiDataRegistryObserver& aRegObserver,
       
    73     TBool aLargeIcons) :
       
    74     iRegObserver(aRegObserver),
       
    75     iSession( aSession),
       
    76     iLargeIcons( aLargeIcons ),
       
    77     iBitmapsLoaded( 0 ),
       
    78     iDescriptionLength( KMceVisibleTextLength )
       
    79     {
       
    80     }
       
    81 
       
    82 CMceBitmapResolver::~CMceBitmapResolver()
       
    83     {
       
    84     if ( iIcons )
       
    85         {
       
    86         iIcons->ResetAndDestroy();
       
    87         }
       
    88     delete iIcons;
       
    89     delete iIconIndexes;
       
    90     // iSession deleted by Ui class.
       
    91     }
       
    92 
       
    93 
       
    94 // ----------------------------------------------------
       
    95 // CMceBitmapResolver::ConstructL
       
    96 // ----------------------------------------------------
       
    97 void CMceBitmapResolver::ConstructL()
       
    98     {
       
    99     // security data caging
       
   100     TParse fp;
       
   101     fp.Set( AknIconUtils::AvkonIconFileName(), &KDC_RESOURCE_FILES_DIR , NULL );
       
   102     iFilenameAvkon = fp.FullName();
       
   103     
       
   104     fp.Set( KMceDirAndFileMuiu, &KDC_APP_BITMAP_DIR , NULL );
       
   105     iFilenameMuiu = fp.FullName();
       
   106 
       
   107     iIcons = new(ELeave) CAknIconArray( KMceIconArrayGranularity );
       
   108     iIconIndexes = new(ELeave) CArrayFixFlat<TMceBitmapListItem>(
       
   109         KMceIconArrayGranularity );
       
   110 
       
   111     TMceBitmapListItem listItem;
       
   112     listItem.iExtraItem = EFalse;
       
   113     listItem.iMtm.iUid = KUidMsvLocalServiceMtmValue;
       
   114     listItem.iType.iUid = KUidMsvFolderEntryValue;
       
   115 
       
   116     listItem.iId = KErrNone;
       
   117     listItem.iExtraItem = ETrue; 
       
   118     
       
   119     CreateAndAppendIconL( KAknsIIDQgnIndiMarkedAdd, iFilenameAvkon, EMbmAvkonQgn_indi_marked_add, &listItem );
       
   120     
       
   121     CreateAndAppendIconL( KAknsIIDQgnPropMceWriteSub, EMbmMuiuQgn_prop_mce_write_sub, &listItem );
       
   122     CreateAndAppendIconL( KAknsIIDQgnPropMceRemoteSub, EMbmMuiuQgn_prop_mce_remote_sub, &listItem );
       
   123     CreateAndAppendIconL( KAknsIIDQgnPropMceRemoteNewSub, EMbmMuiuQgn_prop_mce_remote_new_sub, &listItem );
       
   124     CreateAndAppendIconL( KAknsIIDQgnPropMceDrSub, EMbmMuiuQgn_prop_mce_dr_sub, &listItem );
       
   125 
       
   126     listItem.iExtraItem = EFalse;
       
   127     listItem.iId = KMsvGlobalInBoxIndexEntryId;
       
   128     CreateAndAppendIconL( KAknsIIDQgnPropMceInboxSub, EMbmMuiuQgn_prop_mce_inbox_sub, &listItem );
       
   129     CreateAndAppendIconL( KAknsIIDQgnPropMceInboxNewSub, EMbmMuiuQgn_prop_mce_inbox_new_sub, &listItem );
       
   130 
       
   131     listItem.iId = KMceDocumentsEntryId;
       
   132     CreateAndAppendIconL( KAknsIIDQgnPropMceDocumentsSub, EMbmMuiuQgn_prop_mce_documents_sub, &listItem );
       
   133     CreateAndAppendIconL( KAknsIIDQgnPropMceDocumentsNewSub, EMbmMuiuQgn_prop_mce_documents_new_sub, &listItem );
       
   134 
       
   135     listItem.iId = KMsvDraftEntryId;
       
   136     CreateAndAppendIconL( KAknsIIDQgnPropMceDraftsSub, EMbmMuiuQgn_prop_mce_drafts_sub, &listItem );
       
   137     listItem.iId = KMsvSentEntryId;
       
   138     CreateAndAppendIconL( KAknsIIDQgnPropMceSentSub, EMbmMuiuQgn_prop_mce_sent_sub, &listItem );
       
   139     listItem.iId = KMsvGlobalOutBoxIndexEntryId;
       
   140     CreateAndAppendIconL( KAknsIIDQgnPropMceOutboxSub, EMbmMuiuQgn_prop_mce_outbox_sub, &listItem );
       
   141 
       
   142     listItem.iId = KErrNone;
       
   143     CreateAndAppendIconL( KAknsIIDQgnPropMceUnknownRead, EMbmMuiuQgn_prop_mce_unknown_read, &listItem );
       
   144 
       
   145     CreateAndAppendIconL( KAknsIIDQgnPropMceTemplate, iFilenameAvkon, EMbmAvkonQgn_prop_folder_temp, &listItem );
       
   146     CreateAndAppendIconL( KAknsIIDQgnPropFolderSmall, iFilenameAvkon, EMbmAvkonQgn_prop_folder_small, &listItem );
       
   147     CreateAndAppendIconL( KAknsIIDQgnPropFolderSmallNew, iFilenameAvkon, EMbmAvkonQgn_prop_folder_small_new, &listItem );
       
   148     CreateAndAppendIconL( KAknsIIDQgnIndiAttachementAdd, iFilenameMuiu, EMbmMuiuQgn_indi_attach_add, &listItem, ETrue );
       
   149     CreateAndAppendIconL( KAknsIIDQgnIndiConnectionOnAdd, iFilenameMuiu, EMbmMuiuQgn_indi_connection_on_add, &listItem, ETrue );
       
   150 
       
   151     CreateAndAppendIconL( KAknsIIDQgnIndiConnectionAlwaysAdd, iFilenameMuiu, EMbmMuiuQgn_indi_connection_always_add, &listItem, ETrue );
       
   152     CreateAndAppendIconL( KAknsIIDQgnIndiConnectionInactiveAdd, iFilenameMuiu, EMbmMuiuQgn_indi_connection_inactive_add, &listItem, ETrue );
       
   153     CreateAndAppendIconL( KAknsIIDQgnIndiConnectionInactiveAdd, iFilenameMuiu, EMbmMuiuQgn_indi_connection_on_roam_add, &listItem, ETrue );
       
   154     CreateAndAppendIconL( KAknsIIDQgnIndiMcePriorityHigh, iFilenameAvkon, EMbmAvkonQgn_indi_mce_priority_high, &listItem, ETrue );
       
   155     CreateAndAppendIconL( KAknsIIDQgnIndiMcePriorityLow, iFilenameAvkon, EMbmAvkonQgn_indi_mce_priority_low, &listItem, ETrue );
       
   156     
       
   157    _LIT( KMceExtraIconsDirAndFile,"MceExtraIcons.mbm" );
       
   158     TParse cvfp;
       
   159     cvfp.Set( KMceExtraIconsDirAndFile, &KDC_APP_BITMAP_DIR , NULL );
       
   160 
       
   161     listItem.iExtraItem = ETrue;
       
   162     CreateAndAppendIconL( KAknsIIDQgnPropImIbox,  cvfp.FullName(),  EMbmMceextraiconsQgn_prop_im_ibox , &listItem );
       
   163     CreateAndAppendIconL( KAknsIIDQgnPropImIboxNew,  cvfp.FullName(), EMbmMceextraiconsQgn_prop_im_ibox_new , &listItem );
       
   164     // add one dummy item which will be replaced when querying message items icons
       
   165     CreateAndAppendIconL( KAknsIIDQgnPropMceUnknownRead, EMbmMuiuQgn_prop_mce_unknown_read );
       
   166     
       
   167     iDescriptionLength = MceUtils::DescriptionLengthL();
       
   168     FeatureManager::InitializeLibL();
       
   169     iEmailFramework = EFalse;
       
   170     if ( FeatureManager::FeatureSupported( KFeatureIdFfEmailFramework ) )
       
   171         {
       
   172         iEmailFramework = ETrue;
       
   173         }
       
   174     FeatureManager::UnInitializeLib();
       
   175     }
       
   176 
       
   177 // ----------------------------------------------------
       
   178 // CMceBitmapResolver::CreateAndAppendIconL
       
   179 // ----------------------------------------------------
       
   180 void CMceBitmapResolver::CreateAndAppendIconL(  TAknsItemID aId, TInt aBitmapIndex, const TMceBitmapListItem* aListItem /* = NULL */ )
       
   181     {
       
   182     CreateAndAppendIconL( aId, iFilenameMuiu, aBitmapIndex, aListItem );
       
   183     }
       
   184 
       
   185 // ----------------------------------------------------
       
   186 // CMceBitmapResolver::CreateAndAppendIconL
       
   187 // ----------------------------------------------------
       
   188 void CMceBitmapResolver::CreateAndAppendIconL(
       
   189     TAknsItemID aId,
       
   190     const TDesC& aFileName,
       
   191     TInt aBitmapIndex,
       
   192     const TMceBitmapListItem* aListItem /* = NULL */,
       
   193     TBool aColorSkinnedIcon /*= EFalse */ )
       
   194     {
       
   195     MAknsSkinInstance* skins = AknsUtils::SkinInstance();
       
   196   
       
   197     CFbsBitmap* bitmap = NULL;
       
   198     CFbsBitmap* mask = NULL;
       
   199     
       
   200     if ( aListItem && 
       
   201          aListItem->iExtraItem && 
       
   202          aListItem->iType.iUid > 0 &&
       
   203          aListItem->iType.iUid != KUidMsvFolderEntryValue
       
   204        )
       
   205         {
       
   206         // this is extra item and it has application uid, try to load it!
       
   207         TUid uid = aListItem->iType;
       
   208         AknsUtils::CreateAppIconLC( 
       
   209             skins, 
       
   210             uid,
       
   211             EAknsAppIconTypeList, 
       
   212             bitmap,
       
   213             mask );
       
   214         CleanupStack::Pop(2);
       
   215         }
       
   216         
       
   217     if ( !bitmap )    
       
   218         {
       
   219         if ( aColorSkinnedIcon )
       
   220             {
       
   221             AknsUtils::CreateColorIconL(
       
   222                 skins, 
       
   223                 aId, 
       
   224                 KAknsIIDQsnIconColors,
       
   225                 EAknsCIQsnIconColorsCG13,
       
   226                 bitmap,
       
   227                 mask, 
       
   228                 aFileName, 
       
   229                 aBitmapIndex, 
       
   230                 aBitmapIndex + 1,
       
   231                 KRgbBlack);  
       
   232             }
       
   233         else
       
   234             {
       
   235             AknsUtils::CreateIconL( skins, aId, bitmap,
       
   236                 mask, aFileName, aBitmapIndex, aBitmapIndex + 1 );  
       
   237             }
       
   238         }
       
   239 
       
   240     CGulIcon* icon = CGulIcon::NewL( bitmap, mask );
       
   241   
       
   242     CleanupStack::PushL( icon );
       
   243     if ( aListItem && aListItem->iExtraItem && aListItem->iId >= KMceFirstExtraItemId )
       
   244         {
       
   245         iIcons->InsertL( iIconIndexes->Count(), icon );
       
   246         }
       
   247     else
       
   248         {
       
   249         iIcons->AppendL( icon );
       
   250         }
       
   251     CleanupStack::Pop( icon );
       
   252 
       
   253     if ( aListItem )
       
   254         {
       
   255         iIconIndexes->AppendL( *aListItem );
       
   256         }
       
   257     iBitmapsLoaded = iIconIndexes->Count();
       
   258     }
       
   259 
       
   260 
       
   261 // ----------------------------------------------------
       
   262 // CMceBitmapResolver::IconArray
       
   263 // ----------------------------------------------------
       
   264 CArrayPtrFlat<CGulIcon>* CMceBitmapResolver::IconArray()
       
   265     {
       
   266     return iIcons;
       
   267     }
       
   268 
       
   269 // ----------------------------------------------------
       
   270 // CMceBitmapResolver::BitmapIndex
       
   271 // ----------------------------------------------------
       
   272 TInt CMceBitmapResolver::BitmapIndex( const TMceBitmapListItem& aItem ) const
       
   273     {
       
   274     TInt foundIndex = KErrNotFound;
       
   275     if ( aItem.iExtraItem )
       
   276         {
       
   277         if ( aItem.iId == KMceWriteMessageId )
       
   278             {
       
   279             foundIndex = EMceBitmapIndexWrite;
       
   280             }
       
   281         else if ( aItem.iId == KMceDeliveryReportsId )
       
   282             {
       
   283             foundIndex = EMceBitmapIndexDr;
       
   284             }
       
   285         else if ( aItem.iId == KMceNoMailboxesListId )
       
   286             {
       
   287             foundIndex = EMceBitmapIndexRemote;
       
   288             }
       
   289         else
       
   290             {
       
   291             const TInt count = iIconIndexes->Count();
       
   292             for ( TInt i = 0; i < count; i++)
       
   293                 {
       
   294                 const TMceBitmapListItem item = (*iIconIndexes)[i];
       
   295                 if ( (*iIconIndexes)[i].iId == aItem.iId )
       
   296                     {
       
   297                     foundIndex = i;
       
   298                     }
       
   299                 }
       
   300             if ( foundIndex == KErrNotFound )
       
   301                 {
       
   302                 foundIndex = EMceBitmapIndexUnknown;
       
   303                 }
       
   304             }
       
   305         }
       
   306     if ( foundIndex == KErrNotFound &&
       
   307         aItem.iMtm.iUid == KUidMsvLocalServiceMtmValue &&
       
   308         aItem.iType.iUid == KUidMsvFolderEntryValue )
       
   309         {
       
   310         foundIndex = LocalEntryBitmapIndex( aItem.iId );
       
   311         }
       
   312 
       
   313     if ( foundIndex == KErrNotFound &&
       
   314          aItem.iType.iUid == KUidMsvServiceEntryValue )
       
   315         {
       
   316         // item is service entry (remote mailbox usually) so this
       
   317         // icon is loaded from mtm uid data when needed and
       
   318         // its index is last in icon array
       
   319         foundIndex = iIcons->Count()-1;
       
   320         }
       
   321 
       
   322     return ( foundIndex == KErrNotFound ?
       
   323         EMceBitmapIndexUnknown :
       
   324         foundIndex );
       
   325     }
       
   326 
       
   327 #ifndef RD_MSG_NAVIPANE_IMPROVEMENT
       
   328 // ----------------------------------------------------
       
   329 // CMceBitmapResolver::BitmapIndex
       
   330 // ----------------------------------------------------
       
   331 TInt CMceBitmapResolver::BitmapIndex( const TMsvEntry& aEntry )
       
   332     {
       
   333     TInt foundIndex = KErrNotFound;
       
   334     const TMsvId id = aEntry.Id();
       
   335     if ( aEntry.iMtm == KUidMsvLocalServiceMtm &&
       
   336          aEntry.iType == KUidMsvFolderEntry )
       
   337         {
       
   338         foundIndex = LocalEntryBitmapIndex( id );        
       
   339 
       
   340         // check if folder has unread messages
       
   341         if ( id ==  KMsvGlobalInBoxIndexEntryId ||
       
   342             id ==  KMceDocumentsEntryId ||
       
   343             id >= KFirstFreeEntryId
       
   344             )
       
   345             {
       
   346             TBool unreadMessages = EFalse;
       
   347             TRAPD(err, ( unreadMessages = HasUnreadMessagesL( id ) ) );
       
   348             if (err == KErrNone && unreadMessages )
       
   349                 {
       
   350                 foundIndex++;
       
   351                 }
       
   352             }
       
   353         }
       
   354 
       
   355     // special handling for remote mailboxes to make main view appear faster in startup
       
   356     if ( aEntry.iType == KUidMsvServiceEntry &&
       
   357          ( aEntry.iMtm == KSenduiMtmImap4Uid ||
       
   358            aEntry.iMtm == KSenduiMtmPop3Uid )
       
   359          )
       
   360         {
       
   361         foundIndex = EMceBitmapIndexRemote;
       
   362         TBool unreadMessages = EFalse;
       
   363         TRAPD(err, ( unreadMessages = HasUnreadMessagesL( id ) ) );
       
   364         if (err == KErrNone && unreadMessages )
       
   365             {
       
   366             foundIndex++;
       
   367             }
       
   368         }
       
   369 
       
   370     if ( foundIndex == KErrNotFound )
       
   371         {
       
   372         TRAPD(err, ( foundIndex = LoadBitmapL( aEntry ) ) );
       
   373         if (err != KErrNone )
       
   374             {
       
   375             foundIndex = KErrNotFound;
       
   376             }
       
   377         }
       
   378 
       
   379     return ( foundIndex == KErrNotFound ?
       
   380         EMceBitmapIndexUnknown : foundIndex );
       
   381     }
       
   382 
       
   383 #else
       
   384 // ----------------------------------------------------
       
   385 // CMceBitmapResolver::BitmapIndex
       
   386 // ----------------------------------------------------
       
   387 TInt CMceBitmapResolver::BitmapIndex( const TMsvEntry& aEntry )
       
   388     {
       
   389     TInt messageCount = 0;
       
   390     return BitmapIndex( aEntry, messageCount );
       
   391     }
       
   392 // ----------------------------------------------------
       
   393 // CMceBitmapResolver::BitmapIndex
       
   394 // ----------------------------------------------------
       
   395 TInt CMceBitmapResolver::BitmapIndex( const TMsvEntry& aEntry, TInt& aMessageCount )
       
   396     {
       
   397     TInt foundIndex = KErrNotFound;
       
   398     aMessageCount = 0;
       
   399     TInt unreadCount = 0;
       
   400     TBool unreadMessages = EFalse;
       
   401     const TMsvId id = aEntry.Id();
       
   402     if ( aEntry.iMtm == KUidMsvLocalServiceMtm &&
       
   403          aEntry.iType == KUidMsvFolderEntry )
       
   404         {
       
   405         foundIndex = LocalEntryBitmapIndex( id );        
       
   406 
       
   407         //Get count and check if inbox folder has  unread messages
       
   408         if ( id ==  KMsvGlobalInBoxIndexEntryId ||
       
   409             id ==  KMceDocumentsEntryId ||
       
   410             id == KMsvDraftEntryIdValue ||
       
   411             id == KMsvSentEntryIdValue ||
       
   412             id == KMsvGlobalOutBoxIndexEntryIdValue ||
       
   413             id >= KFirstFreeEntryId
       
   414             )
       
   415             {
       
   416             // In case of  inbox, need to know message count and is  
       
   417             // there at least one unread message. 
       
   418             // No need of unread count and sub folder checking
       
   419         
       
   420             if(id == KMsvGlobalInBoxIndexEntryId )
       
   421                 {
       
   422                 TRAPD(err, aMessageCount = 
       
   423                     FindVisibleCountWithUnreadMessageL(id, unreadMessages)); 
       
   424     
       
   425                 if (err == KErrNone && unreadMessages )
       
   426                     {
       
   427                     foundIndex++;
       
   428                     }
       
   429                 }
       
   430             // for Draft/outbox/sent no need to go for sub folder checking 
       
   431             // and unread count checking
       
   432             else if(id == KMsvDraftEntryIdValue ||
       
   433                id == KMsvSentEntryIdValue ||
       
   434                id == KMsvGlobalOutBoxIndexEntryIdValue)
       
   435                 {
       
   436                 TRAP_IGNORE(aMessageCount = FindVisibleCountL(id));                
       
   437                 }
       
   438             
       
   439             else if(id ==  KMceDocumentsEntryId)
       
   440                 {
       
   441                 // no logic change for draft
       
   442                 // need total count, including sub folder count
       
   443                 // need unread message info also to show proper icon.
       
   444                 TRAPD(err, ( unreadMessages = HasUnreadMessagesL( id, aMessageCount, unreadCount ) ) );
       
   445                 if (err == KErrNone && unreadMessages )
       
   446                     {
       
   447                     foundIndex++;
       
   448                     }
       
   449                 }
       
   450             }
       
   451         }
       
   452 
       
   453     // special handling for remote mailboxes to make main view appear faster in startup
       
   454     if ( aEntry.iType == KUidMsvServiceEntry &&
       
   455          ( aEntry.iMtm == KSenduiMtmImap4Uid ||
       
   456            aEntry.iMtm == KSenduiMtmPop3Uid )
       
   457          )
       
   458         {
       
   459         foundIndex = EMceBitmapIndexRemote;
       
   460         TRAPD(err, ( unreadMessages = HasUnreadMessagesL( id, aMessageCount, unreadCount ) ) );
       
   461         if (err == KErrNone && unreadMessages )
       
   462             {
       
   463             foundIndex++;
       
   464             }
       
   465         }
       
   466 
       
   467     if ( foundIndex == KErrNotFound )
       
   468         {
       
   469         TInt err = KErrNone;
       
   470         if ( aEntry.iType == KUidMsvServiceEntry ||
       
   471             aEntry.iType == KUidMsvFolderEntry)
       
   472             {
       
   473             TRAP(err, ( unreadMessages = HasUnreadMessagesL( id, aMessageCount, unreadCount ) ) );
       
   474             }
       
   475         TRAP(err, ( foundIndex = LoadBitmapL( aEntry, unreadCount ) ) );
       
   476         if (err != KErrNone )
       
   477             {
       
   478             foundIndex = KErrNotFound;
       
   479             }
       
   480         }
       
   481 
       
   482     return ( foundIndex == KErrNotFound ?
       
   483         EMceBitmapIndexUnknown : foundIndex );
       
   484     }
       
   485 #endif // RD_MSG_NAVIPANE_IMPROVEMENT
       
   486 // ----------------------------------------------------
       
   487 // CMceBitmapResolver::LoadBitmapL
       
   488 // ----------------------------------------------------
       
   489 #ifndef RD_MSG_NAVIPANE_IMPROVEMENT
       
   490 TInt CMceBitmapResolver::LoadBitmapL( const TMsvEntry& aEntry, TInt aPriority )
       
   491 #else
       
   492 TInt CMceBitmapResolver::LoadBitmapL( const TMsvEntry& aEntry, TBool aHasUnreadMessages )
       
   493 #endif
       
   494     {
       
   495     CBaseMtmUiData* uiData=iRegObserver.GetMtmUiDataL( aEntry.iMtm );
       
   496     if ( uiData )
       
   497         {
       
   498         TInt flags = 0;
       
   499         if ( aEntry.iType == KUidMsvServiceEntry ||
       
   500             aEntry.iType == KUidMsvFolderEntry)
       
   501             {
       
   502             TBool unreadMessages = EFalse;
       
   503             TInt err = KErrNone;
       
   504 #ifndef RD_MSG_NAVIPANE_IMPROVEMENT
       
   505             TRAP( err, ( unreadMessages = HasUnreadMessagesL( aEntry.Id() ) ) );
       
   506 #else
       
   507             unreadMessages = aHasUnreadMessages;
       
   508 #endif // RD_MSG_NAVIPANE_IMPROVEMENT
       
   509             
       
   510             // leave error codes are filtered, because it is not important to know
       
   511             // if there are unread messages or not, 
       
   512             // just different icon would be displayed
       
   513             if (err == KErrNone && unreadMessages )
       
   514                 {
       
   515                 flags = EMtudEntryStateOpen; // includes unread messages
       
   516                 }
       
   517 
       
   518             //check for sub folders           
       
   519 
       
   520             TMsvSelectionOrdering selectionOrdering( KMsvGroupByType, EMsvSortByNone, ETrue );
       
   521 	        CMsvEntry* entry = iSession->GetEntryL( aEntry.Id() );
       
   522             entry->SetSortTypeL( selectionOrdering ); 
       
   523             CleanupStack::PushL( entry );
       
   524             TInt index = entry->Count()-1;
       
   525             while ( ( index>=0 ) && ( (*entry)[index].iType != KUidMsvFolderEntry ) )
       
   526                 {
       
   527                 index--;
       
   528                 }
       
   529             CleanupStack::PopAndDestroy( entry );
       
   530             if( index != -1 )
       
   531                 {                
       
   532                 flags |= EMtudEntryStateSubFolder;
       
   533                 }
       
   534 
       
   535             }
       
   536 
       
   537         const CBaseMtmUiData::CBitmapArray* bitmaps = NULL;
       
   538         
       
   539 #ifndef RD_MSG_NAVIPANE_IMPROVEMENT
       
   540         if ( aPriority == KMceMmsPriority )
       
   541             {
       
   542             bitmaps = &uiData->ContextIcon( aEntry, ETrue );
       
   543             }
       
   544         else
       
   545             {
       
   546             bitmaps = &uiData->ContextIcon( aEntry, flags );
       
   547             }
       
   548 #else
       
   549         bitmaps = &uiData->ContextIcon( aEntry, flags );
       
   550             
       
   551 #endif        
       
   552  
       
   553         if ( bitmaps )
       
   554             {
       
   555             CGulIcon* tempBmp = NULL;
       
   556             
       
   557             if ( bitmaps->Count() == 1 )
       
   558                 {
       
   559                 tempBmp = CGulIcon::NewL( bitmaps->At( 0 ) );
       
   560                 }
       
   561             else if ( bitmaps->Count() > 1 )
       
   562                 {
       
   563                 tempBmp = CGulIcon::NewL( bitmaps->At( 0 ), bitmaps->At( 1 ) );
       
   564                 }
       
   565             
       
   566             if ( tempBmp )
       
   567                 {
       
   568                 CleanupStack::PushL( tempBmp );
       
   569                 tempBmp->SetBitmapsOwnedExternally( ETrue );
       
   570                 
       
   571 #ifndef RD_MSG_NAVIPANE_IMPROVEMENT
       
   572                 if ( aPriority == KMceMmsPriority )
       
   573                     {
       
   574                     iIcons->AppendL( tempBmp );
       
   575                     }
       
   576                 else
       
   577                     {
       
   578                     TInt index = iIcons->Count() - 1;
       
   579                     iIcons->AppendL( tempBmp ); // Array will be of count 22
       
   580                     // index greater than 20 so 21 or 22
       
   581                     if ( index > iBitmapsLoaded )
       
   582                         {
       
   583                         while ( iIcons->Count() != iBitmapsLoaded+1 )
       
   584                             {
       
   585                             CGulIcon* iconToBeDelete = iIcons->At( index );
       
   586                             iIcons->Delete( index );
       
   587                             delete iconToBeDelete;
       
   588                             index--;
       
   589                             }
       
   590                         }
       
   591                     else
       
   592                         {
       
   593                         CGulIcon* iconToBeDelete = iIcons->At( index );
       
   594                         iIcons->Delete( index );
       
   595                         delete iconToBeDelete;
       
   596                         }
       
   597                     }
       
   598 #else
       
   599                 TInt index = iIcons->Count() - 1;
       
   600                 iIcons->AppendL( tempBmp ); // Array will be of count 22
       
   601                 // index greater than 20 so 21 or 22
       
   602                 if ( index > iBitmapsLoaded )
       
   603                     {
       
   604                     while ( iIcons->Count() != iBitmapsLoaded+1 )
       
   605                         {
       
   606                         CGulIcon* iconToBeDelete = iIcons->At( index );
       
   607                         iIcons->Delete( index );
       
   608                         delete iconToBeDelete;
       
   609                         index--;
       
   610                         }
       
   611                     }
       
   612                 else
       
   613                     {
       
   614                     CGulIcon* iconToBeDelete = iIcons->At( index );
       
   615                     iIcons->Delete( index );
       
   616                     delete iconToBeDelete;
       
   617                     }
       
   618                     
       
   619 
       
   620 #endif                
       
   621                 CleanupStack::Pop(); // tempBmp
       
   622                 }
       
   623             }
       
   624         else
       
   625             {
       
   626             return KErrNotFound;
       
   627             }
       
   628         }
       
   629     else
       
   630         {
       
   631         // something is wrong
       
   632         return EMceBitmapIndexUnknown;
       
   633         }
       
   634     return iIcons->Count() - 1;
       
   635     }
       
   636 
       
   637 #ifndef RD_MSG_NAVIPANE_IMPROVEMENT
       
   638 // ----------------------------------------------------
       
   639 // CMceBitmapResolver::HasUnreadMessagesL
       
   640 // ----------------------------------------------------
       
   641 TBool CMceBitmapResolver::HasUnreadMessagesL( const TMsvId aId )
       
   642     {
       
   643     TBool unreadMessages = EFalse;
       
   644     CMsvEntry* entry = iSession->GetEntryL( aId );
       
   645     CleanupStack::PushL( entry );
       
   646 
       
   647     const TInt count = entry->Count();
       
   648     for ( TInt loop = 0; !unreadMessages && loop < count; loop++ )
       
   649         {
       
   650         if ( (*entry)[loop].iType.iUid == KUidMsvFolderEntryValue )
       
   651             {
       
   652             unreadMessages = HasUnreadMessagesL( (*entry)[loop].Id() );
       
   653             }
       
   654         else
       
   655             {
       
   656             unreadMessages = (*entry)[loop].Unread();
       
   657             }
       
   658         }
       
   659 
       
   660     CleanupStack::PopAndDestroy( entry );
       
   661 
       
   662     return unreadMessages;
       
   663     }
       
   664 #else
       
   665 
       
   666 // ----------------------------------------------------
       
   667 // CMceBitmapResolver::HasUnreadMessagesL
       
   668 // ----------------------------------------------------
       
   669 TBool CMceBitmapResolver::HasUnreadMessagesL( 
       
   670     const TMsvId aFolderId, TInt& aMessages, TInt& aUnreadMessages )
       
   671     {
       
   672     CMsvEntry* entry = iSession->GetEntryL( aFolderId );
       
   673     CleanupStack::PushL( entry );
       
   674 
       
   675     const TInt count = entry->Count();
       
   676     for ( TInt loop = 0; loop < count; loop++ )
       
   677         {
       
   678         const TMsvEntry& tEntry = (*entry)[loop];
       
   679         if ( tEntry.iType == KUidMsvFolderEntry )
       
   680             {
       
   681             HasUnreadMessagesL( tEntry.Id(), aMessages, aUnreadMessages );
       
   682             }
       
   683         else if ( tEntry.iType == KUidMsvMessageEntry )
       
   684             {
       
   685             aMessages++;
       
   686             if ( tEntry.Unread() )
       
   687                 {
       
   688                 aUnreadMessages++;
       
   689                 }
       
   690             }
       
   691         }
       
   692 
       
   693     CleanupStack::PopAndDestroy(entry); // entry
       
   694     return aUnreadMessages;
       
   695     }
       
   696     
       
   697 #endif // RD_MSG_NAVIPANE_IMPROVEMENT
       
   698 
       
   699 // ----------------------------------------------------
       
   700 // CMceBitmapResolver::LocalEntryBitmapIndex
       
   701 // ----------------------------------------------------
       
   702 TInt CMceBitmapResolver::LocalEntryBitmapIndex( TMsvId aEntryId ) const
       
   703     {
       
   704     TInt foundIndex = EMceBitmapIndexFolderSmall;
       
   705     switch( aEntryId )
       
   706         {
       
   707         case KMsvGlobalInBoxIndexEntryId:
       
   708             foundIndex = EMceBitmapIndexInbox;
       
   709             break;
       
   710         case KMsvGlobalOutBoxIndexEntryId:
       
   711             foundIndex = EMceBitmapIndexOutbox;
       
   712             break;
       
   713         case KMsvDraftEntryId:
       
   714             foundIndex = EMceBitmapIndexDrafts;
       
   715             break;
       
   716         case KMsvSentEntryId:
       
   717             foundIndex = EMceBitmapIndexSent;
       
   718             break;
       
   719         case KMceDocumentsEntryId:
       
   720             foundIndex = EMceBitmapIndexDocuments;
       
   721             break;
       
   722         case KMceTemplatesEntryId:
       
   723             foundIndex = EMceBitmapIndexFolderTemp;
       
   724             break;
       
   725         default:
       
   726             // set in foundIndex declaration
       
   727             break;
       
   728         }
       
   729     return foundIndex;
       
   730     }
       
   731 
       
   732 // ----------------------------------------------------
       
   733 // CMceBitmapResolver::ChangeBitmapInIconArrayL
       
   734 // ----------------------------------------------------
       
   735 void CMceBitmapResolver::ChangeBitmapInIconArrayL(  )
       
   736     {   
       
   737     TBool colorSkinnedBitmap = EFalse;
       
   738     TAknsItemID id; 
       
   739     id.iMajor = 0;
       
   740     id.iMinor = 0;
       
   741     TMceBitmapListItem bitmapListItem;
       
   742 
       
   743     TInt count = iIcons->Count();
       
   744     TInt bitmapIndex = 0;
       
   745     TPtrC fileName( iFilenameMuiu );
       
   746     MAknsSkinInstance* skins = AknsUtils::SkinInstance();
       
   747 
       
   748     for ( TInt cc=count; --cc>=0; )
       
   749         {
       
   750         colorSkinnedBitmap = EFalse;
       
   751         switch( cc )
       
   752             {
       
   753             case EMceBitmapIndexWrite:
       
   754                 fileName.Set( iFilenameMuiu );
       
   755                 bitmapIndex = EMbmMuiuQgn_prop_mce_write_sub;
       
   756                 id = KAknsIIDQgnPropMceWriteSub;
       
   757                 break;
       
   758             case EMceBitmapIndexRemote:
       
   759                 fileName.Set( iFilenameMuiu );
       
   760                 bitmapIndex = EMbmMuiuQgn_prop_mce_remote_sub;
       
   761                 id = KAknsIIDQgnPropMceRemoteSub;
       
   762                 break;
       
   763             case EMceBitmapIndexRemoteNew:
       
   764                 fileName.Set( iFilenameMuiu );
       
   765                 bitmapIndex = EMbmMuiuQgn_prop_mce_remote_new_sub;
       
   766                 id = KAknsIIDQgnPropMceRemoteNewSub;
       
   767                 break;
       
   768             case EMceBitmapIndexDr:
       
   769                 fileName.Set( iFilenameMuiu );
       
   770                 bitmapIndex = EMbmMuiuQgn_prop_mce_dr_sub;
       
   771                 id = KAknsIIDQgnPropMceDrSub;
       
   772                 break;
       
   773             case EMceBitmapIndexInbox:
       
   774                 fileName.Set( iFilenameMuiu );
       
   775                 bitmapIndex = EMbmMuiuQgn_prop_mce_inbox_sub;
       
   776                 id = KAknsIIDQgnPropMceInboxSub;
       
   777                 break;
       
   778             case EMceBitmapIndexInboxNew:
       
   779                 fileName.Set( iFilenameMuiu );
       
   780                 bitmapIndex = EMbmMuiuQgn_prop_mce_inbox_new_sub;
       
   781                 id = KAknsIIDQgnPropMceInboxNewSub;
       
   782                 break;
       
   783             case EMceBitmapIndexDocuments:
       
   784                 fileName.Set( iFilenameMuiu );
       
   785                 bitmapIndex = EMbmMuiuQgn_prop_mce_documents_sub;
       
   786                 id = KAknsIIDQgnPropMceDocumentsSub;
       
   787                 break;
       
   788             case EMceBitmapIndexDocumentsNew:
       
   789                 fileName.Set( iFilenameMuiu );
       
   790                 bitmapIndex = EMbmMuiuQgn_prop_mce_documents_new_sub;
       
   791                 id = KAknsIIDQgnPropMceDocumentsNewSub;            
       
   792                 break;
       
   793             case EMceBitmapIndexDrafts:
       
   794                 fileName.Set( iFilenameMuiu );
       
   795                 bitmapIndex = EMbmMuiuQgn_prop_mce_drafts_sub;
       
   796                 id = KAknsIIDQgnPropMceDraftsSub;
       
   797                 break;
       
   798             case EMceBitmapIndexSent:
       
   799                 fileName.Set( iFilenameMuiu );
       
   800                 bitmapIndex = EMbmMuiuQgn_prop_mce_sent_sub;
       
   801                 id = KAknsIIDQgnPropMceSentSub;
       
   802                 break;
       
   803             case EMceBitmapIndexOutbox:
       
   804                 fileName.Set( iFilenameMuiu );
       
   805                 bitmapIndex = EMbmMuiuQgn_prop_mce_outbox_sub;
       
   806                 id = KAknsIIDQgnPropMceOutboxSub;
       
   807                 break;
       
   808             case EMceBitmapIndexUnknown:
       
   809                 fileName.Set( iFilenameMuiu );
       
   810                 bitmapIndex = EMbmMuiuQgn_prop_mce_unknown_read;
       
   811                 id = KAknsIIDQgnPropMceUnknownRead;
       
   812                 break;
       
   813             case EMceBitmapIndexFolderTemp:
       
   814                 fileName.Set( iFilenameAvkon );
       
   815                 bitmapIndex = EMbmAvkonQgn_prop_folder_temp;
       
   816                 id = KAknsIIDQgnPropMceTemplate;
       
   817                 break;
       
   818             case EMceBitmapIndexFolderSmall:
       
   819                 fileName.Set( iFilenameAvkon );
       
   820                 bitmapIndex = EMbmAvkonQgn_prop_folder_small;
       
   821                 id = KAknsIIDQgnPropFolderSmall;
       
   822                 break;
       
   823             case EMceBitmapIndexFolderSmallNew:
       
   824                 fileName.Set( iFilenameAvkon );
       
   825                 bitmapIndex = EMbmAvkonQgn_prop_folder_small_new;
       
   826                 id = KAknsIIDQgnPropFolderSmallNew;
       
   827                 break;
       
   828             case EMceBitmapIndexAttachment:
       
   829                 fileName.Set( iFilenameMuiu );
       
   830                 bitmapIndex = EMbmMuiuQgn_indi_attach_add;
       
   831                 id = KAknsIIDQgnIndiAttachementAdd;
       
   832                 colorSkinnedBitmap = ETrue;
       
   833                 break;
       
   834             case EMceBitmapIndexMailboxConnectionOn:
       
   835                 fileName.Set( iFilenameMuiu );
       
   836                 bitmapIndex = EMbmMuiuQgn_indi_connection_on_add;
       
   837                 id = KAknsIIDQgnIndiConnectionOnAdd;
       
   838                 colorSkinnedBitmap = ETrue;
       
   839                 break;
       
   840             case EMceBitmapIndexMessageSelected:
       
   841                 fileName.Set( iFilenameAvkon );
       
   842                 bitmapIndex = EMbmAvkonQgn_indi_marked_add;
       
   843                 id = KAknsIIDQgnIndiMarkedAdd;
       
   844                 colorSkinnedBitmap = ETrue;
       
   845                 break;
       
   846             case EMceBitmapIndexAlwaysAdd:
       
   847                 fileName.Set( iFilenameMuiu );
       
   848                 bitmapIndex = EMbmMuiuQgn_indi_connection_always_add;
       
   849                 id = KAknsIIDQgnIndiConnectionAlwaysAdd;
       
   850                 colorSkinnedBitmap = ETrue;
       
   851                 break;
       
   852             case EMceBitmapIndexAlwaysRoaming:
       
   853                 fileName.Set( iFilenameMuiu );
       
   854                 bitmapIndex = EMbmMuiuQgn_indi_connection_on_roam_add;
       
   855                 id = KAknsIIDQgnIndiConnectionInactiveAdd;
       
   856                 colorSkinnedBitmap = ETrue;
       
   857                 break;
       
   858             case EMceBitmapIndexPriorityHigh:
       
   859                 fileName.Set( iFilenameAvkon );
       
   860                 bitmapIndex = EMbmAvkonQgn_indi_mce_priority_high;
       
   861                 id = KAknsIIDQgnIndiMcePriorityHigh;
       
   862                 colorSkinnedBitmap = ETrue;
       
   863                 break;
       
   864             case EMceBitmapIndexPriorityLow:
       
   865                 fileName.Set( iFilenameAvkon );
       
   866                 bitmapIndex = EMbmAvkonQgn_indi_mce_priority_low;
       
   867                 id = KAknsIIDQgnIndiMcePriorityLow;
       
   868                 colorSkinnedBitmap = ETrue;
       
   869                 break;
       
   870             case EMceBitmapIndexInactiveAdd:
       
   871                 fileName.Set( iFilenameMuiu );
       
   872                 bitmapIndex = EMbmMuiuQgn_indi_connection_inactive_add;
       
   873                 id = KAknsIIDQgnIndiConnectionInactiveAdd;
       
   874                 colorSkinnedBitmap = ETrue;
       
   875                 break;
       
   876             case EMceBitmapIndexConversation:
       
   877                   {
       
   878                   _LIT( KMceExtraIconsDirAndFile,"MceExtraIcons.mbm" );
       
   879                   TParse cvfp;
       
   880                   cvfp.Set(KMceExtraIconsDirAndFile, &KDC_APP_BITMAP_DIR, NULL );
       
   881                   fileName.Set(cvfp.FullName());
       
   882                   bitmapIndex = EMbmMceextraiconsQgn_prop_im_ibox;
       
   883                   id = KAknsIIDQgnPropImIbox;      
       
   884                   colorSkinnedBitmap = EFalse;
       
   885                   }
       
   886                   break;
       
   887                   
       
   888             case EMceBitmapIndexConversationNew:
       
   889                  {
       
   890                 _LIT( KMceExtraIconsDirAndFile,"MceExtraIcons.mbm" );
       
   891                   TParse cvfp;
       
   892                   cvfp.Set(KMceExtraIconsDirAndFile, &KDC_APP_BITMAP_DIR, NULL );
       
   893                   fileName.Set(cvfp.FullName());
       
   894                   bitmapIndex = EMbmMceextraiconsQgn_prop_im_ibox_new;
       
   895                   id = KAknsIIDQgnPropImIboxNew; 
       
   896                   colorSkinnedBitmap = EFalse;
       
   897                  }
       
   898                 break;
       
   899             case EMceBitmapIndexReplaceMtmIcon:
       
   900             default:
       
   901                 fileName.Set( iFilenameMuiu );
       
   902                 bitmapIndex = EMbmMuiuQgn_prop_mce_unknown_read;
       
   903                 id = KAknsIIDQgnPropMceUnknownRead;
       
   904                 break;
       
   905             } 
       
   906         
       
   907         if ( cc < iIconIndexes->Count() )
       
   908             {
       
   909             bitmapListItem = (*iIconIndexes)[cc];
       
   910             }
       
   911         else
       
   912             {
       
   913             bitmapListItem.iExtraItem = EFalse;
       
   914             }
       
   915         
       
   916         CFbsBitmap* bitmap = NULL;
       
   917         CFbsBitmap* mask = NULL;
       
   918         
       
   919         if ( bitmapListItem.iExtraItem &&
       
   920              bitmapListItem.iId >= KMceFirstExtraItemId
       
   921            )
       
   922             {
       
   923             if ( bitmapListItem.iType.iUid > 0 &&
       
   924                  bitmapListItem.iType.iUid != KUidMsvFolderEntryValue )
       
   925                 {
       
   926                 // this is extra item and it has application uid, try to load it!
       
   927                 TUid uid = bitmapListItem.iType;
       
   928                 AknsUtils::CreateAppIconLC( 
       
   929                     skins, 
       
   930                     uid,
       
   931                     EAknsAppIconTypeList, 
       
   932                     bitmap,
       
   933                     mask );
       
   934                 CleanupStack::Pop(2);
       
   935                 }
       
   936             else
       
   937                 {
       
   938                 // do no changes, this is extremly dirty way but once in the lifetime...
       
   939                 continue;
       
   940                 }
       
   941             }
       
   942             
       
   943         if ( !bitmap )
       
   944             {
       
   945             if ( colorSkinnedBitmap )
       
   946                 {
       
   947                 TRgb rgb; // What to add here?
       
   948                         
       
   949                 AknsUtils::CreateColorIconL(
       
   950                     skins, 
       
   951                     id, 
       
   952                     KAknsIIDQsnIconColors,
       
   953                     EAknsCIQsnIconColorsCG13,
       
   954                     bitmap,
       
   955                     mask, 
       
   956                     fileName, 
       
   957                     bitmapIndex, 
       
   958                     bitmapIndex + 1,
       
   959                     rgb );  
       
   960                 
       
   961                 }
       
   962             else
       
   963                 {
       
   964                 AknsUtils::CreateIconL( skins, id, bitmap,
       
   965                 mask, fileName, bitmapIndex, bitmapIndex + 1 );
       
   966                 }
       
   967             }
       
   968 
       
   969 
       
   970         CGulIcon* icon = CGulIcon::NewL( bitmap, mask );
       
   971      
       
   972         CleanupStack::PushL( icon );
       
   973         CGulIcon* iconToBeDelete = iIcons->At( cc );
       
   974         iIcons->At( cc ) = icon;
       
   975         delete iconToBeDelete;
       
   976         iconToBeDelete = NULL;
       
   977 
       
   978         CleanupStack::Pop( icon );
       
   979     
       
   980         }  
       
   981     }
       
   982 
       
   983 // ----------------------------------------------------
       
   984 // CMceBitmapResolver::LocalEntryBitmapIndex
       
   985 // ----------------------------------------------------
       
   986 TInt CMceBitmapResolver::MtmIconIndex()
       
   987     {
       
   988     return iBitmapsLoaded;
       
   989     }
       
   990 
       
   991 // ----------------------------------------------------
       
   992 // CMceBitmapResolver::DescriptionLength
       
   993 // ----------------------------------------------------
       
   994 TInt CMceBitmapResolver::DescriptionLength()
       
   995     {
       
   996     return iDescriptionLength;
       
   997     }
       
   998 
       
   999 #ifdef RD_MSG_NAVIPANE_IMPROVEMENT
       
  1000 // ----------------------------------------------------
       
  1001 // CMceBitmapResolver::FindVisibleCountL
       
  1002 // ----------------------------------------------------
       
  1003 TInt CMceBitmapResolver::FindVisibleCountL(TMsvId aFolderId ) const
       
  1004     {
       
  1005     // This function can be optimzied further 
       
  1006     // after the new optimized API from message store
       
  1007     // This is applicable for Draft\sent\outbox
       
  1008     
       
  1009     TInt visiblecount=0;
       
  1010     TInt emailcount=0;
       
  1011     TInt itemcount;
       
  1012     
       
  1013     // Cmail message count needs to be filtered 
       
  1014     CMsvEntry* entry = iSession->GetEntryL( aFolderId );
       
  1015     CleanupStack::PushL( entry );
       
  1016     itemcount=entry->Count();
       
  1017          
       
  1018     //Find email messages 
       
  1019     CMsvEntrySelection *smtpselection = entry->ChildrenWithMtmL( KUidMsgTypeSMTP );
       
  1020     CleanupStack::PushL( smtpselection );
       
  1021 
       
  1022     CMsvEntrySelection *pop3selection = NULL;
       
  1023     CMsvEntrySelection *imapselection = NULL ;
       
  1024     CMsvEntrySelection *cmailselection = NULL ;
       
  1025     
       
  1026     if(!iEmailFramework)
       
  1027         {
       
  1028         pop3selection = entry->ChildrenWithMtmL( KUidMsgTypePOP3 );
       
  1029         CleanupStack::PushL( pop3selection );
       
  1030         imapselection = entry->ChildrenWithMtmL( KUidMsgTypeIMAP4 );
       
  1031         CleanupStack::PushL( imapselection );
       
  1032         }
       
  1033     else
       
  1034         {
       
  1035         cmailselection = entry->ChildrenWithMtmL( 
       
  1036                 TUid::Uid(KUidMsgTypeFsMtmVal));
       
  1037         CleanupStack::PushL( cmailselection );
       
  1038         }
       
  1039 
       
  1040     if ( smtpselection!=0 && smtpselection->Count()>0 )
       
  1041         {
       
  1042         emailcount=emailcount+smtpselection->Count();
       
  1043         }
       
  1044 
       
  1045     if(!iEmailFramework)
       
  1046         {
       
  1047         if ( pop3selection!=0 && pop3selection->Count()>0 )
       
  1048             {
       
  1049             emailcount=emailcount+pop3selection->Count();
       
  1050             }
       
  1051         if ( imapselection!=0 && imapselection->Count()>0 )
       
  1052             {
       
  1053             emailcount=emailcount+imapselection->Count();
       
  1054             }        
       
  1055         }
       
  1056     else
       
  1057         {
       
  1058         if ( cmailselection!=0 && cmailselection->Count()>0 )
       
  1059             {
       
  1060             emailcount=emailcount+cmailselection->Count();
       
  1061             }
       
  1062         }
       
  1063 
       
  1064     visiblecount = itemcount - emailcount;
       
  1065 
       
  1066     if(iEmailFramework)
       
  1067         {
       
  1068         CleanupStack::PopAndDestroy( cmailselection );       
       
  1069         }
       
  1070     else
       
  1071         {
       
  1072         CleanupStack::PopAndDestroy(imapselection);
       
  1073         CleanupStack::PopAndDestroy( pop3selection );
       
  1074         }
       
  1075     CleanupStack::PopAndDestroy( smtpselection );
       
  1076     CleanupStack::PopAndDestroy( entry );
       
  1077     return visiblecount; 
       
  1078     }
       
  1079 
       
  1080 // ----------------------------------------------------
       
  1081 // CMceBitmapResolver::FindVisibleCountWithUnreadMessageL
       
  1082 // ----------------------------------------------------
       
  1083 TInt CMceBitmapResolver::FindVisibleCountWithUnreadMessageL(TMsvId aFolderId 
       
  1084                                              , TBool& aUnreadMessages) const
       
  1085     {
       
  1086     // This function can be optimzied further 
       
  1087     // after the new optimized API from message store
       
  1088     // This is applicable for Inbox
       
  1089     
       
  1090     aUnreadMessages = EFalse;    
       
  1091     TInt itemcount;
       
  1092     CMsvEntry* entry = iSession->GetEntryL( aFolderId );
       
  1093     CleanupStack::PushL( entry );
       
  1094     itemcount=entry->Count();
       
  1095         
       
  1096     // No need of cmail filtering, because Mailbox has its own
       
  1097     // Inbox folder    
       
  1098     // Check at least one Unread message
       
  1099     for ( TInt loop = 0; loop < itemcount; loop++ )
       
  1100         {
       
  1101         const TMsvEntry& tEntry = (*entry)[loop];
       
  1102         if ( tEntry.iType == KUidMsvMessageEntry )
       
  1103             {
       
  1104             if ( tEntry.Unread() )
       
  1105                 {
       
  1106                 aUnreadMessages= ETrue;
       
  1107                 break;
       
  1108                 }
       
  1109             }
       
  1110          }
       
  1111     CleanupStack::PopAndDestroy( entry );
       
  1112     
       
  1113     return itemcount; 
       
  1114     }
       
  1115 
       
  1116 #endif //RD_MSG_NAVIPANE_IMPROVEMENT
       
  1117 //  End of File