vtuis/videotelui/inc/commands/cvtuicmdcontext.h
changeset 0 ed9695c8bcbe
equal deleted inserted replaced
-1:000000000000 0:ed9695c8bcbe
       
     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:  Command context base class definition.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef C_VTUICMDCONTEXT_H
       
    20 #define C_VTUICMDCONTEXT_H
       
    21 
       
    22 #include <e32base.h>
       
    23 
       
    24 #include "tvtuicmdcontexttype.h"
       
    25 
       
    26 class CVtUiCmdValidatorBase;
       
    27 class CVtUiCmdValidationActionBase;
       
    28 class MVtUiCommandManager;
       
    29 class CVtUiCmdCustomValidationActionBase;
       
    30 
       
    31 /**
       
    32  *  CVtUiCmdContext
       
    33  *
       
    34  *  Command context base class. This class defines context in which commands
       
    35  *  will be validated.
       
    36  *
       
    37  *  @since S60 v3.2
       
    38  */
       
    39 NONSHARABLE_CLASS( CVtUiCmdContext ) : public CBase
       
    40     {
       
    41 
       
    42 public: // public methods
       
    43 
       
    44     /**
       
    45      * C++ destructor.
       
    46      */
       
    47     ~CVtUiCmdContext();
       
    48 
       
    49     /**
       
    50      * Returns reference priority.
       
    51      *
       
    52      * @return Validator priority.
       
    53      */
       
    54      TInt ReferencePriority() const;
       
    55 
       
    56     /**
       
    57      * Returns context type.
       
    58      *
       
    59      * @return Context type.
       
    60      */
       
    61      TVtUiCmdContextType ContextType() const;
       
    62 
       
    63     /**
       
    64      * Adds validator to context.
       
    65      *
       
    66      * @param aValidator Validator reference to be added into this context.
       
    67      * @return KErrNone if validator supports this context and adding succeeded.
       
    68      * KErrNotSupported if validator does not support this context.
       
    69      * Other system wide error code that may happen during add.
       
    70      */
       
    71     TInt AddValidator( CVtUiCmdValidatorBase& aValidator );
       
    72 
       
    73     /**
       
    74      * Removes validator to context.
       
    75      *
       
    76      * @param aValidator Constant validator reference to be removed from this
       
    77      * context.
       
    78      * @return Validator priority.
       
    79      */
       
    80     void RemoveValidator( const CVtUiCmdValidatorBase& aValidator );
       
    81 
       
    82 public: // pure virtual methods
       
    83 
       
    84     /**
       
    85      * Do validation.
       
    86      *
       
    87      * @param aAction Action to be validated.
       
    88      */
       
    89     virtual void ValidateL( CVtUiCmdValidationActionBase& aAction ) = 0;
       
    90 
       
    91 protected:
       
    92 
       
    93     /**
       
    94      * C++ constructor
       
    95      */
       
    96     CVtUiCmdContext( MVtUiCommandManager& aCommandManager,
       
    97         TVtUiCmdContextType aCtxType, TInt aReferencePriority );
       
    98 
       
    99     /**
       
   100      * Validates menu items.
       
   101     */
       
   102     void ValidateMenuItemsL( CVtUiCmdValidationActionBase& aAction );
       
   103 
       
   104     /**
       
   105      * Validates softkey items.
       
   106     */
       
   107     void ValidateSoftkeyItemsL( CVtUiCmdValidationActionBase& aAction );
       
   108 
       
   109     /**
       
   110      * Validates toolbar items.
       
   111     */
       
   112     void ValidateToolbarItemsL( CVtUiCmdValidationActionBase& aAction );
       
   113 
       
   114     /**
       
   115      * Custom action validation.
       
   116     */
       
   117     void CustomValidationL( CVtUiCmdCustomValidationActionBase& aAction );
       
   118 
       
   119     /**
       
   120      * Registers command context to command policy manager.
       
   121      */
       
   122     void RegisterCommandContextL();
       
   123 
       
   124     /**
       
   125      * Unregisters command context from command policy manager.
       
   126      */
       
   127     void UnregisterCommandContext();
       
   128 
       
   129 protected: // data
       
   130 
       
   131     // Reference to policy manager (for cleanup)
       
   132     MVtUiCommandManager& iCommandManager;
       
   133 
       
   134 private: // data
       
   135 
       
   136     // Validator list (ordered by priority)
       
   137     RPointerArray< CVtUiCmdValidatorBase > iValidators;
       
   138 
       
   139     // Validator priority
       
   140     const TInt iReferencePriority;
       
   141 
       
   142     // Context type.
       
   143     const TVtUiCmdContextType iContextType;
       
   144 
       
   145     };
       
   146 
       
   147 #endif // C_VTUICMDCONTEXT_H