cbs/cbsui/UiInc/CCbsUiTopicView.h
branchRCL_3
changeset 20 987c9837762f
parent 0 ff3b6d0fd310
equal deleted inserted replaced
19:7d48bed6ce0c 20:987c9837762f
       
     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:  Header file for the CCbsUiTopicView class.
       
    15 *
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 #ifndef __CCBSUITOPICVIEW_H
       
    21 #define __CCBSUITOPICVIEW_H
       
    22 
       
    23 //  INCLUDES
       
    24 #include <aknview.h>
       
    25 #include <CbsCommon.h>
       
    26 #include <AknNaviDecoratorObserver.h>
       
    27 #include "MCbsUiTopicMonitorObserver.h"
       
    28 #include "MSaveMessageController.h"
       
    29 #include "CbsUiDebug.h"
       
    30 
       
    31   
       
    32 //  FORWARD DECLARATIONS
       
    33 
       
    34 class CCbsUiTopicViewContainer;
       
    35 class MCbs;
       
    36 class CAknNavigationDecorator;
       
    37 class CAknNavigationControlContainer;
       
    38 
       
    39 //  CLASS DEFINITIONS 
       
    40 
       
    41 /**
       
    42 * For showing message in one topic.
       
    43 */
       
    44 class CCbsUiTopicView : public CAknView, 
       
    45                         public MCbsUiTopicMonitorObserver,
       
    46                         public MSaveMessageController,
       
    47                         public MAknNaviDecoratorObserver
       
    48     {
       
    49     private: // Data declaration
       
    50 
       
    51         enum TTopicViewFocusState 
       
    52             {
       
    53             ESetFocusToCurrentHandle, 
       
    54             ESetFocusToFirstItem, 
       
    55             ESetFocusToNewestMessage, 
       
    56             ENoFocusUpdate 
       
    57             };
       
    58 
       
    59     public: // Constructors and destructor        
       
    60       
       
    61         /**
       
    62         * Creates instance of the class.
       
    63         *    
       
    64         * @param aServer reference to the server
       
    65         * @return It is the created instance.
       
    66         */
       
    67         static CCbsUiTopicView* NewL( MCbs& aServer );
       
    68         
       
    69         /**
       
    70         * Destructor.
       
    71         */
       
    72         ~CCbsUiTopicView();
       
    73         
       
    74     public: // New functions        
       
    75      
       
    76         /**
       
    77         * Marks the current handle. This should be called only when 
       
    78         * the Options menu is created and when the Ok (selection) key
       
    79         * has been pressed.
       
    80         */
       
    81         void MarkCurrentlyFocusedHandle();
       
    82 
       
    83         /**
       
    84         * Handle changes in container when rect changes.
       
    85         */
       
    86         void HandleRectChangeInContainer();
       
    87 
       
    88     public: // From MCbsUiTopicMonitorObserver
       
    89 
       
    90         /**
       
    91         * Topic list or topic messages are changed.
       
    92         *
       
    93         * @param aEvent reason for event
       
    94         * @param aTopicNumber Topic number, which caused the event
       
    95         */
       
    96         void TopicListChangedL(
       
    97             TCbsTopicListEvent aEvent, TCbsTopicNumber aTopicNumber );
       
    98 
       
    99     public: // From MSaveMessageController
       
   100 
       
   101         /**
       
   102         *   Saves a message (the saved message won't be deleted to make 
       
   103         *   room for new messages).
       
   104         *
       
   105         *   Return codes:
       
   106         *   KErrNone            Message is saved.
       
   107         *   KErrGeneral         Message not saved -- total maximum of saved 
       
   108         *                       messages reached.
       
   109         *   KErrNotFound        Message not saved -- no message associated
       
   110         *                       with the given handle.
       
   111         *   KErrDiskFull        Message not saved -- FFS out of space.
       
   112         *
       
   113         *   @param  aHandle     Handle to the message to be saved.
       
   114         *   @return             Return code.
       
   115         */
       
   116         TInt SaveMessage( const TCbsMessageHandle& aHandle );
       
   117 
       
   118     private: // from MEikMenuObserver
       
   119     
       
   120         /**
       
   121         * Sets the options menu according to the current message.
       
   122         *
       
   123         * @param aResouceId Id of the resouce.
       
   124         * @param aMenuPane Pointer to the menu pane.
       
   125         */ 
       
   126         void DynInitMenuPaneL( TInt aResourceId, CEikMenuPane* aMenuPane );
       
   127 
       
   128         /**
       
   129         * Overrides MEikMenuObserver function SetEmphasis. Default 
       
   130         * implementation has been copied here. 
       
   131         * 
       
   132         * Checks if the menu pane is showing. If the menu pane is not
       
   133         * showing, message is unlocked, because it has been locked when
       
   134         * the menu pane was created. 
       
   135         * 
       
   136         * @param aMenuControl pointer to the menu control
       
   137         * @param aEmphasis ETrue if menu is showing; otherwise EFalse
       
   138         */
       
   139     	void SetEmphasis( CCoeControl* aMenuControl,TBool aEmphasis );
       
   140     
       
   141     public: // from CAknView
       
   142         
       
   143         /**
       
   144         * Returns the view id.
       
   145         */
       
   146         TUid Id() const;        
       
   147 
       
   148         /**
       
   149         * To catch which command is selected before menu pane is closed.
       
   150         *
       
   151         * @param aCommand command to be processed
       
   152         */
       
   153         void ProcessCommandL( TInt aCommand );
       
   154        
       
   155         /**
       
   156         * Processes the command.
       
   157         *    
       
   158         * @param aCommand It is the command to be processed.
       
   159         */
       
   160         void HandleCommandL( TInt aCommand );         
       
   161        
       
   162     protected: // from CAknView
       
   163         
       
   164         /**
       
   165         * Activates the view.
       
   166         *
       
   167         * @param aPrevViewId previous view id
       
   168         * @param aCustomMessageId id of the custom message
       
   169         * @param aCustomMessage message data
       
   170         */
       
   171         void DoActivateL(
       
   172             const TVwsViewId& aPrevViewId, 
       
   173             TUid aCustomMessageId, const TDesC8& aCustomMessage );
       
   174         
       
   175         /**
       
   176         * Deactivates the view.
       
   177         */
       
   178         void DoDeactivate();        
       
   179 
       
   180     private: // New functions
       
   181 
       
   182         /**
       
   183         * Sets focus to message, according to aIndex.
       
   184         *
       
   185         * @param aIndex Index of the focused message.
       
   186         */
       
   187         void SetFocusToMessage( TInt aIndex );
       
   188        
       
   189         /**
       
   190         * Reloads the messages.
       
   191         */
       
   192         void ReloadMessagesL();        
       
   193       
       
   194         /**
       
   195         * Return the total amount of messages. ("loaded").
       
   196         *
       
   197         * @return total amount of messages
       
   198         */
       
   199         TInt TotalMessages() const;
       
   200 
       
   201         /**
       
   202         * Locks the message in the server. Only one message can locked
       
   203         * at same time. When new message is locked, old message is unlocked.
       
   204         *
       
   205         * @param aHandle Message handle to be locked.
       
   206         */
       
   207         TInt LockMessage( TCbsMessageHandle aHandle );
       
   208 
       
   209         /**
       
   210         * Unlocks the message from the server.
       
   211         */
       
   212         void UnLockMessage();
       
   213 
       
   214         /**
       
   215         * Updates the status pane.
       
   216         */
       
   217         void UpdateTitlePaneL( const TCbsTopic& aTopic ) const;
       
   218 
       
   219         /**
       
   220         * Updates the title pane.
       
   221         */
       
   222         void UpdateNaviPaneL( const TCbsTopic& aTopic );
       
   223         
       
   224         /**
       
   225         * Shows the message in a dialog.
       
   226         */
       
   227         void ShowMessageL();
       
   228 
       
   229         /**
       
   230         * Finds message index by handle.
       
   231         *
       
   232         * @param aIndex it will contain the topic index
       
   233         * @param aMessageHandle handle to the message
       
   234         * @return KErrNone if handle exists
       
   235         */
       
   236         TInt FindMessageIndexByHandle(
       
   237             TInt& aIndex,
       
   238             const TCbsMessageHandle& aMessageHandle );
       
   239         
       
   240         /**
       
   241         * Loads all message titles from the server in one topic and offers
       
   242         * those to the container.
       
   243         *
       
   244         * @param aTopicNumber Message headers will be loaded from this topic.
       
   245         */
       
   246         void LoadAllMessageTitlesL( TCbsTopicNumber aTopicNumber );
       
   247 
       
   248         /**
       
   249         * Prepares container for reloading.
       
   250         */
       
   251         void PrepareReloading();
       
   252 
       
   253         /**
       
   254         * Sets focus in the list box according to current topic number.
       
   255         * It also set the focus according to the view focus state.
       
   256         *
       
   257         * @param aFocusState indicates where to put the focus
       
   258         */
       
   259         void SetFocusAfterReloading( TTopicViewFocusState aFocusState );
       
   260 
       
   261         /**
       
   262         * Sets a new current handle according to aDeletedHandle.
       
   263         *
       
   264         * @param aDeletedHandle A handle to message which has been deleted.
       
   265         */
       
   266         void SetNewCurrentHandle( TCbsMessageHandle aDeletedHandle );
       
   267 
       
   268         /**
       
   269         * Sets current topic number according to aToPrev
       
   270         * 
       
   271         * @param aToPrev Sets current topic number to previous if ETrue
       
   272         */
       
   273         void SetCurrentTopicNumber( TBool aToPrev );
       
   274 
       
   275         /**
       
   276         * Sets current topic number to aTopicNumberDes. It is used in
       
   277         * view activation.
       
   278         *
       
   279         * @param aTopicNumberDes new current topic number
       
   280         */
       
   281         void SetCurrentTopicNumberAndMessageHandle( const TDesC8& aTopicNumberDes );
       
   282 
       
   283         /**
       
   284         * Activates message view with the aMsgHandle.
       
   285         *
       
   286         * @param aMsgHandle A message handle to be activeted.
       
   287         */
       
   288         void ActivateMsgViewL( TCbsMessageHandle aMsgHandle ) const;
       
   289 
       
   290         /**
       
   291         * Activates topic list view with topic number.
       
   292         *
       
   293         * @param aTopicNumber sets the topic number in topic list view.
       
   294         */
       
   295         void ActivateTopicListViewL( TCbsTopicNumber aTopicNumber ) const;
       
   296 
       
   297         /**
       
   298         * Checks if it is possible to move to previous, next
       
   299         * or both directions.
       
   300         *
       
   301         * @param aToPrevious ETrue if it is possible to move to previous topic
       
   302         * @param aToNext ETrue if it is possible to move to next topic
       
   303         * @param error code
       
   304         */
       
   305         TInt CheckIfCanMove( TBool& aToPrevious, TBool& aToNext );
       
   306 
       
   307         /**
       
   308         * Activates the list box after changes. List box is owned by 
       
   309         * the container.
       
   310         */
       
   311         void ActivateListBoxL();
       
   312         
       
   313         /**
       
   314         * Set the middle soft key text.
       
   315         *
       
   316         * @param aResourceId    Resource to be read (text label)
       
   317         * @param aCommandId     Command ID for MSK command
       
   318         */
       
   319         void SetMiddleSoftKeyLabelL( const TInt aResourceId, const TInt aCommandId );
       
   320         
       
   321         /**
       
   322         * Removes MSK command mappings.       
       
   323         */
       
   324         void RemoveCommandFromMSK();
       
   325 
       
   326     private:
       
   327         
       
   328         /**
       
   329         * It defines the type for message handle lists.
       
   330         */
       
   331         typedef CArrayFixFlat< TCbsMessageHandle > TCbsUiMessageHandleList;       
       
   332       
       
   333         /**
       
   334         * Constructor.
       
   335         *
       
   336         * @param aServer reference to the server
       
   337         * @param aApplication reference to the application
       
   338         */
       
   339         CCbsUiTopicView( MCbs& aServer );
       
   340         
       
   341         /**
       
   342         * Finalizes the construction.
       
   343         */
       
   344         void ConstructL(); 
       
   345         
       
   346     private: // From MAknNaviDecoratorObserver
       
   347         
       
   348         /**
       
   349          * Method for handling touch events on navigator (navi pane)
       
   350          * 
       
   351          * @param aEventID Id of the event.
       
   352          */
       
   353         void HandleNaviDecoratorEventL( TInt aEventID );
       
   354 
       
   355     private: // Data
       
   356        
       
   357         // container to the CCbsUiTopicView
       
   358         CCbsUiTopicViewContainer* iContainer; 
       
   359         
       
   360         // navi pane variables
       
   361         CAknNavigationControlContainer* iNaviContainer;
       
   362       
       
   363         // navi pane
       
   364         CAknNavigationDecorator* iDecoratedLabel;
       
   365         
       
   366         // navi pane
       
   367         CAknNavigationDecorator* iPreviousDecoratedLabel;
       
   368      
       
   369         // reference to server
       
   370         MCbs& iServer;
       
   371         
       
   372         // array for message handles
       
   373         TCbsUiMessageHandleList* iHandles;
       
   374 
       
   375         // handle to a message, which is focused on.
       
   376         TCbsMessageHandle iCurrentHandle;
       
   377 
       
   378         // Topic number, which this view is currently handling.
       
   379         TCbsTopicNumber iCurrentTopicNumber;
       
   380 
       
   381         // If this is ETrue, message can be unlocked and there fore
       
   382         // deleted. It is set EFalse in ProcessCommandL, ETrue
       
   383         // in DoActivateL and in HandleCommandL.
       
   384         TBool iCanUnlock;
       
   385         
       
   386     };
       
   387     
       
   388     
       
   389 #endif // __CCBSUITOPICVIEW_H
       
   390     
       
   391 // End of File