vtuis/lcvtplugin/inc/states/tlcvtpluginstates.h
branchRCL_3
changeset 25 779871d1e4f4
parent 24 f15ac8e65a02
child 26 590f6f022902
equal deleted inserted replaced
24:f15ac8e65a02 25:779871d1e4f4
     1 /*
       
     2 * Copyright (c) 2008 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:  Concrete VT plugin state classes
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef T_LCVTPLUGINSTATES_H
       
    20 #define T_LCVTPLUGINSTATES_H
       
    21 
       
    22 #include "tlcvtstatebase.h"
       
    23 #include <babitflags.h>
       
    24 #include <vtengcommands.h>
       
    25 
       
    26 
       
    27 /**
       
    28 *  Initial application state. Responsible for startup phase 1 and
       
    29 *  startup phase 2 (see EVtUiAppUiStartup in CVtUiAppUi.cpp).
       
    30 *  Certain other state changes are required for phase 2 and history
       
    31 *  of their reception is handled with precondition flags.
       
    32 *
       
    33 *  @since S60 v3.2
       
    34 */
       
    35 class TLcVtStateStarting : public TLcVtStateBase
       
    36     {
       
    37 public:
       
    38     /**
       
    39     * returns singleton instance of TLcVtStateStarting
       
    40     * @param aCtx state context
       
    41     * @param aUiStates UI states
       
    42     * @return singleton
       
    43     */
       
    44     static TLcVtStateStarting* InstanceL(
       
    45         MLcVtStateContext& aCtx,
       
    46         TLcVtStates& aUiStates );
       
    47 
       
    48 public: // from TLcVtStateBase
       
    49 
       
    50     /** @see TLcVtStateBase */
       
    51     virtual void LcVtStartupPhase1DoneL();
       
    52 
       
    53     /** @see TLcVtStateBase */
       
    54     virtual void LcVtStartupPhase2DoneL();
       
    55 
       
    56     /** @see TLcVtStateBase */
       
    57     virtual TEventResponse HandleVtEventL( TInt aEvent );
       
    58 
       
    59     /** @see TLcVtStateBase */
       
    60     virtual TEventResponse HandleCommandL( const TInt aCommand );
       
    61 
       
    62     /** @see TLcVtStateBase */
       
    63     virtual TBool HandleForegroundChangedL( TBool aIsForeground );
       
    64 
       
    65     /** @see TLcVtStateBase */
       
    66     virtual TBool PreHandleForegroundChangedL( TBool aIsForeground );
       
    67 
       
    68 private: // from TLcVtStateBase
       
    69 
       
    70     /** @see TLcVtStateBase */
       
    71     virtual void OpenL();
       
    72 
       
    73     /** @see TLcVtStateBase */
       
    74     virtual void Close();
       
    75 
       
    76 private: // new methods
       
    77 
       
    78     void CheckSessionStateL();
       
    79     
       
    80     static TInt AsynchOpen( TAny* aAny );
       
    81     
       
    82     void DoOpenL();
       
    83     
       
    84     /** Preconditions that must be passed in order to proceed
       
    85      * to Phase 2 in startup.
       
    86      */
       
    87     enum TPreconditions
       
    88         {
       
    89         /** waiting for CLI from engine*/
       
    90         EWaitingCLI,
       
    91         /** waiting for phase1 to complete */
       
    92         EWaitingPhase1ToComplete,
       
    93         /** waiting for engine to get proper state */
       
    94         EWaitingSessionState
       
    95     };
       
    96 
       
    97     /**
       
    98     * Clears precondition passed as argument and checks if any
       
    99     * preconditions hold and if not proceeds to phase 2 of startup.
       
   100     */
       
   101     void CheckPhase2StartupL( const TPreconditions aClearCondition );
       
   102     
       
   103     void HandleCLIReceivedL();
       
   104 
       
   105 private: // constructors and destructors
       
   106 
       
   107     // c++ constructor
       
   108     TLcVtStateStarting(
       
   109         MLcVtStateContext& aCtx,
       
   110         TLcVtStates& aUiStates );
       
   111 
       
   112     // Destructor
       
   113     virtual ~TLcVtStateStarting();
       
   114 
       
   115 private: // data members
       
   116 
       
   117     // Precondition for state change to running
       
   118     TBitFlags8 iPreconditions;
       
   119 
       
   120     // Singleton
       
   121     static TLcVtStateStarting* iInstance;
       
   122     
       
   123     // Starts phase1 startup in state state context. Needed because
       
   124     // initial state is opened from within state context construction.
       
   125     CAsyncCallBack*     iStartCallback;
       
   126     };
       
   127 
       
   128 /**
       
   129 *  Application state that is active in normal operation.
       
   130 *
       
   131 *  @since S60 v3.2
       
   132 */
       
   133 class TLcVtStateRunning : public TLcVtStateBase
       
   134     {
       
   135 public:
       
   136     /**
       
   137     * returns singleton instance of TLcVtStateRunning
       
   138     * @param aCtx state context
       
   139     * @param aUiStates UI states
       
   140     * @return singleton
       
   141     */
       
   142     static TLcVtStateRunning* InstanceL(
       
   143         MLcVtStateContext& aCtx,
       
   144         TLcVtStates& aUiStates );
       
   145 
       
   146 public: // from TLcVtStateBase
       
   147 
       
   148     /** @see TLcVtStateBase */
       
   149     virtual TEventResponse HandleVtEventL( TInt aEvent );
       
   150 
       
   151     /** @see TLcVtStateBase */
       
   152     virtual TEventResponse HandleCommandL( const TInt aCommand );
       
   153 
       
   154     /** @see TLcVtStateBase */
       
   155     virtual TBool HandleForegroundChangedL( TBool aIsForeground );
       
   156 
       
   157     /** @see TLcVtStateBase */
       
   158     virtual TBool PreHandleForegroundChangedL( TBool aIsForeground );
       
   159     /** @see TLcVtStateBase */
       
   160     //virtual void HandleLayoutChangedL();
       
   161 
       
   162     /** @see TLcVtStateBase */
       
   163     //virtual void StartDtmfTone( const TChar& aTone );
       
   164 
       
   165     /** @see TLcVtStateBase */
       
   166     //virtual void StopDtmfTone();
       
   167 
       
   168     /** @see TLcVtStateBase */
       
   169     virtual void OpenL();
       
   170 
       
   171 private: // from TLcVtStateBase
       
   172     /** @see TLcVtStateBase */
       
   173     virtual void Close();
       
   174 
       
   175 private: // constructors and destructors
       
   176 
       
   177     // c++ constructor
       
   178     TLcVtStateRunning(
       
   179         MLcVtStateContext& aCtx,
       
   180         TLcVtStates& aUiStates );
       
   181 
       
   182     // Destructor
       
   183     virtual ~TLcVtStateRunning();
       
   184 
       
   185 private: // new functions
       
   186 
       
   187     /** Requests call handling subsystem to initiate a voice call.
       
   188      * Starts shutdown of the application.
       
   189      */
       
   190     void CreateVoiceCallL();
       
   191 
       
   192     /** Dials emergency call and starts shutdown */
       
   193     void DialEmergencyCallL();
       
   194     
       
   195     void ShutdownWithEngineCommandL( const TInt aCommand );
       
   196 
       
   197 private: // data members
       
   198     // singleton
       
   199     static TLcVtStateRunning* iInstance;
       
   200     
       
   201     };
       
   202 
       
   203 /**
       
   204 *  Application state that is active during shutdown.
       
   205 *
       
   206 *  @since S60 v3.2
       
   207 */
       
   208 class TLcVtStateResetting : public TLcVtStateBase
       
   209     {
       
   210 public:
       
   211     /**
       
   212     * returns singleton instance of TLcVtStateResetting
       
   213     * @param aCtx state context
       
   214     * @param aUiStates UI states
       
   215     * @param aCommand engine command to send when resetting state activates
       
   216     * @return singleton
       
   217     */
       
   218     static TLcVtStateResetting* InstanceL(
       
   219         MLcVtStateContext& aCtx,
       
   220         TLcVtStates& aUiStates,
       
   221         const TVtEngCommandId aCommand = KVtEngCommandNone );
       
   222 
       
   223 public: // from TLcVtStateBase
       
   224 
       
   225     /** @see TLcVtStateBase */
       
   226     virtual void LcVtStartupFailedL();
       
   227 
       
   228     /** @see TLcVtStateBase */
       
   229     virtual void ShutdownDoneL();
       
   230 
       
   231     /** @see TLcVtStateBase */
       
   232     virtual TEventResponse HandleVTCommandPerformedL(
       
   233         TVtEngCommandId aCommand,
       
   234         const TInt aError );
       
   235 
       
   236     /** @see TLcVtStateBase */
       
   237     virtual TEventResponse HandleVtEventL( TInt aEvent );
       
   238 
       
   239     /** @see TLcVtStateBase */
       
   240     virtual TEventResponse HandleCommandL( const TInt aCommand );
       
   241 
       
   242     /** @see TLcVtStateBase */
       
   243     virtual TBool HandleForegroundChangedL( TBool aIsForeground );
       
   244 
       
   245     /** @see TLcVtStateBase */
       
   246     virtual TBool PreHandleForegroundChangedL( TBool aIsForeground );
       
   247 
       
   248     /** @see TLcVtStateBase */
       
   249     //virtual void HandleLayoutChangedL();
       
   250 
       
   251 private: // from TLcVtStateBase
       
   252 
       
   253     /** @see TLcVtStateBase */
       
   254     virtual void OpenL();
       
   255 
       
   256     /** @see TLcVtStateBase */
       
   257     virtual void Close();
       
   258 
       
   259 private: // constructors and destructors
       
   260 
       
   261     // c++ constructor
       
   262     TLcVtStateResetting(
       
   263         MLcVtStateContext& aCtx,
       
   264         TLcVtStates& aUiStates,
       
   265         const TVtEngCommandId aCommand = KVtEngCommandNone );
       
   266 
       
   267     // Destructor
       
   268     virtual ~TLcVtStateResetting();
       
   269 
       
   270 private: // data members
       
   271 
       
   272     // Singleton
       
   273     static TLcVtStateResetting* iInstance;
       
   274     
       
   275     // Used in user originated shutdown (end active call/switch to voice)
       
   276     TVtEngCommandId iCommand;
       
   277     };
       
   278 
       
   279 #endif // T_LCVTPLUGINSTATES_H