bluetoothcommsprofiles/btpan/panagt/panagtremdev.h
changeset 0 29b1cd4cb562
equal deleted inserted replaced
-1:000000000000 0:29b1cd4cb562
       
     1 // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #ifndef PANAGTREMDEV_H
       
    17 #define PANAGTREMDEV_H
       
    18 
       
    19 /**
       
    20 @file
       
    21 @note PAN agent remote device class definition, and remote device state base class definitions
       
    22 @internalComponent
       
    23 */
       
    24 
       
    25 #include "panagt.h"
       
    26 #include "panhelper.h"
       
    27 #include "panagtutils.h"
       
    28 
       
    29 #ifdef SYMBIAN_NON_SEAMLESS_NETWORK_BEARER_MOBILITY
       
    30 #include <elements/nm_node.h>
       
    31 #include <comms-infras/ss_common.h>
       
    32 #include "panmessages.h"
       
    33 #endif
       
    34 
       
    35 class MBnepChannelControl;
       
    36 class TPanConnectionList;
       
    37 
       
    38 
       
    39 
       
    40 namespace PanAgent
       
    41 /**
       
    42 @internalComponent
       
    43 @released
       
    44 @since v8.1
       
    45 */
       
    46 {
       
    47 
       
    48 /**
       
    49 The number of role negotiation cycles we are willing to go through before terminating the 
       
    50 connection to the remote device
       
    51 @internalComponent
       
    52 */
       
    53 const TUint KMaxBnepNegotiationCyles = 3;
       
    54 
       
    55 /**
       
    56 The amount of time we will wait for a role response before resending the role request
       
    57 @internalComponent
       
    58 */
       
    59 const TUint KMaxTimeToWaitForRoleResponse = 10*1000*1000; // 10 secs (from PAN spec v1.0)
       
    60 
       
    61 /**
       
    62 The maximum amount of time we will wait for a master/slave switch to occur
       
    63 @internalComponent
       
    64 */
       
    65 const TUint KMaxTimeToWaitForBasebandRoleSwitch = 5*1000*1000;	// 5 secs
       
    66 
       
    67 class MPanConnectionNotifyForState
       
    68 /**
       
    69 A mirror class of MPanConnectionNotify, but with leaving versions of the methods to allow easier 
       
    70 error handling for each state. This class should be kept in sync with the methods in MPanConnectionNofify.
       
    71 @see MPanConnectionNotify
       
    72 */
       
    73 	{
       
    74 public:
       
    75 	virtual void BnepRoleRequestFromRemoteDeviceL(const TUUID& aRequestedLocalRole, const TUUID& aRequestedRemoteRole) = 0;
       
    76 	virtual void BnepRoleResponseFromRemoteDeviceL(TBnepSetupConnectionResponseMessage aRoleResponseCode) = 0;
       
    77 	virtual void RemoteDeviceDisconnectL(TInt aError) = 0;
       
    78 	};
       
    79 
       
    80 class MPanRemDevStateMachineNotify;
       
    81 NONSHARABLE_CLASS(CPanRemDevStateBase) : public CBase, public MPanConnectionNotifyForState
       
    82 /**
       
    83 Base class for remote device states
       
    84 @internalComponent
       
    85 */
       
    86 	{
       
    87 #ifdef SYMBIAN_NON_SEAMLESS_NETWORK_BEARER_MOBILITY
       
    88     friend class CPanRemoteDeviceStateMachine;
       
    89 #endif
       
    90 
       
    91 protected:
       
    92 	enum TPanRemDevStates
       
    93 		{
       
    94 		EPanRemDevStatePerformingSdpQuery,
       
    95 		EPanRemDevStateConnectingSocket,
       
    96 		EPanRemDevStateWaitingForLocalRoleStateMachineAvailabilityForOutgoingConnection,
       
    97 		EPanRemDevStateWaitingForLocalRoleStateMachineAvailabilityForIncomingConnection,
       
    98 		EPanRemDevStateWaitingForLocalRoleStateMachineAvailabilityForIncomingRoleChangeRequest,
       
    99 		// EPanRemDevStatePerformingRoleNegotiationForOutgoingBase,
       
   100 		EPanRemDevStatePerformingRoleNegotiationForOutgoingConnection,
       
   101 		EPanRemDevStatePerformingRoleNegotiationForIncomingConnection,
       
   102 		EPanRemDevStatePerformingRoleNegotiationForOutgoingRoleChange,
       
   103 		EPanRemDevStatePerformingDelayedRoleNegotiationForOutgoingConnection,
       
   104 		// EPanRemDevStateWaitingForRoleSwitchBase,
       
   105 		EPanRemDevStateWaitingForRoleSwitchForOutgoingConnection,
       
   106 		EPanRemDevStateWaitingForRoleSwitchForIncomingConnection,
       
   107 		EPanRemDevStateWaitingForRoleSwitchForOutgoingRoleChangeRequest,
       
   108 		EPanRemDevStateWaitingForRoleSwitchForIncomingRoleChangeRequest,
       
   109 		EPanRemDevStateActive,
       
   110 		EPanRemDevStateShutdown,
       
   111 		EPanRemDevStateIncomingNotification,
       
   112 		
       
   113 #ifdef SYMBIAN_NON_SEAMLESS_NETWORK_BEARER_MOBILITY
       
   114 		EPanRemDevStatePaused,
       
   115 #endif		
       
   116 		};
       
   117 
       
   118 public:
       
   119 	virtual ~CPanRemDevStateBase();
       
   120 	virtual void OnEntryL() = 0;
       
   121 	
       
   122 	// MPanConnectionNotifyForState methods (downcalls from state machine)
       
   123 	virtual void BnepRoleRequestFromRemoteDeviceL(const TUUID& aRequestedLocalRole, const TUUID& aRequestedRemoteRole);
       
   124 	virtual void BnepRoleResponseFromRemoteDeviceL(TBnepSetupConnectionResponseMessage aRoleResponseCode);
       
   125 	virtual void RemoteDeviceDisconnectL(TInt aError);
       
   126 	
       
   127 	//
       
   128 	// Other downcalls from state machine
       
   129 	//
       
   130 	/**
       
   131 	Called from the state machine when it's ready to negotiate roles for this connection
       
   132 	@note This can be called when the connection is active, and indicates that the state machine wants to renegotiate roles
       
   133 	@note Clients must set a flag and initiate a callback to start the RoleRequest() process to prevent call stacks from getting too large
       
   134 	@leave To indicate that an unrecoverable error has occured, and that the connection should be shut down
       
   135 	*/
       
   136 	virtual void ReadyForRoleRequestL();
       
   137 	
       
   138 	/**
       
   139 	A locally-initiated disconnect
       
   140 	*/
       
   141 	virtual void ShutdownL() = 0;
       
   142 
       
   143 	virtual TRemoteDeviceState GetState() const = 0;
       
   144 	
       
   145 	// Async translation calls - needed to convert an async event from signalling a TRequestStatus into an async event as a function call on this object
       
   146 	virtual void AsyncEventCompleteL();
       
   147 	virtual void AsyncEventCancelL();
       
   148 
       
   149 protected:
       
   150 	CPanRemDevStateBase(MPanRemDevStateMachineNotify& aStateMachine, TPanRemDevStates aStateNumber);
       
   151 
       
   152 	void ConvertUuidsToPanRolesL(const TUUID& aLocalRoleUuid, const TUUID& aRemoteRoleUuid, TBluetoothPanRole& aLocalRole, TBluetoothPanRole& aRemoteRole);
       
   153 	TInt PerformMasterSlaveSwitchIfNecessary(TBluetoothPanRole aLocalRole);
       
   154 
       
   155 	MPanRemDevStateMachineNotify& StateMachine();
       
   156 	
       
   157 	void PanicInState(TPanAgentPanic aPanic) const;
       
   158 
       
   159 private:
       
   160 	TInt UuidToPanRole(const TUUID& aUuid, TBluetoothPanRole& aRole);
       
   161 	TInt BecomePiconetMaster();
       
   162 
       
   163 public:
       
   164 
       
   165 private:
       
   166 	MPanRemDevStateMachineNotify& iStateMachine;
       
   167 	TPanRemDevStates iStateNumber;
       
   168 	};
       
   169 
       
   170 class MPanRemDevStateMachineNotify
       
   171 /**
       
   172 Upcalls from states to state machine
       
   173 @internalComponent
       
   174 */
       
   175 	{
       
   176 public:
       
   177 	//
       
   178 	// Accessor methods
       
   179 	//
       
   180 	/**
       
   181 	Get a handle to the local role
       
   182 	*/
       
   183 	virtual TBluetoothPanRole& LocalRole() = 0;
       
   184 	
       
   185 	/**
       
   186 	Get a handle to the remote role
       
   187 	*/
       
   188 	virtual TBluetoothPanRole& RemoteRole() = 0;
       
   189 	
       
   190 	/**
       
   191 	Get handle to PAN remote SDP querier
       
   192 	*/
       
   193 	virtual RPanRemoteSdpQuerier& RemoteSdpQuerier() = 0;
       
   194 
       
   195 	/**
       
   196 	Get role array
       
   197 	*/
       
   198 	virtual TPanDeviceRolesList& RemoteRolesList() = 0;
       
   199 	
       
   200 	/**
       
   201 	Get WorthTrying role array
       
   202 	*/
       
   203 	virtual TPanDeviceWorthTryingRolesList& RemoteWorthTryingRolesList() = 0;
       
   204 	
       
   205 	/**
       
   206 	Get the remote device address
       
   207 	*/
       
   208 	virtual TBTSockAddr& RemSockAddr() = 0;
       
   209 	
       
   210 	/**
       
   211 	Get a handle to the socket
       
   212 	*/
       
   213 	virtual RInternalSocket& Socket() = 0;
       
   214 	
       
   215 	/**
       
   216 	Get a handle to commdb
       
   217 	*/
       
   218 	virtual CCommsDbAccess& Database() = 0;
       
   219 	
       
   220 	/**
       
   221 	Get hold of the state machine's TRequestStatus either to use it for an async call, or to check its value after an event has completed
       
   222 	@return The state machine's TRequestStatus
       
   223 	*/
       
   224 	virtual TRequestStatus& Status() = 0;
       
   225 
       
   226 	/**
       
   227 	Are SDP queries disabled by the settings in commdb?
       
   228 	*/
       
   229 	virtual void SdpQueriesDisabled(TBool aSdpQueriesStatus) = 0;
       
   230 	virtual TBool IsSdpQueriesDisabled() = 0;
       
   231 	
       
   232 	/**
       
   233 	Get the error that occured (for shutdown state)
       
   234 	*/
       
   235 	virtual TInt Error() const = 0;
       
   236 	
       
   237 	/**
       
   238 	Have we got to a stage where we have a BNEP channel open?
       
   239 	*/
       
   240 	virtual TBool HasBnepChannel() const = 0;
       
   241 	
       
   242 	//
       
   243 	// do'er methods
       
   244 	//
       
   245 	/**
       
   246 	Make the parent object active
       
   247 	*/
       
   248 	virtual void SetActive() = 0;
       
   249 	
       
   250 	/**
       
   251 	Cancel the pending AO
       
   252 	@note It is the caller's responsibilty to ensure that whichever event it was waiting for is also cancelled
       
   253 	*/
       
   254 	virtual void Cancel() = 0;
       
   255 	
       
   256 	/**
       
   257 	Inform the PAN agent role state machine that we are now active
       
   258 	*/
       
   259 	virtual void DeviceActive() = 0;
       
   260 	
       
   261 	/**
       
   262 	Inform the PAN agent role state machine that the role upgrade failed
       
   263 	*/
       
   264 	virtual void RoleChangeFailed() = 0;
       
   265 	
       
   266 	/**
       
   267 	Inform the PAN agent role state machine that our shutdown is complete
       
   268 	*/
       
   269 	virtual void ShutdownComplete() = 0;
       
   270 	
       
   271 	/**
       
   272 	Call to initiate an outgoing PAN connection from the remote device state machine.
       
   273 	@param aLocalRole The local role will be decided by the PAN agent state machine logic.  
       
   274 	                  No value should be passed into this method call for this parameter.
       
   275 	                  When this method returns with KErrNone this value will contain the local role to connect to.
       
   276 	@param aRemoteRole The remote role will be decided by the PAN agent state machine logic.
       
   277 	                  No value should be passed into this method call for this parameter
       
   278 	                  When this method returns with KErrNone this value will contain the remote role to connect to.
       
   279 	@param aWorthTryingRemoteRoles This is a list of the remote PAN roles that are worth trying to connect to this device.
       
   280 	@return A system wide or PAN agnet specific error code indicating if the connection should continue
       
   281 	*/
       
   282 	virtual TInt InitiateOutgoingConnection(TBluetoothPanRole& aLocalRole, TBluetoothPanRole& aRemoteRole, TPanDeviceWorthTryingRolesList& aWorthTryingRemoteRoles) = 0;
       
   283 
       
   284 	/**
       
   285 	Call to initiate an outgoing role change with an existing remote device from the remote device state machine.
       
   286 	@param aLocalRole The local role will be decided by the PAN agent state machine logic.  
       
   287 	                  No value should be passed into this method call for this parameter.
       
   288 	                  When this method returns with KErrNone this value will contain the local role to connect to.
       
   289 	@param aRemoteRole The remote role will be decided by the PAN agent state machine logic.
       
   290 	                  No value should be passed into this method call for this parameter
       
   291 	                  When this method returns with KErrNone this value will contain the remote role to connect to.
       
   292 	@return A system wide or PAN agnet specific error code indicating if the role change procedure should continue
       
   293 	*/
       
   294 	virtual TInt PerformLocalRoleChangeRequest(TBluetoothPanRole& aLocalRole, TBluetoothPanRole& aRemoteRole) = 0;
       
   295 
       
   296 	/**
       
   297 	Called from the remote device state machine when it has received a role change request from the peer device.
       
   298 	@param aLocalRole The requested local role from the peer BNEP Setup Request.  
       
   299 	@param aRemoteRole The requested remote role from the peer BNEP Setup Request.  
       
   300 	@return A system wide or PAN agnet specific error code indicating if the role change procedure should continue.
       
   301 	*/
       
   302 	virtual TInt RoleChangeRequestFromPeer(TBluetoothPanRole aLocalRole, TBluetoothPanRole aRemoteRole) = 0;
       
   303 
       
   304 	/**
       
   305 	Called from the remote device state machine when it has received a incoming connection request from a peer device.
       
   306 	@param aLocalRole The requested local role from the peer BNEP Setup Request.  
       
   307 	@param aRemoteRole The requested remote role from the peer BNEP Setup Request.  
       
   308 	@return A system wide or PAN agnet specific error code indicating if the incoming connection request should be accepted.
       
   309 	*/
       
   310 	virtual TInt IncomingConnectionFromPeer(TBluetoothPanRole aLocalRole, TBluetoothPanRole aRemoteRole) = 0;
       
   311 	
       
   312 	/**
       
   313 	Send a role request to the remote device
       
   314 	@param aLocalRole The proposed local role
       
   315 	@param aRemoteRole The proposed remote role
       
   316 	*/
       
   317 	virtual void SendRoleRequest(TBluetoothPanRole aLocalRole, TBluetoothPanRole aRemoteRole) = 0;
       
   318 	
       
   319 	/**
       
   320 	Send a role reponse to the remote device
       
   321 	@param aRoleReponseCode A BNEP error code indicating the status of the request
       
   322 	*/
       
   323 	virtual void SendRoleResponse(TBnepSetupConnectionResponseMessage aRoleResponseCode) = 0;
       
   324 
       
   325 #ifdef SYMBIAN_NON_SEAMLESS_NETWORK_BEARER_MOBILITY
       
   326 	/**
       
   327 	Create a new BNEP channel
       
   328 	@param aConnectedSocket An L2CAP socket connected to the remote device
       
   329 	@param aActivity the activity to be used when sending the creation request to Bnep
       
   330 	*/
       
   331 	virtual void CreateNewBnepConnection(RInternalSocket& aConnectedSocket, TPanMessage::TPanActivity aActivity) = 0;
       
   332 
       
   333 #else
       
   334 	/**
       
   335 	Create a new BNEP channel
       
   336 	@param aConnectedSocket An L2CAP socket connected to the remote device
       
   337 	*/
       
   338 	virtual void CreateNewBnepConnectionL(RInternalSocket& aConnectedSocket) = 0;
       
   339 #endif
       
   340 
       
   341 	/**
       
   342 	Disconnect the BNEP channel.  This should disconnect the remote remote device if it is connected.
       
   343 	@note This is safe to call at any point - if there is no BNEP channel at the moment, the implementation should just do nothing
       
   344 	*/
       
   345 	virtual void DisconnectBnepChannel() = 0;
       
   346 
       
   347 	/**
       
   348 	Specify if uplink access is allowed for this remote device
       
   349 	*/
       
   350 	virtual void SetUplinkAccessAllowed(TBool aAllowed) = 0;
       
   351 
       
   352 	/**
       
   353 	Read if uplink access is allowed for this remote device
       
   354 	*/
       
   355 	virtual TBool UplinkAccessAllowed() const = 0;
       
   356 		
       
   357 	/**
       
   358 	Put the state machine into a new state
       
   359 	@param aState The new state
       
   360 	*/
       
   361 	virtual void SetState(CPanRemDevStateBase& aState) = 0;
       
   362 	
       
   363 	/**
       
   364 	Get a handle to physical link adapter
       
   365 	*/
       
   366 	virtual RBTPhysicalLinkAdapter& PhysicalLinkAdapter() = 0;
       
   367 	
       
   368 	/**
       
   369 	Initialise physical link adapter
       
   370 	*/
       
   371 	virtual void OpenPhysicalLinkAdapterL() = 0;
       
   372 
       
   373 	virtual void SetRetryConnect() = 0;
       
   374 
       
   375 	virtual TInt IncrementConnectionRetryAttempts() = 0;
       
   376 	virtual void ResetConnectionRetryAttempts() = 0;
       
   377 	
       
   378 	virtual void ResetRetryParameters() = 0;
       
   379 	virtual TBool WorthTrying() = 0;
       
   380 	
       
   381 	/**
       
   382 	Populate the PAN connection list provided as an argument
       
   383 	@param A reference to the PAN connection list contained that should be populated.
       
   384 	*/	
       
   385 	virtual void GetExistingConnections(TPanConnectionList& aPanConnectionList) = 0;
       
   386 	virtual void Shutdown(TInt aError) = 0;
       
   387 protected:
       
   388 	virtual ~MPanRemDevStateMachineNotify() {};
       
   389 	};
       
   390 	
       
   391 NONSHARABLE_CLASS(CPanRemoteDeviceStateMachine) :
       
   392     public CActive,
       
   393 #ifdef SYMBIAN_NON_SEAMLESS_NETWORK_BEARER_MOBILITY
       
   394     public Messages::ASimpleNodeIdBase,
       
   395 #endif
       
   396     private MPanConnectionNotify,
       
   397     private MPanRemDevStateMachineNotify
       
   398 /**
       
   399 Management of a connection to a remote device
       
   400 @note This has a 1-1 relationship with BNEP channels in the bnep packet driver
       
   401 @internalComponent
       
   402 */
       
   403 	{
       
   404 public:
       
   405 	static CPanRemoteDeviceStateMachine* NewL(RInternalSocket& aConnectedSocket, MRemoteDeviceNotify& aParent, CCommsDbAccess& aDatabase);
       
   406 	static CPanRemoteDeviceStateMachine* NewL(const TBTDevAddr& aRemDevAddr, MRemoteDeviceNotify& aParent, CCommsDbAccess& aDatabase);
       
   407 	~CPanRemoteDeviceStateMachine();
       
   408 
       
   409 	// MPanConnectionNotify methods	
       
   410 	virtual void BnepRoleRequestFromRemoteDevice(const TUUID& aRequestedLocalRole, const TUUID& aRequestedRemoteRole);
       
   411 	virtual void BnepRoleResponseFromRemoteDevice(TBnepSetupConnectionResponseMessage aRoleResponseCode);
       
   412 	virtual void RemoteDeviceDisconnect(TInt aError);
       
   413 
       
   414 #ifndef SYMBIAN_NON_SEAMLESS_NETWORK_BEARER_MOBILITY
       
   415 	virtual MPanLinkControlBase& BnepConnectionController();
       
   416 #endif
       
   417 
       
   418 	// Downcalls from pan agent state machine
       
   419 	void ReadyForRoleRequest();
       
   420 	void Disconnect();
       
   421 	TInt DisallowRoleSwitch();
       
   422 	TInt AllowRoleSwitch();
       
   423 	TBTDevAddr DevAddr() const;
       
   424 
       
   425 	// MPanAgtRemDevStateMachineNotify methods (upcalls from states)
       
   426 	virtual TBluetoothPanRole& LocalRole();
       
   427 	virtual TBluetoothPanRole& RemoteRole();
       
   428 	virtual RPanRemoteSdpQuerier& RemoteSdpQuerier();
       
   429 	virtual TPanDeviceRolesList& RemoteRolesList();
       
   430 	virtual TPanDeviceWorthTryingRolesList& RemoteWorthTryingRolesList();
       
   431 	virtual TBTSockAddr& RemSockAddr();	
       
   432 	virtual RInternalSocket& Socket();
       
   433 	virtual CCommsDbAccess& Database();
       
   434 	virtual TRequestStatus& Status();
       
   435 	virtual void SdpQueriesDisabled(TBool aSdpQueriesStatus);
       
   436 	virtual TBool IsSdpQueriesDisabled();
       
   437 	virtual TInt Error() const;
       
   438 	virtual TBool HasBnepChannel() const;
       
   439 	virtual void SetActive();
       
   440 	virtual void Cancel();
       
   441 	virtual void DeviceActive();
       
   442 	virtual void RoleChangeFailed();
       
   443 	virtual void ShutdownComplete();
       
   444 
       
   445 	virtual TInt InitiateOutgoingConnection(TBluetoothPanRole& aLocalRole, TBluetoothPanRole& aRemoteRole, TPanDeviceWorthTryingRolesList& aWorthTryingRemoteRoles);
       
   446 	virtual TInt PerformLocalRoleChangeRequest(TBluetoothPanRole& aLocalRole, TBluetoothPanRole& aRemoteRole);
       
   447 	virtual TInt RoleChangeRequestFromPeer(TBluetoothPanRole aLocalRole, TBluetoothPanRole aRemoteRole);
       
   448 	virtual TInt IncomingConnectionFromPeer(TBluetoothPanRole aLocalRole, TBluetoothPanRole aRemoteRole);
       
   449 
       
   450 	virtual void SendRoleRequest(TBluetoothPanRole aLocalRole, TBluetoothPanRole aRemoteRole);
       
   451 	virtual void SendRoleResponse(TBnepSetupConnectionResponseMessage aRoleResponseCode);
       
   452 
       
   453 #ifdef SYMBIAN_NON_SEAMLESS_NETWORK_BEARER_MOBILITY
       
   454 	virtual void CreateNewBnepConnection(RInternalSocket& aConnectedSocket, TPanMessage::TPanActivity aActivity);
       
   455 #else
       
   456 	virtual void CreateNewBnepConnectionL(RInternalSocket& aConnectedSocket);
       
   457 #endif
       
   458 
       
   459 	virtual void DisconnectBnepChannel();
       
   460 	virtual void SetUplinkAccessAllowed(TBool aAllowed);
       
   461 	virtual TBool UplinkAccessAllowed() const;
       
   462 	virtual void SetState(CPanRemDevStateBase& aState);
       
   463 	virtual RBTPhysicalLinkAdapter& PhysicalLinkAdapter();
       
   464 	virtual void OpenPhysicalLinkAdapterL();
       
   465 	virtual void SetRetryConnect();
       
   466 	virtual TInt IncrementConnectionRetryAttempts();
       
   467 	virtual void ResetConnectionRetryAttempts();
       
   468 	virtual void ResetRetryParameters();
       
   469 	virtual TBool WorthTrying();
       
   470 	
       
   471 	virtual TRemoteDeviceState GetState() const;
       
   472 
       
   473 	virtual TBool NewConnectedDeviceProgressSent() const;
       
   474 	virtual void SetNewConnectedDeviceProgressSent(TBool aNewConnectedDeviceProgressSent);
       
   475 
       
   476 	virtual void GetExistingConnections(TPanConnectionList& aPanConnectionList);
       
   477 	virtual void Shutdown(TInt aError);
       
   478 
       
   479 	// CActive methods
       
   480 	virtual void RunL();
       
   481 	virtual void DoCancel();
       
   482 	
       
   483 #ifdef SYMBIAN_NON_SEAMLESS_NETWORK_BEARER_MOBILITY
       
   484 protected:
       
   485     // From ESock::MCFNode, via ESock::ACFNodeIdBase
       
   486 	void ReceivedL(const Messages::TRuntimeCtxId& aSender, const Messages::TNodeId& aRecipient, Messages::TSignatureBase& aCFMessage);
       
   487 #endif
       
   488 
       
   489 private:
       
   490 	CPanRemoteDeviceStateMachine(MRemoteDeviceNotify& aParent, CCommsDbAccess& aDatabase);
       
   491 	void ConstructL(const TBTDevAddr& aRemDevAddr);
       
   492 	void ConstructL(RInternalSocket& aConnectedSocket);
       
   493 		
       
   494 public:
       
   495 
       
   496 private:
       
   497 	TBTSockAddr iRemSockAddr;  		//< needed for baseband role switching, and SDP queries
       
   498 	TBool iSdpQueriesDisabled;		//< Are SDP queries disabled by the settings in commdb?
       
   499 
       
   500 	TBluetoothPanRole iLocalRole;	//< the local role (or proposed local role) for this connection
       
   501 	TBluetoothPanRole iRemoteRole;	//< the remote role (or proposed remote role) for this connection
       
   502 	TPanDeviceRolesList iRemotePanRolesFromSdp; //< The roles that the remote device is advertising, discovered using SDP
       
   503 	TPanDeviceWorthTryingRolesList iRemoteWorthTryingRoles; // The roles that are worth trying with the remote device
       
   504 
       
   505 #ifdef SYMBIAN_NON_SEAMLESS_NETWORK_BEARER_MOBILITY									
       
   506 	Messages::TNodeId iBnepChannelController; 
       
   507 #else
       
   508 	MBnepChannelControl* iBnepChannelController; //< interface to channel in bnep packet driver
       
   509 #endif
       
   510 	
       
   511 	MRemoteDeviceNotify& iParent; 	//< The class to be notified when events occur
       
   512 	CCommsDbAccess& iDatabase;		//< Handle to commdb to allow us to read it (note that reading through this handle also takes account of an overrides that might be set)
       
   513 	
       
   514 	RInternalSocket iSocket;		//< Socket used for creating new outgoing connections, or as a quick place to stash the (connected) incoming socket whilst we set up the initial state
       
   515 									// also used later as the socket to communicate with the proxy SAP
       
   516 	TInt iError;					//< Somewhere to stash any error that occurs for access by shutdown state
       
   517 	
       
   518 	CPanRemDevStateBase* iState; 	//< Our current state
       
   519 	CPanRemDevStateBase* iShutdownState; //< Preallocate to ensure we can always shut down a connection
       
   520 
       
   521 	RPanRemoteSdpQuerier iRemoteSdpQuerier;	//< Remote SDP querier
       
   522 	RSocketServ iSockServ;
       
   523 	RBTPhysicalLinkAdapter iPhysicalLinkAdapter;
       
   524 	
       
   525 	TInt iConnectionRetryAttempts;
       
   526 	
       
   527 	TBool iUplinkAccessAllowed;				//< Indicates if the remote device is allowed access to the uplink
       
   528 	TBool iNewConnectedDeviceProgressSent;	//< Indicates if a new connected device notification has been sent from the agent to the RConnection client for this remote device
       
   529 	};
       
   530 	
       
   531 }	// PanAgent
       
   532 #endif // PANAGTREMDEV_H