655 /** |
654 /** |
656 Take this SAP off the mux, since once it's in error state we |
655 Take this SAP off the mux, since once it's in error state we |
657 don't want to get any more notifications from the mux |
656 don't want to get any more notifications from the mux |
658 **/ |
657 **/ |
659 { |
658 { |
|
659 // Depending where we came from we may have applied either a |
|
660 // park override or an all LPM override. We remove both these |
|
661 // overrides because it's safe to remove an override that |
|
662 // hasn't been applied. |
|
663 // Note that although park is one of the LPMs the different |
|
664 // levels of override are managed separately, so an |
|
665 // UndoOverrideLPM does not remove an explicit park only |
|
666 // override. |
|
667 aSAP.iProtocol.ControlPlane().ModifyPhysicalLink(EUndoOverridePark, aSAP.iRemoteDev); |
|
668 aSAP.iProtocol.ControlPlane().ModifyPhysicalLink(EUndoOverrideLPM, aSAP.iRemoteDev); |
660 |
669 |
661 aSAP.DeregisterCodService(); // See if there is a Service to remove for CodMan |
670 aSAP.DeregisterCodService(); // See if there is a Service to remove for CodMan |
662 |
671 |
663 if(aSAP.iMux) |
672 if(aSAP.iMux) |
664 { |
673 { |
692 { |
701 { |
693 aSAP.iNotifyNewDataCallback->Cancel(); |
702 aSAP.iNotifyNewDataCallback->Cancel(); |
694 } |
703 } |
695 aSAP.iNewDataToNotify=0; |
704 aSAP.iNewDataToNotify=0; |
696 aSAP.iDataBuffer.Reset(); |
705 aSAP.iDataBuffer.Reset(); |
|
706 |
|
707 // Depending where we came from we may have applied either a |
|
708 // park override or an all LPM override. We remove both these |
|
709 // overrides because it's safe to remove an override that |
|
710 // hasn't been applied. |
|
711 // Note that although park is one of the LPMs the different |
|
712 // levels of override are managed separately, so an |
|
713 // UndoOverrideLPM does not remove an explicit park only |
|
714 // override. |
697 aSAP.iProtocol.ControlPlane().ModifyPhysicalLink(EUndoOverridePark, aSAP.iRemoteDev); |
715 aSAP.iProtocol.ControlPlane().ModifyPhysicalLink(EUndoOverridePark, aSAP.iRemoteDev); |
|
716 aSAP.iProtocol.ControlPlane().ModifyPhysicalLink(EUndoOverrideLPM, aSAP.iRemoteDev); |
|
717 |
698 if(aSAP.iMux) |
718 if(aSAP.iMux) |
699 { |
719 { |
700 aSAP.iMux->DetachSAP(aSAP); |
720 aSAP.iMux->DetachSAP(aSAP); |
701 } |
721 } |
702 aSAP.DeregisterCodService(); // See if there is a Service to remove for CodMan |
722 aSAP.DeregisterCodService(); // See if there is a Service to remove for CodMan |
703 |
|
704 } |
723 } |
705 |
724 |
706 void TRfcommStateClosed::Error(CRfcommSAP& /*aSAP*/, TInt /*aErr*/, |
725 void TRfcommStateClosed::Error(CRfcommSAP& /*aSAP*/, TInt /*aErr*/, |
707 CRfcommSAP::TErrorTypes /*aType*/) |
726 CRfcommSAP::TErrorTypes /*aType*/) |
708 /** |
727 /** |
729 SignalError(aSAP, KErrRfcommBadAddress, MSocketNotify::EErrorConnect); |
748 SignalError(aSAP, KErrRfcommBadAddress, MSocketNotify::EErrorConnect); |
730 return; |
749 return; |
731 } |
750 } |
732 |
751 |
733 aSAP.RegisterCodService(); // See if there is a Service set for CodMan |
752 aSAP.RegisterCodService(); // See if there is a Service set for CodMan |
734 |
753 |
|
754 // Override LPM while we do some sigalling to ensure it can complete in |
|
755 // a timely fashion. |
|
756 aSAP.iProtocol.ControlPlane().ModifyPhysicalLink(EOverrideLPM, aSAP.iRemoteDev); |
|
757 |
735 // First get a Mux. |
758 // First get a Mux. |
736 ChangeState(aSAP, CRfcommStateFactory::EWaitForMux); |
759 ChangeState(aSAP, CRfcommStateFactory::EWaitForMux); |
737 } |
760 } |
738 |
761 |
739 TInt TRfcommStateClosed::PassiveOpen(CRfcommSAP& aSAP, |
762 TInt TRfcommStateClosed::PassiveOpen(CRfcommSAP& aSAP, |
1311 newSAP->iDLCI=aDLCI; |
1334 newSAP->iDLCI=aDLCI; |
1312 newSAP->iServerChannel=aMux.MakeServerChannel(aDLCI); |
1335 newSAP->iServerChannel=aMux.MakeServerChannel(aDLCI); |
1313 newSAP->iRemoteDev=aMux.RemoteBTAddr(); |
1336 newSAP->iRemoteDev=aMux.RemoteBTAddr(); |
1314 // Must come after registering the remote address with the new SAP because we will need |
1337 // Must come after registering the remote address with the new SAP because we will need |
1315 // the remote address to find a link in LinkMgrProtocol to override LPM on |
1338 // the remote address to find a link in LinkMgrProtocol to override LPM on |
1316 newSAP->iProtocol.ControlPlane().ModifyPhysicalLink(EOverrideLPMWithTimeout, newSAP->iRemoteDev); |
1339 newSAP->iProtocol.ControlPlane().ModifyPhysicalLink(EOverrideLPM, newSAP->iRemoteDev); |
1317 newSAP->iUserDefinedMTU=aSAP.iUserDefinedMTU; // We take our cues as |
1340 newSAP->iUserDefinedMTU=aSAP.iUserDefinedMTU; // We take our cues as |
1318 // regards max MTU from |
1341 // regards max MTU from |
1319 // the listening SAP. |
1342 // the listening SAP. |
1320 |
1343 |
1321 newSAP->iMux=&aMux; |
1344 newSAP->iMux=&aMux; |
1736 SignalError(aSAP, err, MSocketNotify::EErrorConnect); |
1759 SignalError(aSAP, err, MSocketNotify::EErrorConnect); |
1737 ChangeState(aSAP, CRfcommStateFactory::EClosed); |
1760 ChangeState(aSAP, CRfcommStateFactory::EClosed); |
1738 return; |
1761 return; |
1739 } |
1762 } |
1740 |
1763 |
|
1764 // Depending where we came from we may have applied either a |
|
1765 // park override or an all LPM override. We remove both these |
|
1766 // overrides because it's safe to remove an override that |
|
1767 // hasn't been applied. |
|
1768 // Note that although park is one of the LPMs the different |
|
1769 // levels of override are managed separately, so an |
|
1770 // UndoOverrideLPM does not remove an explicit park only |
|
1771 // override. |
1741 aSAP.iProtocol.ControlPlane().ModifyPhysicalLink(EUndoOverridePark, aSAP.iRemoteDev); |
1772 aSAP.iProtocol.ControlPlane().ModifyPhysicalLink(EUndoOverridePark, aSAP.iRemoteDev); |
|
1773 aSAP.iProtocol.ControlPlane().ModifyPhysicalLink(EUndoOverrideLPM, aSAP.iRemoteDev); |
|
1774 |
1742 aSAP.iSocket->ConnectComplete(); |
1775 aSAP.iSocket->ConnectComplete(); |
1743 aSAP.CTS(EFalse); // So that we block should anyone try to write |
1776 aSAP.CTS(EFalse); // So that we block should anyone try to write |
1744 // anything through this SAP before we get MSC |
1777 // anything through this SAP before we get MSC |
1745 // from remote side. |
1778 // from remote side. |
1746 aSAP.iReceivedMSC=EFalse; // Until we receive an MSC, we consider any |
1779 aSAP.iReceivedMSC=EFalse; // Until we receive an MSC, we consider any |
1777 void TRfcommStateOpen::Shutdown(CRfcommSAP& aSAP) |
1810 void TRfcommStateOpen::Shutdown(CRfcommSAP& aSAP) |
1778 /** |
1811 /** |
1779 Shutdown the open channel gracefully |
1812 Shutdown the open channel gracefully |
1780 **/ |
1813 **/ |
1781 { |
1814 { |
|
1815 // Only override park for disconnect. We need to be able |
|
1816 // to send the signalling, but we don't care if it takes |
|
1817 // ages. No point starting a sniff bun-fight. |
1782 aSAP.iProtocol.ControlPlane().ModifyPhysicalLink(EOverridePark, aSAP.iRemoteDev); |
1818 aSAP.iProtocol.ControlPlane().ModifyPhysicalLink(EOverridePark, aSAP.iRemoteDev); |
1783 aSAP.iClosePending=ETrue; |
1819 aSAP.iClosePending=ETrue; |
1784 ChangeState(aSAP, CRfcommStateFactory::EDisconnect); |
1820 ChangeState(aSAP, CRfcommStateFactory::EDisconnect); |
1785 } |
1821 } |
1786 |
1822 |
1794 { |
1830 { |
1795 // Send a DISC using the DLCI based overload which ensures that |
1831 // Send a DISC using the DLCI based overload which ensures that |
1796 // the queued DISC frame does not get deleted when the SAP gets |
1832 // the queued DISC frame does not get deleted when the SAP gets |
1797 // removed from the muxer |
1833 // removed from the muxer |
1798 __ASSERT_DEBUG(aSAP.iMux!=NULL,PanicInState(ERfcommNullMux)); |
1834 __ASSERT_DEBUG(aSAP.iMux!=NULL,PanicInState(ERfcommNullMux)); |
|
1835 |
|
1836 // Only override park for disconnect. We need to be able |
|
1837 // to send the signalling, but we don't care if it takes |
|
1838 // ages. No point starting a sniff bun-fight. |
1799 aSAP.iProtocol.ControlPlane().ModifyPhysicalLink(EOverridePark, aSAP.iRemoteDev); |
1839 aSAP.iProtocol.ControlPlane().ModifyPhysicalLink(EOverridePark, aSAP.iRemoteDev); |
1800 aSAP.iMux->SendDISC(aSAP.DLCI()); // Disassociated from the SAP |
1840 aSAP.iMux->SendDISC(aSAP.DLCI()); // Disassociated from the SAP |
1801 ChangeState(aSAP, CRfcommStateFactory::EClosed); |
1841 ChangeState(aSAP, CRfcommStateFactory::EClosed); |
1802 } |
1842 } |
1803 |
1843 |