messagingappbase/mce/src/MceMainViewListItemArray.cpp
branchRCL_3
changeset 60 7fdbb852d323
child 66 fc3320e39880
equal deleted inserted replaced
57:ebe688cedc25 60:7fdbb852d323
       
     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 *     Item array for the message items to be displayed by mce.
       
    16 *     Main view items are kept in memory (CArrayFixFlat<TMceListItem>) when created but
       
    17 *     Message view list items are fetched from the msgs when needed in MdcaPoint function
       
    18 *
       
    19 */
       
    20 
       
    21 
       
    22 
       
    23 // INCLUDE FILES
       
    24 
       
    25 #include <AknUtils.h>       // AknTextUtils
       
    26 #include <mtudcbas.h>
       
    27 #include <msvids.h>
       
    28 #include <NpdApi.h>         // CNotepadApi
       
    29 //#include "MtmRegistryObserver.h" // MMtmUiDataRegistryObserver
       
    30 #include <StringLoader.h>   // StringLoader
       
    31 #include <mce.rsg>
       
    32 #include <SenduiMtmUids.h>  // mtm uids
       
    33 #include <eikenv.h>
       
    34 #include <centralrepository.h>
       
    35 #include <messaginginternalcrkeys.h>
       
    36 
       
    37 
       
    38 #include <MTMStore.h>
       
    39 #include <commonphoneparser.h>
       
    40 
       
    41 #include <aknappui.h>
       
    42 #include <akncontext.h>
       
    43 #include <aknconsts.h>
       
    44 #include <e32math.h>
       
    45 
       
    46 #include <bldvariant.hrh>
       
    47 #include <featmgr.h>
       
    48 #include <NumberGrouping.h>
       
    49 #include <mmsconst.h>
       
    50 #include <mmsgenutils.h>
       
    51 #include <mmsclient.h>
       
    52 #include <mtclreg.h>
       
    53 #include <muiu.mbg>
       
    54 #include <mtudreg.h>        // CMtmUiDataRegistry
       
    55 
       
    56 // security data caging
       
    57 #include <data_caging_path_literals.hrh>
       
    58 #include <miutset.h>
       
    59 #include <msvapi.h>
       
    60 
       
    61 #include <ImumInternalApi.h>            // CImumInternalApi
       
    62 #include <ImumInSettingsData.h>         // CImumInSettingsData
       
    63 
       
    64 #include <muiuflags.h>
       
    65 
       
    66 #include "MceMainViewListItemArrayIncludes.h"
       
    67 #include <mceextraitems.rsg>
       
    68 //FS Email stuff
       
    69 #include <ImumInHealthServices.h>
       
    70 #include <muiumsvuiserviceutilitiesinternal.h>
       
    71 #include <MessagingDomainCRKeys.h>
       
    72 #include <bautils.h>
       
    73 
       
    74 // CONSTANTS
       
    75 
       
    76 // LOCAL CONSTANTS AND MACROS
       
    77 enum
       
    78     {
       
    79     KMceListArrayDocAmount = 0x0,
       
    80     KMceListArrayDocAmountMany,
       
    81     KMceListArrayDocAmountTemp,
       
    82     KMceListArrayDocAmountTemps,
       
    83     KMceListArrayDocNoMessages,
       
    84     KMceListArrayNumberOneMessage,
       
    85     KMceListArrayNumberOfMsgs, 
       
    86     KMceListArrayTimeFormatBuffer,
       
    87     KMceListArrayDateFormatBuffer
       
    88     };
       
    89 
       
    90 //cmail update
       
    91 #define KUidMsgTypeFsMtmVal               0x2001F406
       
    92 #define KConversationUidVal               0x2002A540  //Conversation Application UID
       
    93 
       
    94 //cmail update
       
    95 
       
    96 // ================= MEMBER FUNCTIONS =======================
       
    97 
       
    98 // C++ default constructor can NOT contain any code that
       
    99 // might leave.
       
   100 //
       
   101 CMceMainViewListItemArray::CMceMainViewListItemArray(
       
   102     CMsvSessionPtr aSession,
       
   103     TMsvId /*aFolderId*/,
       
   104     TMceListType /*aListType*/,
       
   105     CMceBitmapResolver& aBitmapResolver ) :
       
   106     CArrayFixFlat<TMceListItem>( KMceListGranuality ),
       
   107     iSession( aSession ),
       
   108 //    KMsvRootIndexEntryId( aFolderId ),
       
   109 //    iListType( aListType ),
       
   110     iBitmapResolver( aBitmapResolver )
       
   111     {
       
   112     iMailboxArray.Reset();
       
   113     iDescriptionLength = iBitmapResolver.DescriptionLength();
       
   114     }
       
   115 
       
   116 // ----------------------------------------------------
       
   117 // CMceMainViewListItemArray::ConstructL
       
   118 // Symbian OS default constructor can leave.
       
   119 // ----------------------------------------------------
       
   120 void CMceMainViewListItemArray::ConstructL()
       
   121     {
       
   122     FeatureManager::InitializeLibL();
       
   123     if ( FeatureManager::FeatureSupported( KFeatureIdSelectableEmail ) )
       
   124         {
       
   125         iSelectableEmail = ETrue;
       
   126         }
       
   127     if ( FeatureManager::FeatureSupported( KFeatureIdFfEmailFramework ) )
       
   128         {
       
   129         iEmailFramework = ETrue;
       
   130         }
       
   131     FeatureManager::UnInitializeLib();
       
   132     iCoeEnv = CEikonEnv::Static();
       
   133     iUiRegistry = CMtmUiDataRegistry::NewL(*iSession); 
       
   134     ReadMainViewItemsFromRepositoryL();
       
   135     ReadExtraItemsResourceL();
       
   136     
       
   137     // read phone number grouping feature flag
       
   138     // sort by details sorts remote mailboxes alphabetical order
       
   139     iFolderEntry = CMsvEntry::NewL(
       
   140         *iSession,
       
   141         KMsvRootIndexEntryId,
       
   142         TMsvSelectionOrdering(
       
   143             KMsvGroupByStandardFolders, EMsvSortByDetails ));
       
   144     
       
   145     iEmailApi = CreateEmailApiL( &*iSession );
       
   146     Reset();
       
   147     AddFoldersL();
       
   148     iIdleLoader = CMceUtilsIdleClass::NewL( *this );
       
   149     iIdleLoader->StartL();
       
   150     iNumberOfMessagesStrings = new(ELeave)CDesCArrayFlat( KMceListGranuality );
       
   151     TBuf<KMcePrintableTextLength> tempString;
       
   152     StringLoader::Load( tempString, R_MCE_DOC_AMOUNT, iCoeEnv );
       
   153     iNumberOfMessagesStrings->AppendL( tempString );
       
   154     StringLoader::Load( tempString, R_MCE_DOC_AMOUNT_MANY, iCoeEnv );
       
   155     iNumberOfMessagesStrings->AppendL( tempString );
       
   156     StringLoader::Load( tempString, R_MCE_DOC_AMOUNT_TEMP, iCoeEnv );
       
   157     iNumberOfMessagesStrings->AppendL( tempString );
       
   158     StringLoader::Load( tempString, R_MCE_DOC_AMOUNT_TEMPS, iCoeEnv );
       
   159     iNumberOfMessagesStrings->AppendL( tempString );
       
   160     StringLoader::Load( tempString, R_MCE_DOC_NO_MESSAGES, iCoeEnv);
       
   161     iNumberOfMessagesStrings->AppendL( tempString );
       
   162     StringLoader::Load( tempString, R_MCE_NUMBER_ONE_MESSAGE, iCoeEnv);
       
   163     iNumberOfMessagesStrings->AppendL( tempString );
       
   164     StringLoader::Load( tempString, R_MCE_NUMBER_OF_MSGS, iCoeEnv);
       
   165     iNumberOfMessagesStrings->AppendL( tempString );
       
   166 
       
   167     HBufC* timeFormat = iCoeEnv->
       
   168         AllocReadResourceLC( R_QTN_TIME_USUAL_WITH_ZERO );
       
   169     iNumberOfMessagesStrings->AppendL( *timeFormat );
       
   170     CleanupStack::PopAndDestroy();
       
   171     
       
   172     HBufC* dateFormat = iCoeEnv->
       
   173             AllocReadResourceLC( R_QTN_DATE_WITHOUT_YEAR_WITH_ZERO );
       
   174     iNumberOfMessagesStrings->AppendL( *dateFormat );
       
   175     CleanupStack::PopAndDestroy();
       
   176     
       
   177     
       
   178     // todo
       
   179     iListBoxText = HBufC::NewL( iDescriptionLength*3 ); 
       
   180     iDefaultViewSettings  = KMceConversationview;
       
   181     }
       
   182 
       
   183 // Two-phased constructor.
       
   184 CMceMainViewListItemArray* CMceMainViewListItemArray::NewL(
       
   185     CMsvSessionPtr aSession,
       
   186     TMsvId aFolderId,
       
   187     TMceListType aListType,
       
   188     CMceBitmapResolver& aBitmapResolver )
       
   189     {
       
   190     CMceMainViewListItemArray* self = new (ELeave) CMceMainViewListItemArray(
       
   191         aSession, aFolderId, aListType, aBitmapResolver );
       
   192     CleanupStack::PushL(self);
       
   193     self->ConstructL();
       
   194     CleanupStack::Pop(); // self
       
   195     return self;
       
   196     }
       
   197 
       
   198 
       
   199 // Destructor
       
   200 CMceMainViewListItemArray::~CMceMainViewListItemArray( )
       
   201     {
       
   202     delete iExtraItemsArray;
       
   203     delete iMainViewItems;
       
   204     delete iFolderEntry;
       
   205     delete iListBoxText;
       
   206     delete iNumberOfMessagesStrings;
       
   207 //    delete iUiRegistry;
       
   208     delete iEmailApi;
       
   209     iMailboxArray.Reset();
       
   210     delete iIdleLoader;
       
   211     delete iUiRegistry;
       
   212     // iSession deleted elsewhere
       
   213     }
       
   214 
       
   215 // ---------------------------------------------------------------------------
       
   216 // CMceMainViewListItemArray::MakeItemL()
       
   217 // ---------------------------------------------------------------------------
       
   218 //
       
   219 void CMceMainViewListItemArray::MakeItemL( 
       
   220     TMceListItem& aListItem,
       
   221     const TMsvEntry& aEntry ) const
       
   222     {
       
   223     aListItem.iPrintableText.Zero();
       
   224 
       
   225     const TMsvId id=aEntry.Id();
       
   226     StripAndAppendString( 
       
   227         aListItem.iPrintableText,
       
   228         aEntry.iDetails );
       
   229 
       
   230     aListItem.iMsvId = id;
       
   231     aListItem.iExtraItem = EFalse;
       
   232     aListItem.iIconIndex = KErrNotFound;  
       
   233     aListItem.iText.Zero();
       
   234     }
       
   235 
       
   236 // ---------------------------------------------------------------------------
       
   237 // CMceMainViewListItemArray::InsertItemL()
       
   238 // ---------------------------------------------------------------------------
       
   239 //
       
   240 void CMceMainViewListItemArray::InsertItemL( 
       
   241     const TMsvEntry& aEntry, 
       
   242     const TInt aIndex )
       
   243     {
       
   244     TMceListItem tempItem;
       
   245     MakeItemL( tempItem, aEntry );
       
   246     InsertL( aIndex, tempItem );
       
   247     }
       
   248 
       
   249 
       
   250 // ----------------------------------------------------
       
   251 // CMceMainViewListItemArray::AddItemL
       
   252 // ----------------------------------------------------
       
   253 void CMceMainViewListItemArray::AddItemL( const TMsvEntry& aEntry )
       
   254     {
       
   255     TMceListItem tempItem;
       
   256     MakeItemL( tempItem, aEntry );
       
   257     AppendL( tempItem );
       
   258     }
       
   259 
       
   260 
       
   261 // ---------------------------------------------------------------------------
       
   262 // CMceListItemArray::AddFolderItemL()
       
   263 // ---------------------------------------------------------------------------
       
   264 //
       
   265 void CMceMainViewListItemArray::AddFolderItemL( TMsvId aEntryId )
       
   266     {
       
   267     TMsvId service = KMsvLocalServiceIndexEntryId;
       
   268     TMsvEntry entry;
       
   269     if ( iSession->GetEntry(aEntryId,service,entry) == KErrNone )
       
   270     	{
       
   271     	AddItemL( entry );
       
   272     	}
       
   273     }
       
   274 
       
   275 // ----------------------------------------------------
       
   276 // CMceMainViewListItemArray::ItemIndex
       
   277 // ----------------------------------------------------
       
   278 TInt CMceMainViewListItemArray::ItemIndex(TMsvId aItemId) const
       
   279     {
       
   280     TInt foundItem = KErrNotFound;
       
   281     const TInt count = Count();
       
   282 
       
   283     for( TInt loop = 0; loop < count && foundItem == KErrNotFound ; loop++)
       
   284         {
       
   285         if ( !At(loop).iExtraItem && At(loop).iMsvId == aItemId )
       
   286             {
       
   287             foundItem = loop;
       
   288             }
       
   289         }
       
   290     return foundItem;
       
   291     }
       
   292 
       
   293 // ----------------------------------------------------
       
   294 // CMceMainViewListItemArray::ExtraItemIndex
       
   295 // ----------------------------------------------------
       
   296 TInt CMceMainViewListItemArray::ExtraItemIndex( TInt aItemId ) const
       
   297     {
       
   298     TInt foundItem = KErrNotFound;
       
   299     const TInt count = Count();
       
   300 
       
   301     for( TInt loop = 0; loop < count && foundItem == KErrNotFound ; loop++)
       
   302         {
       
   303         if ( At(loop).iExtraItem && At(loop).iMsvId == aItemId )
       
   304             {
       
   305             foundItem = loop;
       
   306             }
       
   307         }
       
   308     return foundItem;
       
   309     }
       
   310 
       
   311 // ----------------------------------------------------
       
   312 // CMceListItemArray::ItemId
       
   313 // ----------------------------------------------------
       
   314 TMsvId CMceMainViewListItemArray::ItemId( TInt aIndex ) const
       
   315     {
       
   316     TMsvId id = KErrNotFound;
       
   317     if ( aIndex >= 0 && aIndex < Count() )
       
   318         {
       
   319         if ( !At(aIndex).iExtraItem )
       
   320             {
       
   321             id = At(aIndex).iMsvId;
       
   322             }
       
   323         }
       
   324     return id;
       
   325     }
       
   326 
       
   327 // ----------------------------------------------------
       
   328 // CMceMainViewListItemArray::Item
       
   329 // ----------------------------------------------------
       
   330 const TMceListItem CMceMainViewListItemArray::Item( TInt aIndex ) const
       
   331     {
       
   332     TMceListItem tempItem;
       
   333     tempItem.iMsvId = At(aIndex).iMsvId;
       
   334     tempItem.iExtraItem = At(aIndex).iExtraItem;
       
   335     return tempItem;
       
   336     }
       
   337 
       
   338 // ----------------------------------------------------
       
   339 // CMceMainViewListItemArray::AddExtraItemL
       
   340 // ----------------------------------------------------
       
   341 void CMceMainViewListItemArray::AddExtraItemL( TMceListItem& aNewItem, TInt aIndex )
       
   342     {
       
   343     TMcePrintableText tempText = aNewItem.iPrintableText; // let's save string
       
   344 
       
   345     aNewItem.iExtraItem = ETrue;
       
   346     // make sure it will not be mixed with items in msgs
       
   347     TMceBitmapListItem bitmapItem;
       
   348     bitmapItem.iExtraItem = ETrue;
       
   349     bitmapItem.iMtm.iUid = KUidMsvLocalServiceMtmValue;
       
   350     bitmapItem.iType.iUid = KUidMsvFolderEntryValue;
       
   351     bitmapItem.iId = aNewItem.iMsvId;
       
   352     const TInt index = iBitmapResolver.BitmapIndex( bitmapItem );
       
   353     aNewItem.iPrintableText.Zero();
       
   354     aNewItem.iPrintableText.AppendNum( index );
       
   355     aNewItem.iPrintableText.Append( KColumnListSeparator );
       
   356     aNewItem.iPrintableText.Append( tempText );
       
   357     aNewItem.iText.Zero();
       
   358     InsertL( aIndex, aNewItem );
       
   359     }
       
   360 
       
   361 
       
   362 // ----------------------------------------------------
       
   363 // CMceMainViewListItemArray::AddExtraItemWithIconL
       
   364 // ----------------------------------------------------
       
   365 void CMceMainViewListItemArray::AddExtraItemWithIconL( 
       
   366     TMceListItem& aNewItem, 
       
   367     TInt aIndex, 
       
   368     TInt aIconIndex,
       
   369     TUid aApplicationUid )
       
   370     {
       
   371     TMcePrintableText tempText = aNewItem.iPrintableText; // let's save string
       
   372     TMcePrintableText secondarytxt = aNewItem.iSecondaryText;
       
   373     aNewItem.iExtraItem = ETrue;
       
   374     // make sure it will not be mixed with items in msgs
       
   375     TMceBitmapListItem bitmapItem;
       
   376     bitmapItem.iExtraItem = ETrue;
       
   377     bitmapItem.iMtm = aApplicationUid ; //KUidMsvLocalServiceMtmValue;
       
   378     bitmapItem.iType = aApplicationUid; //KUidMsvFolderEntryValue;
       
   379     bitmapItem.iId = aNewItem.iMsvId;
       
   380     // here to add loading of the icon...
       
   381     _LIT( KMceExtraIconsDirAndFile,"MceExtraIcons.mbm" );
       
   382     TParse fp;
       
   383     fp.Set( KMceExtraIconsDirAndFile, &KDC_APP_BITMAP_DIR , NULL );
       
   384     // trap this and if fails, set index = Unknown.
       
   385     TInt error = KErrNone;
       
   386     
       
   387     // Add the bitmap
       
   388     TRAP( error, iBitmapResolver.CreateAndAppendIconL( \
       
   389         KAknsIIDDefault,\
       
   390         fp.FullName(),\
       
   391         aIconIndex,\
       
   392         &bitmapItem ) );
       
   393     
       
   394     // Handle the error
       
   395     TInt index;
       
   396     if ( error == KErrNone )
       
   397     	{
       
   398     	index = iBitmapResolver.BitmapIndex( bitmapItem );
       
   399     	}
       
   400     else
       
   401     	{
       
   402     	index = EMceBitmapIndexUnknown;
       
   403     	}
       
   404     
       
   405     aNewItem.iPrintableText.Zero();
       
   406     aNewItem.iPrintableText.AppendNum( index );
       
   407     aNewItem.iPrintableText.Append( KColumnListSeparator );
       
   408     aNewItem.iPrintableText.Append( tempText );
       
   409     aNewItem.iPrintableText.Append( KColumnListSeparator );
       
   410     aNewItem.iPrintableText.Append( secondarytxt );
       
   411     aNewItem.iText.Zero();
       
   412     InsertL( aIndex, aNewItem );
       
   413     }
       
   414 
       
   415 // ----------------------------------------------------
       
   416 // CMceMainViewListItemArray::MdcaCount
       
   417 // ----------------------------------------------------
       
   418 TInt CMceMainViewListItemArray::MdcaCount() const
       
   419     {
       
   420     return Count();
       
   421     }
       
   422 
       
   423 // ----------------------------------------------------
       
   424 // CMceMainViewListItemArray::MdcaPoint
       
   425 // ----------------------------------------------------
       
   426 TPtrC CMceMainViewListItemArray::MdcaPoint( TInt aIndex ) const
       
   427     {
       
   428     const TMceListItem& item = At( aIndex );
       
   429     if ( item.iExtraItem )
       
   430         {
       
   431         if ( item.iMsvId == KMceDeliveryReportsId )
       
   432             {
       
   433             TPtr tempText = iListBoxText->Des();
       
   434             tempText.Copy( item.iPrintableText );
       
   435             return tempText;
       
   436             }
       
   437      else if(  item.iApplicationUid == KConversationUidVal )
       
   438             {          
       
   439             return CreateConversationsListItem( aIndex );
       
   440             }
       
   441         else
       
   442             {
       
   443             return item.iPrintableText;
       
   444             }
       
   445         }
       
   446     else
       
   447         {
       
   448         return MakeStringForMainView( aIndex );
       
   449         }
       
   450     }
       
   451 
       
   452 // ----------------------------------------------------
       
   453 // CMceMainViewListItemArray::MakeStringForMainView
       
   454 // ----------------------------------------------------
       
   455 TPtrC CMceMainViewListItemArray::MakeStringForMainView( TInt aIndex ) const
       
   456     {
       
   457     TPtr tempText = iListBoxText->Des();
       
   458     tempText.Zero();
       
   459     TMsvEntry entry;
       
   460     TMsvId serviceId;
       
   461     
       
   462     const TMceListItem& item = At( aIndex );
       
   463     if ( iSession->GetEntry( item.iMsvId, serviceId, entry ) == KErrNone )
       
   464         {
       
   465         if ( item.iIconIndex <= KErrNone || item.iIconIndex >= iBitmapResolver.MtmIconIndex() )
       
   466             {
       
   467             TInt messageCount = 0;
       
   468             TMsvId id = entry.Id();
       
   469             CONST_CAST( TMceListItem*, &item)->iIconIndex = iBitmapResolver.BitmapIndex( entry, messageCount );
       
   470             if(iDefaultViewSettings == KMceConversationview && id == KMsvGlobalInBoxIndexEntryId )
       
   471                 {
       
   472                 CONST_CAST( TMceListItem*, &item)->iIconIndex = EMceBitmapIndexInbox;
       
   473                 }            
       
   474             CONST_CAST( TMceListItem*, &item)->iMessageCount = messageCount;
       
   475             }
       
   476         else if(iListItemArrayObserver )
       
   477             {
       
   478              if(iListItemArrayObserver->MceListItemArrayFlickEvent())
       
   479                  {
       
   480                  return item.iText;
       
   481                  }
       
   482             }
       
   483         
       
   484         tempText.AppendNum( item.iIconIndex );
       
   485         tempText.Append( KColumnListSeparator );
       
   486         tempText.Append( item.iPrintableText );
       
   487         AppendMessageCountString( tempText, item.iMessageCount );
       
   488                
       
   489         if ( entry.Connected() )
       
   490             {
       
   491             if ( iRoaming )
       
   492                 {
       
   493                 tempText.Append( KColumnListSeparator );
       
   494                 tempText.AppendNum( (TInt) EMceBitmapIndexAlwaysRoaming );
       
   495                 }
       
   496             else
       
   497                 {
       
   498                 tempText.Append( KColumnListSeparator );
       
   499                 tempText.AppendNum( (TInt) EMceBitmapIndexMailboxConnectionOn );
       
   500                 }
       
   501             }
       
   502         else if (  iAlwaysOnline && ( entry.iMtm == KSenduiMtmImap4Uid || 
       
   503             entry.iMtm == KSenduiMtmPop3Uid ) )
       
   504             {
       
   505             TBool dateTime = EFalse;
       
   506             TBool aoAccount = EFalse;
       
   507             TRAP_IGNORE( dateTime = AlwaysOnlineDateTimeValidL( serviceId, aoAccount ) );
       
   508             if ( dateTime )
       
   509                 {
       
   510                 // within the update interval
       
   511                 tempText.Append( KColumnListSeparator );
       
   512                 if ( iRoaming )
       
   513                     {
       
   514                     tempText.AppendNum( (TInt) EMceBitmapIndexAlwaysRoaming );
       
   515                     }
       
   516                 else
       
   517                     { 
       
   518                     tempText.AppendNum( (TInt) EMceBitmapIndexAlwaysAdd );
       
   519                     }
       
   520                 }
       
   521             else if ( aoAccount )
       
   522                 {
       
   523                 // outside the interval
       
   524                 tempText.Append( KColumnListSeparator );
       
   525                 if ( iRoaming )
       
   526                     {
       
   527                     tempText.AppendNum( (TInt) EMceBitmapIndexAlwaysRoaming );
       
   528                     }
       
   529                 else
       
   530                     {
       
   531                     tempText.AppendNum( (TInt) EMceBitmapIndexInactiveAdd );
       
   532                     }
       
   533                 }
       
   534             }
       
   535         }
       
   536     else
       
   537         {
       
   538         // this should never happend
       
   539         __ASSERT_DEBUG( 0, Panic(EMceListItemArrayEntryNotFound ) );
       
   540         tempText.AppendNum( (TInt)EMceBitmapIndexUnknown );
       
   541         tempText.Append( KColumnListSeparator );
       
   542         tempText.Append( item.iPrintableText );        
       
   543         }
       
   544     //save the complete string as chache, will be used when flick will start
       
   545     CONST_CAST( TMceListItem*, &item)->iText.Zero();
       
   546     CONST_CAST( TMceListItem*, &item)->iText.Copy(tempText);
       
   547     return tempText;
       
   548     }
       
   549 
       
   550 // ---------------------------------------------------------------------------
       
   551 // CMceMainViewListItemArray::ShouldAddToListL()
       
   552 // ---------------------------------------------------------------------------
       
   553 //
       
   554 TBool CMceMainViewListItemArray::ShouldAddToListL( 
       
   555     const TMsvEntry& aEntry,
       
   556     const TMsvId aId )
       
   557     {
       
   558     TBool add =
       
   559         // Is it a folder
       
   560         ( aEntry.iType == KUidMsvFolderEntry ) ||
       
   561         // Is it a local service id
       
   562         ( aId == KMsvLocalServiceIndexEntryId ) ||
       
   563         // Is it service but not local one?
       
   564         ( ( aEntry.iType == KUidMsvServiceEntry && 
       
   565             aEntry.Id() != KMsvLocalServiceIndexEntryId ) );
       
   566 
       
   567     // Mailboxes are added later, so ignore them here            
       
   568     return add ? !iEmailApi->MailboxUtilitiesL().IsMailMtm( aEntry.iMtm, ETrue ) : EFalse;        
       
   569     }
       
   570 
       
   571 // ---------------------------------------------------------------------------
       
   572 // CMceMainViewListItemArray::CollectServicesL()
       
   573 // ---------------------------------------------------------------------------
       
   574 //
       
   575 TInt CMceMainViewListItemArray::CollectServicesL( const TMsvId aId )
       
   576     {    
       
   577     const TMsvEntry* tEntry;
       
   578     const TInt count = iFolderEntry->Count();
       
   579     for (TInt cc = 0; cc < count; cc++)
       
   580         {
       
   581         tEntry = &( *iFolderEntry )[cc];
       
   582         if ( ShouldAddToListL( *tEntry, aId ) )
       
   583             {
       
   584             AddItemL( *tEntry );            
       
   585             }
       
   586         }
       
   587         
       
   588     return Count();
       
   589     }
       
   590 
       
   591 // ---------------------------------------------------------------------------
       
   592 // CMceMainViewListItemArray::AddMailboxesL()
       
   593 // ---------------------------------------------------------------------------
       
   594 void CMceMainViewListItemArray::AddMailboxesL( const TInt /*aMailboxIndex*/ )
       
   595     {
       
   596     // add mailboxes only if smtp mtm is installed
       
   597     if ( iUiRegistry->IsPresent( KSenduiMtmSmtpUid ) )
       
   598         {
       
   599         // Get the list of valid IMAP4, POP3, and SyncML mailboxes
       
   600         TInt err  = MceUtils::GetHealthyMailboxListL( 
       
   601             iEmailApi->HealthServicesL(),
       
   602             iMailboxArray,
       
   603             ETrue,
       
   604             ETrue,
       
   605             ETrue,
       
   606             ETrue );
       
   607 
       
   608     // for use of CMceMainViewListView::AddExtraItemsL() so that 
       
   609     // MceUtils::GetHealthyMailboxListL won't be called twice
       
   610         iErrGetHealthyMailBoxList = err;
       
   611         iMaiboxArrayCount = iMailboxArray.Count(); 
       
   612 //        MCELOGGER_WRITE_FORMAT("AddMailboxesL: iMaiboxArrayCount: %d", iMaiboxArrayCount );
       
   613         
       
   614         if ( iMaiboxArrayCount )
       
   615             {
       
   616             // Add the items to main view array in alphabetical order        
       
   617             for ( TInt mbox = 0; mbox < iMaiboxArrayCount; mbox++)
       
   618                 {   
       
   619                 // cmail update
       
   620                 if(iEmailFramework)
       
   621                     {                   
       
   622                     //IF mtm UID matches with uidMsgTypeFsMtmVal, skip the entry
       
   623                     //cmail should not be visible in MCE main view
       
   624                     TMsvId service;
       
   625                     TMsvEntry entry;
       
   626                     User::LeaveIfError( iSession->GetEntry( iMailboxArray[mbox], service, entry ) );
       
   627                     if(entry.iMtm.iUid == KUidMsgTypeFsMtmVal)
       
   628                         {
       
   629                         continue;
       
   630                         }
       
   631                     }
       
   632                 //cmail update
       
   633                 AddItemL( iFolderEntry->ChildDataL( iMailboxArray[mbox] ) );
       
   634                 }            
       
   635             }
       
   636         else
       
   637             {
       
   638             //Cmail update
       
   639             // If iEmailFramework is true , donot show "MailBox"
       
   640             // even if selectable email is true.
       
   641             if(!iEmailFramework)
       
   642                 {
       
   643                 if ( !iSelectableEmail  || ( iSelectableEmail && 
       
   644                         !MsvUiServiceUtilitiesInternal::OtherEmailMTMExistL( *iSession ) ) )
       
   645                     {
       
   646                     // add special mailbox entry
       
   647                     AddExtraItemFromResourceL( R_MCE_MAIN_VIEW_NO_MAILBOXES, KMceNoMailboxesListId );
       
   648                     }
       
   649                 }
       
   650             }
       
   651         }
       
   652         
       
   653     }
       
   654 
       
   655 // ---------------------------------------------------------------------------
       
   656 // CMceMainViewListItemArray::AddExtraItemFromResourceL()
       
   657 // ---------------------------------------------------------------------------
       
   658 //
       
   659 void CMceMainViewListItemArray::AddExtraItemFromResourceL( TInt aResourceId, TInt aCommandId )
       
   660     {
       
   661     TMceListItem tempItem;
       
   662     tempItem.iExtraItem = ETrue;
       
   663     tempItem.iMsvId = aCommandId;
       
   664     StringLoader::Load( tempItem.iPrintableText, aResourceId, iCoeEnv );
       
   665 
       
   666     HBufC* line2text = NULL;
       
   667     switch ( aResourceId )
       
   668         {
       
   669         case R_MCE_MAIN_VIEW_DELIVERY_REPORTS:
       
   670             line2text = StringLoader::LoadL( R_MCE_MAIN_VIEW_DELIVERY_INFORMATION, iEikonEnv );
       
   671         break;
       
   672         case R_MCE_MAIN_VIEW_NO_MAILBOXES:
       
   673             line2text = StringLoader::LoadL( R_MCE_MAIN_VIEW_NO_MAILBOXES_DEFINED, iEikonEnv );
       
   674         break;
       
   675         default:
       
   676             // others does not have line2...
       
   677         break;
       
   678         }
       
   679     
       
   680     if ( line2text )
       
   681         {
       
   682         tempItem.iPrintableText.Append( KColumnListSeparator );
       
   683         tempItem.iPrintableText.Append( *line2text );
       
   684         delete line2text;
       
   685         line2text = NULL;
       
   686         }
       
   687     
       
   688     // always add at the end
       
   689     AddExtraItemL( tempItem, Count() );
       
   690     }
       
   691 
       
   692 // ----------------------------------------------------
       
   693 // CMceMainViewListItemArray::AddFoldersL
       
   694 // Adds the children of TMsvId aId to the listbox
       
   695 // ----------------------------------------------------
       
   696 void CMceMainViewListItemArray::AddFoldersL( )
       
   697     {
       
   698     Reset();
       
   699     TInt count = iMainViewItems->Count();
       
   700     TInt extraItemCommandCount = 0;
       
   701     
       
   702     for ( TInt i=0; i<count; i++ )
       
   703         {
       
   704         TMsvId folderId = (*iMainViewItems)[i];
       
   705         switch ( folderId )
       
   706             {
       
   707             case KMceWriteMessageListIdValue:
       
   708                 AddExtraItemFromResourceL( R_MCE_MAIN_VIEW_WRITE_MESSAGE, folderId );
       
   709             break;
       
   710             case KMceNoMailboxesListIdValue:
       
   711                 AddMailboxesL( KErrNotFound );
       
   712                 //AddExtraItemFromResourceL();
       
   713             break;
       
   714             case KMceDeliveryReportsListIdValue:
       
   715                 AddExtraItemFromResourceL( R_MCE_MAIN_VIEW_DELIVERY_REPORTS, folderId );
       
   716             break;
       
   717             default:
       
   718             if ( folderId > KMsvRootIndexEntryIdValue )
       
   719                 {
       
   720                 AddFolderItemL( folderId );
       
   721                 }
       
   722              else if ( folderId == KMceExtraItemPlaceHolderValue )
       
   723                 {
       
   724                 AddExtraItemCommandL( extraItemCommandCount );
       
   725                 extraItemCommandCount++;
       
   726                 }
       
   727             break;
       
   728             }
       
   729         }
       
   730     }
       
   731     
       
   732 // ----------------------------------------------------
       
   733 // CMceMainViewListItemArray::AddInboxDocumentsL
       
   734 // ----------------------------------------------------
       
   735 void CMceMainViewListItemArray::AddInboxDocumentsL( )
       
   736     {
       
   737     iFolderEntry->SetEntryL( KMsvLocalServiceIndexEntryId );
       
   738     AddItemL( iFolderEntry->
       
   739         ChildDataL( KMsvGlobalInBoxIndexEntryId ) );
       
   740     AddItemL( iFolderEntry->ChildDataL( KMceDocumentsEntryId ) );
       
   741     }
       
   742 
       
   743 // ----------------------------------------------------
       
   744 // CMceMainViewListItemArray::AddDraftSentOutboxL
       
   745 // ----------------------------------------------------
       
   746 void CMceMainViewListItemArray::AddDraftSentOutboxL( )
       
   747     {
       
   748     iFolderEntry->SetEntryL( KMsvLocalServiceIndexEntryId );
       
   749     AddItemL( iFolderEntry->ChildDataL( KMsvDraftEntryId ) );
       
   750     AddItemL( iFolderEntry->ChildDataL( KMsvSentEntryId ) );
       
   751     AddItemL( iFolderEntry->
       
   752     ChildDataL( KMsvGlobalOutBoxIndexEntryId ) );
       
   753     }
       
   754 
       
   755 // ----------------------------------------------------
       
   756 // CMceMainViewListItemArray::HandleSessionEventL
       
   757 // ----------------------------------------------------
       
   758 void CMceMainViewListItemArray::HandleSessionEventL(
       
   759     TMsvSessionEvent aEvent, TAny* /*aArg1*/, TAny* /*aArg2*/, TAny* /*aArg3*/)
       
   760     {
       
   761     switch (aEvent)
       
   762         {
       
   763     case EMsvEntriesCreated:
       
   764     case EMsvEntriesChanged:
       
   765     case EMsvEntriesDeleted:
       
   766     case EMsvMediaChanged:
       
   767     case EMsvMediaUnavailable:
       
   768     case EMsvMediaAvailable:
       
   769         Reset();
       
   770         AddFoldersL();
       
   771         break;
       
   772 
       
   773     case EMsvCloseSession:        
       
   774         break;
       
   775 
       
   776     default:
       
   777         break;
       
   778         }
       
   779     }
       
   780 
       
   781 // ----------------------------------------------------
       
   782 // CMceMainViewListItemArray::StripAndAppendString
       
   783 // ----------------------------------------------------
       
   784 void CMceMainViewListItemArray::StripAndAppendString(TDes& aTargetString, const TDesC& aSourceString) const
       
   785     {
       
   786     TRAP_IGNORE( MceUtils::StripAndAppendStringL(
       
   787         aTargetString,
       
   788         aSourceString,
       
   789         iDescriptionLength ) );
       
   790     }
       
   791 
       
   792 // ----------------------------------------------------
       
   793 // CMceMainViewListItemArray::IsFolderRemote
       
   794 // return ETrue, if remote folder
       
   795 //
       
   796 // ----------------------------------------------------
       
   797 TBool CMceMainViewListItemArray::IsFolderRemote() const
       
   798     {
       
   799     TMsvId service = KMsvLocalServiceIndexEntryId;
       
   800     TMsvEntry entry;
       
   801     if ( iSession->GetEntry(KMsvRootIndexEntryId,service,entry) == KErrNone )
       
   802     	{
       
   803     	return KMsvLocalServiceIndexEntryId != service;
       
   804     	}
       
   805     else
       
   806     	{
       
   807     	return EFalse;
       
   808     	}
       
   809     }
       
   810 
       
   811 // ----------------------------------------------------
       
   812 // CMceMainViewListItemArray::ConstructMainViewL
       
   813 // add folders in main view
       
   814 //
       
   815 // ----------------------------------------------------
       
   816 
       
   817 void CMceMainViewListItemArray::ConstructMainViewL()
       
   818     {
       
   819     delete iFolderEntry;
       
   820     iFolderEntry = NULL;
       
   821     iFolderEntry = CMsvEntry::NewL(
       
   822         *iSession,
       
   823         KMsvRootIndexEntryId,
       
   824         TMsvSelectionOrdering(
       
   825             KMsvGroupByStandardFolders, EMsvSortByDetails ) );
       
   826     AddFoldersL();
       
   827     }
       
   828 
       
   829 // ----------------------------------------------------
       
   830 // CMceMainViewListItemArray::FolderId
       
   831 // return folder id
       
   832 //
       
   833 // ----------------------------------------------------
       
   834 TMsvId CMceMainViewListItemArray::FolderId() const
       
   835     {
       
   836     return KMsvRootIndexEntryId;
       
   837     }
       
   838 
       
   839 
       
   840 // ----------------------------------------------------
       
   841 // CMceMainViewListItemArray::IsConnected
       
   842 // return ETrue, if account is connected
       
   843 //
       
   844 // ----------------------------------------------------
       
   845 TBool CMceMainViewListItemArray::IsConnected() const
       
   846     {
       
   847     TMsvEntry entry;
       
   848     entry = iFolderEntry->Entry();
       
   849 
       
   850     TMsvEntry serviceEntry;
       
   851     TMsvId serviceId;
       
   852     if ( iSession->GetEntry(entry.iServiceId,serviceId,serviceEntry) == KErrNone )
       
   853     	{
       
   854     	return serviceEntry.Connected();
       
   855     	}
       
   856     else
       
   857     	{
       
   858     	return EFalse;
       
   859     	}
       
   860     }
       
   861 
       
   862 
       
   863 // ----------------------------------------------------
       
   864 // CMceMainViewListItemArray::AlwaysOnlineDateTimeValidL
       
   865 // 
       
   866 //
       
   867 // ----------------------------------------------------
       
   868 TBool CMceMainViewListItemArray::AlwaysOnlineDateTimeValidL( const TMsvId aAccount, TBool &aoDefined ) const
       
   869     {
       
   870     // Check if the always online is turned on
       
   871     TInt64 flags = 0;    
       
   872     iEmailApi->MailboxUtilitiesL().QueryAlwaysOnlineStateL( 
       
   873         aAccount, flags );
       
   874                     
       
   875     aoDefined = 
       
   876         ( flags & MImumInMailboxUtilities::EFlagTurnedOn ) ? ETrue : EFalse;            
       
   877     return ( flags & MImumInMailboxUtilities::EFlagWaitingToConnect ) ? 
       
   878         ETrue : EFalse;
       
   879     }
       
   880 
       
   881 // ----------------------------------------------------
       
   882 // CMceMainViewListItemArray::AlwaysOnlineAccountL
       
   883 //
       
   884 // ----------------------------------------------------
       
   885 TBool CMceMainViewListItemArray::AlwaysOnlineAccountL( 
       
   886 	const TMsvId /*aAccount*/, 
       
   887     const CImumInSettingsData& aSettingsData ) const
       
   888     {
       
   889     TInt online = 0;
       
   890     aSettingsData.GetAttr( TImumDaSettings::EKeyAutoRetrieval, online );
       
   891     return online != TImumDaSettings::EValueAutoOff;
       
   892     }
       
   893 
       
   894 // ----------------------------------------------------
       
   895 // CMceMainViewListItemArray::SetRoaming
       
   896 // sets roaming flag
       
   897 //
       
   898 // ----------------------------------------------------
       
   899 void CMceMainViewListItemArray::SetRoaming( TBool aRoaming )
       
   900     {
       
   901     iRoaming = aRoaming;
       
   902     }
       
   903 
       
   904 // ----------------------------------------------------
       
   905 // CMceMainViewListItemArray::Roaming
       
   906 // gets roaming flag
       
   907 //
       
   908 // ----------------------------------------------------
       
   909 TBool CMceMainViewListItemArray::Roaming() const
       
   910     {
       
   911     return iRoaming;
       
   912     }
       
   913 
       
   914 // ----------------------------------------------------
       
   915 // CMceMainViewListItemArray::SetAlwaysOnline
       
   916 // sets always online flag
       
   917 //
       
   918 // ----------------------------------------------------
       
   919 void CMceMainViewListItemArray::SetAlwaysOnline( TBool aAlwaysOnline )
       
   920     {
       
   921     iAlwaysOnline = aAlwaysOnline;
       
   922     }
       
   923 
       
   924 // ----------------------------------------------------
       
   925 // CMceMainViewListItemArray::GetEmailApi
       
   926 // Returns the reference to the email API
       
   927 // ----------------------------------------------------
       
   928 CImumInternalApi* CMceMainViewListItemArray::GetEmailApi()
       
   929     {
       
   930     return iEmailApi;
       
   931     }
       
   932 
       
   933 // ----------------------------------------------------
       
   934 // CMceMainViewListItemArray::
       
   935 // ----------------------------------------------------
       
   936 void CMceMainViewListItemArray::AppendMessageCountString( TDes& aBuffer, TInt aMessageCount ) const
       
   937     {
       
   938     aBuffer.Append( KColumnListSeparator );
       
   939     if ( aMessageCount == 0)
       
   940         {
       
   941         aBuffer.Append( (*iNumberOfMessagesStrings)[
       
   942             KMceListArrayDocNoMessages] );
       
   943         }
       
   944     else if ( aMessageCount == 1 )
       
   945         {
       
   946         TBuf<KMcePrintableTextLength> tempString;
       
   947         tempString.Append((*iNumberOfMessagesStrings)[
       
   948             KMceListArrayNumberOneMessage] );
       
   949         AknTextUtils::LanguageSpecificNumberConversion( tempString );
       
   950         aBuffer.Append( tempString );
       
   951         }
       
   952     else
       
   953         {
       
   954         TBuf<KMcePrintableTextLength> tempString;
       
   955         StringLoader::Format( tempString,
       
   956             (*iNumberOfMessagesStrings)[KMceListArrayNumberOfMsgs],
       
   957             -1, // no index in the key string
       
   958             aMessageCount );
       
   959         AknTextUtils::LanguageSpecificNumberConversion( tempString );
       
   960         aBuffer.Append( tempString );
       
   961         }
       
   962     }
       
   963     
       
   964 
       
   965 // ----------------------------------------------------
       
   966 // CMceMainViewListItemArray::GetHealthyMailboxListResult( TInt& aCount )
       
   967 // ----------------------------------------------------    
       
   968 TInt CMceMainViewListItemArray::GetHealthyMailboxListResult( TInt& aCount )
       
   969     {
       
   970     aCount = iMaiboxArrayCount;
       
   971     return iErrGetHealthyMailBoxList;
       
   972     }  
       
   973 
       
   974 // ----------------------------------------------------
       
   975 // CMceMainViewListItemArray::
       
   976 // ----------------------------------------------------
       
   977 void CMceMainViewListItemArray::StartListUpdateL()
       
   978     {
       
   979     const TInt count = Count();
       
   980     TInt i = 0;
       
   981     for ( i = 0; i < count; i++ )
       
   982         {
       
   983         At( i ).iIconIndex = KErrNotFound;
       
   984         }
       
   985     iIdleCounter = 0; // update only item which icon index is not valid
       
   986     if ( iIdleLoader )
       
   987         {
       
   988         iIdleLoader->StartL();
       
   989         }
       
   990     }
       
   991 
       
   992 // ----------------------------------------------------
       
   993 // CMceMainViewListItemArray::
       
   994 // ----------------------------------------------------
       
   995 void CMceMainViewListItemArray::ResetIconIndexL( TInt aIndex )
       
   996     {
       
   997     iIdleCounter = 0;
       
   998     At( aIndex ).iIconIndex = KErrNotFound;
       
   999     if ( iIdleLoader )
       
  1000         {
       
  1001         iIdleLoader->StartL();
       
  1002         }
       
  1003     }
       
  1004 
       
  1005 // ----------------------------------------------------
       
  1006 // CMceMainViewListItemArray::
       
  1007 // ----------------------------------------------------
       
  1008 TBool CMceMainViewListItemArray::MMceUtilsIdleClassStepL( )
       
  1009     {
       
  1010     const TInt count = Count();
       
  1011     // iIdleCounter set to 0 in functions StartListUpdateL and ResetIconIndexL
       
  1012     for ( ; iIdleCounter < count; iIdleCounter++ )
       
  1013         {
       
  1014         TMceListItem& item = At( iIdleCounter );
       
  1015         if ( !item.iExtraItem && ( item.iIconIndex <= KErrNone || item.iIconIndex > iBitmapResolver.MtmIconIndex() ) )
       
  1016             {
       
  1017             TMsvEntry entry;
       
  1018             TMsvId serviceId;
       
  1019             if ( iSession->GetEntry( item.iMsvId, serviceId, entry ) == KErrNone )
       
  1020                 {
       
  1021                 TInt messageCount = 0;
       
  1022                 TMsvId id = entry.Id();
       
  1023                 item.iIconIndex = iBitmapResolver.BitmapIndex( entry, messageCount );  
       
  1024                 if(iDefaultViewSettings == KMceConversationview && id == KMsvGlobalInBoxIndexEntryId )
       
  1025                     {
       
  1026                     item.iIconIndex = EMceBitmapIndexInbox;                    
       
  1027                     }
       
  1028                   item.iMessageCount = messageCount;
       
  1029 //                        item.iUnreadMessageCount = unreadMessageCount;
       
  1030                 if ( iListItemArrayObserver )
       
  1031                     {
       
  1032                     iListItemArrayObserver->MceListItemArrayChangedL();
       
  1033                     }
       
  1034 //                    iIdleCounter++;
       
  1035                 break;
       
  1036                 }
       
  1037             }
       
  1038         }
       
  1039     return iIdleCounter < count;
       
  1040     }
       
  1041 
       
  1042 // ----------------------------------------------------
       
  1043 // CMceMainViewListItemArray::
       
  1044 // ----------------------------------------------------
       
  1045 void CMceMainViewListItemArray::SetListItemArrayObserver( MMceMainViewListItemArrayObserver* aObserver )
       
  1046     {
       
  1047     iListItemArrayObserver = aObserver;
       
  1048     }
       
  1049 
       
  1050 // ----------------------------------------------------
       
  1051 // CMceMainViewListView::ReadExtraItemsResourceL
       
  1052 // ----------------------------------------------------
       
  1053 void CMceMainViewListItemArray::ReadExtraItemsResourceL()
       
  1054     {
       
  1055     if ( !iExtraItemsArray )
       
  1056         {
       
  1057         iExtraItemsArray = new( ELeave ) CMceMainViewExtraItemArray( KMceListGranuality );
       
  1058         }
       
  1059     else
       
  1060         {
       
  1061         iExtraItemsArray->Reset();
       
  1062         }
       
  1063     
       
  1064     _LIT(KDirAndMceExtraItemsResFileName,"mceextraitems.rsc");
       
  1065             TFileName fileName; 
       
  1066 		    fileName.Insert( 0,KDC_APP_RESOURCE_DIR );
       
  1067 		    fileName.Append( KDirAndMceExtraItemsResFileName );
       
  1068             TFindFile finder( iCoeEnv->FsSession() );
       
  1069             //Search Y->A then Z:
       
  1070 		    BaflUtils::NearestLanguageFile(iCoeEnv->FsSession(),fileName);
       
  1071 		    TInt err = finder.FindByDir(fileName , KDC_APP_RESOURCE_DIR );
       
  1072             if(err == KErrNone)
       
  1073 		        {                            
       
  1074                 RConeResourceLoader resources( *iCoeEnv );
       
  1075 
       
  1076                 TInt err = KErrNone;
       
  1077                 TRAP( err, resources.OpenL(fileName) );
       
  1078 
       
  1079                 if ( err == KErrNone )
       
  1080                     {
       
  1081                     TResourceReader reader;
       
  1082                     iEikonEnv->CreateResourceReaderLC( reader, R_MCE_EXTRA_ITEMS );
       
  1083 
       
  1084                     const TInt count = reader.ReadInt16();
       
  1085                     TMceMainViewExtraItem extraItem;
       
  1086                     extraItem.iCommandId = KMceFirstExtraItemId;
       
  1087                     for ( TInt loop = 0; loop < count; loop++ )
       
  1088                         {
       
  1089                         HBufC* txt = reader.ReadHBufCL();   // message text
       
  1090                         extraItem.iPrintableText.Copy( *txt );
       
  1091                         delete txt;
       
  1092                         txt = NULL;
       
  1093                         txt = reader.ReadHBufCL();   // message text
       
  1094                         extraItem.iCommandText.Copy( *txt );
       
  1095                         delete txt;
       
  1096 
       
  1097                         TInt depricatedResource = reader.ReadInt16(); // this is not used anymore, but left in resource so no DC break.
       
  1098                         extraItem.iIconIndex = reader.ReadInt16();
       
  1099                         TUid applicationUid;
       
  1100                         applicationUid.iUid = reader.ReadUint32();
       
  1101                         extraItem.iApplicationUid = applicationUid.iUid;
       
  1102                         // secondary text
       
  1103                         txt = reader.ReadHBufCL();   //secondary text                       
       
  1104                         if(txt)
       
  1105                             {
       
  1106                             extraItem.iSecondaryText.Copy( *txt );
       
  1107                             delete txt;
       
  1108                             txt = NULL;
       
  1109                             }   
       
  1110                         else
       
  1111                             {
       
  1112                             extraItem.iSecondaryText.Copy(KNullDesC());
       
  1113                             }
       
  1114                         iExtraItemsArray->AppendL( extraItem );
       
  1115                         extraItem.iCommandId++;
       
  1116                         }
       
  1117                     CleanupStack::PopAndDestroy(); // reader
       
  1118                     resources.Close();
       
  1119                     }
       
  1120                 }
       
  1121             }
       
  1122 
       
  1123 
       
  1124 // ----------------------------------------------------
       
  1125 // CMceMainViewListView::ExtraItemCommandLC
       
  1126 // ----------------------------------------------------
       
  1127 HBufC* CMceMainViewListItemArray::ExtraItemCommandLC( TInt aCommandId )
       
  1128     {
       
  1129     HBufC* commandText = HBufC::NewLC( KMcePrintableTextLength );
       
  1130     TPtr tempText = commandText->Des();
       
  1131     
       
  1132     const TInt count = iExtraItemsArray->Count();
       
  1133     for (TInt i=0; i<count; i++ )
       
  1134         {
       
  1135         if ( aCommandId == (*iExtraItemsArray)[i].iCommandId )
       
  1136             {
       
  1137             tempText.Copy( (*iExtraItemsArray)[i].iCommandText );
       
  1138             i=count;
       
  1139             }
       
  1140         }
       
  1141     
       
  1142     return commandText;    
       
  1143     }
       
  1144     
       
  1145 // ----------------------------------------------------
       
  1146 // CMceMainViewListView::AddExtraItemCommandL
       
  1147 // ----------------------------------------------------
       
  1148 void CMceMainViewListItemArray::AddExtraItemCommandL( TInt aIndex )
       
  1149     {
       
  1150     if ( aIndex < iExtraItemsArray->Count() )
       
  1151         {
       
  1152         const TMceMainViewExtraItem& extraItem = (*iExtraItemsArray)[aIndex];
       
  1153         TMceListItem tempItem;
       
  1154         tempItem.iExtraItem = ETrue;
       
  1155         tempItem.iMsvId = extraItem.iCommandId;
       
  1156        	tempItem.iPrintableText.Copy( extraItem.iPrintableText );
       
  1157        	tempItem.iSecondaryText.Copy(extraItem.iSecondaryText);
       
  1158        	tempItem.iApplicationUid = extraItem.iApplicationUid; 
       
  1159        	TUid appUid;
       
  1160        	appUid.iUid = extraItem.iApplicationUid;
       
  1161        	AddExtraItemWithIconL( tempItem, Count(), extraItem.iIconIndex, appUid );
       
  1162         }
       
  1163     }
       
  1164 
       
  1165 // ----------------------------------------------------
       
  1166 // CMceMainViewListView::ReadMainViewItemsFromRepositoryL
       
  1167 // ----------------------------------------------------
       
  1168 void CMceMainViewListItemArray::ReadMainViewItemsFromRepositoryL()
       
  1169     {
       
  1170     if ( !iMainViewItems )
       
  1171         {
       
  1172         iMainViewItems = new( ELeave ) CMsvEntrySelection();
       
  1173         }
       
  1174     else
       
  1175         {
       
  1176         iMainViewItems->Reset();        
       
  1177         }
       
  1178     CRepository* repository = CRepository::NewLC(KCRUidMuiuSettings);
       
  1179     for ( TInt i = KMuiuMceMainViewRow1; i<=KMuiuMceMainViewRow16; i++ )
       
  1180         {
       
  1181         TInt value = 0;
       
  1182         if ( repository->Get( i, value ) == KErrNone && value > KErrNotFound )
       
  1183             {
       
  1184             iMainViewItems->AppendL( value );
       
  1185             }
       
  1186         }
       
  1187     CleanupStack::PopAndDestroy( repository );
       
  1188     }
       
  1189 
       
  1190 // ----------------------------------------------------
       
  1191 // CMceMainViewListItemArray::CreateConversationsListItem()
       
  1192 // ----------------------------------------------------
       
  1193 TPtrC CMceMainViewListItemArray::CreateConversationsListItem( TInt aIndex ) const
       
  1194     {
       
  1195     const TMceListItem& item = At( aIndex );
       
  1196     if(!iListItemArrayObserver->MceListItemArrayFlickEvent())
       
  1197        {       
       
  1198         TPtr tempText = iListBoxText->Des();        
       
  1199         tempText.Zero();
       
  1200         TInt bitmapidx = EMceBitmapIndexConversation;
       
  1201         if(iDefaultViewSettings == KMceConversationview )
       
  1202            {
       
  1203            TInt msgCount = 0;
       
  1204            TInt unreadCount = 0;                   
       
  1205            TRAPD(Errcode,iBitmapResolver.HasUnreadMessagesL(KMsvGlobalInBoxIndexEntryId,msgCount,unreadCount));         
       
  1206            if( unreadCount > 0 ) 
       
  1207                {
       
  1208                bitmapidx =  EMceBitmapIndexConversationNew ;
       
  1209                }
       
  1210            }    
       
  1211         tempText.AppendNum(bitmapidx);
       
  1212         TPtrC Ptr(item.iPrintableText);          
       
  1213         TInt  pos = Ptr.Locate(KColumnListSeparator);
       
  1214         TPtrC Ptr1(Ptr.Mid(pos));
       
  1215         tempText.Append(Ptr1);                
       
  1216         CONST_CAST( TMceListItem*, &item)->iText.Zero();
       
  1217         CONST_CAST( TMceListItem*, &item)->iText.Copy(tempText);
       
  1218         return tempText;
       
  1219        }
       
  1220     else
       
  1221        {
       
  1222        return item.iText;
       
  1223        }      
       
  1224    }
       
  1225 
       
  1226 // ----------------------------------------------------
       
  1227 // CMceMainViewListItemArray::SetDefaultViewSettings()
       
  1228 // ----------------------------------------------------
       
  1229 void CMceMainViewListItemArray::SetDefaultViewSettings(TBool aVal)
       
  1230     {
       
  1231     iDefaultViewSettings = aVal;   
       
  1232     Reset();
       
  1233     TRAP_IGNORE(AddFoldersL());
       
  1234     }
       
  1235 //  End of File