bluetoothengine/bteng/inc/btengserver.h
branchRCL_3
changeset 8 0707dd69d236
parent 0 f63038272f30
child 12 b23265fb36da
--- a/bluetoothengine/bteng/inc/btengserver.h	Fri Feb 19 22:59:18 2010 +0200
+++ b/bluetoothengine/bteng/inc/btengserver.h	Fri Mar 12 15:43:23 2010 +0200
@@ -20,13 +20,10 @@
 #define BTENGSERVER_H
 
 #include <bluetooth/btpowercontrol.h>
-#ifndef __WINS__
-#include <bluetooth/dutmode.h>
-#endif  //__WINS__  
 #include <bt_sock.h>
 #include <bttypes.h>
-#include <btfeaturescfg.h>
-#include "btengdomaincrkeys.h"
+#include <btserversdkcrkeys.h>
+
 #include "btengconstants.h"
 
 class CBTEngSrvState;
@@ -40,6 +37,7 @@
 class TEComResolverParams;
 class CImplementationInformation;
 class CDeltaTimer;
+class CBTEngSrvSettingsMgr;
 
 /**
  * Main function in which the server is running.
@@ -75,7 +73,8 @@
     EBTEngPanicArgumentIsNull,
     EBTEngPanicMemberVarIsNull,
     EBTEngPanicCorrupt,
-    EBTEngPanicCorruptSettings
+    EBTEngPanicCorruptSettings,
+    EBTEngPanicExpectSetPowerOpcode,
     };
 
 
@@ -90,43 +89,114 @@
 NONSHARABLE_CLASS( CBTEngServer ) : public CPolicyServer
     {
 
-    friend class CBTEngSrvSession;
-    friend class CBTEngSrvState;
     friend class CBTEngSrvPluginMgr;
-    friend class CBTEngSrvKeyWatcher;
     friend class CBTEngPairMan;
 
 public:
 
+    /**  Enumeration of bitmask for keeping track of different timers. */
+    enum TTimerQueued
+        {
+        ENone               = 0x00,
+        EScanModeTimer      = 0x01,
+        EIdleTimer          = 0x02,
+        EAutoPowerOffTimer  = 0x04,
+        ESspDebugModeTimer  = 0x08 
+        };
+
+    /**
+     * Two-phased constructor.
+     */
     static CBTEngServer* NewLC();
 
+    /**
+     * Destructor.
+     */
     virtual ~CBTEngServer();
 
     /**
-     * ?description
+     * Getter for power change state machine instance.
+     *
+     * @since Symbian^3
+     * @return Pointer to instance of state machine.
+     */
+    inline CBTEngSrvState* StateMachine() const
+            { return iServerState; }
+
+    /**
+     * Getter for settings manager instance.
+     *
+     * @since Symbian^3
+     * @return Pointer to instance of settings manager.
+     */
+    inline CBTEngSrvSettingsMgr* SettingsManager() const
+            { return iSettingsMgr; }
+
+    /**
+     * Getter for plug-in manager instance.
+     *
+     * @since Symbian^3
+     * @return Pointer to instance of plug-in manager.
+     */
+    inline CBTEngSrvPluginMgr* PluginManager() const
+            { return iPluginMgr; }
+
+    /**
+     * Getter for baseband connection manager instance.
+     *
+     * @since Symbian^3
+     * @return Pointer to instance of baseband connection manager.
+     */
+    inline CBTEngSrvBBConnMgr* BasebandConnectionManager() const
+            { return iBBConnMgr; }
+
+    /**
+     * Getter for pairing manager. Ownership is not transferred.
+     *
+     * @since Symbian^3
+     * @return Pointer to instance of baseband connection manager.
+     */
+    inline CBTEngPairMan* PairManager() const
+            { return iPairMan; }
+
+    /**
+     * Getter for socket server session.
+     * This handle can be used for creating subsessions.
+     *
+     * @since Symbian^3
+     * @return Reference to session with the socket server.
+     */
+    inline RSocketServ& SocketServer()
+            { return  iSocketServ; }
+
+    /**
+     * Getter for registry server session.
+     * This handle can be used for creating subsessions.
+     *
+     * @since Symbian^3
+     * @return Reference to session with the registry server.
+     */
+    inline RBTRegServ& RegistrServer()
+            { return iBTRegServ; }
+
+    /**
+     * Set Bluetooth on or off
      *
      * @since S60 v3.2
      * @param aState The new power state.
-     * @param aTemp Turn BT off after use (ETrue) or not (EFalse).
+     * @param aTemporary Turn BT off after use (ETrue) or not (EFalse).
      */
