vtuis/lcvtplugin/inc/base/clcvtappshutter.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:  Class responsible for application exit.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef C_VTUIAPPSHUTTER_H
       
    20 #define C_VTUIAPPSHUTTER_H
       
    21 
       
    22 #include <babitflags.h>
       
    23 
       
    24 #include    <mphcltemergencycallobserver.h>
       
    25 #include    <cphcltemergencycall.h>
       
    26 #include    <rphcltserver.h>
       
    27 
       
    28 class CAsyncCallBack;
       
    29 class MLcVtShutterObserver;
       
    30 class MLcVtStateContext;
       
    31 
       
    32 /**
       
    33 * Shutdown service for the application. This is singleton
       
    34 * which deletes itself when shutdown is complete.
       
    35 *
       
    36 * @since S60 v3.2
       
    37 */                       
       
    38 class CLcVtAppShutter : public CBase
       
    39     {
       
    40 public:          
       
    41 
       
    42     /**
       
    43     * Returns the instance of application shutter.
       
    44     *
       
    45     * @param aComms for sending call ending related commands to Phone.
       
    46     * @param aObserver observer informed when shutdown is completed.
       
    47     * @return the application shutter
       
    48     */
       
    49     static CLcVtAppShutter* InstanceL( 
       
    50         MLcVtShutterObserver& aObserver );
       
    51 
       
    52     /**
       
    53     *  Starts shutdown.
       
    54     */
       
    55     void StartShutdown();
       
    56 
       
    57     /**
       
    58     * Starts shutdown because emergency call was requested by the user.
       
    59     * If supplied number is detected other than emergency number this method
       
    60     * leaves KErrArgument.
       
    61     * @param aStateContext for accessing emergency number and local
       
    62     * variation.
       
    63     */
       
    64     void ShutdownWithEmergencyCallL( MLcVtStateContext& aStateContext );
       
    65                                
       
    66     /**
       
    67     * Callback from emergency caller.
       
    68     */
       
    69     void EmergencyCallDoneL();
       
    70                                    
       
    71 private:
       
    72 
       
    73     /**
       
    74     * Exits the application if no pending shutdown preparation
       
    75     * is ongoing. Deletes itself as last action.
       
    76     */
       
    77     void ShutdownIfReadyAndDestroy();
       
    78 
       
    79     
       
    80     /**
       
    81     * Enques async callback.
       
    82     */
       
    83     void EnqueCallbackL( TCallBack& aCallback );
       
    84 
       
    85     /**
       
    86     * Asynch callback handling response to emergency call creation.
       
    87     */
       
    88     static TInt EmergencyResponseCallback( TAny* aAny );
       
    89 
       
    90     /** C++ constructor */
       
    91     CLcVtAppShutter( MLcVtShutterObserver& aObserver );
       
    92 
       
    93     /** destructor */
       
    94     ~CLcVtAppShutter();
       
    95 
       
    96 private: // for making shutdown with emergency call
       
    97     class CEmergencyCaller : public CBase, private MPhCltEmergencyCallObserver
       
    98         {
       
    99         public:         
       
   100             /**
       
   101             * Dials emergency call. Object destroys itself when
       
   102             * response is received.
       
   103             */
       
   104             static CEmergencyCaller* DialEmergencyL(
       
   105                 CLcVtAppShutter& aObserver,
       
   106                 MLcVtStateContext& aStateContext );
       
   107             
       
   108             // Destructor
       
   109             ~CEmergencyCaller();
       
   110             
       
   111         private: // C++ constructor
       
   112             
       
   113             CEmergencyCaller( 
       
   114                 CLcVtAppShutter& aObserver, 
       
   115                 MLcVtStateContext& aStateContext );
       
   116             
       
   117             /**
       
   118             * 2nd phase constructor
       
   119             */
       
   120             void ConstructL();
       
   121             
       
   122         public: // from MPhCltEmergencyCallObserver       
       
   123             /**
       
   124             * @see  MPhCltEmergencyCallObserver::HandleEmergencyDialL
       
   125             */
       
   126             virtual void HandleEmergencyDialL( const TInt aStatus );
       
   127 
       
   128         private: // Data
       
   129 
       
   130             // Emergency number
       
   131             TPhCltTelephoneNumber iNumber;             
       
   132             
       
   133             // Phone Server session
       
   134             RPhCltServer          iServer;
       
   135             
       
   136             // Emergency call handler
       
   137             CPhCltEmergencyCall*  iEmergency;
       
   138             
       
   139             // Observer for callback
       
   140             CLcVtAppShutter&      iObserver;
       
   141 
       
   142             // State context for gettin entered numbers and local variation
       
   143             MLcVtStateContext&    iStateContext;
       
   144         };
       
   145 private: // Data
       
   146 
       
   147     /**
       
   148     * Guard flags for completing shutdown.
       
   149     * All must be cleared before shutdown
       
   150     * can be completed.
       
   151     */
       
   152     enum TShutterFlags 
       
   153         {                               
       
   154         /** Waiting for call on StartShutdown() */
       
   155         EShutterWaitingStart,
       
   156         /** Waiting for callback on emegency call request */
       
   157         EShutterWaitingEmergencyCallback,
       
   158         };
       
   159     
       
   160     // Asynch callback
       
   161     CAsyncCallBack* iCallback;
       
   162     
       
   163     // guard flags          
       
   164     TBitFlags8 iPendingStateFlags;
       
   165      
       
   166     // Observer to notify when application exit
       
   167     // is allowed.
       
   168     MLcVtShutterObserver& iObserver;
       
   169 
       
   170     // Handles emergency call dialling    
       
   171     CEmergencyCaller* iEmergencyCaller;
       
   172 
       
   173     };
       
   174 
       
   175 #endif // C_VTUIAPPSHUTTER_H