cbs/cbsui/UiInc/CCbsUiTopicListView.h
branchRCL_3
changeset 19 7d48bed6ce0c
parent 18 594d59766373
child 20 987c9837762f
equal deleted inserted replaced
18:594d59766373 19:7d48bed6ce0c
     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 *  This is the application main view. Shows all the topics which
       
    16 *  has been received and their status: subscribed, hotmarked, new messages
       
    17 *
       
    18 *
       
    19 */
       
    20 
       
    21 
       
    22 #ifndef __CCBSTOPICLISTVIEW_H
       
    23 #define __CCBSTOPICLISTVIEW_H
       
    24 
       
    25 // INCLUDES
       
    26 #include <aknview.h>
       
    27 #include <CbsCommon.h>
       
    28 #include "MCbsUiTopicMonitorObserver.h"
       
    29 #include "CbsUiDebug.h"
       
    30 	
       
    31 // CONSTANTS  
       
    32 const TInt KNumberOfStandardTopics = 17;
       
    33 
       
    34  
       
    35 // FORWARD DECLARATIONS
       
    36 
       
    37 class CSelectionList;
       
    38 class CListBoxNumbers;
       
    39 class CCbsUiTopicListViewContainer;
       
    40 class MCbs;
       
    41 class CAknNavigationDecorator;
       
    42 class CAknNavigationControlContainer;
       
    43 
       
    44 // CLASS DECLARATION
       
    45 
       
    46 /**
       
    47 * This is the application main view. Shows all the topics which
       
    48 * has been received and their status: subscribed, hotmarked, new messages
       
    49 *  
       
    50 */
       
    51 class CCbsUiTopicListView : public CAknView, 
       
    52                             public MCbsUiTopicMonitorObserver
       
    53     {
       
    54     private: // Data declaration
       
    55 
       
    56         enum TTopicListViewFocusState
       
    57             {
       
    58             ESetFocusToCurrentHandle,
       
    59             ESetFocusToFirstItem,
       
    60             ESetFocusToNewestItem,
       
    61             ENoFocusUpdate 
       
    62             };
       
    63 
       
    64     public: // Constructors and destructor
       
    65 
       
    66         /**
       
    67         * Creates an instance of the class.
       
    68         *
       
    69         * @param aServer It is the server.
       
    70         * @return It returns a pointer to the created class.
       
    71         */
       
    72         static CCbsUiTopicListView* NewL( MCbs& aServer );
       
    73         
       
    74         /**
       
    75         * Destructor.
       
    76         */
       
    77         virtual ~CCbsUiTopicListView();
       
    78         
       
    79     public: // New functions
       
    80 
       
    81         /**
       
    82         * Calls the server to add or change a topic. Which is called
       
    83         * depends on the type of the dialog.
       
    84         *
       
    85         * @param aType is it a edit or add query. True is add query
       
    86         * @param aNumber topic number to add or change
       
    87         * @param aName topic name to add or change
       
    88         * @return error code if something goes wrong
       
    89         */
       
    90         TInt EditTopic( 
       
    91             TBool aType, 
       
    92             TCbsTopicNumber aNumber, 
       
    93             const TCbsTopicName aName );
       
    94 
       
    95         /** 
       
    96         * Adds a topic with specified number and name.
       
    97         *
       
    98         * @param  aNumber It is the number of the topic.
       
    99         * @param  aName It is the name of the topic.
       
   100         * @return a error code if the addition fails
       
   101         */
       
   102         TInt AddTopic( 
       
   103             const TCbsTopicNumber& aNumber, 
       
   104             const TCbsTopicName& aName );       
       
   105 
       
   106         /**
       
   107         * Marks topic which is focused. This should be called only when 
       
   108         * the Options menu is created and when the Ok (selection) key
       
   109         * has been pressed. Focus behaviour is based on this.
       
   110         */
       
   111         void MarkCurrentHandle();
       
   112         
       
   113     public: // From MCbsUiTopicMonitorObserver
       
   114 
       
   115         /**
       
   116         * Topic list or topic messages are changed.
       
   117         *
       
   118         * @param aEvent reason for event
       
   119         * @param aTopicNumber Topic number, which caused the event
       
   120         */
       
   121         void TopicListChangedL(
       
   122             TCbsTopicListEvent aEvent, TCbsTopicNumber aTopicNumber );
       
   123      
       
   124     public: // from CAknView
       
   125         
       
   126         /**
       
   127         * Returns the identifier of the view.
       
   128         *
       
   129         * @return It returns the identifier.
       
   130         */
       
   131         TUid Id() const;        
       
   132     
       
   133         /**
       
   134         * Handles the options menu commands.
       
   135         *
       
   136         * @param aCommand command to be executed
       
   137         */
       
   138         void HandleCommandL( TInt aCommand );
       
   139 
       
   140     public: // New function
       
   141         /**
       
   142         * Handle changes in container when rect changes.
       
   143         */
       
   144         void HandleRectChangeInContainer();
       
   145 
       
   146     private: // from CAknView
       
   147         
       
   148         /**
       
   149         * Activates the view.
       
   150         *
       
   151         * @param aPrevViewId
       
   152         * @param aCustomMessageId
       
   153         */
       
   154         void DoActivateL(
       
   155             const TVwsViewId& aPrevViewId, 
       
   156             TUid aCustomMessageId, 
       
   157             const TDesC8& aCustomMessage );
       
   158         
       
   159         /**
       
   160         * Deactivates the view.
       
   161         */
       
   162         void DoDeactivate();     
       
   163 
       
   164         /**
       
   165         * Checks new topic count, if it has been changed after
       
   166         * application switch.
       
   167         */
       
   168         void ViewActivatedL(
       
   169             const TVwsViewId& aPrevViewId,
       
   170             TUid aCustomMessageId,const 
       
   171             TDesC8& aCustomMessage );
       
   172 
       
   173         void ViewDeactivated();
       
   174       
       
   175     private: // MEikMenuObserver 
       
   176 
       
   177         /**
       
   178         * Sets the menu items according to the state of the topic, which
       
   179         * is focused on. Used when options menu is opened. Marks also 
       
   180         * a current topic handle.
       
   181         *
       
   182         * @param aResourceId resource id of the menu
       
   183         * @param aMenuPane used to modify menu dynamically
       
   184         */
       
   185         void DynInitMenuPaneL( TInt aResourceId, CEikMenuPane* aMenuPane );         
       
   186 
       
   187     private: // New functions
       
   188 
       
   189         /**
       
   190         * Sets current topic number according to aTopicNumber.
       
   191         *
       
   192         * @param aTopicNumber contains current topic number.
       
   193         */
       
   194         void SetCurrentTopicNumber( const TDesC8& aTopicNumber );
       
   195 
       
   196         /**
       
   197         * Sets current topic number according to aTopicNumber.
       
   198         *
       
   199         * @param aTopicNumber new current topic number.
       
   200         */
       
   201         void SetCurrentTopicNumber( const TCbsTopicNumber aTopicNumber );
       
   202 
       
   203         /**
       
   204         * Updates the topics information.
       
   205         */
       
   206         void ReloadTopicsL();
       
   207 
       
   208         /**
       
   209         * Prepares container for reloading.
       
   210         */
       
   211         void PrepareReloading();
       
   212 
       
   213         /**
       
   214         * Reloads topics from the server.
       
   215         */
       
   216         void ReloadL();
       
   217 
       
   218         /**
       
   219         * Ends reloading.
       
   220         */
       
   221         void EndReloadingL();
       
   222 
       
   223         /**
       
   224         * Sets focus after reload. Should be called after ReloadTopicsL().
       
   225         *
       
   226         * @param aFocusState focus is set according to this
       
   227         */
       
   228         void SetFocusAfterReload( TTopicListViewFocusState aFocusState );
       
   229 
       
   230         /**
       
   231         * Sets focus to aIndex.
       
   232         *
       
   233         * @param aIndex new focused index
       
   234         */
       
   235         void SetFocusToTopic( TInt aIndex );
       
   236 
       
   237         /**
       
   238         * Updates the focus according to Selection Service after deletion.
       
   239         *
       
   240         * @param aDeletedTopic Calculates the new focus according to deleted
       
   241         *                      topic.
       
   242         */
       
   243         void UpdateCurrentTopicAfterDeletion( TCbsTopicNumber aDeletedTopic );
       
   244         
       
   245         /**
       
   246         * Returns the total amount of topics.
       
   247         *
       
   248         * @return It is the amount of topics.
       
   249         */
       
   250         TInt TotalTopics() const;                      
       
   251        
       
   252         /**
       
   253         * Requests the view to move to the previous topic.
       
   254         */
       
   255         void MoveToPreviousTopic();
       
   256    
       
   257         /**
       
   258         * Writes a CBS to title pane.
       
   259         */
       
   260         void UpdateTitlePaneL() const;
       
   261 
       
   262         /**
       
   263         * Writes to navi pane a right message:
       
   264         * No new messages
       
   265         * One new message
       
   266         * %N new messages
       
   267         */
       
   268         void UpdateNaviPaneL();
       
   269 
       
   270         /**
       
   271         * Gets resouce id for text to be displayed.
       
   272         *
       
   273         * @param aUnreadMessages Number of unread messages.
       
   274         * @return resource id for text
       
   275         */ 
       
   276         TInt GetInfoResourceId( TInt aUnreadMessages ) const;
       
   277 
       
   278         /**
       
   279         * Creates a new decorated label to navi pane.
       
   280         *
       
   281         * @param aResourceId text resource id.
       
   282         * @param aUnreadMessages number of unread messages
       
   283         */
       
   284         void CreateNewLabelL( TInt aResourceId, TInt aUnreadMessages );
       
   285 
       
   286         /**
       
   287         * Launches an edit or add topic query dialog.
       
   288         *
       
   289         * @param aType          type of the query. 
       
   290         *                       ETrue is add and EFalse is edit query.
       
   291         * @param aTopicName     name of the topic
       
   292         * @param aTopicNumber   number of the topic
       
   293         */
       
   294         void ShowTopicQueryL( 
       
   295             TBool aType, 
       
   296             TDes& aTopicName, 
       
   297             TDes& aTopicNumber );
       
   298 
       
   299         /**
       
   300         * Launchs the edit topic query with the right parameters.
       
   301         */
       
   302         void ShowEditTopicQueryL();
       
   303 
       
   304         /**
       
   305         * Checks if there has come new topics while this function was
       
   306         * last called. Shows a note how many new topics has been added,
       
   307         * since last been in TopicListView.
       
   308         */
       
   309         void CheckNewTopicCountL();
       
   310 
       
   311         /**
       
   312         * Returns the new topics count from server.
       
   313         * 
       
   314         * @return new topic count
       
   315         */
       
   316         TInt GetNewTopicsCount();
       
   317 
       
   318         /**
       
   319         * Changes the topic name and number to the specified.
       
   320         *
       
   321         * @param  aHandle It is the handle to the topic.
       
   322         * @param  aNumber It is the new number of the topic.
       
   323         * @param  aName It is the name of the topic.
       
   324         * @return error code in case fail
       
   325         */
       
   326         TInt UpdateTopic( 
       
   327             const TCbsTopicNumber& aOldNumber,
       
   328             const TCbsTopicNumber& aNumber,
       
   329             const TCbsTopicName& aName );
       
   330 
       
   331         /**
       
   332         * Finds topic index by topic number.
       
   333         *
       
   334         * @param aIndex it will contain the topic index
       
   335         * @param aTopicNumber topic number
       
   336         * @return KErrNone if no errors
       
   337         */
       
   338         TInt FindTopicIndexByNumber( 
       
   339             TInt& aIndex, 
       
   340             const TCbsTopicNumber& aTopicNumber );
       
   341 
       
   342         /**
       
   343         * Activates the topic view.
       
   344         */
       
   345         void ActivateTopicViewL() const;
       
   346 
       
   347         /**
       
   348         * Activates settings view.
       
   349         */
       
   350         void ActivateSettingsViewL() const;
       
   351 
       
   352         /**
       
   353         * Activates a add from index dialog.
       
   354         */
       
   355         void ActivateAddFromIndexViewL();
       
   356 
       
   357         /**
       
   358         * Activates an idle object to show an information note. 
       
   359         * Used in call back function.
       
   360         *
       
   361         * @param aNewTopics count of new topics
       
   362         * @return always KErrNone
       
   363         */
       
   364         static TInt ActivateBackgroundNoteL( TAny* aNewTopics );
       
   365         
       
   366     private:
       
   367         
       
   368         /**
       
   369         * It is type for topic handles array.
       
   370         */
       
   371         typedef CArrayFixFlat< TCbsTopicNumber > TCbsUiTopicNumberList;
       
   372         
       
   373         /**
       
   374         * Constructor.
       
   375         * 
       
   376         * @param aServer connection to the server
       
   377         */
       
   378         CCbsUiTopicListView(MCbs& aServer);
       
   379         
       
   380         /**
       
   381         * Finalizes the construction.
       
   382         *
       
   383         * Note that it is assumed that the server exists for the life 
       
   384         * time of the class.
       
   385         */
       
   386         void ConstructL();
       
   387      
       
   388     private: // Data        
       
   389 
       
   390         // It is the control for the view.
       
   391         CCbsUiTopicListViewContainer* iContainer;
       
   392         
       
   393         // It is the label in status pane.
       
   394         CAknNavigationDecorator* iDecoratedLabel;        
       
   395    
       
   396         // Pointer to server session. Owned by UiApp
       
   397         MCbs& iServer;        
       
   398        
       
   399         // It is the array that contains the topic numbers.
       
   400         TCbsUiTopicNumberList* iTopicNumberList;
       
   401        
       
   402         // Handle that is focused.        
       
   403         TCbsTopicNumber iCurrentTopicNumber;
       
   404 
       
   405         // For updating information about messages to navi pane.
       
   406         CAknNavigationControlContainer* iNaviPane;
       
   407 
       
   408         // iFocusState is set in HandleCommandL and focus is set in 
       
   409         // TopicListChangedL.
       
   410         TTopicListViewFocusState iFocusState;
       
   411 
       
   412         // To see wheather it is needed to update navi pane.
       
   413         // if ETrue: navi pane is not updated
       
   414         TBool iAddFromIndexDialogIsActive;
       
   415 
       
   416         // for showing background note
       
   417         CIdle* iBackgroundNote;
       
   418 
       
   419         // Count of new topics.
       
   420         TInt iNewTopicsCount;
       
   421 
       
   422 
       
   423     };
       
   424     
       
   425     
       
   426 #endif // __CCBSTOPICLISTVIEW_H
       
   427     
       
   428     
       
   429 // End of File