-    void SetPowerStateL( TBTPowerStateValue aState, TBool aTemporary );
+    void SetPowerStateL( TBTPowerState aState, TBool aTemporary );
 
     /**
-     * ?description
+     * Set Bluetooth on or off upon a client power management request.
+     * This function is only for power management request from clients of bteng server.
      *
-     * @since S60 v3.2
-     * @param ?arg1 ?description
+     * @since Symbian^3
+     * @param aMessage The message containing the detail of power management request.
      */
-    void SetVisibilityModeL( TBTVisibilityMode aMode, TInt aTime );
+    void SetPowerStateL( const RMessage2 aMessage );
     
-     /**
-     * ?description
-     *
-     * @since S60 v3.2
-     * @param ?arg1 ?description
-     */
-    void UpdateVisibilityModeL( TInt aStackScanMode );
-
     /**
      * ?description
      *
@@ -141,23 +211,7 @@
      * @since S60 v3.2
      * @param ?arg1 ?description
      */
-    void SetDutMode( TInt aDutMode );
-
-    /**
-     * ?description
-     *
-     * @since S60 v3.2
-     * @param ?arg1 ?description
-     */
-    void ScanModeTimerCompletedL();
-
-    /**
-     * ?description
-     *
-     * @since S60 v3.2
-     * @param ?arg1 ?description
-     */
-     void DisconnectAllCompleted();
+    void DisconnectAllCompleted();
 
     /**
      * ?description
@@ -172,86 +226,89 @@
      *
      * @since S60 v3.2
      */
-     void AddSession();
+    void AddSession();
 
     /**
      * Decrement the session count.
      *
-     * @since S60 v3.2
+     * @since Symbian^3
+     * @param aSession the session to be cloased.
      * @param aAutoOff Indicator if this session had requested BT temporary on.
      */
-     void RemoveSession( TBool aAutoOff );
-     
-     /**
-     * ?description
+    void RemoveSession(CSession2* aSession, TBool aAutoOff );
+
+    /**
+     * Queue a new timer.
+     *
+     * @since Symbian^3
+     * @param aTimer Identifier for the timer to be queued.
+     * @param aInterval The interval for timer callback.
+     */
+    void QueueTimer( CBTEngServer::TTimerQueued aTimer, TInt64 aInterval );
+
+    /**
+     * Remove a queued timer.
+     *
+     * @since Symbian^3
+     * @param aTimer Identifier for the timer to be removed.
+     */
+    void RemoveTimer( CBTEngServer::TTimerQueued aTimer );
+
+    /**
+     * Check if a specific timer is currently queued.
+     *
+     * @since Symbian^3
+     * @param aTimer Identifier for the timer to check.
+     */
+    inline TBool IsTimerQueued( CBTEngServer::TTimerQueued aTimer ) const
+            { return ( iTimerQueued & aTimer ); }
+
+    /**
+     * Returns the service (limited to services managed in bteng scope)
+     * level connection status of the specified device.
+     *
+     * @param aAddr the address of the device
+     * @return one of TBTEngConnectionStatus enums
+     */
+    TBTEngConnectionStatus IsDeviceConnected( const TBTDevAddr& aAddr );
+
+    /**
+     * Checks if power is off and no session are connected, and
+     * starts a shutdown timer if so.
      *
      * @since S60 v3.2
      * @param ?arg1 ?description
      */
-     void SetUiIndicatorsL();
-     
-     /**
+    void CheckIdle();
+
+    /**
      * ?description
      *
      * @since S60 v3.2
      * @param ?arg1 ?description
      */
-     void SetIndicatorStateL( const TInt aIndicator, const TInt aState );
-
-    /**
-     * Check whether BT should be turned off automatically.
-     *
-     * @since S60 v5.0
-     */
-     void CheckAutoPowerOffL();
+    void ManageDIServiceL( TBool aState );
 
     /**
-     * Utility to get HW power state.
-     *
-     * @since S60 v5.1
-     * @param aState On return, this will contain the current HW power state.
-     * @return KErrNone if successful, otherwise one of the system-wide error codes.
-     */
-    TInt GetHwPowerState( TBTPowerStateValue& aState );
-
-     /**
-     * queue a timer if Simple Pairing debug mode has been enabled.
+     * Callback function for completion of disconnecting all 
+     * Bluetoooth Baseband links.
      *
      * @since S60 v3.2
-     * @param aDebugMode State of Simple Pairing debug mode.
+     * @param aPtr Pointer to ourselves.
+     * @return Result
      */
