bluetoothengine/btnotif/btnotifsrv/inc/btnotifconnectiontracker.h
changeset 33 837dcc42fd6a
parent 19 43824b19ee35
child 40 997690c3397a
--- a/bluetoothengine/btnotif/btnotifsrv/inc/btnotifconnectiontracker.h	Fri May 14 16:01:46 2010 +0300
+++ b/bluetoothengine/btnotif/btnotifsrv/inc/btnotifconnectiontracker.h	Thu May 27 13:01:44 2010 +0300
@@ -1,23 +1,18 @@
 /*
-* ============================================================================
-*  Name        : btnotifconnectiontracker.h
-*  Part of     : bluetoothengine / btnotif
-*  Description : Bluetooth connection tracker and manager.
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
 *
-*  Copyright © 2009 Nokia Corporation and/or its subsidiary(-ies).
-*  All rights reserved.
-*  This component and the accompanying materials are made available
-*  under the terms of "Eclipse Public License v1.0"
-*  which accompanies this distribution, and is available
-*  at the URL "http://www.eclipse.org/legal/epl-v10.html".
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
 *
-*  Initial Contributors:
-*  Nokia Corporation - initial contribution.
+* Contributors:
 *
-*  Contributors:
-*  Nokia Corporation
-* ============================================================================
-* Template version: 4.2
+* Description: Bluetooth connection tracker and manager.
+*
 */
 
 #ifndef BTNOTIFCONNECTIONTRACKER_H
@@ -27,13 +22,11 @@
 #include <e32property.h>
 #include <btmanclient.h>
 #include <bluetooth/pairing.h>
-#include <btengconnman.h>
-#include <btservices/btsimpleactive.h>
 #include "btnotifserver.h"
 
-class CBTNotifConnection;
 class CBTNotificationManager;
 class CbtnotifConnectionTrackerTest;
+class CBTNotifPairingManager;
 
 
 
@@ -42,10 +35,7 @@
  *  
  *  @since Symbian^4
  */
