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(); |
|
291 |
289 |
292 TInt err = aSignalHandler.ChannelConfig().UpdateLocalConfigWithEntityCapabilities(); |
290 TInt err = aSignalHandler.ChannelConfig().UpdateLocalConfigWithEntityCapabilities(); |
293 if (err == KErrNone) |
291 if (err == KErrNone) |
294 { |
292 { |
295 // Get a free source CID for this channel to use. |
293 // Get a free source CID for this channel to use. |
298 if(err == KErrNone) |
296 if(err == KErrNone) |
299 { |
297 { |
300 // Update local Port. |
298 // Update local Port. |
301 aSignalHandler.SetLocalPort(port); |
299 aSignalHandler.SetLocalPort(port); |
302 |
300 |
|
301 // Override park to allow the connection to be made. |
|
302 aSignalHandler.OverrideParkMode(); |
|
303 |
303 // Active connection. Send a Connect Request command. |
304 // Active connection. Send a Connect Request command. |
304 err = aSignalHandler.ConstructConnectionRequest(); |
305 err = aSignalHandler.ConstructConnectionRequest(); |
305 if(err == KErrNone) |
306 if(err == KErrNone) |
306 { |
307 { |
307 aSignalHandler.SetState(iFactory.GetState(CL2CAPSignalStateFactory::EWaitConnectRsp)); |
308 aSignalHandler.SetState(iFactory.GetState(CL2CAPSignalStateFactory::EWaitConnectRsp)); |
327 if(err == KErrNone) |
328 if(err == KErrNone) |
328 { |
329 { |
329 // Update local Port. |
330 // Update local Port. |
330 aSignalHandler.SetLocalPort(port); |
331 aSignalHandler.SetLocalPort(port); |
331 |
332 |
332 // Override all LPMs to try and avoid signalling timeouts |
333 // Override park to allow the connection to be made. |
333 aSignalHandler.OverrideLPM(); |
334 aSignalHandler.OverrideParkMode(); |
|
335 // Override all LPMs (if timeout not set to zero) |
|
336 aSignalHandler.OverrideLPMWithTimeout(); |
334 |
337 |
335 // Send a response with a 'pending' result and start security procedure. |
338 // Send a response with a 'pending' result and start security procedure. |
336 err = aSignalHandler.ConstructConnectionResponse(aSignalHandler.GetOutstandingRequestID(), |
339 err = aSignalHandler.ConstructConnectionResponse(aSignalHandler.GetOutstandingRequestID(), |
337 EConnectPending, |
340 EConnectPending, |
338 EConnectPendAuthorization); |
341 EConnectPendAuthorization); |
379 // Cancel the configuration timer. |
382 // Cancel the configuration timer. |
380 aSignalHandler.CancelTimer(); |
383 aSignalHandler.CancelTimer(); |
381 |
384 |
382 aSignalHandler.iOpenChannelRequestAwaitingPeerEntityConfig = EFalse; |
385 aSignalHandler.iOpenChannelRequestAwaitingPeerEntityConfig = EFalse; |
383 |
386 |
384 // Depending where we came from we may have applied either a |
387 // If Park mode has been overridden during either channel establishment or |
385 // park override or an all LPM override. We remove both these |
388 // channel disconnect, remove the override. |
386 // overrides because it's safe to remove an override that |
389 // NB It is safe to call this method multiple times. |
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. |
|
392 aSignalHandler.UndoOverrideParkMode(); |
390 aSignalHandler.UndoOverrideParkMode(); |
393 aSignalHandler.UndoOverrideLPM(); |
|
394 |
391 |
395 // If the signal handler has left the closed state, it will have been added |
392 // If the signal handler has left the closed state, it will have been added |
396 // to the SH list in the Muxer. Now that the closed state is being |
393 // to the SH list in the Muxer. Now that the closed state is being |
397 // re-entered, remove the handler from the Muxer queue. |
394 // re-entered, remove the handler from the Muxer queue. |
398 // NB It is safe to call this method multiple times. |
395 // NB It is safe to call this method multiple times. |
1092 aSignalHandler.SetState(iFactory.GetState(CL2CAPSignalStateFactory::EWaitConfig)); |
1089 aSignalHandler.SetState(iFactory.GetState(CL2CAPSignalStateFactory::EWaitConfig)); |
1093 aSignalHandler.ConfigureChannel(); |
1090 aSignalHandler.ConfigureChannel(); |
1094 } |
1091 } |
1095 else |
1092 else |
1096 { |
1093 { |
1097 // Depending where we came from we may have applied either a |
1094 // Remove and park override. |
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. |
|
1105 aSignalHandler.UndoOverrideParkMode(); |
1095 aSignalHandler.UndoOverrideParkMode(); |
1106 aSignalHandler.UndoOverrideLPM(); |
|
1107 |
1096 |
1108 // Cancel the configuration timer. |
1097 // Cancel the configuration timer. |
1109 aSignalHandler.CancelTimer(); |
1098 aSignalHandler.CancelTimer(); |
1110 |
1099 |
1111 // Inform the SAP that the channel is now configured and ready to use. |
1100 // Inform the SAP that the channel is now configured and ready to use. |
1158 } |
1147 } |
1159 |
1148 |
1160 void TL2CAPSigStateWaitDisconnect::DisconnectResponse(CL2CapSAPSignalHandler& aSignalHandler) const |
1149 void TL2CAPSigStateWaitDisconnect::DisconnectResponse(CL2CapSAPSignalHandler& aSignalHandler) const |
1161 { |
1150 { |
1162 LOG_FUNC |
1151 LOG_FUNC |
1163 // We've got a disconnect response, we're done. Any remaing stuff on the queue |
1152 aSignalHandler.DrainPendingCommands(); |
1164 // is redundant, so ditch it and close synchronously. |
1153 } |
1165 aSignalHandler.FlushAllQueues(); |
1154 |
1166 |
1155 // "Artificial" state events |
|
1156 void TL2CAPSigStateWaitDisconnect::PendingCommandsDrained(CL2CapSAPSignalHandler& aSignalHandler) const |
|
1157 { |
|
1158 LOG_FUNC |
1167 // If an error condition has been recorded forward the error |
1159 // If an error condition has been recorded forward the error |
1168 // to the SAP. |
1160 // to the SAP. |
1169 if(aSignalHandler.SignalHandlerErrorCode() != KErrNone) |
1161 if(aSignalHandler.SignalHandlerErrorCode() != KErrNone) |
1170 { |
1162 { |
1171 Error(aSignalHandler, aSignalHandler.SignalHandlerErrorCode(), aSignalHandler.SignalHandlerErrorAction()); |
1163 Error(aSignalHandler, aSignalHandler.SignalHandlerErrorCode(), aSignalHandler.SignalHandlerErrorAction()); |
1174 { |
1166 { |
1175 // This will delete the signal handler if the SAP has detached. |
1167 // This will delete the signal handler if the SAP has detached. |
1176 aSignalHandler.SetState(iFactory.GetState(CL2CAPSignalStateFactory::EClosed)); |
1168 aSignalHandler.SetState(iFactory.GetState(CL2CAPSignalStateFactory::EClosed)); |
1177 aSignalHandler.SignalHandlerDisconnectedCanClose(); |
1169 aSignalHandler.SignalHandlerDisconnectedCanClose(); |
1178 } |
1170 } |
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 } |
|
1198 } |
1171 } |
1199 |
1172 |
1200 void TL2CAPSigStateWaitDisconnect::Enter(CL2CapSAPSignalHandler& aSignalHandler) const |
1173 void TL2CAPSigStateWaitDisconnect::Enter(CL2CapSAPSignalHandler& aSignalHandler) const |
1201 { |
1174 { |
1202 LOG_FUNC |
1175 LOG_FUNC |
1203 // Only override park for disconnect. We need to be able |
1176 // Override park to allow the disconnect to continue. |
1204 // to send the signalling, but we don't care if it takes |
|
1205 // ages. No point starting a sniff bun-fight. |
|
1206 aSignalHandler.OverrideParkMode(); |
1177 aSignalHandler.OverrideParkMode(); |
1207 |
1178 |
1208 // Cancel the configuration timer. |
1179 // Cancel the configuration timer. |
1209 aSignalHandler.CancelTimer(); |
1180 aSignalHandler.CancelTimer(); |
1210 } |
1181 } |