158 } |
158 } |
159 |
159 |
160 |
160 |
161 // This needs to be a macro or the 'return' won't return properly |
161 // This needs to be a macro or the 'return' won't return properly |
162 #define CLOSE_RETURN_IF_ERROR(error) if (error) { LinkDown(); SCOSocket().Close(); ESCOSocket().Close(); return error; } |
162 #define CLOSE_RETURN_IF_ERROR(error) if (error) { LinkDown(); SCOSocket().Close(); ESCOSocket().Close(); return error; } |
163 #define CLOSE_LISTENER_RETURN_IF_ERROR(error) if (error) { ListeningSCOSocket().Close(); ListeningESCOSocket().Close(); return error; } |
|
164 |
163 |
165 EXPORT_C TInt CBluetoothSynchronousLink::SetupConnection(const TBTDevAddr& aBDAddr, const TBTSyncPackets& aPacketTypes) |
164 EXPORT_C TInt CBluetoothSynchronousLink::SetupConnection(const TBTDevAddr& aBDAddr, const TBTSyncPackets& aPacketTypes) |
166 { |
165 { |
167 TBool openSCO = EFalse; |
166 TBool openSCO = EFalse; |
168 TBool openESCO = EFalse; |
167 TBool openESCO = EFalse; |
189 |
188 |
190 TBTSyncPacketTypes packetsESCO = packets & TBTSyncPackets::ESyncAnyESCOPacket; |
189 TBTSyncPacketTypes packetsESCO = packets & TBTSyncPackets::ESyncAnyESCOPacket; |
191 if (packetsESCO) |
190 if (packetsESCO) |
192 { |
191 { |
193 iSCOTypes |= EeSCO; |
192 iSCOTypes |= EeSCO; |
194 openESCO = ETrue; |
193 openESCO = ETrue; |
195 } |
194 } |
196 |
195 |
197 // but must be one |
196 // but must be one |
198 __ASSERT_ALWAYS(packetsSCO || packetsESCO, Panic(EBadSyncPacketTypes)); |
197 __ASSERT_ALWAYS(packetsSCO || packetsESCO, Panic(EBadSyncPacketTypes)); |
199 |
198 |
200 if (iBTSynchronousLinkAttacherSCO->IsActive()) |
199 if (iBTSynchronousLinkAttacherSCO->IsActive() || iBTSynchronousLinkAttacherESCO->IsActive()) |
201 { |
200 { |
202 FLOG(_L("Link attacher already active")); |
201 FLOG(_L("Link attacher already active")); |
203 return KErrInUse; |
202 return KErrInUse; |
204 } |
203 } |
205 |
|
206 if (iBTSynchronousLinkAttacherESCO->IsActive()) |
|
207 { |
|
208 FLOG(_L("Link attacher already active")); |
|
209 return KErrInUse; |
|
210 } |
|
211 |
204 |
212 TInt linkState = LinkUp(aBDAddr); |
205 TInt linkState = LinkUp(aBDAddr); |
213 if (linkState != KErrNone) |
206 if (linkState != KErrNone) |
214 { |
207 { |
215 FLOG(_L("Baseband link not available")); |
208 FLOG(_L("Baseband link not available")); |
335 The physical link will remain unless no other services are running on it. |
328 The physical link will remain unless no other services are running on it. |
336 @return Error code |
329 @return Error code |
337 */ |
330 */ |
338 EXPORT_C TInt CBluetoothSynchronousLink::Disconnect() |
331 EXPORT_C TInt CBluetoothSynchronousLink::Disconnect() |
339 { |
332 { |
340 if (!SCOSocket().SubSessionHandle()) |
333 if (!SCOSocket().SubSessionHandle() && !ESCOSocket().SubSessionHandle()) |
341 { |
334 { |
342 if(!ESCOSocket().SubSessionHandle()) |
335 return KErrDisconnected; |
343 { |
336 } |
344 return KErrDisconnected; |
337 |
345 } |
338 if (iBTSynchronousLinkDetacherSCO->IsActive() || iBTSynchronousLinkDetacherESCO->IsActive()) |
346 } |
|
347 |
|
348 if (iBTSynchronousLinkDetacherSCO->IsActive() || |
|
349 iBTSynchronousLinkDetacherESCO->IsActive()) |
|
350 { |
339 { |
351 return KErrInUse; |
340 return KErrInUse; |
352 } |
341 } |
353 |
342 |
354 __ASSERT_ALWAYS(iSCOTypes, Panic(EBadSyncPacketTypes)); |
343 __ASSERT_ALWAYS(iSCOTypes, Panic(EBadSyncPacketTypes)); |
497 @param aPacketTypes Bitmask of supported packets. |
486 @param aPacketTypes Bitmask of supported packets. |
498 @return Error code |
487 @return Error code |
499 */ |
488 */ |
500 EXPORT_C TInt CBluetoothSynchronousLink::AcceptConnection(const TBTSyncPackets& aPacketTypes) |
489 EXPORT_C TInt CBluetoothSynchronousLink::AcceptConnection(const TBTSyncPackets& aPacketTypes) |
501 { |
490 { |
|
491 TRAPD(err, AcceptConnectionL(aPacketTypes)); |
|
492 return err; |
|
493 } |
|
494 |
|
495 void CBluetoothSynchronousLink::AcceptConnectionL(const TBTSyncPackets& aPacketTypes) |
|
496 { |
502 TBool listenForSCO = EFalse; |
497 TBool listenForSCO = EFalse; |
503 TBool listenForESCO = EFalse; |
498 TBool listenForESCO = EFalse; |
504 |
499 |
505 FTRACE(FPrint(_L("AcceptConnection on CBTSyncLink 0x%08x"), this)); |
500 FTRACE(FPrint(_L("AcceptConnection on CBTSyncLink 0x%08x"), this)); |
506 |
501 |
507 TBTSyncPacketTypes packets = aPacketTypes(); |
502 TBTSyncPacketTypes packets = aPacketTypes(); |
508 |
|
509 |
503 |
510 __ASSERT_ALWAYS(packets, Panic(EBadSyncPacketTypes)); |
504 __ASSERT_ALWAYS(packets, Panic(EBadSyncPacketTypes)); |
511 packets &= (TBTSyncPackets::ESyncAnySCOPacket | TBTSyncPackets::ESyncAnyESCOPacket); |
505 packets &= (TBTSyncPackets::ESyncAnySCOPacket | TBTSyncPackets::ESyncAnyESCOPacket); |
512 if (!packets) |
506 if (!packets) |
513 { |
507 { |
514 return KErrNotSupported; |
508 User::Leave(KErrNotSupported); |
515 } |
509 } |
516 |
510 |
517 if (iBTSynchronousLinkAccepterSCO->IsActive()) |
511 if (iBTSynchronousLinkAccepterSCO->IsActive() || iBTSynchronousLinkAccepterESCO->IsActive()) |
518 { |
512 { |
519 return KErrInUse; |
513 User::Leave(KErrInUse); |
520 } |
514 } |
|
515 |
|
516 User::LeaveIfError(ListeningSCOSocket().Open(iSockServer, KBTAddrFamily, KSockBluetoothTypeSCO, KBTLinkManager)); |
|
517 CleanupClosePushL(ListeningSCOSocket()); |
521 |
518 |
522 if (iBTSynchronousLinkAccepterESCO->IsActive()) |
519 User::LeaveIfError(ListeningESCOSocket().Open(iSockServer, KBTAddrFamily, KSockBluetoothTypeESCO, KBTLinkManager)); |
523 { |
520 CleanupClosePushL(ListeningESCOSocket()); |
524 return KErrInUse; |
521 |
525 } |
522 CleanupStack::PushL(TCleanupItem(StaticResetScoTypes, this)); // we want to clear any setting of SCO types upon leaving |
526 |
|
527 TInt err = ListeningSCOSocket().Open(iSockServer, KBTAddrFamily, KSockBluetoothTypeSCO, KBTLinkManager); |
|
528 if(err) |
|
529 { |
|
530 return err; |
|
531 } |
|
532 |
|
533 err = ListeningESCOSocket().Open(iSockServer, KBTAddrFamily, KSockBluetoothTypeESCO, KBTLinkManager); |
|
534 if(err) |
|
535 { |
|
536 ListeningSCOSocket().Close(); |
|
537 return err; |
|
538 } |
|
539 |
523 |
540 TBTSyncPacketTypes packetsSCO = packets & TBTSyncPackets::ESyncAnySCOPacket; |
524 TBTSyncPacketTypes packetsSCO = packets & TBTSyncPackets::ESyncAnySCOPacket; |
541 if (packetsSCO) |
525 if (packetsSCO) |
542 { |
526 { |
543 err = ListeningSCOSocket().SetOpt(ESyncUserPacketTypes, KSolBtSCO, packetsSCO); |
527 TInt err = ListeningSCOSocket().SetOpt(ESyncUserPacketTypes, KSolBtSCO, packetsSCO); |
544 if(!err) |
528 if(!err) |
545 { |
529 { |
546 iSCOTypes |= ESCO; |
530 iSCOTypes |= ESCO; |
547 listenForSCO = ETrue; |
531 listenForSCO = ETrue; |
548 } |
532 } |
549 } |
533 } |
550 |
534 |
551 TBTSyncPacketTypes packetsESCO = packets & TBTSyncPackets::ESyncAnyESCOPacket; |
535 TBTSyncPacketTypes packetsESCO = packets & TBTSyncPackets::ESyncAnyESCOPacket; |
552 if (packetsESCO) |
536 if (packetsESCO) |
553 { |
537 { |
554 err = ListeningESCOSocket().SetOpt(ESyncUserPacketTypes, KSolBtSCO, packetsESCO); |
538 TInt err = ListeningESCOSocket().SetOpt(ESyncUserPacketTypes, KSolBtSCO, packetsESCO); |
555 if (!err) |
539 if (!err) |
556 { |
540 { |
557 iSCOTypes |= EeSCO; |
541 iSCOTypes |= EeSCO; |
558 listenForESCO = ETrue; |
542 listenForESCO = ETrue; |
559 } |
|
560 |
543 |
561 TPckgBuf<TBTeSCOLinkParams> options; |
544 TPckgC<TBTeSCOLinkParams> options(iRequestedLink); |
562 options() = iRequestedLink; |
545 User::LeaveIfError(ListeningESCOSocket().SetOpt(EeSCOExtOptions, KSolBtESCO, options)); |
563 err = ListeningESCOSocket().SetOpt(EeSCOExtOptions, KSolBtESCO, options); |
546 } |
564 CLOSE_LISTENER_RETURN_IF_ERROR(err); |
|
565 } |
547 } |
566 |
548 |
567 __ASSERT_ALWAYS(listenForSCO || listenForESCO, Panic(EBadSyncPacketTypes)); |
549 __ASSERT_ALWAYS(listenForSCO || listenForESCO, Panic(EBadSyncPacketTypes)); |
568 |
550 |
569 TBTSockAddr sa; |
551 TBTSockAddr sa; |
578 sa.SetBTAddr(TBTDevAddr()); // I don't think this matters which address is being used |
560 sa.SetBTAddr(TBTDevAddr()); // I don't think this matters which address is being used |
579 sa.SetSecurity(sec); |
561 sa.SetSecurity(sec); |
580 |
562 |
581 if (listenForSCO) |
563 if (listenForSCO) |
582 { |
564 { |
583 err = ListeningSCOSocket().Bind(sa); |
565 User::LeaveIfError(ListeningSCOSocket().Bind(sa)); |
584 CLOSE_LISTENER_RETURN_IF_ERROR(err); |
566 User::LeaveIfError(ListeningSCOSocket().Listen(KSCOListenQueSize)); |
|
567 User::LeaveIfError(SCOSocket().Open(SocketServer())); |
|
568 CleanupClosePushL(SCOSocket()); |
|
569 } |
|
570 |
|
571 if(listenForESCO) |
|
572 { |
|
573 User::LeaveIfError(ListeningESCOSocket().Bind(sa)); |
|
574 User::LeaveIfError(ListeningESCOSocket().Listen(KSCOListenQueSize)); |
|
575 User::LeaveIfError(ESCOSocket().Open(SocketServer())); |
|
576 } |
|
577 |
|
578 // Now we can't fail synchronously, so we're ready to begin the accept. |
|
579 if(listenForESCO) |
|
580 { |
|
581 iBTSynchronousLinkAccepterESCO->Accept(); |
|
582 } |
585 |
583 |
586 err = ListeningSCOSocket().Listen(KSCOListenQueSize); |
|
587 CLOSE_LISTENER_RETURN_IF_ERROR(err); |
|
588 |
|
589 err = SCOSocket().Open(SocketServer()); |
|
590 if(err) |
|
591 { |
|
592 return err; |
|
593 } |
|
594 } |
|
595 |
|
596 if(listenForESCO) |
|
597 { |
|
598 err = ListeningESCOSocket().Bind(sa); |
|
599 CLOSE_LISTENER_RETURN_IF_ERROR(err); |
|
600 |
|
601 err = ListeningESCOSocket().Listen(KSCOListenQueSize); |
|
602 CLOSE_LISTENER_RETURN_IF_ERROR(err); |
|
603 |
|
604 err = ESCOSocket().Open(SocketServer()); |
|
605 if(err) |
|
606 { |
|
607 return err; |
|
608 } |
|
609 } |
|
610 |
|
611 if (listenForSCO) |
584 if (listenForSCO) |
612 { |
585 { |
613 iBTSynchronousLinkAccepterSCO->Accept(ListeningSCOSocket()); |
586 CleanupStack::Pop(&SCOSocket()); |
614 } |
587 iBTSynchronousLinkAccepterSCO->Accept(); |
615 |
588 } |
616 if(listenForESCO) |
589 |
617 { |
590 CleanupStack::Pop(3); // StaticResetScoTypes, ListeningESCOSocket(), ListeningSCOSocket() |
618 iBTSynchronousLinkAccepterESCO->Accept(ListeningESCOSocket()); |
591 } |
619 } |
592 |
620 |
593 void CBluetoothSynchronousLink::StaticResetScoTypes(TAny* aThis) |
621 return err; |
594 { |
|
595 static_cast<CBluetoothSynchronousLink*>(aThis)->iSCOTypes = 0; |
622 } |
596 } |
623 |
597 |
624 |
598 |
625 /** |
599 /** |
626 Cancel ability to respond to a remote request to set up a synchronous link. |
600 Cancel ability to respond to a remote request to set up a synchronous link. |
627 It is possible for a race condition to mean that a connection has been established, |
601 |
628 but as this call consumes the callback, for this fact not to reach the caller. |
602 It is possible for a race condition to mean that a connection has been established |
629 For this reason, it may be desirable to follow a call to CancelAccept with a call |
603 but the notifier has not yet received the call-back. In this case no call-back will |
630 to Disconnect. |
604 be received and the link (if established) will be immediately shutdown. |
631 @see CBluetoothSynchronousLink::Disconnect |
|
632 */ |
605 */ |
633 EXPORT_C void CBluetoothSynchronousLink::CancelAccept() |
606 EXPORT_C void CBluetoothSynchronousLink::CancelAccept() |
634 { |
607 { |
635 iBTSynchronousLinkAccepterSCO->Cancel(); |
608 iBTSynchronousLinkAccepterSCO->Cancel(); |
636 iBTSynchronousLinkAccepterESCO->Cancel(); |
609 iBTSynchronousLinkAccepterESCO->Cancel(); |
637 iBTSynchronousLinkBaseband->StopAll(); |
610 iBTSynchronousLinkBaseband->StopAll(); |
638 |
611 |
|
612 iSCOTypes = 0; |
|
613 |
|
614 LinkDown(); |
|
615 |
639 ListeningSCOSocket().Close(); |
616 ListeningSCOSocket().Close(); |
640 ListeningESCOSocket().Close(); |
617 ListeningESCOSocket().Close(); |
641 SCOSocket().Close(); |
618 SCOSocket().Close(); |
642 ESCOSocket().Close(); |
619 ESCOSocket().Close(); |
643 } |
620 } |
894 |
871 |
895 TSockAddr sockAddr; |
872 TSockAddr sockAddr; |
896 if (aSCOType & ESCO) |
873 if (aSCOType & ESCO) |
897 { |
874 { |
898 iBTSynchronousLinkAccepterESCO->Cancel(); |
875 iBTSynchronousLinkAccepterESCO->Cancel(); |
|
876 ListeningESCOSocket().Close(); |
|
877 ESCOSocket().Close(); |
|
878 |
899 SCOSocket().RemoteName(sockAddr); |
879 SCOSocket().RemoteName(sockAddr); |
900 } |
880 } |
901 else |
881 else |
902 { |
882 { |
903 iBTSynchronousLinkAccepterSCO->Cancel(); |
883 iBTSynchronousLinkAccepterSCO->Cancel(); |
|
884 ListeningSCOSocket().Close(); |
|
885 SCOSocket().Close(); |
|
886 |
904 ESCOSocket().RemoteName(sockAddr); |
887 ESCOSocket().RemoteName(sockAddr); |
905 } |
888 } |
906 |
889 |
907 if(sockAddr.Family() == KBTAddrFamily) |
890 if(sockAddr.Family() == KBTAddrFamily) |
908 { |
891 { |
909 TBTSockAddr& btSockAddr = static_cast<TBTSockAddr&>(sockAddr); // subclasses of TSockAddr are forbidden to add members |
892 TBTSockAddr& btSockAddr = static_cast<TBTSockAddr&>(sockAddr); |
910 TBTDevAddr da = btSockAddr.BTAddr(); |
893 TBTDevAddr da = btSockAddr.BTAddr(); |
911 TInt linkState = LinkUp(da); |
894 aErr = LinkUp(da); |
912 |
895 if(aErr == KErrNone) |
913 __ASSERT_ALWAYS((linkState == KErrNone), Panic(EBasebandFailedConnect)); |
896 { |
914 |
897 iBTSynchronousLinkBaseband->PreventPark(); |
915 iBTSynchronousLinkBaseband->PreventPark(); |
898 iBTSynchronousLinkBaseband->CatchEvents(); |
916 iBTSynchronousLinkBaseband->CatchEvents(); |
899 UpdateLinkParams(aSCOType); |
917 UpdateLinkParams(aSCOType); |
900 } |
|
901 else |
|
902 { |
|
903 FTRACE(FPrint(_L("Failed to \"LinkUp\" the synchronous link (aErr %d)"), aErr)); |
|
904 } |
918 } |
905 } |
919 else |
906 else |
920 { |
907 { |
921 // reading RemoteName has failed, probably socket state is already closed |
908 // reading RemoteName has failed, probably socket state is already closed |
922 // for example after quick disconnection initiated from remote side |
909 // for example after quick disconnection initiated from remote side |
923 aErr = KErrDisconnected; |
910 aErr = KErrDisconnected; |
924 } |
911 } |
925 } |
912 } |
926 else |
913 |
|
914 if(aErr != KErrNone) |
927 { |
915 { |
928 iNegotiatedLink = TBTeSCOLinkParams(0, 0, 0, 0); |
916 iNegotiatedLink = TBTeSCOLinkParams(0, 0, 0, 0); |
|
917 CancelAccept(); // makes sure everything is cleaned up. |
929 } |
918 } |
930 |
919 |
931 #ifdef __FLOGGING__ |
920 #ifdef __FLOGGING__ |
932 TRAPD(err, Notifier().HandleAcceptConnectionCompleteL(aErr)); |
921 TRAPD(err, Notifier().HandleAcceptConnectionCompleteL(aErr)); |
933 FTRACE(FPrint(_L("Accept upcall to link owner returned %d"), err)); |
922 FTRACE(FPrint(_L("Accept upcall to link owner returned %d"), err)); |
934 User::LeaveIfError(err); |
923 User::LeaveIfError(err); |
935 #else |
924 #else |
936 Notifier().HandleAcceptConnectionCompleteL(aErr); |
925 Notifier().HandleAcceptConnectionCompleteL(aErr); |
937 #endif |
926 #endif |
938 |
|
939 ListeningSCOSocket().Close(); |
|
940 ListeningESCOSocket().Close(); |
|
941 } |
927 } |
942 |
928 |
943 |
929 |
944 void CBluetoothSynchronousLink::HandleSendCompleteL(TInt aErr) |
930 void CBluetoothSynchronousLink::HandleSendCompleteL(TInt aErr) |
945 { |
931 { |
1032 //for CBluetoothSynchronousLink |
1018 //for CBluetoothSynchronousLink |
1033 // |
1019 // |
1034 CBTSynchronousLinkBaseband* CBTSynchronousLinkBaseband::NewL(CBluetoothSynchronousLink& aParent) |
1020 CBTSynchronousLinkBaseband* CBTSynchronousLinkBaseband::NewL(CBluetoothSynchronousLink& aParent) |
1035 { |
1021 { |
1036 CBTSynchronousLinkBaseband* self = new(ELeave) CBTSynchronousLinkBaseband(aParent); |
1022 CBTSynchronousLinkBaseband* self = new(ELeave) CBTSynchronousLinkBaseband(aParent); |
1037 CleanupStack::PushL(self); |
|
1038 self->ConstructL(); |
|
1039 CleanupStack::Pop(self); |
|
1040 return self; |
1023 return self; |
1041 } |
1024 } |
1042 |
1025 |
1043 |
1026 |
1044 CBTSynchronousLinkBaseband::CBTSynchronousLinkBaseband(CBluetoothSynchronousLink& aParent) |
1027 CBTSynchronousLinkBaseband::CBTSynchronousLinkBaseband(CBluetoothSynchronousLink& aParent) |
1045 : CActive(CActive::EPriorityStandard), iParent(aParent) |
1028 : CActive(CActive::EPriorityStandard), iParent(aParent) |
1046 {} |
|
1047 |
|
1048 |
|
1049 void CBTSynchronousLinkBaseband::ConstructL() |
|
1050 { |
1029 { |
1051 CActiveScheduler::Add(this); |
1030 CActiveScheduler::Add(this); |
1052 } |
1031 } |
1053 |
|
1054 |
1032 |
1055 CBTSynchronousLinkBaseband::~CBTSynchronousLinkBaseband() |
1033 CBTSynchronousLinkBaseband::~CBTSynchronousLinkBaseband() |
1056 { |
1034 { |
1057 StopAll(); |
1035 StopAll(); |
1058 } |
1036 } |
1091 { |
1069 { |
1092 iParent.Baseband().AllowLowPowerModes(EParkMode); |
1070 iParent.Baseband().AllowLowPowerModes(EParkMode); |
1093 Cancel(); |
1071 Cancel(); |
1094 } |
1072 } |
1095 |
1073 |
1096 |
1074 |
1097 void CBTSynchronousLinkBaseband::DoCancel() |
1075 void CBTSynchronousLinkBaseband::DoCancel() |
1098 { |
1076 { |
1099 iParent.Baseband().CancelNextBasebandChangeEventNotifier(); |
1077 iParent.Baseband().CancelNextBasebandChangeEventNotifier(); |
1100 } |
1078 } |
1101 |
1079 |
1102 |
1080 |
1103 //-- |
1081 //-- |
1104 CBTSynchronousLinkAttacher* CBTSynchronousLinkAttacher::NewL(CBluetoothSynchronousLink& aParent, TSCOType aSCOType) |
1082 CBTSynchronousLinkAttacher* CBTSynchronousLinkAttacher::NewL(CBluetoothSynchronousLink& aParent, TSCOType aSCOType) |
1105 { |
1083 { |
1106 CBTSynchronousLinkAttacher* self = new (ELeave) CBTSynchronousLinkAttacher(aParent, aSCOType); |
1084 CBTSynchronousLinkAttacher* self = new (ELeave) CBTSynchronousLinkAttacher(aParent, aSCOType); |
1107 CleanupStack::PushL(self); |
|
1108 self->ConstructL(); |
|
1109 CleanupStack::Pop(self); |
|
1110 return self; |
1085 return self; |
1111 } |
1086 } |
1112 |
|
1113 |
1087 |
1114 CBTSynchronousLinkAttacher::CBTSynchronousLinkAttacher(CBluetoothSynchronousLink& aParent, TSCOType aSCOType) |
1088 CBTSynchronousLinkAttacher::CBTSynchronousLinkAttacher(CBluetoothSynchronousLink& aParent, TSCOType aSCOType) |
1115 : CActive(CActive::EPriorityStandard), iParent(aParent), iSCOType(aSCOType) |
1089 : CActive(CActive::EPriorityStandard), iParent(aParent), iSCOType(aSCOType) |
1116 { |
1090 { |
1117 } |
|
1118 |
|
1119 void CBTSynchronousLinkAttacher::ConstructL() |
|
1120 { |
|
1121 CActiveScheduler::Add(this); |
1091 CActiveScheduler::Add(this); |
1122 } |
1092 } |
1123 |
1093 |
1124 CBTSynchronousLinkAttacher::~CBTSynchronousLinkAttacher() |
1094 CBTSynchronousLinkAttacher::~CBTSynchronousLinkAttacher() |
1125 { |
1095 { |
1172 |
1141 |
1173 //-- |
1142 //-- |
1174 CBTSynchronousLinkDetacher* CBTSynchronousLinkDetacher::NewL(CBluetoothSynchronousLink& aParent, TSCOType aSCOType) |
1143 CBTSynchronousLinkDetacher* CBTSynchronousLinkDetacher::NewL(CBluetoothSynchronousLink& aParent, TSCOType aSCOType) |
1175 { |
1144 { |
1176 CBTSynchronousLinkDetacher* self = new (ELeave) CBTSynchronousLinkDetacher(aParent, aSCOType); |
1145 CBTSynchronousLinkDetacher* self = new (ELeave) CBTSynchronousLinkDetacher(aParent, aSCOType); |
1177 CleanupStack::PushL(self); |
|
1178 self->ConstructL(); |
|
1179 CleanupStack::Pop(self); |
|
1180 return self; |
1146 return self; |
1181 } |
1147 } |
1182 |
|
1183 |
1148 |
1184 CBTSynchronousLinkDetacher::CBTSynchronousLinkDetacher(CBluetoothSynchronousLink& aParent, TSCOType aSCOType) |
1149 CBTSynchronousLinkDetacher::CBTSynchronousLinkDetacher(CBluetoothSynchronousLink& aParent, TSCOType aSCOType) |
1185 : CActive(CActive::EPriorityStandard), iParent(aParent), iSCOType(aSCOType) |
1150 : CActive(CActive::EPriorityStandard), iParent(aParent), iSCOType(aSCOType) |
1186 { |
|
1187 } |
|
1188 |
|
1189 void CBTSynchronousLinkDetacher::ConstructL() |
|
1190 { |
1151 { |
1191 CActiveScheduler::Add(this); |
1152 CActiveScheduler::Add(this); |
1192 } |
1153 } |
1193 |
1154 |
1194 CBTSynchronousLinkDetacher::~CBTSynchronousLinkDetacher() |
1155 CBTSynchronousLinkDetacher::~CBTSynchronousLinkDetacher() |
1238 |
1199 |
1239 //-- |
1200 //-- |
1240 CBTSynchronousLinkAccepter* CBTSynchronousLinkAccepter::NewL(CBluetoothSynchronousLink& aParent, TSCOType aSCOType) |
1201 CBTSynchronousLinkAccepter* CBTSynchronousLinkAccepter::NewL(CBluetoothSynchronousLink& aParent, TSCOType aSCOType) |
1241 { |
1202 { |
1242 CBTSynchronousLinkAccepter* self = new (ELeave) CBTSynchronousLinkAccepter(aParent, aSCOType); |
1203 CBTSynchronousLinkAccepter* self = new (ELeave) CBTSynchronousLinkAccepter(aParent, aSCOType); |
1243 CleanupStack::PushL(self); |
|
1244 self->ConstructL(); |
|
1245 CleanupStack::Pop(self); |
|
1246 return self; |
1204 return self; |
1247 } |
1205 } |
1248 |
1206 |
1249 |
1207 |
1250 CBTSynchronousLinkAccepter::CBTSynchronousLinkAccepter(CBluetoothSynchronousLink& aParent, TSCOType aSCOType) |
1208 CBTSynchronousLinkAccepter::CBTSynchronousLinkAccepter(CBluetoothSynchronousLink& aParent, TSCOType aSCOType) |
1251 : CActive(CActive::EPriorityStandard), iParent(aParent), iSCOType(aSCOType) |
1209 : CActive(CActive::EPriorityStandard), iParent(aParent), iSCOType(aSCOType) |
1252 { |
1210 { |
1253 } |
|
1254 |
|
1255 void CBTSynchronousLinkAccepter::ConstructL() |
|
1256 { |
|
1257 CActiveScheduler::Add(this); |
1211 CActiveScheduler::Add(this); |
1258 } |
1212 } |
1259 |
1213 |
1260 CBTSynchronousLinkAccepter::~CBTSynchronousLinkAccepter() |
1214 CBTSynchronousLinkAccepter::~CBTSynchronousLinkAccepter() |
1261 { |
1215 { |
1262 Cancel(); |
1216 Cancel(); |
1263 } |
1217 } |
1264 |
1218 |
1265 void CBTSynchronousLinkAccepter::Accept(RSocket& aSocket) |
1219 void CBTSynchronousLinkAccepter::Accept() |
1266 |
1220 |
1267 { |
1221 { |
1268 __ASSERT_ALWAYS(!IsActive(), Panic(EUnfinishedBusiness)); |
1222 __ASSERT_ALWAYS(!IsActive(), Panic(EUnfinishedBusiness)); |
1269 |
1223 |
1270 FLOG(_L("CBTSynchronousLinkAccepter accept sync link")); |
1224 FLOG(_L("CBTSynchronousLinkAccepter accept sync link")); |
1271 if (iSCOType == ESCO) |
1225 if (iSCOType == ESCO) |
1272 { |
1226 { |
1273 aSocket.Accept(iParent.SCOSocket(), iStatus); |
1227 iParent.ListeningSCOSocket().Accept(iParent.SCOSocket(), iStatus); |
1274 } |
1228 } |
1275 else |
1229 else |
1276 { |
1230 { |
1277 aSocket.Accept(iParent.ESCOSocket(), iStatus); |
1231 iParent.ListeningESCOSocket().Accept(iParent.ESCOSocket(), iStatus); |
1278 } |
1232 } |
1279 SetActive(); |
1233 SetActive(); |
1280 } |
1234 } |
1281 |
1235 |
1282 |
1236 |
1313 |
1267 |
1314 //-- |
1268 //-- |
1315 CBTSynchronousLinkSender* CBTSynchronousLinkSender::NewL(CBluetoothSynchronousLink& aParent, TSCOType aSCOType) |
1269 CBTSynchronousLinkSender* CBTSynchronousLinkSender::NewL(CBluetoothSynchronousLink& aParent, TSCOType aSCOType) |
1316 { |
1270 { |
1317 CBTSynchronousLinkSender* self = new (ELeave) CBTSynchronousLinkSender(aParent, aSCOType); |
1271 CBTSynchronousLinkSender* self = new (ELeave) CBTSynchronousLinkSender(aParent, aSCOType); |
1318 CleanupStack::PushL(self); |
|
1319 self->ConstructL(); |
|
1320 CleanupStack::Pop(self); |
|
1321 return self; |
1272 return self; |
1322 } |
1273 } |
1323 |
1274 |
1324 |
1275 |
1325 CBTSynchronousLinkSender::CBTSynchronousLinkSender(CBluetoothSynchronousLink& aParent, TSCOType aSCOType) |
1276 CBTSynchronousLinkSender::CBTSynchronousLinkSender(CBluetoothSynchronousLink& aParent, TSCOType aSCOType) |
1326 : CActive(CActive::EPriorityStandard), iParent(aParent), iSCOType(aSCOType) |
1277 : CActive(CActive::EPriorityStandard), iParent(aParent), iSCOType(aSCOType) |
1327 { |
|
1328 } |
|
1329 |
|
1330 void CBTSynchronousLinkSender::ConstructL() |
|
1331 { |
1278 { |
1332 CActiveScheduler::Add(this); |
1279 CActiveScheduler::Add(this); |
1333 } |
1280 } |
1334 |
1281 |
1335 CBTSynchronousLinkSender::~CBTSynchronousLinkSender() |
1282 CBTSynchronousLinkSender::~CBTSynchronousLinkSender() |
1401 |
1348 |
1402 //-- |
1349 //-- |
1403 CBTSynchronousLinkReceiver* CBTSynchronousLinkReceiver::NewL(CBluetoothSynchronousLink& aParent, TSCOType aSCOType) |
1350 CBTSynchronousLinkReceiver* CBTSynchronousLinkReceiver::NewL(CBluetoothSynchronousLink& aParent, TSCOType aSCOType) |
1404 { |
1351 { |
1405 CBTSynchronousLinkReceiver* self = new (ELeave) CBTSynchronousLinkReceiver(aParent, aSCOType); |
1352 CBTSynchronousLinkReceiver* self = new (ELeave) CBTSynchronousLinkReceiver(aParent, aSCOType); |
1406 CleanupStack::PushL(self); |
|
1407 self->ConstructL(); |
|
1408 CleanupStack::Pop(self); |
|
1409 return self; |
1353 return self; |
1410 } |
1354 } |
1411 |
1355 |
1412 |
1356 |
1413 CBTSynchronousLinkReceiver::CBTSynchronousLinkReceiver(CBluetoothSynchronousLink& aParent, TSCOType aSCOType) |
1357 CBTSynchronousLinkReceiver::CBTSynchronousLinkReceiver(CBluetoothSynchronousLink& aParent, TSCOType aSCOType) |
1414 : CActive(CActive::EPriorityStandard), iParent(aParent), iSCOType(aSCOType) |
1358 : CActive(CActive::EPriorityStandard), iParent(aParent), iSCOType(aSCOType) |
1415 { |
|
1416 } |
|
1417 |
|
1418 void CBTSynchronousLinkReceiver::ConstructL() |
|
1419 { |
1359 { |
1420 CActiveScheduler::Add(this); |
1360 CActiveScheduler::Add(this); |
1421 } |
1361 } |
1422 |
1362 |
1423 CBTSynchronousLinkReceiver::~CBTSynchronousLinkReceiver() |
1363 CBTSynchronousLinkReceiver::~CBTSynchronousLinkReceiver() |