-     void CheckSspDebugModeL( TBool aDebugMode );
-     
-     /**
-      * Gets the access to pairing manager. Ownership is not transferred.
-      * @return the pairing manager
-      */
-     CBTEngPairMan& PairManager();
-     
-     /**
-      * Be informed when registry remote device table is changed
-      */
-     void RemoteRegistryChangeDetected();
+    static TInt DisconnectAllCallBack( TAny* aPtr );
 
-     /**
-      * gets the reference of socket server session
-      */
-     RSocketServ& SocketServ();
-     
-     /**
-      * gets the reference of registry session.
-      */
-     RBTRegServ& BTRegServ();
-     
-     /**
-      * Returns the service (limited to services managed in bteng scope)
-      * level connection status of the specified device.
-      *
-      * @param aAddr the address of the device
-      * @return one of TBTEngConnectionStatus enums
-      */
-     TBTEngConnectionStatus IsDeviceConnected( const TBTDevAddr& aAddr );
-     
+    /**
+     * Callback function for turning BT off automatically after all
+     * connections are gone.
+     *
+     * @since S60 v5.0
+     * @param aPtr Pointer to ourselves.
+     * @return Result
+     */
+    static TInt AutoPowerOffCallBack( TAny* aPtr );
+
 // from base class CPolicyServer
 
     /**
@@ -264,10 +321,6 @@
     virtual CSession2* NewSessionL( const TVersion& aVersion, 
                                      const RMessage2& aMessage ) const;
 
-// from base class MBTPowerManagerObserver
-
-    BluetoothFeatures::TEnterpriseEnablementMode EnterpriseEnablementMode() const;
-    
 private:
 
     CBTEngServer();
@@ -275,81 +328,6 @@
     void ConstructL();
 
     /**
-     * Checks if power is off and no session are connected, and
-     * starts a shutdown timer if so.
-     *
-     * @since S60 v3.2
-     * @param ?arg1 ?description
-     */
-     void CheckIdle();
-
-    /**
-     * ?description
-     *
-     * @since S60 v3.2
-     * @param ?arg1 ?description
-     */
-    TInt SetPowerState( TBool aState );
-
-    /**
-     * ?description
-     *
-     * @since S60 v3.2
-     * @param ?arg1 ?description
-     */
-    TInt SetLocalNameL();
-    
-    TInt GetLocalNameFromRegistryL(TDes& aName);
-
-    /**
-     * ?description
-     *
-     * @since S60 v3.2
-     * @param ?arg1 ?description
-     */
-    void SetClassOfDeviceL();
-
-    /**
-     * ?description
-     *
-     * @since S60 v3.2
-     * @param ?arg1 ?description
-     */
-    void InitBTStackL();
-
-    /**
-     * ?description
-     *
-     * @since S60 v3.2
-     * @param ?arg1 ?description
-     */
-    void StopBTStackL();
-
-    /**
-     * ?description
-     *
-     * @since S60 v3.2
-     * @param ?arg1 ?description
-     */
-    void UpdateCenRepPowerKeyL( TBTPowerStateValue aValue );
-
-    /**
-     * ?description
-     *
-     * @since S60 v3.2
-     * @param ?arg1 ?description
-     */
-    void LoadBTPowerManagerL();
-
-    /**
-     * ?description
-     *
-     * @since S60 v3.2
-     * @param ?arg1 ?description
-     */
-    void ManageDIServiceL( TBool aState );
-    
-    /**
      * Reads the product-specific IDs for this phone from central repository.
      * These values are used in the BT Device Information profile.
      *
@@ -358,19 +336,6 @@
      * @param aProductId On return, holds the product ID for this phone.
      */
     void GetProductIdsL( TInt& aVendorId, TInt& aProductId );
