bluetoothengine/bteng/inc/btengsrvstate.h
changeset 0 f63038272f30
child 10 0707dd69d236
equal deleted inserted replaced
-1:000000000000 0:f63038272f30
       
     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:  Bluetooth Engine server state machine class declaration.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef BTENGSRVSTATE_H
       
    21 #define BTENGSRVSTATE_H
       
    22 
       
    23 
       
    24 //#include <?include_file>
       
    25 
       
    26 #include "btengactive.h"
       
    27 #include "btserversdkcrkeys.h"
       
    28 
       
    29 class MBTEngActiveObserver;
       
    30 class CBTEngServer;
       
    31 
       
    32 /**  ?description */
       
    33 //const ?type ?constant_var = ?constant;
       
    34 
       
    35 
       
    36 /**
       
    37  *  Class CBTEngSrvState
       
    38  *
       
    39  *  This class implements the state machine for BTEng server.
       
    40  *  The state machine is used for Bluetooth power on and power off operations.
       
    41  *  A state machine is needed because the required operations for loading and 
       
    42  *  initalizing all required services is time-consuming and would be too long 
       
    43  *  to handle in one operation. It also includes asynchronous operations.
       
    44  *  It is implemented in a separate class to make it easier extensible as well 
       
    45  *  as to give a better overview of the state transitions and operations.
       
    46  *
       
    47  *  The state machine is initialized in state Init, and ends in state Idle. Any
       
    48  *  state in between are temporary states (i.e. not accepting states).
       
    49  *
       
    50  *  @lib bteng.lib
       
    51  *  @since S60 v3.2
       
    52  */
       
    53 NONSHARABLE_CLASS( CBTEngSrvState ) : public CBase
       
    54     {
       
    55 
       
    56 public:
       
    57 
       
    58     /**  Enumeration of BTEng server states */
       
    59     enum TBTEngSrvState
       
    60         {
       
    61         EInit,
       
    62         EInitBTStack,
       
    63         ELoadDIService,
       
    64         ELoadPlugins,
       
    65         ELoadNextPlugin,
       
    66         EIdle,
       
    67         EWaitingForPowerOff,
       
    68         EStopBTStack,
       
    69         EUnloadDIService,
       
    70         EUnloadPlugins,
       
    71         EDisconnectPlugins,
       
    72         };
       
    73 
       
    74     /**  Enumeration of BTEng server states */
       
    75     enum TBTEngSrvOperation
       
    76         {
       
    77         ESrvOpIdle,
       
    78         EPowerOff,
       
    79         EPowerOn
       
    80         };
       
    81 
       
    82     /**  ?description */
       
    83 //    typedef ?declaration
       
    84 
       
    85     /**
       
    86      * Two-phase constructor
       
    87      */
       
    88     static CBTEngSrvState* NewL( CBTEngServer* aServer );
       
    89 
       
    90     /**
       
    91      * Destructor
       
    92      */
       
    93     virtual ~CBTEngSrvState();
       
    94 
       
    95     /**
       
    96      * ?description
       
    97      *
       
    98      * @since S60 v3.2
       
    99      * @param ?arg1 ?description
       
   100      * @param ?arg2 ?description
       
   101      * @return ?description
       
   102      */
       
   103     CBTEngSrvState::TBTEngSrvOperation CurrentOperation();
       
   104 
       
   105     /**
       
   106      * ?description
       
   107      *
       
   108      * @since S60 v3.2
       
   109      * @param ?arg1 ?description
       
   110      * @param ?arg2 ?description
       
   111      * @return ?description
       
   112      */
       
   113     void StartStateMachineL( TBool aState );
       
   114 
       
   115     /**
       
   116      * ?description
       
   117      *
       
   118      * @since S60 v3.2
       
   119      * @param ?arg1 ?description
       
   120      * @param ?arg2 ?description
       
   121      * @return ?description
       
   122      */
       
   123     void ChangeState();    
       
   124 
       
   125 private:
       
   126 
       
   127     /**
       
   128      * C++ default constructor
       
   129      */
       
   130     CBTEngSrvState( CBTEngServer* aServer );
       
   131 
       
   132     /**
       
   133      * Symbian 2nd-phase constructor
       
   134      */
       
   135     void ConstructL();
       
   136     
       
   137     static TInt ChangeStateCb(TAny* aThis);
       
   138     
       
   139     void RequestCompletedL();
       
   140     
       
   141     void HandleError(TInt aError);
       
   142 
       
   143 private: // data
       
   144 
       
   145     /**
       
   146      * Our current state.
       
   147      */
       
   148     TInt iState;
       
   149 
       
   150     /**
       
   151      * The current command (power-on or power-off Bluetooth).
       
   152      */
       
   153     TBTEngSrvOperation iOperation;
       
   154 
       
   155     /**
       
   156      * The active object used for state transitions.
       
   157      * Own.
       
   158      */
       
   159     CAsyncCallBack* iAsyncCallback;
       
   160 
       
   161     /**
       
   162      * The server instance.
       
   163      * Not own.
       
   164      */
       
   165     CBTEngServer* iServer;
       
   166 
       
   167     };
       
   168 
       
   169 
       
   170 #endif // BTENGSRVSTATE