messagingappbase/mce/src/MceBitmapResolver.cpp
branchRCL_3
changeset 28 fbb813aef148
parent 22 52d61119153d
equal deleted inserted replaced
24:e00582ce7ecd 28:fbb813aef148
    23 // INCLUDE FILES
    23 // INCLUDE FILES
    24 #include <mtudcbas.h>       // cbasemtmuidata
    24 #include <mtudcbas.h>       // cbasemtmuidata
    25 #include "MtmRegistryObserver.h" // mmtmuidataregistryobserver
    25 #include "MtmRegistryObserver.h" // mmtmuidataregistryobserver
    26 #include <msvuids.h>
    26 #include <msvuids.h>
    27 #include <msvids.h>         // fixed entry ids
    27 #include <msvids.h>         // fixed entry ids
       
    28 #include <MTMStore.h>       // cmtmstore
       
    29 #include <miutset.h>
    28 #include <gulicon.h>        // CGulIcon
    30 #include <gulicon.h>        // CGulIcon
    29 #include <AknIconArray.h>   // cakniconarray
    31 #include <AknIconArray.h>   // cakniconarray
    30 #include <fbs.h>            // CFbsFont
    32 #include <fbs.h>            // CFbsFont
    31 #include <muiu.mbg>         // bitmap enums
    33 #include <muiu.mbg>         // bitmap enums
    32 #include <avkon.mbg>        // bitmap enums
    34 #include <avkon.mbg>        // bitmap enums
    33 #include <mtud.hrh>         // EMtudEntryStateOpen
    35 #include <mtud.hrh>         // EMtudEntryStateOpen
    34 #include <SenduiMtmUids.h>  // mtm uids
    36 #include <SenduiMtmUids.h>  // mtm uids
       
    37 #include <bldvariant.hrh>
       
    38 #include <featmgr.h>
    35 #include "MceUtils.h"
    39 #include "MceUtils.h"
    36 #include "MceListItem.h"
    40 #include "MceListItem.h"
    37 #include "MceBitmapResolver.h"
    41 #include "MceBitmapResolver.h"
    38 #include "MceIds.h"         //kmcedocumentsentryid
    42 #include "MceIds.h"         //kmcedocumentsentryid
    39 #include <mceextraicons.mbg>
    43 #include <mceextraicons.mbg>
    40 // security data caging
    44 // security data caging
    41 #include <data_caging_path_literals.hrh>
    45 #include <data_caging_path_literals.hrh>
    42 #include <bldvariant.hrh>
       
    43 #include <AknIconUtils.h>
    46 #include <AknIconUtils.h>
    44 
    47 
    45 
    48 
    46 // LOCAL CONSTANTS AND MACROS
    49 // LOCAL CONSTANTS AND MACROS
    47 
    50 
   146     CreateAndAppendIconL( KAknsIIDQgnIndiConnectionOnAdd, iFilenameMuiu, EMbmMuiuQgn_indi_connection_on_add, &listItem, ETrue );
   149     CreateAndAppendIconL( KAknsIIDQgnIndiConnectionOnAdd, iFilenameMuiu, EMbmMuiuQgn_indi_connection_on_add, &listItem, ETrue );
   147 
   150 
   148     CreateAndAppendIconL( KAknsIIDQgnIndiConnectionAlwaysAdd, iFilenameMuiu, EMbmMuiuQgn_indi_connection_always_add, &listItem, ETrue );
   151     CreateAndAppendIconL( KAknsIIDQgnIndiConnectionAlwaysAdd, iFilenameMuiu, EMbmMuiuQgn_indi_connection_always_add, &listItem, ETrue );
   149     CreateAndAppendIconL( KAknsIIDQgnIndiConnectionInactiveAdd, iFilenameMuiu, EMbmMuiuQgn_indi_connection_inactive_add, &listItem, ETrue );
   152     CreateAndAppendIconL( KAknsIIDQgnIndiConnectionInactiveAdd, iFilenameMuiu, EMbmMuiuQgn_indi_connection_inactive_add, &listItem, ETrue );
   150     CreateAndAppendIconL( KAknsIIDQgnIndiConnectionInactiveAdd, iFilenameMuiu, EMbmMuiuQgn_indi_connection_on_roam_add, &listItem, ETrue );
   153     CreateAndAppendIconL( KAknsIIDQgnIndiConnectionInactiveAdd, iFilenameMuiu, EMbmMuiuQgn_indi_connection_on_roam_add, &listItem, ETrue );
   151     CreateAndAppendIconL( KAknsIIDQgnIndiMcePriorityHigh, iFilenameAvkon, EMbmAvkonQgn_indi_mce_priority_high, &listItem );
   154     CreateAndAppendIconL( KAknsIIDQgnIndiMcePriorityHigh, iFilenameAvkon, EMbmAvkonQgn_indi_mce_priority_high, &listItem, ETrue );
   152     CreateAndAppendIconL( KAknsIIDQgnIndiMcePriorityLow, iFilenameAvkon, EMbmAvkonQgn_indi_mce_priority_low, &listItem );
   155     CreateAndAppendIconL( KAknsIIDQgnIndiMcePriorityLow, iFilenameAvkon, EMbmAvkonQgn_indi_mce_priority_low, &listItem, ETrue );
   153     
   156     
   154    _LIT( KMceExtraIconsDirAndFile,"MceExtraIcons.mbm" );
   157    _LIT( KMceExtraIconsDirAndFile,"MceExtraIcons.mbm" );
   155     TParse cvfp;
   158     TParse cvfp;
   156     cvfp.Set( KMceExtraIconsDirAndFile, &KDC_APP_BITMAP_DIR , NULL );
   159     cvfp.Set( KMceExtraIconsDirAndFile, &KDC_APP_BITMAP_DIR , NULL );
   157 
   160 
   160     CreateAndAppendIconL( KAknsIIDQgnPropImIboxNew,  cvfp.FullName(), EMbmMceextraiconsQgn_prop_im_ibox_new , &listItem );
   163     CreateAndAppendIconL( KAknsIIDQgnPropImIboxNew,  cvfp.FullName(), EMbmMceextraiconsQgn_prop_im_ibox_new , &listItem );
   161     // add one dummy item which will be replaced when querying message items icons
   164     // add one dummy item which will be replaced when querying message items icons
   162     CreateAndAppendIconL( KAknsIIDQgnPropMceUnknownRead, EMbmMuiuQgn_prop_mce_unknown_read );
   165     CreateAndAppendIconL( KAknsIIDQgnPropMceUnknownRead, EMbmMuiuQgn_prop_mce_unknown_read );
   163     
   166     
   164     iDescriptionLength = MceUtils::DescriptionLengthL();
   167     iDescriptionLength = MceUtils::DescriptionLengthL();
       
   168     FeatureManager::InitializeLibL();
       
   169     iEmailFramework = EFalse;
       
   170     if ( FeatureManager::FeatureSupported( KFeatureIdFfEmailFramework ) )
       
   171         {
       
   172         iEmailFramework = ETrue;
       
   173         }
       
   174     FeatureManager::UnInitializeLib();
   165     }
   175     }
   166 
   176 
   167 // ----------------------------------------------------
   177 // ----------------------------------------------------
   168 // CMceBitmapResolver::CreateAndAppendIconL
   178 // CMceBitmapResolver::CreateAndAppendIconL
   169 // ----------------------------------------------------
   179 // ----------------------------------------------------
   206         
   216         
   207     if ( !bitmap )    
   217     if ( !bitmap )    
   208         {
   218         {
   209         if ( aColorSkinnedIcon )
   219         if ( aColorSkinnedIcon )
   210             {
   220             {
   211             TRgb rgb; // What to add here?
       
   212                     
       
   213             AknsUtils::CreateColorIconL(
   221             AknsUtils::CreateColorIconL(
   214                 skins, 
   222                 skins, 
   215                 aId, 
   223                 aId, 
   216                 KAknsIIDQsnIconColors,
   224                 KAknsIIDQsnIconColors,
   217                 EAknsCIQsnIconColorsCG13,
   225                 EAknsCIQsnIconColorsCG13,
   218                 bitmap,
   226                 bitmap,
   219                 mask, 
   227                 mask, 
   220                 aFileName, 
   228                 aFileName, 
   221                 aBitmapIndex, 
   229                 aBitmapIndex, 
   222                 aBitmapIndex + 1,
   230                 aBitmapIndex + 1,
   223                 rgb );  
   231                 KRgbBlack);  
   224             }
   232             }
   225         else
   233         else
   226             {
   234             {
   227             AknsUtils::CreateIconL( skins, aId, bitmap,
   235             AknsUtils::CreateIconL( skins, aId, bitmap,
   228                 mask, aFileName, aBitmapIndex, aBitmapIndex + 1 );  
   236                 mask, aFileName, aBitmapIndex, aBitmapIndex + 1 );  
   394     if ( aEntry.iMtm == KUidMsvLocalServiceMtm &&
   402     if ( aEntry.iMtm == KUidMsvLocalServiceMtm &&
   395          aEntry.iType == KUidMsvFolderEntry )
   403          aEntry.iType == KUidMsvFolderEntry )
   396         {
   404         {
   397         foundIndex = LocalEntryBitmapIndex( id );        
   405         foundIndex = LocalEntryBitmapIndex( id );        
   398 
   406 
   399         // check if folder has unread messages
   407         //Get count and check if inbox folder has  unread messages
   400         if ( id ==  KMsvGlobalInBoxIndexEntryId ||
   408         if ( id ==  KMsvGlobalInBoxIndexEntryId ||
   401             id ==  KMceDocumentsEntryId ||
   409             id ==  KMceDocumentsEntryId ||
   402             id == KMsvDraftEntryIdValue ||
   410             id == KMsvDraftEntryIdValue ||
   403             id == KMsvSentEntryIdValue ||
   411             id == KMsvSentEntryIdValue ||
   404             id == KMsvGlobalOutBoxIndexEntryIdValue ||
   412             id == KMsvGlobalOutBoxIndexEntryIdValue ||
   405             id >= KFirstFreeEntryId
   413             id >= KFirstFreeEntryId
   406             )
   414             )
   407             {
   415             {
   408             TRAPD(err, ( unreadMessages = HasUnreadMessagesL( id, aMessageCount, unreadCount ) ) );
   416             // In case of  inbox, need to know message count and is  
   409             if (err == KErrNone && unreadMessages )
   417             // there at least one unread message. 
   410                 {
   418             // No need of unread count and sub folder checking
   411                 foundIndex++;
   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                     }
   412                 }
   449                 }
   413             }
   450             }
   414         }
   451         }
   415 
   452 
   416     // special handling for remote mailboxes to make main view appear faster in startup
   453     // special handling for remote mailboxes to make main view appear faster in startup
   651                 aUnreadMessages++;
   688                 aUnreadMessages++;
   652                 }
   689                 }
   653             }
   690             }
   654         }
   691         }
   655 
   692 
   656     CleanupStack::PopAndDestroy(); // entry
   693     CleanupStack::PopAndDestroy(entry); // entry
   657     return aUnreadMessages;
   694     return aUnreadMessages;
   658     }
   695     }
   659     
   696     
   660 #endif // RD_MSG_NAVIPANE_IMPROVEMENT
   697 #endif // RD_MSG_NAVIPANE_IMPROVEMENT
   661 
   698 
   957 TInt CMceBitmapResolver::DescriptionLength()
   994 TInt CMceBitmapResolver::DescriptionLength()
   958     {
   995     {
   959     return iDescriptionLength;
   996     return iDescriptionLength;
   960     }
   997     }
   961 
   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
   962 //  End of File
  1117 //  End of File