messagingappbase/mce/inc/MceMainViewListItemArray.h
branchRCL_3
changeset 60 7fdbb852d323
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 #ifndef MCEMAINVIEWLISTITEMARRAY_H
       
    24 #define MCEMAINVIEWLISTITEMARRAY_H
       
    25 
       
    26 //  INCLUDES
       
    27 
       
    28 #include <bldvariant.hrh>
       
    29 #include <msvapi.h>     // MMsvSessionObserver
       
    30 #include <bamdesca.h>   // MDesCArray
       
    31 #include <badesca.h>    // CDesCArrayFlat
       
    32 
       
    33 
       
    34 #include "MceListItem.h"
       
    35 #include "MceUtils.h"
       
    36 #include "MceUtilsIdleClass.h"
       
    37 
       
    38 #include "mcetemplate.h"
       
    39 #include <PhCltTypes.h>
       
    40 
       
    41 // CONSTANTS
       
    42 
       
    43 // FORWARD DECLARATIONS
       
    44 class CMsvSession;
       
    45 class CMceBitmapResolver;
       
    46 class MMtmUiDataRegistryObserver;
       
    47 class CMtmUiDataRegistry;
       
    48 class CImumInternalApi;
       
    49 class CImumInSettingsData;
       
    50 class CMceLogEngine;
       
    51 class CRepository;
       
    52 class CCoeEnv;
       
    53 
       
    54 /**
       
    55 * Main view list item array observer.
       
    56 * Called when main view list item texts are updated
       
    57 * @since S60 5.0
       
    58 */
       
    59 class MMceMainViewListItemArrayObserver
       
    60     {
       
    61     public:
       
    62         /**
       
    63         * Called when idle loader has changed main view text
       
    64         * TODO: add what has happened, add, remove, update etc.?
       
    65         */
       
    66         virtual void MceListItemArrayChangedL(
       
    67         ) = 0;
       
    68         
       
    69         /**
       
    70          * Called when Main view refresh is happening 
       
    71          * and need to know flick is ON\OFF
       
    72          */
       
    73         virtual TBool MceListItemArrayFlickEvent(
       
    74         ) = 0;
       
    75         
       
    76     };
       
    77     
       
    78 
       
    79 // CLASS DECLARATION
       
    80 
       
    81 /**
       
    82 *  Item array for the message items to be displayed by mce.
       
    83 *  Main view items are kept in memory (CArrayFixFlat<TMceListItem>) when created but
       
    84 *  Message view list items are fetched from the msgs when needed in MdcaPoint function
       
    85 */
       
    86 class CMceMainViewListItemArray :
       
    87     public CArrayFixFlat<TMceListItem>,
       
    88     public MMsvSessionObserver,
       
    89     public MDesCArray,
       
    90     public MMceUtilsIdleClassObserver   
       
    91     {
       
    92     public:
       
    93         /**
       
    94         * Two-phased constructor.
       
    95         */
       
    96         static CMceMainViewListItemArray* NewL(
       
    97             CMsvSessionPtr aSession,
       
    98             TMsvId aFolderId,
       
    99             TMceListType aListType,
       
   100             CMceBitmapResolver& aBitmapResolver );
       
   101 
       
   102         /**
       
   103         * Destructor.
       
   104         */
       
   105         virtual ~CMceMainViewListItemArray();
       
   106 
       
   107     public:
       
   108 
       
   109         /**
       
   110         * Returns list index of the message
       
   111         * @param aItemId: item to be searched.
       
   112         * @return Index of the item.
       
   113         */
       
   114         TInt ItemIndex( TMsvId aItemId ) const;
       
   115 
       
   116         
       
   117         /**
       
   118         * Returns list index of the extra item:
       
   119         *   KMceWriteMessageListIdValue
       
   120         *   KMceNoMailboxesListIdValue
       
   121         *   KMceDeliveryReportsListIdValue
       
   122         * @param aItemId: item to be searched.
       
   123         * @return Index of the item.
       
   124         * @since S60 v5.0
       
   125         */
       
   126         TInt ExtraItemIndex( TInt aItemId ) const;
       
   127 
       
   128         /**
       
   129         * Returns message id of the list item.
       
   130         * @param aIndex: index of the item to be returned
       
   131         * @return message id (TMsvId)
       
   132         */
       
   133         TMsvId ItemId( TInt aIndex ) const;
       
   134 
       
   135         /**
       
   136         * @param aIndex
       
   137         * @return TMceListItem
       
   138         */
       
   139         const TMceListItem Item( TInt aIndex ) const;
       
   140 
       
   141         /**
       
   142         * Changes folder of the list.
       
   143         * @param aFolderId: folder id to be changed.
       
   144         */
       
   145         void SetFolderL( TMsvId aFolderId );
       
   146         
       
   147         /**
       
   148         * Returns main view's extra item command text.
       
   149         * See more details of main view extra items from
       
   150         * mceextraitems project. 
       
   151         * @param aCommandId: command id received from the menu (CMceMainViewListView::StartAppL)
       
   152         * @return: command text buffer. for example 'http://www.nokia.com'.
       
   153         *    if aCommandId not found, then empty buffer returned.
       
   154         * @since S60 v5.0
       
   155         */ 
       
   156         HBufC* ExtraItemCommandLC( TInt aCommandId );
       
   157 
       
   158 private:        
       
   159         /**
       
   160         * Add item not in msgs (CBS, ...).
       
   161         * @param aNewItem: TMceListItem to be added to the list
       
   162         * @param aIndex: index in the list to be added (0 = first)
       
   163         */
       
   164         void AddExtraItemL( TMceListItem& aNewItem, TInt aIndex );
       
   165 
       
   166         /**
       
   167         * Add item not in msgs (CBS, ...).
       
   168         * @param aNewItem: TMceListItem to be added to the list
       
   169         * @param aIndex: index in the list to be added (0 = first)
       
   170         * @param aIconIndex: index of the icon in file MceExtraIcons
       
   171         * @param aApplicationUid: Related Application uid. This is used 
       
   172         *        when loading correct application icon. If this is not set, 
       
   173         *        then icon is loaded from MceExtraIcons.
       
   174         */
       
   175         void AddExtraItemWithIconL( 
       
   176             TMceListItem& aNewItem, 
       
   177             TInt aIndex, 
       
   178             TInt aIconIndex,
       
   179             TUid aApplicationUid );
       
   180 
       
   181 public:
       
   182         /**
       
   183         * Help needs info, if remote folder or own folder
       
   184         */
       
   185         TBool IsFolderRemote() const;        
       
   186 
       
   187         /**
       
   188         * Checks if mail account is always online
       
   189         * @param aAccount: service id
       
   190         * @param aAlwaysOnlineSettings: CIMASettingsDataExtension reference
       
   191         * Returns ETrue, if always online account 
       
   192         */
       
   193         TBool AlwaysOnlineAccountL( 
       
   194             const TMsvId aAccount, 
       
   195             const CImumInSettingsData& aAlwaysOnlineSettings ) const;
       
   196         
       
   197         /**
       
   198         * Sets roaming flag
       
   199         * @param aRoaming: roaming flag         
       
   200         */
       
   201         void SetRoaming( TBool aRoaming );
       
   202        
       
   203         /**
       
   204         * Gets roaming flag            
       
   205         */
       
   206         TBool Roaming() const;
       
   207 
       
   208         /**
       
   209         * Sets always online flag
       
   210         * @param aAlwaysOnline: always online flag         
       
   211         */
       
   212         void SetAlwaysOnline( TBool aAlwaysOnline );
       
   213 
       
   214         /* 
       
   215         * Gets results from MceUtils::GetHealthyMailboxListL
       
   216         * @para aCount:  iMailboxArray.Count()
       
   217         * @return err from MceUtils::GetHealthyMailBoxL()
       
   218         * from 3.2
       
   219         */
       
   220         TInt GetHealthyMailboxListResult( TInt& aCount );
       
   221 
       
   222 
       
   223     public:     // Functions from base classes
       
   224 
       
   225         /**
       
   226         * From MDesCArray
       
   227         */
       
   228         virtual TInt MdcaCount() const;
       
   229 
       
   230         /**
       
   231         * From MDesCArray
       
   232         */
       
   233         virtual TPtrC MdcaPoint(TInt aIndex) const;
       
   234 
       
   235     public:    // Functions from base classes
       
   236         /**
       
   237         * From MMsvSessionObserver
       
   238         */
       
   239         virtual void HandleSessionEventL(
       
   240             TMsvSessionEvent aEvent,
       
   241             TAny* aArg1,
       
   242             TAny* aArg2,
       
   243             TAny* aArg3);
       
   244 
       
   245         /**
       
   246         * Reconstructs main view folder list
       
   247         */
       
   248         void ConstructMainViewL();
       
   249 
       
   250         /**
       
   251         * Help needs folder id
       
   252         */
       
   253         TMsvId FolderId() const;        
       
   254 
       
   255         /**
       
   256         * Help needs info, if remote account is connected
       
   257         */
       
   258         TBool IsConnected() const;
       
   259         
       
   260         /**
       
   261          * Returns the pointer to Imum's internal email API        
       
   262          * 
       
   263          * @since S60 v3.2
       
   264          * @return pointer to email API
       
   265          */
       
   266         CImumInternalApi* GetEmailApi();
       
   267 
       
   268         /**
       
   269         *
       
   270         */
       
   271         void ResetIconIndexL( TInt aIndex );
       
   272         
       
   273         /**
       
   274         *
       
   275         */
       
   276         void StartListUpdateL();
       
   277         
       
   278         TBool MMceUtilsIdleClassStepL();
       
   279         void SetListItemArrayObserver( MMceMainViewListItemArrayObserver* aObserver );
       
   280          /* 
       
   281          * Set the Default Message viewing style 
       
   282          */
       
   283         void SetDefaultViewSettings(TBool );
       
   284     
       
   285     private:
       
   286 
       
   287         /**
       
   288         * By default Symbian OS constructor is private.
       
   289         */
       
   290         void ConstructL();
       
   291 
       
   292         /**
       
   293         *
       
   294         */
       
   295         CMceMainViewListItemArray(
       
   296             CMsvSessionPtr aSession,
       
   297             TMsvId aFolderId,
       
   298             TMceListType aListType,
       
   299             CMceBitmapResolver& aBitmapResolver );
       
   300 
       
   301         /**
       
   302         * Adds TMsvEntry to the array (used only in Main view).
       
   303         * @param aEntry TMsvEntry of the item to be added.
       
   304         * @return nothing
       
   305         */
       
   306         void AddItemL( const TMsvEntry& aEntry );
       
   307 
       
   308         /**
       
   309         * Adds main view folders to the array (used only in Main view)
       
   310         */
       
   311         void AddFoldersL();
       
   312 
       
   313         /**
       
   314         * Adds folders Inbox and Documents to the array
       
   315         * (used only in Main view).
       
   316         */
       
   317         void AddInboxDocumentsL();
       
   318 
       
   319         /**
       
   320         * Adds folders Draft, Sent, Outbox to the array
       
   321         * (used only in Main view).
       
   322         */
       
   323         void AddDraftSentOutboxL();
       
   324 
       
   325         /**
       
   326         * Appends aSourceString to aTargetString and changes KColumnListSeparator
       
   327         * characters to space characters.
       
   328         * @param aTargetString buffer to append aSource string.
       
   329         * @param aSourceString source buffer.
       
   330         */
       
   331         void StripAndAppendString(TDes& aTargetString, const TDesC& aSourceString) const;
       
   332 
       
   333         /**
       
   334         * Creates string for main view listbox. Called by MdcaPoint.
       
   335         * @param aIndex: index of the message to be drawn
       
   336         */
       
   337         TPtrC MakeStringForMainView( TInt aIndex ) const;
       
   338 
       
   339         /**
       
   340         * Checks if always online account and always online date/time valid
       
   341         * @param aAccount: service id
       
   342         * @return ETrue,if always online account and always online date/time valid
       
   343         */
       
   344         TBool AlwaysOnlineDateTimeValidL( const TMsvId aAccount, TBool &aoDefined ) const;
       
   345 
       
   346 
       
   347         /**
       
   348         * Handles folders, messages string
       
   349         * @param aBuffer: buffer to be append
       
   350         * @param aEntry TMsvEntry of the item.
       
   351         */
       
   352         void HandleFolderMessagesStringL( TDes& aBuffer, const TMsvEntry& aEntry ) const; 
       
   353     
       
   354         /**
       
   355          * 
       
   356          *
       
   357          * @since S60 v3.2
       
   358          * @param 
       
   359          * @return 
       
   360          * @leave &(leavedesc)s
       
   361          */
       
   362         void StoreIndex( const TInt aIndex );
       
   363     
       
   364         /**
       
   365          * 
       
   366          *
       
   367          * @since S60 v3.1
       
   368          * @param 
       
   369          * @return 
       
   370          * @leave 
       
   371          */
       
   372         void MakeItemL( 
       
   373             TMceListItem& aListItem, 
       
   374             const TMsvEntry& aEntry ) const;
       
   375 
       
   376         /**
       
   377          * 
       
   378          *
       
   379          * @since S60 v3.1
       
   380          * @param 
       
   381          * @return 
       
   382          * @leave 
       
   383          */
       
   384         void InsertItemL( 
       
   385             const TMsvEntry& aEntry, 
       
   386             const TInt aIndex );
       
   387 
       
   388         /**
       
   389          * Checks if the entry can be added to list
       
   390          *
       
   391          * @since S60 v3.1
       
   392          * @param aEntry Entry to be checked
       
   393          * @param aId Id to be checked
       
   394          * @return ETrue when the entry can be added to list
       
   395          * @return EFalse when the entry can NOT be added to list
       
   396          */
       
   397         TBool ShouldAddToListL( 
       
   398             const TMsvEntry& aEntry,
       
   399             const TMsvId aId );
       
   400 
       
   401 
       
   402         /**
       
   403          * Gathers all the services that needs to be shown to the list
       
   404          *
       
   405          * @since S60 v3.1
       
   406          * @leave KErrNoMemory when failed to add item to list
       
   407          * @return Index of the draft folder
       
   408          */
       
   409         TInt CollectServicesL( const TMsvId aId );
       
   410 
       
   411         /**
       
   412          * 
       
   413          *
       
   414          * @since S60 v3.1
       
   415          * @param 
       
   416          * @return 
       
   417          * @leave 
       
   418          */
       
   419         void AddMailboxesL( const TInt aMailboxIndex );
       
   420         
       
   421         /**
       
   422         *
       
   423         */
       
   424         void AppendMessageCountString( TDes& aBuffer, TInt aMessageCount) const;
       
   425 
       
   426         
       
   427         
       
   428         /**
       
   429         * Adds items 'Write message', 'Mailbox' and 'Delivery reports'
       
   430         * from the string resource. Note that this is different
       
   431         * than iExtraItemsArray despite naming...
       
   432         * @since S60 v5.0
       
   433         */
       
   434         void AddExtraItemFromResourceL( TInt aResourceId, TInt aCommandId );
       
   435 
       
   436     
       
   437         /**
       
   438         * Adds items from mceextraitems resource file to iExtraItemsArray.
       
   439         * That is done only on construct. If main view items needs to be refreshed
       
   440         * then items are read from iExtraItemsArray and no need to 
       
   441         * open resource again.
       
   442         * @since S60 v5.0
       
   443         */
       
   444         void ReadExtraItemsResourceL();
       
   445         
       
   446         /**
       
   447         * Adds mceextraitem from iExtraItemsArray to actual main view array.
       
   448         * @param: aIndex: index of the item in iExtraItemsArray.
       
   449         * @since S60 v5.0
       
   450         */         
       
   451         void AddExtraItemCommandL( TInt aIndex );
       
   452 
       
   453         /**
       
   454         * Adds TMsvEntry item from message store to main view array
       
   455         * @param: aEntryId: id of the entry to be added.
       
   456         * @since S60 v5.0
       
   457         */
       
   458         void AddFolderItemL( TMsvId aEntryId );
       
   459         
       
   460         /**
       
   461         * Reads main view item order from the central repository.
       
   462         * Order of the items are stored in iMainViewItems so
       
   463         * when refresh is needed, no need to open cenrep file again.
       
   464         * @since S60 v5.0
       
   465         */
       
   466         void ReadMainViewItemsFromRepositoryL();
       
   467     
       
   468          /**
       
   469          * Creates Conversation string for main view listbox. 
       
   470          * @param aIndex: index of the message to be drawn
       
   471          */
       
   472          TPtrC CreateConversationsListItem( TInt aIndex ) const;
       
   473     private:    // Data
       
   474         CMsvSessionPtr                  iSession;
       
   475         CMsvEntry*                      iFolderEntry;
       
   476         CMceBitmapResolver&             iBitmapResolver;
       
   477         MMtmUiDataRegistryObserver*     iRegistryObserver;
       
   478         HBufC*                          iListBoxText;
       
   479         CDesCArrayFlat*                 iNumberOfMessagesStrings;
       
   480         TBool                           iAlwaysOnline;
       
   481         TBool                           iRoaming;
       
   482         // Array of mailbox Ids
       
   483         MImumInHealthServices::RMailboxIdArray iMailboxArray;        
       
   484         // Owned: Pointer to email API object
       
   485         CImumInternalApi*               iEmailApi;
       
   486         TInt                            iErrGetHealthyMailBoxList;
       
   487         TInt                            iMaiboxArrayCount;
       
   488         
       
   489         CMceUtilsIdleClass*             iIdleLoader;
       
   490         TInt                            iIdleCounter;
       
   491         MMceMainViewListItemArrayObserver*      iListItemArrayObserver;
       
   492         
       
   493         CCoeEnv*                        iCoeEnv;
       
   494         CMtmUiDataRegistry*             iUiRegistry;
       
   495         CMsvEntrySelection*             iMainViewItems;
       
   496         CMceMainViewExtraItemArray*     iExtraItemsArray;
       
   497         
       
   498         TInt                            iDescriptionLength;
       
   499         //FS Email stuff
       
   500         TBool                           iSelectableEmail;
       
   501         
       
   502         /**
       
   503          * CMail Changes, it will be True if 
       
   504          * KFeatureIdFfEmailFramework is enabled
       
   505          */
       
   506         TBool                           iEmailFramework;        
       
   507         /**
       
   508          *  Holds the current default Messagign viewing style type 
       
   509         */
       
   510         TBool                            iDefaultViewSettings;
       
   511     };
       
   512 
       
   513 #endif      // MCEMAINVIEWLISTITEMARRAY_H
       
   514 
       
   515 // End of File