-    
-	/**
-     * Checks if a client requests temporary power on/off, and keeps track 
-     * of the number of clients requesting that.
-     *
-     * @since S60 v5.0
-     * @param aCurrentState On return, will contain the current power state.
-     * @param aNewState The requested power state.
-     * @param aTemporary Indicates if this is about a tempororary state change.
-     */
-    void CheckTemporaryPowerStateL( TBTPowerStateValue& aCurrentState, 
-                                     TBTPowerStateValue aNewState, 
-                                     TBool aTemporary );
 
     /**
      * Callback function for expiry of CDeltaTimer timer of temporary 
@@ -383,16 +348,6 @@
     static TInt ScanModeTimerCallBack( TAny* aPtr );
     
     /**
-     * Callback function for completion of disconnecting all 
-     * Bluetoooth Baseband links.
-     *
-     * @since S60 v3.2
-     * @param aPtr Pointer to ourselves.
-     * @return Result
-     */
-    static TInt DisconnectAllCallBack( TAny* aPtr );
-    
-    /**
      * Callback function for expiriy CDeltaTimer timer of server idle timeout.
      *
      * @since S60 v3.2
@@ -410,17 +365,7 @@
      * @return Result
      */
     static TInt DebugModeTimerCallBack( TAny* aPtr );
-    
-    /**
-     * Callback function for turning BT off automatically after all
-     * connections are gone.
-     *
-     * @since S60 v5.0
-     * @param aPtr Pointer to ourselves.
-     * @return Result
-     */
-    static TInt AutoPowerOffCallBack( TAny* aPtr );
-	
+
 private: // data
 
     /**
@@ -436,28 +381,6 @@
     TUint32 iDiSdpRecHandle;
 
     /**
-     * Flag indicating if BT is going to be switched off automatically.
-     */
-    TBool iAutoSwitchOff;
-
-    /**
-     * Number of clients that are using BT temporarily.
-     * Note that this is equal or less than the active number of links.
-     */
-    TInt iAutoOffClients;
-
-    /**
-     * Flag indicating hidden mode has been set for temporary power on.
-     */
-    TBool iRestoreVisibility;
-
-    /**
-    * To decide wether DUT mode should be enabled in power mode
-    * change callback.
-    */   
-    TBool iEnableDutMode;
-
-    /**
      * Remember which timer has been queued. (CDeltaTimer does not 
      * provide this information).
      */
@@ -477,24 +400,13 @@
      * Callback for expiry of idle timer.
      */
     TDeltaTimerEntry iIdleCallBack;
+
     /**
      * Callback for expiry of Simple Pairing debug mode.
      */
     TDeltaTimerEntry iDebugModeCallBack;
 
     /**
-     * Handle to BT Power Manager library; this handle must exist 
-     * for the lifetime of the loaded library.
-     */
-    RLibrary iPowerMgrLib;
-#ifndef __WINS__
-    /**
-     *  Handle for DUT mode API
-     */
-    RBluetoothDutMode iDutMode;
-#endif  //__WINS__  
-
-    /**
      * Pairing manager.
      */
     CBTEngPairMan* iPairMan;
@@ -503,20 +415,25 @@
     * Socket Server instance for this and other classes to access Bluetooth socket APIs.
     */   
     RSocketServ iSocketServ;
-    
-    
+
     /**
     * Registry Server instance for bteng to access Bluetooth registry APIs.
     */      
     RBTRegServ iBTRegServ;
-     
+
     /**
-     * BT Power Manager.
+     * Our state machine for handling power on/off.
      * Own.
      */
     CBTEngSrvState* iServerState;
 
     /**
+     * Hardware and stack settings manager.
+     * Own.
+     */
+    CBTEngSrvSettingsMgr* iSettingsMgr;
+
+    /**
      * ECOM plugin manager.
      * Own.
      */
@@ -535,18 +452,6 @@
     CBTEngSrvKeyWatcher* iWatcher;
 
     /**
-     * BT Power Manager (HCIv2 version).
-     */
-    RBTPowerControl iPowerMgr;
-
-#ifdef __WINS__
-    /**
-     * Current BT power state (power manager is not used in emulator).
-     */
-    TBTPowerState iPowerState;
-#endif  //__WINS__
-
-    /**
      * SDP database handler.
      * Own.
      */
@@ -558,7 +463,6 @@
      */
     CDeltaTimer* iTimer;
 
-    BluetoothFeatures::TEnterpriseEnablementMode iEnterpriseEnablementMode;
     };