284 |
284 |
285 void TL2CAPSigStateClosed::OpenChannel(CL2CapSAPSignalHandler& aSignalHandler) const |
285 void TL2CAPSigStateClosed::OpenChannel(CL2CapSAPSignalHandler& aSignalHandler) const |
286 { |
286 { |
287 LOG_FUNC |
287 LOG_FUNC |
288 // The SAP has requested a channel be opened. |
288 // The SAP has requested a channel be opened. |
|
289 // Override all LPMs to try and avoid signalling timeouts |
|
290 aSignalHandler.OverrideLPM(); |
289 |
291 |
290 TInt err = aSignalHandler.ChannelConfig().UpdateLocalConfigWithEntityCapabilities(); |
292 TInt err = aSignalHandler.ChannelConfig().UpdateLocalConfigWithEntityCapabilities(); |
291 if (err == KErrNone) |
293 if (err == KErrNone) |
292 { |
294 { |
293 // Get a free source CID for this channel to use. |
295 // Get a free source CID for this channel to use. |
296 if(err == KErrNone) |
298 if(err == KErrNone) |
297 { |
299 { |
298 // Update local Port. |
300 // Update local Port. |
299 aSignalHandler.SetLocalPort(port); |
301 aSignalHandler.SetLocalPort(port); |
300 |
302 |
301 // Override park to allow the connection to be made. |
|
302 aSignalHandler.OverrideParkMode(); |
|
303 |
|
304 // Active connection. Send a Connect Request command. |
303 // Active connection. Send a Connect Request command. |
305 err = aSignalHandler.ConstructConnectionRequest(); |
304 err = aSignalHandler.ConstructConnectionRequest(); |
306 if(err == KErrNone) |
305 if(err == KErrNone) |
307 { |
306 { |
308 aSignalHandler.SetState(iFactory.GetState(CL2CAPSignalStateFactory::EWaitConnectRsp)); |
307 aSignalHandler.SetState(iFactory.GetState(CL2CAPSignalStateFactory::EWaitConnectRsp)); |
328 if(err == KErrNone) |
327 if(err == KErrNone) |
329 { |
328 { |
330 // Update local Port. |
329 // Update local Port. |
331 aSignalHandler.SetLocalPort(port); |
330 aSignalHandler.SetLocalPort(port); |
332 |
331 |
333 // Override park to allow the connection to be made. |
332 // Override all LPMs to try and avoid signalling timeouts |
334 aSignalHandler.OverrideParkMode(); |
333 aSignalHandler.OverrideLPM(); |
335 // Override all LPMs (if timeout not set to zero) |
|
336 aSignalHandler.OverrideLPMWithTimeout(); |
|
337 |
334 |
338 // Send a response with a 'pending' result and start security procedure. |
335 // Send a response with a 'pending' result and start security procedure. |
339 err = aSignalHandler.ConstructConnectionResponse(aSignalHandler.GetOutstandingRequestID(), |
336 err = aSignalHandler.ConstructConnectionResponse(aSignalHandler.GetOutstandingRequestID(), |
340 EConnectPending, |
337 EConnectPending, |
341 EConnectPendAuthorization); |
338 EConnectPendAuthorization); |
382 // Cancel the configuration timer. |
379 // Cancel the configuration timer. |
383 aSignalHandler.CancelTimer(); |
380 aSignalHandler.CancelTimer(); |
384 |
381 |
385 aSignalHandler.iOpenChannelRequestAwaitingPeerEntityConfig = EFalse; |
382 aSignalHandler.iOpenChannelRequestAwaitingPeerEntityConfig = EFalse; |
386 |
383 |
387 // If Park mode has been overridden during either channel establishment or |
384 // Depending where we came from we may have applied either a |
388 // channel disconnect, remove the override. |
385 // park override or an all LPM override. We remove both these |
389 // NB It is safe to call this method multiple times. |
386 // overrides because it's safe to remove an override that |
|
387 // hasn't been applied. |
|
388 // Note that although park is one of the LPMs the different |
|
389 // levels of override are managed separately, so an |
|
390 // UndoOverrideLPM does not remove an explicit park only |
|
391 // override. |
390 aSignalHandler.UndoOverrideParkMode(); |
392 aSignalHandler.UndoOverrideParkMode(); |
|
393 aSignalHandler.UndoOverrideLPM(); |
391 |
394 |
392 // If the signal handler has left the closed state, it will have been added |
395 // If the signal handler has left the closed state, it will have been added |
393 // to the SH list in the Muxer. Now that the closed state is being |
396 // to the SH list in the Muxer. Now that the closed state is being |
394 // re-entered, remove the handler from the Muxer queue. |
397 // re-entered, remove the handler from the Muxer queue. |
395 // NB It is safe to call this method multiple times. |
398 // NB It is safe to call this method multiple times. |
896 |
899 |
897 // Change of state events |
900 // Change of state events |
898 void TL2CAPSigStateWaitConfig::Enter(CL2CapSAPSignalHandler& aSignalHandler) const |
901 void TL2CAPSigStateWaitConfig::Enter(CL2CapSAPSignalHandler& aSignalHandler) const |
899 { |
902 { |
900 LOG_FUNC |
903 LOG_FUNC |
|
904 // Cancel the Config timer if it's running |
|
905 aSignalHandler.CancelTimer(); |
|
906 |
901 // First start the ConfigReq sending delay timer (see DelayConfigRequest() for why). |
907 // First start the ConfigReq sending delay timer (see DelayConfigRequest() for why). |
902 // It's short lived, we'll start the proper L2CAP config timer when it expires. |
908 // It's short lived, we'll start the proper L2CAP config timer when it expires. |
903 aSignalHandler.StartConfigRequestDelayTimer(); |
909 aSignalHandler.StartConfigRequestDelayTimer(); |
904 } |
910 } |
905 |
911 |
1086 aSignalHandler.SetState(iFactory.GetState(CL2CAPSignalStateFactory::EWaitConfig)); |
1092 aSignalHandler.SetState(iFactory.GetState(CL2CAPSignalStateFactory::EWaitConfig)); |
1087 aSignalHandler.ConfigureChannel(); |
1093 aSignalHandler.ConfigureChannel(); |
1088 } |
1094 } |
1089 else |
1095 else |
1090 { |
1096 { |
1091 // Remove and park override. |
1097 // Depending where we came from we may have applied either a |
|
1098 // park override or an all LPM override. We remove both these |
|
1099 // overrides because it's safe to remove an override that |
|
1100 // hasn't been applied. |
|
1101 // Note that although park is one of the LPMs the different |
|
1102 // levels of override are managed separately, so an |
|
1103 // UndoOverrideLPM does not remove an explicit park only |
|
1104 // override. |
1092 aSignalHandler.UndoOverrideParkMode(); |
1105 aSignalHandler.UndoOverrideParkMode(); |
|
1106 aSignalHandler.UndoOverrideLPM(); |
1093 |
1107 |
1094 // Cancel the configuration timer. |
1108 // Cancel the configuration timer. |
1095 aSignalHandler.CancelTimer(); |
1109 aSignalHandler.CancelTimer(); |
1096 |
1110 |
1097 // Inform the SAP that the channel is now configured and ready to use. |
1111 // Inform the SAP that the channel is now configured and ready to use. |
1144 } |
1158 } |
1145 |
1159 |
1146 void TL2CAPSigStateWaitDisconnect::DisconnectResponse(CL2CapSAPSignalHandler& aSignalHandler) const |
1160 void TL2CAPSigStateWaitDisconnect::DisconnectResponse(CL2CapSAPSignalHandler& aSignalHandler) const |
1147 { |
1161 { |
1148 LOG_FUNC |
1162 LOG_FUNC |
1149 aSignalHandler.DrainPendingCommands(); |
1163 // We've got a disconnect response, we're done. Any remaing stuff on the queue |
1150 } |
1164 // is redundant, so ditch it and close synchronously. |
1151 |
1165 aSignalHandler.FlushAllQueues(); |
1152 // "Artificial" state events |
1166 |
1153 void TL2CAPSigStateWaitDisconnect::PendingCommandsDrained(CL2CapSAPSignalHandler& aSignalHandler) const |
|
1154 { |
|
1155 LOG_FUNC |
|
1156 // If an error condition has been recorded forward the error |
1167 // If an error condition has been recorded forward the error |
1157 // to the SAP. |
1168 // to the SAP. |
1158 if(aSignalHandler.SignalHandlerErrorCode() != KErrNone) |
1169 if(aSignalHandler.SignalHandlerErrorCode() != KErrNone) |
1159 { |
1170 { |
1160 Error(aSignalHandler, aSignalHandler.SignalHandlerErrorCode(), aSignalHandler.SignalHandlerErrorAction()); |
1171 Error(aSignalHandler, aSignalHandler.SignalHandlerErrorCode(), aSignalHandler.SignalHandlerErrorAction()); |
1163 { |
1174 { |
1164 // This will delete the signal handler if the SAP has detached. |
1175 // This will delete the signal handler if the SAP has detached. |
1165 aSignalHandler.SetState(iFactory.GetState(CL2CAPSignalStateFactory::EClosed)); |
1176 aSignalHandler.SetState(iFactory.GetState(CL2CAPSignalStateFactory::EClosed)); |
1166 aSignalHandler.SignalHandlerDisconnectedCanClose(); |
1177 aSignalHandler.SignalHandlerDisconnectedCanClose(); |
1167 } |
1178 } |
|
1179 |
|
1180 } |
|
1181 |
|
1182 // "Artificial" state events |
|
1183 void TL2CAPSigStateWaitDisconnect::PendingCommandsDrained(CL2CapSAPSignalHandler& aSignalHandler) const |
|
1184 { |
|
1185 LOG_FUNC |
|
1186 // If an error condition has been recorded forward the error |
|
1187 // to the SAP. |
|
1188 if(aSignalHandler.SignalHandlerErrorCode() != KErrNone) |
|
1189 { |
|
1190 Error(aSignalHandler, aSignalHandler.SignalHandlerErrorCode(), aSignalHandler.SignalHandlerErrorAction()); |
|
1191 } |
|
1192 else |
|
1193 { |
|
1194 // This will delete the signal handler if the SAP has detached. |
|
1195 aSignalHandler.SetState(iFactory.GetState(CL2CAPSignalStateFactory::EClosed)); |
|
1196 aSignalHandler.SignalHandlerDisconnectedCanClose(); |
|
1197 } |
1168 } |
1198 } |
1169 |
1199 |
1170 void TL2CAPSigStateWaitDisconnect::Enter(CL2CapSAPSignalHandler& aSignalHandler) const |
1200 void TL2CAPSigStateWaitDisconnect::Enter(CL2CapSAPSignalHandler& aSignalHandler) const |
1171 { |
1201 { |
1172 LOG_FUNC |
1202 LOG_FUNC |
1173 // Override park to allow the disconnect to continue. |
1203 // Only override park for disconnect. We need to be able |
|
1204 // to send the signalling, but we don't care if it takes |
|
1205 // ages. No point starting a sniff bun-fight. |
1174 aSignalHandler.OverrideParkMode(); |
1206 aSignalHandler.OverrideParkMode(); |
1175 |
1207 |
1176 // Cancel the configuration timer. |
1208 // Cancel the configuration timer. |
1177 aSignalHandler.CancelTimer(); |
1209 aSignalHandler.CancelTimer(); |
1178 } |
1210 } |