vtengines/videoteleng/Inc/State/CVtEngStateBase.h
changeset 0 ed9695c8bcbe
equal deleted inserted replaced
-1:000000000000 0:ed9695c8bcbe
       
     1 /*
       
     2 * Copyright (c) 2006 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:  Base class for states
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef CVTENGSTATEBASE_H
       
    21 #define CVTENGSTATEBASE_H
       
    22 
       
    23 //  INCLUDES
       
    24 #include <e32base.h>
       
    25 #include "vtengcommands.h"
       
    26 #include "CVtEngStateManager.h"
       
    27 #include "CVtEngEventManager.h"
       
    28 #include "CVtEngMediaHandler.h"
       
    29 #include "CVtEngSessionHandler.h"
       
    30 #include "CVtEngOperation.h"
       
    31 #include "CVtEngSettings.h"
       
    32 #include "VtEngUtils.h"
       
    33 
       
    34 // FORWARD DECLARATIONS
       
    35 class CVtEngSessionHandler;
       
    36 class CVtEngMediaHandler;
       
    37 class CVtEngAudioHandler;
       
    38 
       
    39 // CLASS DECLARATION
       
    40 
       
    41 /**
       
    42 *  State base class
       
    43 
       
    44 *  @lib videoteleng
       
    45 *  @since 2.6
       
    46 */
       
    47 NONSHARABLE_CLASS( CVtEngStateBase ) : public CBase
       
    48     {
       
    49     public:  // Constructors and destructor
       
    50         
       
    51         /**
       
    52         * Destructor.
       
    53         */
       
    54         virtual ~CVtEngStateBase();
       
    55 
       
    56     public: // New functions
       
    57         
       
    58         /**
       
    59         * Updates state. May result to state transition
       
    60         */
       
    61         virtual void UpdateL() = 0;
       
    62 
       
    63         /**
       
    64         * Checks if a command is valid in current state.
       
    65         * @param aCommandId command to be validated
       
    66         * @return ETrue if command is valid.
       
    67         */
       
    68         virtual TBool ValidateCommand(
       
    69             const TVtEngCommandId aCommandId );
       
    70 
       
    71         /**
       
    72         * Handles an operation. Base class method is empty
       
    73         * and derived classes may handle the operation if applicable.
       
    74         * @param aOp operation to be handled
       
    75         * @return ETrue if handled
       
    76         */
       
    77         virtual TBool HandleL( CVtEngOperation& aOp );
       
    78 
       
    79         /**
       
    80         * Returns session handler.
       
    81         * @return reference to session handler
       
    82         */
       
    83         CVtEngSessionHandler& SessionHandler();
       
    84 
       
    85         /**
       
    86         * Returns media handler.
       
    87         * @return reference to media handler
       
    88         */
       
    89         CVtEngMediaHandler& MediaHandler();
       
    90 
       
    91         /**
       
    92         * Returns audio handler.
       
    93         * @return reference to audio handler
       
    94         */
       
    95         CVtEngAudioHandler& AudioHandler();
       
    96 
       
    97         /**
       
    98         * Creates new state if needed.
       
    99         * @return new state or NULL
       
   100         */
       
   101         CVtEngStateBase* NewStateL( 
       
   102             const MVtEngSessionInfo::TSessionState aState );
       
   103 
       
   104         virtual MVtEngSessionInfo::TSessionState State() const = 0;
       
   105 
       
   106     public: // New functions 
       
   107 
       
   108         /**
       
   109         * Sets new current state. 
       
   110         * @param aOldState old state.
       
   111         */
       
   112         void OpenL( CVtEngStateBase* aOldState );
       
   113 
       
   114         /**
       
   115         * For derived classes to handle state change
       
   116         */
       
   117         virtual void DoOpenL( ) = 0;
       
   118 
       
   119         
       
   120         /**
       
   121         * State uninitialization.
       
   122         */
       
   123         virtual void Close();
       
   124 
       
   125     protected: // new functions
       
   126 
       
   127         /**
       
   128         * Saves configuration to settings for later
       
   129         * usage.
       
   130         */
       
   131         void SaveToSettingsL( CVtEngOperation& aOp );
       
   132 
       
   133         /**
       
   134         * Notifies state change to event manager.
       
   135         * @param aNewState new session state.
       
   136         */
       
   137         void NotifyStateChange( MVtEngSessionInfo::TSessionState aNewState );
       
   138 
       
   139         /**
       
   140         * Saves video state to settings. Used e.g. when video can not be 
       
   141         * started in current state.
       
   142         * @param aEnabled video is enabled
       
   143         */
       
   144         void SetVideoEnabled( TBool aEnabled );
       
   145 
       
   146         /**
       
   147         * Goes to disconnecting or idle state if needed.
       
   148         * @return state object if transition is required.
       
   149         */
       
   150         //CVtEngStateBase* DisconnectingOrIdleStateL();
       
   151 
       
   152         /**
       
   153         * Creates negotiating state if bearer state is connected
       
   154         * and pv state is ESetup, and UI has indicated state changte
       
   155         * is permitted.
       
   156         * @return negotiating state object or NULL
       
   157         */
       
   158         CVtEngStateBase* NegotiatingOrConnectedStateL( 
       
   159             TBool aAcceptOnlyNegotiating = EFalse );
       
   160 
       
   161 
       
   162         /**
       
   163         * Saves video state to settings. Used e.g. when video can not be 
       
   164         * started in current state.
       
   165         * @param aEnabled video is enabled
       
   166         */
       
   167         void TerminateSessionL( CVtEngOperation& aOp );
       
   168 
       
   169     protected:
       
   170 
       
   171         /**
       
   172         * C++ constructor.
       
   173         */
       
   174         CVtEngStateBase( 
       
   175             CVtEngStateManager& aStateManager,
       
   176             CVtEngEventManager& aEventManager );
       
   177 
       
   178     protected:  // Data
       
   179         // State manager
       
   180         CVtEngStateManager& iStateManager;
       
   181 
       
   182         // Event manager
       
   183         CVtEngEventManager& iEventManager;
       
   184 
       
   185     private:
       
   186     };
       
   187 
       
   188 #endif      // CVTENGSTATEBASE_H
       
   189 
       
   190 // End of File