-NONSHARABLE_CLASS( CBTNotifConnectionTracker ) : public CBase,
-                                                 public MBluetoothPhysicalLinksNotifier,
-                                                 public MBTEngConnObserver,
-                                                 public MBtSimpleActiveObserver
+NONSHARABLE_CLASS( CBTNotifConnectionTracker ) : public CBase
     {
 
 public:
@@ -99,43 +89,26 @@
      */
     inline RSocketServ& SocketServerSession()
         { return iSockServ; }
-
+  
     /**
-     * Get the handle to the Bluetooth pairing server.
-     * This handle can be used for creating subsessions.
-     *
-     * @since Symbian^4
-     * @return Session with the socket server or NULL.
-     */
-    inline RBluetoothPairingServer* PairingServerSession()
-        { return iPairingServ; }
-
-    /**
-     * Processes a message from a notifier client related to connections.
+     * Processes a message for notifiers related to pairings.
+     * ( These are usually issued by BT stack. However, any application
+     * is not restricted to do so (e.g., for testing purpose).
      *
      * @since Symbian^4
      * @param aMessage The message containing the details of the client request.
      */
-    void DispatchNotifierMessageL( const RMessage2& aMessage );
-
+    void HandlePairingNotifierRequestL( const RMessage2& aMessage );
+    
     /**
      * Handle a request related to pairing.
      *
      * @since Symbian^4
-     * @param aUid The UID of the notification request.
+     * @param aMessage The message containing the details of the client request.
      */
     void HandleBondingRequestL( const RMessage2& aMessage );
 
     /**
-     * Handle a change in the number of physical connections.
-     * This also handles the case where a connection monitor has finished
-     * its processing, and is now ready for removal.
-     *
-     * @since Symbian^4
-     */
-    void HandleLinkCountChangeL();
-
-    /**
      * Check repeated connection attempts, and record rejected/accepted queries.
      *
      * @since Symbian^4
@@ -146,104 +119,6 @@
      */
     TBool UpdateBlockingHistoryL( const CBTDevice* aDevice, TBool aAccepted );
 
-// from base class MBluetoothPhysicalLinksNotifier
-    /** Notification of a requested connection coming up.
-     * If no error is reported, then that connection is ready for use.
-     * 
-     * @since Symbian^4
-     * @param aErr the returned error
-    */
-    virtual void HandleCreateConnectionCompleteL( TInt aErr );
-
-    /** Notification of a requested disconnection having taken place.
-     * If no error is reported, then that connection has been closed.
-     * 
-     * @since Symbian^4
-     * @param aErr the returned error
-    */
-    virtual void HandleDisconnectCompleteL( TInt aErr );
-
-    /** Notification that all existing connections have been torn down.
-     * If no error is reported, then there are no Bluetooth connections existing.
-     * 
-     * @since Symbian^4
-     * @param aErr the returned error
-    */
-    virtual void HandleDisconnectAllCompleteL( TInt aErr );
-
-// from base class MBTEngConnObserver
-
-    /**
-     * From MBTEngConnObserver.
-     * Indicates to the caller that a service-level connection has completed.
-     * This function is called for both incoming and outgoing connections. 
-     * This function is also called when an outgoing connection request fails, 
-     * e.g. with error code KErrCouldNotConnect.
-     * When this function is called, new commands can be issued to the 
-     * CBTEngConnMan API immediately.
-     *
-     * @since  S60 v3.2
-     * @param  aAddr The address of the remote device.
-     * @param  aErr Status information of the connection. KErrNone if the
-     *              connection succeeded, otherwise the error code with 
-     *              which the outgoing connection failed. KErrAlreadyExists 
-     *              is returned if there already is an existing connection 
-     *              for the selected profile(s), or otherwise e.g. 
-     *              KErrCouldNotConnect or KErrDisconnected for indicating 
-     *              connection problems.
-     * @param  aConflicts If there already is a connection for the selected 
-     *                    profile(s) of an outgoing connection request (the 
-     *                    selection is performed by BTEng), then this array 
-     *                    contains the bluetooth device addresses of the 
-     *                    remote devices for those connections.
-     */
-    virtual void ConnectComplete( TBTDevAddr& aAddr, TInt aErr, 
-                                   RBTDevAddrArray* aConflicts = NULL );
-
-    /**
-     * From MBTEngConnObserver.
-     * Indicates to the caller that a service-level connection has disconnected.
-     * When this function is called, new commands can be issued to the 
-     * CBTEngConnMan API immediately.
-     *
-     * @since  S60 v3.2
-     * @param  aAddr The address of the remote device.
-     * @param  aErr The error code with which the disconnection occured. 
-     *              KErrNone for a normal disconnection, 
-     *              or e.g. KErrDisconnected if the connection was lost.
-     */
-    virtual void DisconnectComplete( TBTDevAddr& aAddr, TInt aErr );
-
-// from base class MBtSimpleActiveObserver
-
-    /**
-     * From MBtSimpleActiveObserver.
-     * Callback to notify that an outstanding request has completed.
-     *
-     * @since Symbian^4
-     * @param aActive The active object helper that completed this request.
-     * @param aStatus The status of the completed request.
-     */
-    virtual void RequestCompletedL( CBtSimpleActive* aActive, TInt aStatus );
-
-    /**
-     * From MBtSimpleActiveObserver.
-     * Callback for handling cancelation of an outstanding request.
-     *
-     * @since Symbian^4
-     * @param aId The ID that identifies the outstanding request.
-     */
-    virtual void CancelRequest( TInt aRequestId );
-    
-    /**
-     * Callback to notify that an error has occurred in RunL.
-     *
-     * @param aActive Pointer to the active object that completed.
-     * @param sError The error occured in RunL
-     */
-    virtual void HandleError( CBtSimpleActive* aActive,
-                                        TInt aError );
-    
 private:
 
     CBTNotifConnectionTracker( CBTNotifServer* aServer );
@@ -251,43 +126,6 @@
     void ConstructL();
 
     /**
-     * Parse a client message and find the correct connection handler
-     * for  dispatching a request.
-     * The parsed client message may be a request that is being served,
-     * in case a cancel request has come in. The opcode identifies the
-     * client message that is currently being dispatched.
-     *
-     * @since Symbian^4
-     * @param aOpcode The opcode of the original request.
-     * @param aMessage The client message to parse.
-     * @param aBuffer On return this contains the parameters read from the message.
-     * @return The connection that is identified by the address in the
-     *         message, or NULL if none found.
-     */
-    CBTNotifConnection* FindConnectionFromMessageL( TInt aOpcode, 
-                const RMessage2& aMessage, TDes8& aBuffer );
-
-    /**
-     * Parse the Bluetooth address from a request for some notification.
-     *
-     * @since Symbian^4
-     * @param aUid The UID of the notification request.
-     * @param aParamsBuf Descriptor containing the parameter read from the
-     *        client message.
-     * @return Bluetooth address parsed from the descriptor.
-     */
-    TBTDevAddr ParseAddressL( TInt aUid, const TDesC8& aParamsBuf ) const;
-
-    /**
-     * Find the handler of a specific connection.
-     *
-     * @since Symbian^4
-     * @param aAddr The remote device address identifying the connection.
-     * @return Connnection handler or NULL;
-     */
-    CBTNotifConnection* FindConnectionHandler( const TBTDevAddr& aAddr ) const;
-
-    /**
      * Record and check the time between connection attempts.
      *
      * @since Symbian^4
@@ -300,30 +138,6 @@
 private: // data
 
     /**
-     * PubSub key for tracking the number of connections.
-     */
-    RProperty iLinkCount;
-
-// ToDo: remove this when registry notifications API is available!!
-    /**
-     * PubSub key for tracking registry changes.
-     */
-    RProperty iRegistryChange;
-
-    /**
-     * Helper active object for observing the link count.
-     * Own.
-     */
-    CBtSimpleActive* iRegistryActive;
-// End ToDo
-
-    /**
-     * Array of pointers to observers of individual connections.
-     */
-    RPointerArray<CBTNotifConnection> iConnArray;
-//    RHashMap<TBTDevAddr,CBTNotifConnection*> iConnArray;
-
-    /**
      * Time of the last denied connection attempt.
      */
     TInt64 iLastReject;
@@ -344,50 +158,16 @@
     RSocketServ iSockServ;
 
     /**
-     * Address placeholder for receiving secure simple pairing results.
-     */
-    TBTDevAddr iSspResultAddr;
-
-    /**
-     * Session with pairing server for receiving secure simple pairing results.
-     */
-    RBluetoothPairingResult iSspResultSession;
-
-    /**
-     * Single session with the pairing server, to be used for subsessions.
-     * Own.
-     */
-    RBluetoothPairingServer* iPairingServ;
-
-    /**
-     * Object for managing the piconet.
-     * Own.
-     */
-    CBTEngConnMan* iConnMan;
-
-    /**
-     * Object for managing the piconet.
-     * Own.
-     */
-    CBluetoothPhysicalLinks* iPhyLinks;
-
-    /**
-     * Helper active object for observing the link count.
-     * Own.
-     */
-    CBtSimpleActive* iLinkCountActive;
-
-    /**
-     * Helper active object for receiving secure simple pairing results.
-     * Own.
-     */
-    CBtSimpleActive* iSspResultActive;
-
-    /**
      * Reference to our parent the server class.
      * Not own.
      */
     CBTNotifServer* iServer;
+    
+    /**
+     * Object for managing the application pairing.
+     * Own.
+     */
+    CBTNotifPairingManager* iPairingManager;
 
     BTUNITTESTHOOK