cbs/cbsui/UiInc/CCbsUIMsgView.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: 
       
    15 *   Class for viewing messages.
       
    16 *
       
    17 *
       
    18 */
       
    19 
       
    20 
       
    21 #ifndef __CBSMSGVIEW_H
       
    22 #define __CBSMSGVIEW_H
       
    23 
       
    24 //  INCLUDES
       
    25 #include <CbsCommon.h>
       
    26 #include <aknview.h>
       
    27 #include <AknNaviDecoratorObserver.h>
       
    28 #include "MCbsUiTopicMonitorObserver.h"
       
    29 #include "MSaveMessageController.h"
       
    30 #include "CbsUiDebug.h"
       
    31 
       
    32 
       
    33 // FORWARD DECLARATIONS
       
    34 class CCbsUiTopicView;
       
    35 class CCbsUiMsgViewContainer;
       
    36 class CAknNavigationDecorator;
       
    37 class CFindItemMenu;
       
    38 class MCbs;
       
    39 class CAknNavigationControlContainer;
       
    40 
       
    41 // CLASS DECLARATION
       
    42 /**
       
    43 *	It is the class for viewing messages.
       
    44 */
       
    45 class CCbsUiMsgView : public CAknView,
       
    46                       public MCbsUiTopicMonitorObserver,
       
    47                       public MSaveMessageController,
       
    48                       public MAknNaviDecoratorObserver                      
       
    49     {
       
    50     public: // Constructors and destructor   
       
    51         
       
    52         /**
       
    53         * Destructor.
       
    54         */
       
    55         ~CCbsUiMsgView();
       
    56         
       
    57         /**
       
    58         * Two-phased constructor.
       
    59         *
       
    60         * @param aServer Reference to cbs server.
       
    61         */
       
    62         static CCbsUiMsgView* NewL( MCbs& aServer );
       
    63         
       
    64     private: // From MEikMenuObserver
       
    65 
       
    66         /*
       
    67         * Adds find item and checks weather delete, keep or both of
       
    68         * them should be removed.
       
    69         *
       
    70         * @param aResourceId resource ID for identifying the menu pane being 
       
    71         *                    initialised.
       
    72         * @param aMenuPane the in-memory representation of the menu pane.
       
    73         */
       
    74         void DynInitMenuPaneL( TInt aResourceId, CEikMenuPane* aMenuPane );
       
    75         
       
    76     private: // From MAknNaviDecoratorObserver
       
    77         
       
    78 		/**
       
    79 		* Method for handling touch events on navigator (navi pane)
       
    80 		* 
       
    81 		* @param aEventID Id of the event.
       
    82 		*/
       
    83     	void HandleNaviDecoratorEventL( TInt aEventID );
       
    84         
       
    85     public: // From MEikCommandObserver
       
    86         
       
    87         /**
       
    88         * Closes context menu if it exists.
       
    89         *
       
    90         * @param aCommandId Command id, which has been pressed.
       
    91         */
       
    92         void ProcessCommandL( TInt aCommandId );
       
    93        
       
    94     public: // From CAknView
       
    95 
       
    96         /**
       
    97         * Returns view id.
       
    98         * 
       
    99         * @return View ID.
       
   100         */
       
   101         TUid Id() const;
       
   102         
       
   103         /**
       
   104         * Handles the command.
       
   105         *
       
   106         * @param aCommand menu command which user has selected from 
       
   107         *                 option menu
       
   108         */
       
   109         void HandleCommandL( TInt aCommand );        
       
   110         
       
   111         /**
       
   112         * Activates the message view. Actiovation depends on the message.
       
   113         * Three variations are: normal, immediate and 
       
   114         *                       soft notification messages.
       
   115         *
       
   116         * @param aPrevViewId Previous view id.
       
   117         * @param aCustomMessageId With this different mechanism of activations
       
   118         *                          are used. Immediate message uses 
       
   119         *                          KCbsImmediateMessageIdInt and normal message
       
   120         *                          uses KCbsUiCustomMessageId. If the message id
       
   121         *                          differ from these, the message is activated
       
   122         *                          by soft notification
       
   123         * @param aCustomMessage Message content.
       
   124         */
       
   125         void DoActivateL(
       
   126             const TVwsViewId& aPrevViewId, 
       
   127             TUid aCustomMessageId, 
       
   128             const TDesC8& aCustomMessage );
       
   129         
       
   130         /**
       
   131         * Deactivates the view and destroys needed objects.
       
   132         */
       
   133         void DoDeactivate();     
       
   134 
       
   135     public: // From MSaveMessageController, these are called from 
       
   136             // CbsUiUtility
       
   137 
       
   138         /**
       
   139         *   Saves a message (the saved message won't be deleted to make 
       
   140         *   room for new messages).
       
   141         *
       
   142         *   Return codes:
       
   143         *   KErrNone            Message is saved.
       
   144         *   KErrGeneral         Message not saved -- total maximum of saved 
       
   145         *                       messages reached.
       
   146         *   KErrNotFound        Message not saved -- no message associated
       
   147         *                       with the given handle.
       
   148         *   KErrDiskFull        Message not saved -- FFS out of space.
       
   149         *
       
   150         *   @param  aHandle     Handle to the message to be saved.
       
   151         *   @return             Return code.
       
   152         */
       
   153         TInt SaveMessage( const TCbsMessageHandle& aHandle );
       
   154 
       
   155     public:        
       
   156 
       
   157         /**
       
   158         * Sets the message information to navi pane. e.g. Message 1/3.
       
   159         */    
       
   160         void UpdateNaviPaneL();
       
   161         
       
   162         /**
       
   163         * When called, next message is displayed
       
   164         */
       
   165         void MoveToNextMessageL();
       
   166         
       
   167         /**
       
   168         * When called, previous message is displayed
       
   169         */
       
   170         void MoveToPreviousMessageL();
       
   171         
       
   172         /**
       
   173         * Topic list or topic messages are changed.
       
   174         *
       
   175         * @param aEvent reason for event
       
   176         * @param aTopicNumber topic number, which caused the event
       
   177         */
       
   178         void TopicListChangedL(
       
   179             TCbsTopicListEvent aEvent, TCbsTopicNumber aTopicNumber );
       
   180 
       
   181         /**
       
   182         * Handle changes in container when rect changes.
       
   183         * Update message and set new rect to container.
       
   184         */
       
   185         void HandleRectChangeInContainerL();
       
   186 
       
   187     private: // Data structures
       
   188 
       
   189         enum TMsgViewSetHandle
       
   190             {
       
   191             EToNext,
       
   192             EToPrevious
       
   193             };
       
   194       
       
   195     private:  // New functions
       
   196 
       
   197         /**
       
   198         * Creates a find item dialog and pass a message to
       
   199         * it and gives the search case, what to look.
       
   200         *
       
   201         * @param aCommand search case
       
   202         */
       
   203         void DoSearchL( TInt aCommand );
       
   204         
       
   205         /**
       
   206         * Removes and destroys the context menu.
       
   207         */
       
   208         void CloseContextMenu();
       
   209 
       
   210         /**
       
   211         * Launch the context menu.
       
   212         */
       
   213         void LaunchContextMenuL();
       
   214 
       
   215         /**
       
   216         * Deletes a old message.
       
   217         */ 
       
   218         void DeleteOldMessage();
       
   219 
       
   220         /**
       
   221         * Loads a message from topic view.
       
   222         *
       
   223         * @return error code if Loading of message has been leaved and catched.
       
   224         */
       
   225         TInt DoLoadMessageL();
       
   226 
       
   227         /**
       
   228         * Activates topic view with defined topic number and message handle.
       
   229         *
       
   230         * @param aTopicNumber which topic the message belongs
       
   231         * @param aHandle which message handle is activating topic view.
       
   232         */
       
   233         void ActivateTopicViewL(
       
   234             TCbsTopicNumber aTopicNumber, TCbsMessageHandle aHandle);
       
   235 
       
   236         /**
       
   237         * Sets current message handle to aMessageHandle.
       
   238         *
       
   239         * @param aMessageHandle message handle         
       
   240         */
       
   241         void SetCurrentMessageHandle( const TDesC8& aMessageHandle );
       
   242 
       
   243         /**
       
   244         * Loads current message buffer.
       
   245         */
       
   246         void LoadMessageL();
       
   247 
       
   248         /**
       
   249         * Adds date and time to a aMessage.
       
   250         *
       
   251         * @param aTime A time when message was received.
       
   252         * @param aMessage Address of actual pointer variable. So after 
       
   253         *                 reallocation real message content is also changed.
       
   254         * @param aResourceArrayId Used resource array for date and time format.
       
   255         */
       
   256         void AddDateAndTimeL( 
       
   257             const TInt64 aTime, HBufC** aMessage, TUint aResourceArrayId ) const;
       
   258 
       
   259         /**
       
   260         * Returns topic number of current message.
       
   261         *
       
   262         * @return current topic number
       
   263         */
       
   264         TCbsTopicNumber CurrentTopicNumber() const;
       
   265 
       
   266         /**
       
   267         * Gets message position in topic where th aHandle belongs.
       
   268         *
       
   269         * @param aHandle message handle
       
   270         * @param aPosition It will contain the message position in topic.
       
   271         * @param aTotal It will contain the total message count in topic,
       
   272         * @return error code
       
   273         */
       
   274         TInt GetMessagePosition(
       
   275             TCbsMessageHandle aHandle, TInt& aPosition, TInt& aTotal );
       
   276 
       
   277         /**
       
   278         * Sets aHandle to previous or next according to aTo
       
   279         * if possible.
       
   280         *
       
   281         * @param aTo sets aHandle to prev or next
       
   282         * @return ETrue if aHandle has been set.
       
   283         */
       
   284         TBool SetHandleTo( TCbsMessageHandle& aHandle, TMsgViewSetHandle aTo );
       
   285 
       
   286         /**
       
   287         * Deletes a message according to a aHandle.
       
   288         *
       
   289         * @param aHandle handle to be deleted.
       
   290         * @return ETrue if message was deleted
       
   291         */
       
   292         TBool DeleteMessageL( TCbsMessageHandle aHandle );
       
   293 
       
   294         /**
       
   295         * Activates topic list view.
       
   296         */
       
   297         void ActivateTopicListViewL() const;
       
   298 
       
   299         /**
       
   300         * Sets current message to newest hot marked message or
       
   301         * activates the topic list view.
       
   302         *
       
   303         * @return ETrue if new view is launched
       
   304         */
       
   305         TBool HandleSoftNotificationL();
       
   306 
       
   307     private: 
       
   308 
       
   309         /**
       
   310         * C++ constructor.
       
   311         *
       
   312         * @param aServer Reference to cbs server.   
       
   313         */
       
   314         CCbsUiMsgView( MCbs& aServer );
       
   315 
       
   316         /**
       
   317         * Two-phased constructor.
       
   318         */
       
   319         void ConstructL();
       
   320         
       
   321     private: // Data
       
   322         
       
   323         // message buffer
       
   324         HBufC* iMessage;
       
   325         
       
   326         // Container class
       
   327         CCbsUiMsgViewContainer* iContainer;
       
   328 
       
   329         // Navi pane variables
       
   330         CAknNavigationControlContainer* iNaviContainer;
       
   331 
       
   332         // NaviPaneDecorator
       
   333         CAknNavigationDecorator* iDecoratedLabel;
       
   334         
       
   335         // NaviPaneDecorator
       
   336         CAknNavigationDecorator* iPreviousDecoratedLabel;        
       
   337       
       
   338         // Find item common component        
       
   339         CFindItemMenu* iFindItemMenu;
       
   340         
       
   341         // Context sensitive menu, which appears when pushed ok key        
       
   342         CEikMenuBar* iContextMenu;
       
   343 
       
   344         // To get a topic count and messages inside
       
   345         // a topic.
       
   346         MCbs& iServer;
       
   347 
       
   348         // Tells if the message is class 0.
       
   349         TBool iIsClass0;
       
   350 
       
   351         // Current message handle
       
   352         TCbsMessageHandle iCurrentHandle;
       
   353 
       
   354         // True if launched from the other application.
       
   355         TBool iFromOtherApplication;
       
   356 
       
   357     };
       
   358     
       
   359 #endif //__CBSMSGVIEW_H
       
   360 
       
   361 
       
   362 // End of file