messagingappbase/mce/inc/MceOneRowMessageListArray.h
changeset 0 72b543305e3a
equal deleted inserted replaced
-1:000000000000 0:72b543305e3a
       
     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 MCEONEROWLISTITEMARRAY_H
       
    24 #define MCEONEROWLISTITEMARRAY_H
       
    25 
       
    26 //  INCLUDES
       
    27 
       
    28 #include "mcetemplate.h"
       
    29 #include <badesca.h>    // CDesCArrayFlat
       
    30 #include <msvapi.h>     // MMsvSessionObserver
       
    31 #include <bldvariant.hrh>
       
    32 #include <PhCltTypes.h>
       
    33 #include <akntreelistconstants.h>
       
    34 #include <akncustomtreeordering.h>
       
    35 
       
    36 // CONSTANTS
       
    37 
       
    38 // FORWARD DECLARATIONS
       
    39 class CMsvSession;
       
    40 class CMceOneRowBitmapResolver;
       
    41 class MMtmUiDataRegistryObserver;
       
    42 class CMceOneRowListItemArrayLoader;
       
    43 class CCoeEnv;
       
    44 class THCListListItem;
       
    45 
       
    46 
       
    47 enum THCListListType
       
    48     {
       
    49     EHCListTypeNone = 0,
       
    50     EHCListTypeTime,
       
    51     EHCListTypeSize,
       
    52     EHCListTypeSender,
       
    53     EHCListTypeSubject,
       
    54     EHCListTypeType
       
    55     };
       
    56     
       
    57 const TInt KOneRowListColumnTextSize = 30;
       
    58 
       
    59 
       
    60 // CLASS DECLARATION
       
    61 class MMceOneRowListItemArrayObserver 
       
    62     {
       
    63     public:
       
    64         virtual void MceListItemArrayChangedL(
       
    65             CArrayFixFlat<TInt>& aChangedItems ) = 0;
       
    66     };
       
    67 
       
    68 
       
    69 /**
       
    70 *  Item array for the message items to be displayed by mce.
       
    71 *  Main view items are kept in memory (CArrayFixFlat<TMceListItem>) when created but
       
    72 *  Message view list items are fetched from the msgs when needed in MdcaPoint function
       
    73 */
       
    74 class CMceOneRowListItemArray :
       
    75     public CBase,
       
    76     public MMsvSessionObserver,
       
    77     public MAknCustomTreeOrdering
       
    78     {
       
    79     public:
       
    80         /**
       
    81         * Two-phased constructor.
       
    82         */
       
    83         static CMceOneRowListItemArray* NewL(
       
    84             CMsvSessionPtr aSession,
       
    85             TMsvId aFolderId );
       
    86 
       
    87         /**
       
    88         * Destructor.
       
    89         */
       
    90         virtual ~CMceOneRowListItemArray();
       
    91 
       
    92     public:
       
    93 
       
    94         /**
       
    95         * Sets MMceListItemArrayObserver
       
    96         * Needed to get notify when MsgStore has changed
       
    97         * @param aObserver: Listitem observer
       
    98         */
       
    99         void SetListItemArrayObserver( MMceOneRowListItemArrayObserver* aObserver );
       
   100 
       
   101         /**
       
   102         * Changes folder of the list.
       
   103         * @param aFolderId: folder id to be changed.
       
   104         */
       
   105         void SetFolderL( TMsvId aFolderId );
       
   106 
       
   107         /**
       
   108         * Currently open folder
       
   109         */
       
   110         TMsvId FolderId();
       
   111         const TMsvEntry& FolderEntry() const;
       
   112 
       
   113         /**
       
   114         * Returns message id of the list item.
       
   115         * @param aIndex: index of the item to be returned
       
   116         * @return message id (TMsvId)
       
   117         */
       
   118         TMsvId ItemId( TInt aIndex );
       
   119 
       
   120         /**
       
   121         * Returns list index of the message
       
   122         * @param aItemId: item to be searched.
       
   123         * @return Index of the item.
       
   124         */
       
   125         TInt ItemIndex( TMsvId aItemId ) const;
       
   126 
       
   127         /**
       
   128         * Sets sort order 
       
   129         * @param aOrdering: 
       
   130         */
       
   131         void SetOrderingL( TInt aType, TBool aOrdering );
       
   132 
       
   133         /**
       
   134         * Checks, if Delete should be discarded in outbox
       
   135         * @param aItemId: id of the item to be checked
       
   136         * @return ETrue, if Delete should be discarded
       
   137         */
       
   138         TBool DeleteDiscard( TMsvId aItemId ) const;
       
   139 
       
   140         /**
       
   141         * returns sort type
       
   142         */
       
   143         TMsvSelectionOrdering SortType();
       
   144 
       
   145         /**
       
   146         * Checks valid phone number
       
   147         * @param aEntryId: message id
       
   148         * @param aEntry: message entry
       
   149         * @param aNumber: phone number
       
   150         * @return ETrue, if valid phone number, in other case return EFalse
       
   151         */
       
   152         TBool CheckValidNumberL( const TMsvId aEntryId, TMsvEntry& aEntry, 
       
   153             TPhCltTelephoneNumber& aNumber ) const;
       
   154             
       
   155         /**
       
   156         * Get entry
       
   157         */
       
   158         TInt GetEntry( TMsvId aEntryId, TMsvEntry& aEntry );
       
   159 
       
   160         /**
       
   161         * Get entry
       
   162         */
       
   163         TInt GetEntry( TInt aIndex, TMsvEntry& aEntry );
       
   164 
       
   165         /**
       
   166         * Get subtitle text
       
   167         */
       
   168         TInt GetSubtitleTextL( TInt aIndex, TDes& aTitleText);
       
   169 
       
   170         /**
       
   171         * Get column text
       
   172         */
       
   173         TInt GetColumnTextL( TInt aIndex, TInt aColumn, TDes& aTitleText);
       
   174 
       
   175         /**
       
   176         * returns folder's parent folder Id
       
   177         */
       
   178         TMsvId GetParentFolderId() const; 
       
   179 
       
   180         /**
       
   181         * Check if item is folder
       
   182         * @param aItemId: id of the item to be checked
       
   183         * @return ETrue if item is folder
       
   184         */
       
   185         TBool IsItemFolder( TMsvId aItemId ) const;
       
   186 
       
   187         /**
       
   188         * @return Id of the tree list item
       
   189         */
       
   190         TAknTreeItemID TreeItemId( TInt aIndex );
       
   191 
       
   192         /**
       
   193         * Gets the MsvId of the entry
       
   194         * @param aTreeItemId: Id of item in tree list
       
   195         */
       
   196         TMsvId MsvItemId( TAknTreeItemID aTreeItemId );
       
   197 
       
   198         /**
       
   199         * @return Id of the parent
       
   200         */
       
   201         TAknTreeItemID ParentItemId( TInt aIndex );
       
   202 
       
   203         /**
       
   204         * @return index of the parent in array, KErrNotFound if item has no parent.
       
   205         */
       
   206         TInt ParentItemIndex( TInt aIndex );
       
   207 
       
   208         /**
       
   209         * Set the item id
       
   210         * @param aIndex: Index of the item
       
   211         * @param aTreeItemId: Id of item in tree list
       
   212         */
       
   213         void SetTreeItemId( TInt aIndex, TAknTreeItemID aTreeItemId );
       
   214 
       
   215         /**
       
   216         * Reset one tree item from the array
       
   217         * @param aTreeItemId: id of the item to be reseted
       
   218         */
       
   219         void ResetTreeItemId( TAknTreeItemID aTreeItemId );
       
   220 
       
   221         /**
       
   222         * Reset all tree items from the array
       
   223         */
       
   224         void ResetAllTreeItemId();
       
   225 
       
   226         /**
       
   227         * Finds first unread message from the opened folder
       
   228         */
       
   229         TBool FindFirstUnreadMessageL( TMsvId& aEntryId ) const;
       
   230 
       
   231         /**
       
   232         * Search unread messages under subtitle
       
   233         * @param aSubtitleID: Subtitle Id
       
   234         * @return ETrue if unread entry is found
       
   235         */
       
   236         TBool FindUnreadMessageUnderSubtitleL( TAknTreeItemID aSubtitleID );
       
   237 
       
   238         /**
       
   239         * Returns folder count
       
   240         */
       
   241         TInt FolderCount();
       
   242         
       
   243         /**
       
   244         * Returns message count
       
   245         * @return: Count
       
   246         */
       
   247         TInt MessageCount();
       
   248 
       
   249         /**
       
   250         * Sets MtmUiDataRegistryObserver
       
   251         * Needed only by Outbox list to get status of the message
       
   252         * @param aRegistryObserver: registry observer (usually object of CMceUi)
       
   253         * @return none
       
   254         */
       
   255         void SetRegistryObserver( MMtmUiDataRegistryObserver* aRegistryObserver );
       
   256 
       
   257 
       
   258         /**
       
   259         * Check if folder is remote
       
   260         */
       
   261         TBool IsFolderRemote() const;
       
   262 
       
   263 
       
   264         /**
       
   265         * Check if item is remote
       
   266         */
       
   267         TBool IsItemRemote( TMsvId aItemId ) const;
       
   268 
       
   269 
       
   270         /**
       
   271         * Check connetion status
       
   272         * @return: connection status
       
   273         */
       
   274         TBool IsConnected() const;
       
   275 
       
   276         /**
       
   277         * Finds index of entry
       
   278         */
       
   279         TInt FindEntryIndex( const TDesC& aMatchString ) const;
       
   280 
       
   281         /**
       
   282         * Rebuild array
       
   283         */
       
   284         void RefreshArrayL();
       
   285 
       
   286         /**
       
   287         * Returns how many items created.
       
   288         */
       
   289         TInt EntryCreatedL( TMsvId aEntryId );
       
   290         
       
   291         /**
       
   292         * 
       
   293         * @param aEntryId: entry that was deleted.
       
   294         * @param aTreeItemId: deleted entry tree id, 0 if not found
       
   295         * @param aParentTreeItemId: parent id, 0 if parent was not deleted.
       
   296         * @return: Is subtitle deleted
       
   297         */
       
   298         TBool EntryDeletedL( 
       
   299             TMsvId aEntryId, 
       
   300             TAknTreeItemID& aTreeItemId, 
       
   301             TAknTreeItemID& aParentTreeItemId );
       
   302 
       
   303 
       
   304     public:     // Functions from base classes
       
   305 
       
   306 
       
   307         /**
       
   308         * From MDesCArray
       
   309         */
       
   310         virtual TInt MdcaCount() const;
       
   311 
       
   312         /**
       
   313         * Compares two items
       
   314         */
       
   315         virtual TInt Compare( TAknTreeItemID aFirst, TAknTreeItemID aSecond );
       
   316 
       
   317         /**
       
   318         * Returns index of the item in the list
       
   319         */
       
   320         TInt ItemIndexTreeId( TAknTreeItemID aTreeItemId );
       
   321 
       
   322         /**
       
   323         * Set item mark
       
   324         * @param aFocused: Current item id
       
   325         * @param aState: Set mark status
       
   326         */
       
   327         void SetItemMarked( TAknTreeItemID aFocused, TBool aState );
       
   328 
       
   329         /**
       
   330         * Gets item mark status
       
   331         * @param aFocused: Current item id
       
   332         * @return: Mark status of the item
       
   333         */
       
   334         TBool GetItemMarkStatusL( TMsvId aEntryId );
       
   335 
       
   336         /**
       
   337         * Returns item type 
       
   338         * @return: Item type 
       
   339         */        
       
   340         TInt HCItemType( TInt aIndex );
       
   341 //        THListItemType HCItemType( TInt aIndex );
       
   342 
       
   343         /**
       
   344         * Returns subfolder item count
       
   345         * @param aParent: subfolder Id
       
   346         * @return: number of items
       
   347         */
       
   348         TInt GetSubfolderItemCount( TAknTreeItemID aParent );
       
   349 
       
   350         /**
       
   351         * Saves marked items
       
   352         * @param: aMarked Array of marked tree items id's
       
   353         */
       
   354         void SaveMarkingL(  RArray<TAknTreeItemID>& aMarked );
       
   355         
       
   356         /**
       
   357         * Checkes whether entry belongs to today or not
       
   358         * @param: aEntry TMsvEntry of the item (entry to be checked)
       
   359         */
       
   360         TBool IsTodaysEntry(const TMsvEntry& aEntry) const;
       
   361 
       
   362     public:    // Functions from base classes
       
   363         /**
       
   364         * From MMsvSessionObserver
       
   365         */
       
   366         virtual void HandleSessionEventL(
       
   367             TMsvSessionEvent aEvent,
       
   368             TAny* aArg1,
       
   369             TAny* aArg2,
       
   370             TAny* aArg3);
       
   371 
       
   372     private:
       
   373 
       
   374         /**
       
   375         * By default Symbian OS constructor is private.
       
   376         */
       
   377         void ConstructL();
       
   378 
       
   379         /**
       
   380         *
       
   381         */
       
   382         CMceOneRowListItemArray(
       
   383             CMsvSessionPtr aSession,
       
   384             TMsvId aFolderId );
       
   385 
       
   386         /**
       
   387         * Appends aSourceString to aTargetString and changes KColumnListSeparator
       
   388         * characters to space characters.
       
   389         * @param aTargetString buffer to append aSource string.
       
   390         * @param aSourceString source buffer.
       
   391         */
       
   392         void StripAndAppendString(TDes& aTargetString, const TDesC& aSourceString) const;
       
   393 
       
   394         /**
       
   395         * Appends folder entry string to the buffer.
       
   396         * @param aBuffer: buffer to be append
       
   397         * @param aEntry: entry to be append. Must be folder.
       
   398         */
       
   399         void AppendFolderString( TDes& aBuffer, const TMsvEntry& aEntry ) const;
       
   400 
       
   401         /**
       
   402         * Appends recipient string to the buffer.
       
   403         * @param aBuffer: buffer to be append
       
   404         * @param aEntry: entry to be append. Must be message.
       
   405         */
       
   406         void AppendRecipientStringL( TDes& aBuffer, const TMsvEntry& aEntry ) const;
       
   407 
       
   408         /**
       
   409         * Handles folders, messages string
       
   410         * @param aBuffer: buffer to be append
       
   411         * @param aEntry TMsvEntry of the item.
       
   412         */
       
   413         void HandleFolderMessagesStringL( TDes& aBuffer, const TMsvEntry& aEntry ) const;
       
   414 
       
   415         /**
       
   416         * Appends Bt/IrDa message entry string to the buffer.
       
   417         * @param aBuffer: buffer to be append
       
   418         * @param aEntry: entry to be append. Must be message.
       
   419         */
       
   420         void AppendBtIrMessageStringL( TDes& aBuffer, const TMsvEntry& aEntry ) const;
       
   421         
       
   422         /**
       
   423         * Get timezone correction to entry time 
       
   424         * @param aEntryTime: 
       
   425         */
       
   426         void GetTime( TTime& aEntryTime, TTime& aCurrentTime ) const;
       
   427 
       
   428         /**
       
   429         * Creates time or date string for message view listbox.
       
   430         * @param aText: buffer to be append
       
   431         * @param aEntry: message entry
       
   432         * @param aSubtitle: title is present or not
       
   433         * @param aShowTime: time to be shown or not
       
   434         */
       
   435         void AppendTimeStringL( TDes& aText, const TMsvEntry& aEntry, TBool aSubtitle, TBool aShowTime = ETrue ) const;
       
   436         
       
   437         /**
       
   438         * Returns whether the entry is Template folder (ETrue) or not (EFalse).
       
   439         * @param aEntry: message entry
       
   440         * @param aText: buffer to be append
       
   441         * @param aColumn: cloumn to be checked
       
   442         */
       
   443         TBool IsFolderTemplate( const TMsvEntry& aEntry, TDes& aText, TInt aColumn );
       
   444 
       
   445     private:    // Data
       
   446         CMsvSessionPtr                  iSession;
       
   447         TMsvId                          iFolderId;
       
   448         CDesCArrayFlat*                 iNumberOfMessagesStrings;
       
   449         CMceOneRowListItemArrayLoader*  iMceListItemArrayLoader;
       
   450         CCoeEnv*                        iOwnEikonEnv;
       
   451 
       
   452         // String array        
       
   453         CDesCArrayFlat*                 iSubtitleStrings;
       
   454         MMtmUiDataRegistryObserver*     iRegistryObserver;
       
   455         TBool                           iShowDate;
       
   456         TInt                            iDescriptionLength;
       
   457 
       
   458     };
       
   459 
       
   460 #endif      // MCEONEROWLISTITEMARRAY_H
       
   461 
       
   462 
       
   463 // End of File