messagingappbase/mce/inc/MceMessageListContainerBase.h
changeset 0 72b543305e3a
equal deleted inserted replaced
-1:000000000000 0:72b543305e3a
       
     1 /*
       
     2 * Copyright (c) 2007 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 *     Pure virtua class for message view to handle listbox.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 #ifndef MCEMESSAGELISTCONTAINERBASE_H
       
    22 #define MCEMESSAGELISTCONTAINERBASE_H
       
    23 
       
    24 //  INCLUDES
       
    25 #include <coecntrl.h> // CCoeControl
       
    26 #include <msvapi.h>
       
    27 //#include "MceListContainer.h"
       
    28 //#include "MceMessageListContTimer.h"
       
    29 
       
    30 #include "mcetemplate.h"
       
    31 #include "MceUtils.h"
       
    32 #include "MceListItem.h"
       
    33 #include <centralrepository.h> //CRepository
       
    34 #include <bldvariant.hrh>
       
    35 #include <eikcmobs.h>
       
    36 #include <e32property.h>
       
    37 
       
    38 // FORWARD DECLARATIONS
       
    39 class CMceMessageListView;
       
    40 class MMtmUiDataRegistryObserver;
       
    41 
       
    42 //CONSTS
       
    43 //const TInt KMceSelectionReplacementSize = 5;
       
    44 enum TMceContainerFlags
       
    45     {
       
    46     EMceOneRowFlagOptionsMenuOpen   = 0x01, // options menu open status
       
    47     EMceOneRowFlagFirstSubtitleOpen = 0x02
       
    48     };
       
    49 
       
    50 
       
    51 // CLASS DECLARATION
       
    52 
       
    53 /**
       
    54 * Base class for all the message list containers. 
       
    55 * This class is used by message list view.
       
    56 * @since S60 5.0
       
    57 */
       
    58 class  CMceMessageListContainerBase :
       
    59     public CCoeControl,
       
    60     public MEikCommandObserver
       
    61     {
       
    62     public:  // Constructors and destructor
       
    63 
       
    64         /**
       
    65         * Destructor.
       
    66         */
       
    67         virtual ~CMceMessageListContainerBase();
       
    68 
       
    69     public:
       
    70     
       
    71         /**
       
    72         * TODO: Needed?
       
    73         * 1 = two row
       
    74         * 2 = hierachical list
       
    75         */
       
    76         virtual TInt MceListId() const = 0;
       
    77     
       
    78         /**
       
    79         * @return number of items in list (total list item count, including ALL the items with one row list)
       
    80         */
       
    81         virtual TInt Count() const = 0;
       
    82         
       
    83         /**
       
    84         * @return message count
       
    85         */
       
    86         virtual TInt MessageCount() const = 0;
       
    87         
       
    88         /**
       
    89         * @return folder count
       
    90         * TODO: some other count also needed? Subtitle row count?
       
    91         */
       
    92         virtual TInt FolderCount() const = 0;
       
    93         
       
    94         /**
       
    95         * Changes currently opened folder
       
    96         * @param aFolderId: id of the folder to be opened.
       
    97         * TODO: should this open inbox in case of imap?
       
    98         */
       
    99         virtual void SetFolderL( TMsvId aFolderId ) = 0;
       
   100         
       
   101         /**
       
   102         * Returns id of the currently opened folder
       
   103         * @return folder id
       
   104         */
       
   105         virtual TMsvId CurrentFolderId() const = 0;
       
   106         
       
   107         /**
       
   108         * Returns the currently opened folder entry.
       
   109         * @return TMsvEntry of the opened folder.
       
   110         */
       
   111         virtual const TMsvEntry& FolderEntry() const = 0;
       
   112 
       
   113         
       
   114         /**
       
   115         * Returns message id of the currently focused item
       
   116         * @return TMsvId of the entry
       
   117         * TODO: should this be TInt so that it could be used to subtitles?
       
   118         */
       
   119         virtual TMsvId  CurrentItemId() const = 0;
       
   120 
       
   121         /**
       
   122         * TMessageListItemType
       
   123         * different list item types, CurrentItemType
       
   124         */
       
   125         enum TMessageListItemType
       
   126             {
       
   127             /**
       
   128             * unknown item (list is empty?)
       
   129             */
       
   130             EMessageListItemUnknown = 0,
       
   131             
       
   132             /**
       
   133             * Item can be found from message store (CurrentItemId() returns TMsvId)
       
   134             */
       
   135             EMessageListItemMsvItem,
       
   136             
       
   137             /**
       
   138             * something else ( one row list; subtitle?)
       
   139             */
       
   140             EMessageListItemSubtitle,
       
   141             
       
   142             /**
       
   143             * Tree list root
       
   144             */
       
   145             EMessageListItemRoot
       
   146             };
       
   147             
       
   148         /**
       
   149         * @return Type of the currently focused item
       
   150         */
       
   151         virtual TMessageListItemType CurrentItemType() const = 0;
       
   152         
       
   153         /**
       
   154         * Changes focus to the entry of the given id.
       
   155         * @return ETrue if aEntryId found otherwise EFalse.
       
   156         */
       
   157         virtual TBool SetCurrentItemIdL( TMsvId aEntryId ) = 0;
       
   158         
       
   159         /**
       
   160         * Changes focus to the first entry.
       
   161         */
       
   162         virtual void ResetCurrentItemL() = 0;
       
   163         
       
   164         
       
   165         /**
       
   166         * Searches aMatchString from the list and returns first found entry id.
       
   167         * Returns KErrNotFound if not found.
       
   168         * TODO: container should move focus automatically?
       
   169         */
       
   170         virtual TMsvId FindEntry( const TDesC& aMatchString ) const = 0;
       
   171         
       
   172         /**
       
   173         * Finds first unread message from the opened folder. 
       
   174         * aEntry is set KErrNotFound if no unread messages in the folder,
       
   175         * otherwise id of the first unread message.
       
   176         * @return ETrue if exactly one unread message in current folder
       
   177         * EFalse otherwise.
       
   178         */
       
   179         virtual TBool FindFirstUnreadMessageL( TMsvId& aEntryId ) const = 0;
       
   180         
       
   181         /**
       
   182         * TODO: that is not needed if container would be msv session observer
       
   183         */
       
   184         virtual void ItemCountChangedL( TBool aItemsAdded ) = 0;
       
   185         
       
   186         /**
       
   187         * Redraw the listbox.
       
   188         */
       
   189         virtual void RefreshListbox() = 0;
       
   190         
       
   191         /**
       
   192         * Returns array of currently selected (marked) messages.
       
   193         * (Focus is added, if no other markings)
       
   194         * Caller's responsibility to destroy array!
       
   195         * @return Array of selected items.
       
   196         */
       
   197         virtual CMsvEntrySelection* CurrentItemSelectionL() = 0;
       
   198 
       
   199         /**
       
   200         * Refreshes selection by calling MarkItemSelectionL and
       
   201         * then returns selection by calling CurrentItemSelectionL
       
   202         * Caller's responsibility to destroy array!
       
   203         * @return Array of selected items.
       
   204         */
       
   205         virtual CMsvEntrySelection* CurrentItemSelectionRefreshL() = 0;
       
   206 
       
   207         /**
       
   208         * Returns number of marked items including focus if no other selections.
       
   209         * @return Number of items marked, if no marked items then 1 is returned (focus).
       
   210         * 0 is returned only if list is empty.
       
   211         */
       
   212         virtual TInt CurrentItemSelectionCount() const = 0;
       
   213         
       
   214         /**
       
   215         * Returns number of selected/marked messages, focus is not included.
       
   216         * @return Number of items selected (0 or more)
       
   217         */
       
   218         virtual TInt SelectionCount() const = 0;
       
   219         
       
   220         /**
       
   221         * Returns ETrue if aItemId is marked.
       
   222         */
       
   223         virtual TBool IsItemSelected( TMsvId aItemId ) = 0;
       
   224 
       
   225         /**
       
   226         * Clears selection.
       
   227         */
       
   228         virtual void ClearSelection() = 0;
       
   229 
       
   230         /**
       
   231         * Reads selected item indexes from the listbox and then stores
       
   232         * selected items TMsvId's to iSelectedEntries array.
       
   233         * If no items marked then currently selected item is added to array
       
   234         *
       
   235         * This can be called when for example opening options menu. Options menu
       
   236         * can overlap whole list box and if then new message is received it is selected
       
   237         * on background. Now if user selected 'Delete' then message which was selected
       
   238         * before opening options menu is deleted, not just received message because
       
   239         * it is stored by this function.
       
   240         */
       
   241         virtual void MarkItemSelectionL() = 0;
       
   242 
       
   243         /**
       
   244         * Adds currently focused item to marked array.
       
   245         */
       
   246         virtual void AddCurrentItemToSelectionL() = 0;
       
   247 
       
   248         /**
       
   249         * Removes currently selected item (== 'cursor') from selected array
       
   250         */
       
   251         virtual void RemoveCurrentItemFromSelection() = 0;
       
   252 
       
   253         /**
       
   254         * TODO: update description for more generic. Now it is only for old list:
       
   255         * Updates selection indexes by reading selected message's TMsvIds from iSelectedEntries
       
   256         * and creates new CSelectionIndexArray.
       
   257         * @param aForceUpdate: set ETrue if index update is wanted to be done even when
       
   258         *   listbox's selection does not include any items.
       
   259         *   Usually this is set true only when calling from CMceBaseListView::HandleEntriesDeletedL
       
   260         */
       
   261         virtual void RefreshSelectionIndexesL( TBool aForceUpdate ) = 0 ;
       
   262 
       
   263         /**
       
   264         * Adds all the messages to listbox selection index array
       
   265         */
       
   266         virtual void AddAllToSelectionL() = 0;
       
   267         
       
   268         /**
       
   269         * Mark all read messages.
       
   270         */
       
   271         virtual void MarkAllReadMessagesL() = 0;
       
   272         
       
   273         /**
       
   274         * Return the count of marked items. if there is no marked item, returns 0;
       
   275         */
       
   276         virtual TInt MarkedItemsCount() = 0;
       
   277 
       
   278         /**
       
   279         * Checks if currently selected item is folder.
       
   280         * @return ETrue if item aItemId is folder.
       
   281         * NOTE: aItemId must be found from msg store. 
       
   282         *       if item not found, returns EFalse;
       
   283         */
       
   284         virtual TBool IsItemFolder( TMsvId aItemId ) const = 0;
       
   285         
       
   286         /**
       
   287         * Returns ETrue if aItemId is under remote service
       
   288         */
       
   289         virtual TBool IsItemRemote( TMsvId aItemId ) const = 0;
       
   290 
       
   291         /**
       
   292         * checks if aFolderId is currently opened
       
   293         * Return ETrue if currently opened folder is aFolderId
       
   294         * For example if needs to be checked if outbox is opened call:
       
   295         *   IsOpenedFolder( KMsvGlobalOutBoxIndexEntryId )
       
   296         */
       
   297         virtual TBool IsOpenedFolder( TMsvId aFolderId ) const = 0;
       
   298 
       
   299         /**
       
   300         * Sets sort order
       
   301         * @param aSortType: from MceCommands.hrh
       
   302         * @param aOrdering: sort ordering(ascending/descending)  
       
   303         */
       
   304         virtual void SetSortTypeL( TInt aSortType, TBool aOrdering ) = 0;
       
   305         
       
   306         /**
       
   307         *
       
   308         */
       
   309         virtual void SetMtmUiDataRegistry( MMtmUiDataRegistryObserver* aRegistryObserver ) = 0;
       
   310 
       
   311         /**
       
   312         * Sets empty text for the listbox.
       
   313         * @param aText: empty text
       
   314         */
       
   315         virtual void SetListEmptyTextL(const TDesC& aText) = 0;
       
   316         
       
   317         /**
       
   318         * TMessageListOperationType
       
   319         * different mailbox operation types to handle cursor 
       
   320         */
       
   321         enum TMessageListOperationType
       
   322             {
       
   323             /**
       
   324             *
       
   325             */
       
   326             EMessageListOperationGeneral = 0,
       
   327             
       
   328             /**
       
   329             *
       
   330             */
       
   331             EMessageListOperationConnect,
       
   332             
       
   333             /**
       
   334             *
       
   335             */
       
   336             EMessageListOperationFetchSelected,
       
   337             
       
   338             /**
       
   339             *
       
   340             */
       
   341             EMessageListOperationFetchNew,
       
   342             
       
   343             /**
       
   344             *
       
   345             */
       
   346             EMessageListOperationDelete,
       
   347             
       
   348             /**
       
   349             * Called when operation is completed
       
   350             * NOTE: this is not 100% to be called when operation is ready.
       
   351             *   For example imap4 create connection operation is not completed
       
   352             *   when connection is created, onle when connection is closed!
       
   353             */
       
   354             EMessageListOperationCompleted
       
   355             };
       
   356 
       
   357         
       
   358         /**
       
   359         * Called by application when operation is started.
       
   360         * List container can set anchor item or what ever it wants to keep 
       
   361         * focus in sensible place during the operation.
       
   362         * OPEN:
       
   363         * Problem is that operation completion is not informed so
       
   364         * listcontainer should handle that somehow...?
       
   365         */
       
   366         virtual void SetAnchorItemIdL( 
       
   367             TMessageListOperationType aOperationType ) = 0;
       
   368             
       
   369         /**
       
   370         * TODO: that is not needed if container would be msv session observer
       
   371         * TODO: remove ItemCountChangedL
       
   372         * @param aEvent: notified events: 
       
   373         *   EMsvEntriesDeleted, EMsvEntriesCreated, EMsvEntriesChanged
       
   374         * @param aSelection: CMsvEntrySelection of the entries changed/deleted/created.
       
   375         * @param aDrawNow: EFalse means CMceUi has ViewUpdateSuppressionFlag ON
       
   376         *   so listbox should not redraw itself, then only update anchor item etc.
       
   377         *   When operation is completed then container will get 
       
   378         *   SetAnchorItemIdL call with parameter EMessageListOperationCompleted.
       
   379         *   ETrue means that listbox can redraw itself if needed.
       
   380         * See also SetAnchorItemIdL
       
   381         */
       
   382         virtual void HandleMsvSessionEventL( 
       
   383             MMsvSessionObserver::TMsvSessionEvent aEvent,
       
   384             CMsvEntrySelection& aSelection,
       
   385             TBool aDraw ) = 0;
       
   386             
       
   387         /**
       
   388         * Returns ETrue if empty list or there are items selected.
       
   389         */
       
   390         virtual TBool DisplayOptionsMenuFromSelectionKey() const = 0;
       
   391 
       
   392         
       
   393         /**
       
   394         * Used to show different menu command offered by message list view
       
   395         * At the moment there are only Expand and Collapse options menu items 
       
   396         * but there can be more...
       
   397         */
       
   398         enum 
       
   399             {
       
   400             /**
       
   401             * Return TMessageListCommandNone if all the menu items dimmed,
       
   402             * otherwise corresponding flag value. 
       
   403             */
       
   404             TMessageListCommandNone = 0,
       
   405             /**
       
   406             * TMessageListCommandExpand: return this if expand command is visible.
       
   407             */
       
   408             TMessageListCommandExpand = 0x01,
       
   409             /**
       
   410             * TMessageListCommandCollapse1: return this if collapse, which is 
       
   411             *    immediately after expand command, is visible.
       
   412             */
       
   413             TMessageListCommandCollapse1 = 0x02,
       
   414             /**
       
   415             * TMessageListCommandCollapse2: return this if collapse, which is 
       
   416             *    after reply command, is visible.
       
   417             */
       
   418             TMessageListCommandCollapse2 = 0x04
       
   419             };
       
   420             
       
   421         /**
       
   422         * Return correct flag to set command visible in message 
       
   423         * list view's options menu. 
       
   424         * if expand valid command, then return TMessageListCommandExpand,
       
   425         * if collapse valid command, then return either TMessageListCommandCollapse1 
       
   426         *    or TMessageListCommandCollapse2 but NOT both.
       
   427         */
       
   428         virtual TUint OptionsCommandSupported() const = 0;
       
   429         
       
   430         /**
       
   431         *
       
   432         */
       
   433         virtual void HandleOptionsCommandL( TInt aCommand ) = 0;
       
   434         
       
   435         /**
       
   436         * Called when time or date format has been changed or 
       
   437         *   midnight is passed. 
       
   438         * @param aChangeFlag: flag defined in TChanges in e32const.h.
       
   439         *   Notifies only the following events:
       
   440         *   - EChangesLocale
       
   441         *   - EChangesMidnightCrossover
       
   442         *   - EChangesSystemTime
       
   443         */
       
   444         virtual void DateTimeFormatChangedL( TInt aChangeFlag ) = 0;
       
   445 
       
   446         /**
       
   447         * Returns container Msk
       
   448         */
       
   449         virtual TInt SetSpecialMskL() = 0;
       
   450 
       
   451         /**
       
   452         * Sets message list container flags
       
   453         * @param aFlag: Name of the flag
       
   454         * @param aState: State for the flag
       
   455         */
       
   456         virtual void SetContainerFlag( TMceContainerFlags aFlag, TBool aState ) = 0;
       
   457 
       
   458         /**
       
   459         *  Updates icon array in case MTM is released (one row list)
       
   460         */
       
   461         virtual void UpdateIconArrayL() = 0;
       
   462         
       
   463     protected:
       
   464     
       
   465         /**
       
   466         *
       
   467         */
       
   468         CMceMessageListContainerBase( CMceMessageListView& aOwningView );
       
   469         
       
   470     protected:
       
   471 
       
   472         CMceMessageListView&            iOwningView;        
       
   473 
       
   474     };
       
   475     
       
   476 
       
   477 #endif
       
   478 
       
   479 // End of file