bluetoothcommsprofiles/btpan/panagt/panagtstates.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 PANAGTSTATES_H
       
    17 #define PANAGTSTATES_H
       
    18 
       
    19 /**
       
    20 @file
       
    21 @note PAN agent role state machine state definitions
       
    22 */
       
    23 
       
    24 #include "panagt.h"
       
    25 #include "panroles.h"
       
    26 
       
    27 namespace PanAgent
       
    28 /**
       
    29 @internalComponent
       
    30 @released
       
    31 @since v8.1
       
    32 */
       
    33 {
       
    34 
       
    35 NONSHARABLE_CLASS(CPanAgtStateUninitialised) : public CPanAgtStateBase
       
    36 /**
       
    37 @internalComponent
       
    38 */
       
    39 	{
       
    40 public:
       
    41 	static CPanAgtStateBase* NewL(MPanAgtStateMachineNotify& aStateMachine);
       
    42 	void OnEntryL();
       
    43 
       
    44 private:
       
    45 	CPanAgtStateUninitialised(MPanAgtStateMachineNotify& aStateMachine);
       
    46 	};
       
    47 
       
    48 NONSHARABLE_CLASS(CPanAgentStateInitialising) : public CPanAgtStateBase
       
    49 /**
       
    50 Bootstrap the connection - create the incoming and outgoing connection starter objects as required
       
    51 @note Outgoing connections must be started here, as opposed to the idle state, to allow transitions
       
    52 back to the idle state without triggering more outgoing connections
       
    53 @internalComponent
       
    54 */
       
    55 	{
       
    56 public:
       
    57 	static CPanAgtStateBase* NewL(MPanAgtStateMachineNotify& aStateMachine);
       
    58 	void OnEntryL();
       
    59 
       
    60 protected:
       
    61 	void DoStartOutgoingL();
       
    62 private:
       
    63 	CPanAgentStateInitialising(MPanAgtStateMachineNotify& aStateMachine);
       
    64 	};
       
    65 	
       
    66 NONSHARABLE_CLASS(CPanAgtStateIdle) : public CPanAgtStateBase
       
    67 /**
       
    68 Idle state - waiting for role request from someone (either local or remote device(s))
       
    69 @internalComponent
       
    70 */
       
    71 	{
       
    72 public:
       
    73 	static CPanAgtStateBase* NewL(MPanAgtStateMachineNotify& aStateMachine);
       
    74 	void OnEntryL();
       
    75 
       
    76 	// MRemoteDeviceNotify methods
       
    77 	virtual void InitiateOutgoingConnectionL(TBluetoothPanRole& aLocalRole, TBluetoothPanRole& aRemoteRole, TPanDeviceWorthTryingRolesList& aWorthTryingRemoteRoles);
       
    78 	virtual void IncomingConnectionFromPeerL(TBluetoothPanRole aLocalRole);
       
    79 
       
    80 	virtual void DeviceDisconnectedL(CPanRemoteDeviceStateMachine& aDevice);
       
    81 	
       
    82 private:
       
    83 	CPanAgtStateIdle(MPanAgtStateMachineNotify& aStateMachine);
       
    84 public:
       
    85 
       
    86 private:
       
    87 
       
    88 	};
       
    89 	
       
    90 NONSHARABLE_CLASS(CPanAgtStateNegotiatingURole) : public CPanAgtStateBase
       
    91 /**
       
    92 Attempting to switch to U role
       
    93 @internalComponent
       
    94 */
       
    95 	{
       
    96 public:
       
    97 	static CPanAgtStateBase* NewL(MPanAgtStateMachineNotify& aStateMachine);
       
    98 	void OnEntryL();
       
    99 
       
   100 	// MRemoteDeviceNotify methods
       
   101 	virtual void InitiateOutgoingConnectionL(TBluetoothPanRole& aLocalRole, TBluetoothPanRole& aRemoteRole, TPanDeviceWorthTryingRolesList& aWorthTryingRemoteRoles);
       
   102 	virtual void IncomingConnectionFromPeerL(TBluetoothPanRole aLocalRole);
       
   103 
       
   104 	virtual void DeviceActiveL(CPanRemoteDeviceStateMachine& aDevice);
       
   105 	virtual void DeviceDisconnectedL(CPanRemoteDeviceStateMachine& aDevice);
       
   106 	
       
   107 protected:
       
   108 	CPanAgtStateNegotiatingURole(MPanAgtStateMachineNotify& aStateMachine, TPanAgtStates aStateNumber);
       
   109 
       
   110 private:
       
   111 	CPanAgtStateNegotiatingURole(MPanAgtStateMachineNotify& aStateMachine);
       
   112 public:
       
   113 
       
   114 private:
       
   115 	};
       
   116 	
       
   117 NONSHARABLE_CLASS(CPanAgtStateURole) : public CPanAgtStateBase
       
   118 /**
       
   119 Outgoing U role
       
   120 @internalComponent
       
   121 */
       
   122 	{
       
   123 public:
       
   124 	static CPanAgtStateBase* NewL(MPanAgtStateMachineNotify& aStateMachine);
       
   125 	void OnEntryL();
       
   126 
       
   127 	// MRemoteDeviceNotify methods
       
   128 	virtual void InitiateOutgoingConnectionL(TBluetoothPanRole& aLocalRole, TBluetoothPanRole& aRemoteRole, TPanDeviceWorthTryingRolesList& aWorthTryingRemoteRoles);
       
   129 	virtual void IncomingConnectionFromPeerL(TBluetoothPanRole aLocalRole);
       
   130 	virtual void RoleChangeRequestFromPeerL(TBluetoothPanRole aLocalRole);
       
   131 
       
   132 	virtual void DeviceActiveL(CPanRemoteDeviceStateMachine& aDevice);
       
   133 	virtual void DeviceDisconnectedL(CPanRemoteDeviceStateMachine& aDevice);
       
   134 
       
   135 	virtual void StateSendRoleNotification();
       
   136 
       
   137 private:
       
   138 	CPanAgtStateURole(MPanAgtStateMachineNotify& aStateMachine);
       
   139 public:
       
   140 
       
   141 private:
       
   142 
       
   143 	};
       
   144 
       
   145 NONSHARABLE_CLASS(CPanAgtStateRenegotiatingActiveConnectionToGnOrNapRoleAtOurBehest) : public CPanAgtStateBase
       
   146 /**
       
   147 We want to act in the GN/NAP role, so renegotiate with the active device (of which there can only
       
   148 be one)
       
   149 @pre We were in U mode, and we decided we needed to go to GN/NAP (if the other end decides to request 
       
   150 a role change, we handle it differently)
       
   151 @note This occurs when a new device connects to us and we need to upgrade our role
       
   152 @note Don't need to do any SDP U role deregistration in this state - there's an active device,
       
   153 so we'll have already deregistered U role from SDP
       
   154 @internalComponent
       
   155 */
       
   156 	{
       
   157 public:
       
   158 	static CPanAgtStateBase* NewL(MPanAgtStateMachineNotify& aStateMachine);
       
   159 	void OnEntryL();
       
   160 
       
   161 	// MRemoteDeviceNotify methods
       
   162 	virtual void InitiateOutgoingConnectionL(TBluetoothPanRole& aLocalRole, TBluetoothPanRole& aRemoteRole, TPanDeviceWorthTryingRolesList& aWorthTryingRemoteRoles);
       
   163 	virtual void IncomingConnectionFromPeerL(TBluetoothPanRole aLocalRole);
       
   164 	virtual void RoleChangeRequestFromPeerL(TBluetoothPanRole aLocalRole);
       
   165 	virtual void PerformLocalRoleChangeRequestL(TBluetoothPanRole& aLocalRole, TBluetoothPanRole& aRemoteRole);
       
   166 
       
   167 	virtual void DeviceActiveL(CPanRemoteDeviceStateMachine& aDevice);
       
   168 	virtual void DeviceRoleChangeFailedL(CPanRemoteDeviceStateMachine& aDevice);
       
   169 	virtual void DeviceDisconnectedL(CPanRemoteDeviceStateMachine& aDevice);
       
   170 
       
   171 private:
       
   172 	CPanRemoteDeviceStateMachine& FindDeviceInActiveState();
       
   173 	CPanAgtStateRenegotiatingActiveConnectionToGnOrNapRoleAtOurBehest(MPanAgtStateMachineNotify& aStateMachine);
       
   174 public:
       
   175 
       
   176 private:
       
   177 
       
   178 	};
       
   179 	
       
   180 NONSHARABLE_CLASS(CPanAgtStateRenegotiatingActiveConnectionToURoleAtPeersBehest) : public CPanAgtStateBase
       
   181 /**
       
   182 The remote device is asking us to move to U role
       
   183 @note Don't need to do any SDP U role deregistration in this state - there's an active device,
       
   184 so we'll have already deregistered U role from SDP
       
   185 @note There might well be a transition from U role state -> this -> U role state. This can be 
       
   186 caused by the peer trying to do a U-U -> U-GN/NAP upgrade (ie. we remain U throughout)
       
   187 */
       
   188 	{
       
   189 public:
       
   190 	static CPanAgtStateBase* NewL(MPanAgtStateMachineNotify& aStateMachine);
       
   191 	void OnEntryL();
       
   192 
       
   193 	// MRemoteDeviceNotify methods
       
   194 	virtual void InitiateOutgoingConnectionL(TBluetoothPanRole& aLocalRole, TBluetoothPanRole& aRemoteRole, TPanDeviceWorthTryingRolesList& aWorthTryingRemoteRoles);
       
   195 	virtual void IncomingConnectionFromPeerL(TBluetoothPanRole aLocalRole);
       
   196 
       
   197 	virtual void DeviceActiveL(CPanRemoteDeviceStateMachine& aDevice);
       
   198 	virtual void DeviceRoleChangeFailedL(CPanRemoteDeviceStateMachine& aDevice);
       
   199 	virtual void DeviceDisconnectedL(CPanRemoteDeviceStateMachine& aDevice);
       
   200 
       
   201 private:
       
   202 	CPanAgtStateRenegotiatingActiveConnectionToURoleAtPeersBehest(MPanAgtStateMachineNotify& aStateMachine);
       
   203 public:
       
   204 
       
   205 private:
       
   206 	
       
   207 	};
       
   208 
       
   209 NONSHARABLE_CLASS(CPanAgtStateRenegotiatingActiveConnectionToGnOrNapRoleAtPeersBehest) : public CPanAgtStateBase
       
   210 /**
       
   211 The remote device is asking us to move to GN/NAP role
       
   212 @note Don't need to do any SDP U role deregistration in this state - there's an active device,
       
   213 so we'll have already deregistered U role from SDP
       
   214 */
       
   215 	{
       
   216 public:
       
   217 	static CPanAgtStateBase* NewL(MPanAgtStateMachineNotify& aStateMachine);
       
   218 	void OnEntryL();
       
   219 
       
   220 	// MRemoteDeviceNotify methods
       
   221 	virtual void InitiateOutgoingConnectionL(TBluetoothPanRole& aLocalRole, TBluetoothPanRole& aRemoteRole, TPanDeviceWorthTryingRolesList& aWorthTryingRemoteRoles);
       
   222 	virtual void IncomingConnectionFromPeerL(TBluetoothPanRole aLocalRole);
       
   223 
       
   224 	virtual void DeviceActiveL(CPanRemoteDeviceStateMachine& aDevice);
       
   225 	virtual void DeviceRoleChangeFailedL(CPanRemoteDeviceStateMachine& aDevice);
       
   226 	virtual void DeviceDisconnectedL(CPanRemoteDeviceStateMachine& aDevice);
       
   227 
       
   228 private:
       
   229 	CPanAgtStateRenegotiatingActiveConnectionToGnOrNapRoleAtPeersBehest(MPanAgtStateMachineNotify& aStateMachine);
       
   230 public:
       
   231 
       
   232 private:
       
   233 	
       
   234 	};
       
   235 
       
   236 	
       
   237 NONSHARABLE_CLASS(CPanAgtStateNegotiatingGnOrNapRole) : public CPanAgtStateBase
       
   238 /**
       
   239 Attempting to switch to GN/NAP role
       
   240 @internalComponent
       
   241 */
       
   242 	{
       
   243 public:
       
   244 	static CPanAgtStateBase* NewL(MPanAgtStateMachineNotify& aStateMachine);
       
   245 	void OnEntryL();
       
   246 	
       
   247 	// MRemoteDeviceNotify methods
       
   248 	virtual void InitiateOutgoingConnectionL(TBluetoothPanRole& aLocalRole, TBluetoothPanRole& aRemoteRole, TPanDeviceWorthTryingRolesList& aWorthTryingRemoteRoles);
       
   249 	virtual void IncomingConnectionFromPeerL(TBluetoothPanRole aLocalRole);
       
   250 
       
   251 	virtual void DeviceActiveL(CPanRemoteDeviceStateMachine& aDevice);
       
   252 	virtual void DeviceRoleChangeFailedL(CPanRemoteDeviceStateMachine& aDevice);
       
   253 	virtual void DeviceDisconnectedL(CPanRemoteDeviceStateMachine& aDevice);
       
   254 
       
   255 protected:
       
   256 	CPanAgtStateNegotiatingGnOrNapRole(MPanAgtStateMachineNotify& aStateMachine, TPanAgtStates aStateNumber);
       
   257 	
       
   258 private:
       
   259 	CPanAgtStateNegotiatingGnOrNapRole(MPanAgtStateMachineNotify& aStateMachine);
       
   260 public:
       
   261 
       
   262 private:
       
   263 
       
   264 	};
       
   265 
       
   266 NONSHARABLE_CLASS(CPanAgtStateGnOrNapRole) : public CPanAgtStateBase
       
   267 /**
       
   268 GN/NAP role
       
   269 @internalComponent
       
   270 */
       
   271 	{
       
   272 public:
       
   273 	static CPanAgtStateBase* NewL(MPanAgtStateMachineNotify& aStateMachine);
       
   274 	void OnEntryL();
       
   275 	
       
   276 	// MRemoteDeviceNotify methods
       
   277 	virtual void InitiateOutgoingConnectionL(TBluetoothPanRole& aLocalRole, TBluetoothPanRole& aRemoteRole, TPanDeviceWorthTryingRolesList& aWorthTryingRemoteRoles);
       
   278 	virtual void IncomingConnectionFromPeerL(TBluetoothPanRole aLocalRole);
       
   279 	virtual void RoleChangeRequestFromPeerL(TBluetoothPanRole aLocalRole);
       
   280 
       
   281 	virtual void DeviceActiveL(CPanRemoteDeviceStateMachine& aDevice);
       
   282 	virtual void DeviceDisconnectedL(CPanRemoteDeviceStateMachine& aDevice);
       
   283 
       
   284 	virtual void StateSendRoleNotification();
       
   285 
       
   286 private:
       
   287 	CPanAgtStateGnOrNapRole(MPanAgtStateMachineNotify& aStateMachine);	
       
   288 public:
       
   289 
       
   290 private:
       
   291 
       
   292 	};
       
   293 		
       
   294 NONSHARABLE_CLASS(CPanAgtStateShutdown) : public CPanAgtStateBase
       
   295 /**
       
   296 Shutting down the whole PAN - disconnect everyone and give up
       
   297 @note This class should only be created by the role state machine at startup. Shutdown should be performed
       
   298 through the state machine using the preallocated class - this allows shutdown in OOM situations.
       
   299 @note This class will always be entered from nifman calling Disconnect().  We can trigger this
       
   300 from the role state machine (SM only, not the states) - states leave to trigger a disconnect.
       
   301 @internalComponent
       
   302 */
       
   303 	{
       
   304 public:
       
   305 	static CPanAgtStateBase* NewL(MPanAgtStateMachineNotify& aStateMachine);
       
   306 	void OnEntryL();
       
   307 	
       
   308 	// MRemoteDeviceNotify methods
       
   309 	virtual void DeviceDisconnectedL(CPanRemoteDeviceStateMachine& aDevice);
       
   310 	~CPanAgtStateShutdown();
       
   311 private:
       
   312 	void ConstructL();
       
   313 	CPanAgtStateShutdown(MPanAgtStateMachineNotify& aStateMachine);
       
   314 
       
   315 	static TInt ShutdownCallback(TAny* aPtr);
       
   316 
       
   317 public:
       
   318 
       
   319 private:
       
   320 	CAsyncCallBack* iShutdownCallback;
       
   321 
       
   322 	};
       
   323 
       
   324 NONSHARABLE_CLASS(CPanAgtStateReconnect) : public CPanAgtStateBase
       
   325 /**
       
   326 Reconnect, a transient state
       
   327 @internalComponent
       
   328 */
       
   329 	{
       
   330 public:
       
   331 	static CPanAgtStateBase* NewL(MPanAgtStateMachineNotify& aStateMachine);
       
   332 	void OnEntryL();
       
   333 	
       
   334 	void DeviceDisconnectedL(CPanRemoteDeviceStateMachine& aDevice);
       
   335 	void Connect();
       
   336 	void CancelReconnect();
       
   337 	~CPanAgtStateReconnect();
       
   338 private:
       
   339 	void ConstructL();
       
   340 	CPanAgtStateReconnect(MPanAgtStateMachineNotify& aStateMachine);
       
   341 	static TInt ServiceStartedCb(TAny* aThisPtr);
       
   342 	static TInt ReconnectCompleteCb(TAny* aThisPtr);
       
   343 	void ServiceStarted();
       
   344 private:
       
   345 	CAsyncCallBack* iReconnectCompleteCallback;
       
   346 	};
       
   347 
       
   348 
       
   349 #ifdef SYMBIAN_NON_SEAMLESS_NETWORK_BEARER_MOBILITY
       
   350 /**
       
   351 This state exists to pause the agent state machine whilst
       
   352 we wait for an async response from BNEP
       
   353 */
       
   354 NONSHARABLE_CLASS(CPanAgtStatePaused) : public CPanAgtStateBase
       
   355     {
       
   356 public:
       
   357     static CPanAgtStatePaused* NewL(MPanAgtStateMachineNotify& aStateMachine, CPanAgtStateBase& aNextState);
       
   358     ~CPanAgtStatePaused();
       
   359 
       
   360 	virtual void OnEntryL();
       
   361 	void TransitionToNextState();
       
   362     
       
   363 private:
       
   364     CPanAgtStatePaused(MPanAgtStateMachineNotify& aStateMachine, CPanAgtStateBase& aNextState);
       
   365     CPanAgtStateBase* iNextState; 
       
   366     };
       
   367 
       
   368 #endif
       
   369 // SYMBIAN_NON_SEAMLESS_NETWORK_BEARER_MOBILITY
       
   370 
       
   371 } // namespace PanAgent
       
   372 
       
   373 #endif
       
   374 // PANAGTSTATES_H