bluetoothengine/bteng/inc/btengsrvsettingsmgr.h
branchRCL_3
changeset 10 0707dd69d236
child 14 f7fbeaeb166a
equal deleted inserted replaced
6:6a29d5ad0713 10:0707dd69d236
       
     1 /*
       
     2 * Copyright (c) 2009 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 to manage Bluetooth hardware and stack settings.
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef BTENGSRVSETTINGSMGR_H
       
    19 #define BTENGSRVSETTINGSMGR_H
       
    20 
       
    21 #include <bluetooth/btpowercontrol.h>
       
    22 #include <btfeaturescfg.h>
       
    23 #ifndef __WINS__
       
    24 #include <bluetooth/dutmode.h>
       
    25 #endif  //__WINS__  
       
    26 
       
    27 #include "btengprivatecrkeys.h"
       
    28 #include "btengconstants.h"
       
    29 #include "btengactive.h"
       
    30 
       
    31 class CBTEngServer;
       
    32 
       
    33 
       
    34 /**
       
    35  *  ?one_line_short_description
       
    36  *  ?more_complete_description
       
    37  *
       
    38  *  @code
       
    39  *   ?good_class_usage_example(s)
       
    40  *  @endcode
       
    41  *
       
    42  *  @lib ?library
       
    43  *  @since S60 ?S60_version *** for example, S60 v3.0
       
    44  */
       
    45 NONSHARABLE_CLASS( CBTEngSrvSettingsMgr ) : public CBase,
       
    46                                             public MBTEngActiveObserver
       
    47     {
       
    48 
       
    49 public:
       
    50 
       
    51     /**
       
    52      * Two-phased constructor.
       
    53      * @param aServer Pointer to server instance.
       
    54      */
       
    55     static CBTEngSrvSettingsMgr* NewL( CBTEngServer* aServer );
       
    56 
       
    57     /**
       
    58      * Destructor.
       
    59      */
       
    60     virtual ~CBTEngSrvSettingsMgr();
       
    61 
       
    62     /**
       
    63      * Utility to get the Bluetooth hardware power state.
       
    64      *
       
    65      * @since Symbian^3
       
    66      * @param aState On return, this will contain the current HW power state.
       
    67      * @return KErrNone if successful, otherwise one of the system-wide error codes.
       
    68      */
       
    69     TInt GetHwPowerState( TBTPowerState& aState );
       
    70 
       
    71     /**
       
    72      * Set the Bluetooth hardware power state.
       
    73      *
       
    74      * @since Symbian^3
       
    75      * @param aState The new power state.
       
    76      */
       
    77     TInt SetHwPowerState( TBTPowerState aState );
       
    78 
       
    79     /**
       
    80      * Set Bluetooth on or off. This function is for internal classes of bteng server
       
    81      * for power management.
       
    82      *
       
    83      * @since Symbian^3
       
    84      * @param aState The new power state.
       
    85      * @param aTemporary Turn BT off after use (ETrue) or not (EFalse).
       
    86      */
       
    87     void SetPowerStateL( TBTPowerState aState, TBool aTemporary );
       
    88     
       
    89     /**
       
    90      * Set Bluetooth on or off upon a client power management request.
       
    91      * This function is only for power management request from clients of bteng server.
       
    92      *
       
    93      * @since Symbian^3
       
    94      * @param aState The new power state.
       
    95      * @param aTemporary Turn BT off after use (ETrue) or not (EFalse).
       
    96      */
       
    97     void SetPowerStateL( const RMessage2 aMessage );
       
    98     
       
    99     /**
       
   100      * Initialize Bluetooth stack settings.
       
   101      *
       
   102      * @since S60 v3.2
       
   103      * @param ?arg1 ?description
       
   104      */
       
   105     void InitBTStackL();
       
   106 
       
   107     /**
       
   108      * Reset settings and disconnect all links.
       
   109      *
       
   110      * @since Symbian^3
       
   111      */
       
   112     void StopBTStackL();
       
   113 
       
   114     /**
       
   115      * Update the central repository key for Bluetooth power state.
       
   116      *
       
   117      * @since Symbian^3
       
   118      * @param aValue The new Bluetooth power state.
       
   119      */
       
   120     void UpdateCenRepPowerKeyL( TBTPowerState aValue );
       
   121 
       
   122     /**
       
   123     * ?description
       
   124     *
       
   125     * @since S60 v3.2
       
   126     * @param ?arg1 ?description
       
   127     */
       
   128     void SetUiIndicatorsL();
       
   129     
       
   130     /**
       
   131     * ?description
       
   132     *
       
   133     * @since S60 v3.2
       
   134     * @param ?arg1 ?description
       
   135     */
       
   136     void SetIndicatorStateL( const TInt aIndicator, const TInt aState );
       
   137 
       
   138     /**
       
   139      * Update the Bluetooth visibility mode.
       
   140      *
       
   141      * @since Symbian^3
       
   142      * @param ?arg1 ?description
       
   143      */
       
   144     void SetVisibilityModeL( TBTVisibilityMode aMode, TInt aTime );
       
   145 
       
   146     /**
       
   147      * Update the Bluetooth visibility mode.
       
   148      *
       
   149      * @since Symbian^3
       
   150      * @param ?arg1 ?description
       
   151      */
       
   152     void UpdateVisibilityModeL( TInt aStackScanMode );
       
   153 
       
   154     /**
       
   155      * Set Device Under Test mode.
       
   156      *
       
   157      * @since Symbian^3
       
   158      * @param aDutMode The mode to be set (DUT mode on or off).
       
   159      */
       
   160     void SetDutMode( TInt aDutMode );
       
   161 
       
   162     /**
       
   163      * Timed visible mode has expired. 
       
   164      *
       
   165      * @since Symbian^3
       
   166      */
       
   167     void ScanModeTimerCompletedL();
       
   168 
       
   169     /**
       
   170      * Check whether BT should be turned off automatically.
       
   171      *
       
   172      * @since Symbian^3
       
   173      */
       
   174     void CheckAutoPowerOffL();
       
   175 
       
   176     /**
       
   177      * Queue a timer if secure simple pairing debug mode has been enabled.
       
   178      *
       
   179      * @since Symbian^3
       
   180      * @param aDebugMode State of Simple Pairing debug mode.
       
   181      */
       
   182     void CheckSspDebugModeL( TBool aDebugMode );
       
   183 
       
   184     /**
       
   185      * Be informed that a session will be closed.
       
   186      *
       
   187      * @since Symbian^3
       
   188      * @param aSession the session to be cloased.
       
   189      */
       
   190     void SessionClosed(CSession2* aSession );
       
   191     
       
   192 private:
       
   193     
       
   194 // from base class MBTEngActiveObserver
       
   195 
       
   196     /**
       
   197      * From MBTEngActiveObserver.
       
   198      * Callback to notify that an outstanding request has completed.
       
   199      *
       
   200      * @since Symbian^3
       
   201      * @param aActive Pointer to the active object that completed.
       
   202      * @param aId The ID that identifies the outstanding request.
       
   203      * @param aStatus The status of the completed request.
       
   204      */
       
   205     virtual void RequestCompletedL( CBTEngActive* aActive, TInt aId, TInt aStatus );
       
   206 
       
   207     /**
       
   208      * From MBTEngActiveObserver.
       
   209      * Callback to notify that an error has occurred in RunL.
       
   210      *
       
   211      * @since Symbian^3
       
   212      * @param aActive Pointer to the active object that completed.
       
   213      * @param aId The ID that identifies the outstanding request.
       
   214      * @param aStatus The status of the completed request.
       
   215      */
       
   216     virtual void HandleError( CBTEngActive* aActive, TInt aId, TInt aError );
       
   217 
       
   218 private:
       
   219 
       
   220     /**
       
   221      * C++ default constructor.
       
   222      */
       
   223     CBTEngSrvSettingsMgr( CBTEngServer* aServer );
       
   224 
       
   225     /**
       
   226      * Symbian second-phase constructor.
       
   227      */
       
   228     void ConstructL();
       
   229 
       
   230     /**
       
   231      * Open a handle to the Bluetooth power manager, and 
       
   232      * initialize the power to off.
       
   233      *
       
   234      * @since Symbian^3
       
   235      */
       
   236     void LoadBTPowerManagerL();
       
   237 
       
   238     /**
       
   239      * Checks if a client requests temporary power on/off, and keeps track 
       
   240      * of the number of clients requesting that.
       
   241      *
       
   242      * @since Symbian^3
       
   243      * @param aCurrentState On return, will contain the current power state.
       
   244      * @param aNewState The requested power state.
       
   245      * @param aTemporary Indicates if this is about a tempororary state change.
       
   246      */
       
   247     void CheckTemporaryPowerStateL( TBTPowerState& aCurrentState,
       
   248                                      TBTPowerState aNewState, TBool aTemporary );
       
   249 
       
   250     /**
       
   251      * Set the Class of Device.
       
   252      *
       
   253      * @since Symbian^3
       
   254      */
       
   255     void SetClassOfDeviceL();
       
   256 
       
   257 private: // data
       
   258 
       
   259 #ifdef __WINS__
       
   260     /**
       
   261      * Current BT power state (power manager is not used in emulator).
       
   262      */
       
   263     TBTPowerState iPowerState;
       
   264 #endif  //__WINS__
       
   265 
       
   266     /**
       
   267      * Flag indicating if BT is allowed to be turned on.
       
   268      */
       
   269     BluetoothFeatures::TEnterpriseEnablementMode iEnterpriseEnablementMode;
       
   270 
       
   271     /**
       
   272      * Flag indicating if BT is going to be switched off automatically.
       
   273      */
       
   274     TBool iAutoSwitchOff;
       
   275 
       
   276     /**
       
   277      * Number of clients that are using BT temporarily.
       
   278      * Note that this is equal or less than the active number of links.
       
   279      */
       
   280     TInt iAutoOffClients;
       
   281 
       
   282     /**
       
   283      * Flag indicating hidden mode has been set for temporary power on.
       
   284      */
       
   285     TBool iRestoreVisibility;
       
   286 
       
   287     /**
       
   288      * BT power control.
       
   289      */
       
   290     RBTPowerControl iPowerMgr;
       
   291 
       
   292     /**
       
   293      * Active object helper.
       
   294      * Own.
       
   295      */
       
   296     CBTEngActive* iActive;
       
   297 
       
   298     /**
       
   299      * The server instance.
       
   300      * Not own.
       
   301      */
       
   302     CBTEngServer* iServer;
       
   303     
       
   304     /**
       
   305      * Client-server message for power change requests.
       
   306      */
       
   307     RMessage2 iMessage;
       
   308     
       
   309     };
       
   310 
       
   311 
       
   312 #endif // BTENGSRVSETTINGS_H