|
1 // Copyright (c) 2003-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 // Implements the base class for baseband SAPs |
|
15 // |
|
16 // |
|
17 |
|
18 #include <bluetooth/logger.h> |
|
19 #include "basebandsap.h" |
|
20 #include "physicallinksmanager.h" |
|
21 #include "physicallinks.h" |
|
22 #include "linkutil.h" |
|
23 |
|
24 #ifdef __FLOG_ACTIVE |
|
25 _LIT8(KLogComponent, LOG_COMPONENT_LINKMGR); |
|
26 #endif |
|
27 |
|
28 #pragma warning (disable: 4100) //unreference formal param { These are both OK |
|
29 #pragma warning (disable: 4355) //this in base init list { for our usage |
|
30 |
|
31 |
|
32 CBTBasebandSAP::CBTBasebandSAP(CPhysicalLinksManager& aLinksMan, CPhysicalLink* aPhysicalLink) |
|
33 : CBluetoothSAP(aLinksMan.SecMan(), aLinksMan.CodMan()), |
|
34 iLinksMan(aLinksMan), |
|
35 iPhysicalLink(aPhysicalLink), |
|
36 iAcceptWatchdog(*this), |
|
37 iQueLink(this) |
|
38 { |
|
39 LOG_FUNC |
|
40 // Initialise handle to a non-zero number |
|
41 iHandle = KInvalidConnectionHandle; |
|
42 } |
|
43 |
|
44 void CBTBasebandSAP::ConstructL() |
|
45 { |
|
46 LOG_FUNC |
|
47 CBluetoothSAP::ConstructL(); |
|
48 } |
|
49 |
|
50 // from CServProviderBase - the saps will not do all of these |
|
51 void CBTBasebandSAP::Start() |
|
52 { |
|
53 LOG_FUNC |
|
54 Panic(EBTBaseSAPUnimplementedEvent); |
|
55 } |
|
56 |
|
57 void CBTBasebandSAP::LocalName(TSockAddr& aAddr) const |
|
58 { |
|
59 LOG_FUNC |
|
60 // base class just returns address as a BTSockAddr |
|
61 TBTSockAddr btAddr; |
|
62 btAddr.SetBTAddr(iLinksMan.LinkManagerProtocol().LocalBTAddress()); |
|
63 aAddr = btAddr; |
|
64 } |
|
65 |
|
66 TInt CBTBasebandSAP::SetLocalName(TSockAddr& /*aAddr*/) |
|
67 { |
|
68 LOG_FUNC |
|
69 return KErrNotSupported; |
|
70 } |
|
71 |
|
72 void CBTBasebandSAP::RemName(TSockAddr& aAddr) const |
|
73 { |
|
74 LOG_FUNC |
|
75 // base class just returns address as a BTSockAddr |
|
76 TBTSockAddr btAddr; |
|
77 btAddr.SetBTAddr(iRemoteDev); |
|
78 aAddr = btAddr; |
|
79 } |
|
80 |
|
81 TInt CBTBasebandSAP::SetRemName(TSockAddr& aAddr) |
|
82 { |
|
83 LOG_FUNC |
|
84 // base class just sets BTAddr |
|
85 TBTSockAddr btAddr = TBTSockAddr::Cast(aAddr); |
|
86 iRemoteDev = btAddr.BTAddr(); |
|
87 return KErrNone; |
|
88 } |
|
89 |
|
90 TInt CBTBasebandSAP::GetOption(TUint /*aLevel*/,TUint /*aName*/,TDes8& /*aOption*/) const |
|
91 { |
|
92 LOG_FUNC |
|
93 Panic(EBTBaseSAPUnimplementedEvent); |
|
94 return KErrNotSupported; |
|
95 } |
|
96 |
|
97 void CBTBasebandSAP::Ioctl(TUint /*aLevel*/,TUint /*aName*/, TDes8* /*aOption*/) |
|
98 { |
|
99 LOG_FUNC |
|
100 Panic(EBTBaseSAPUnimplementedEvent); |
|
101 } |
|
102 |
|
103 void CBTBasebandSAP::CancelIoctl(TUint /*aLevel*/,TUint /*aName*/) |
|
104 { |
|
105 LOG_FUNC |
|
106 Panic(EBTBaseSAPUnimplementedEvent); |
|
107 } |
|
108 |
|
109 TInt CBTBasebandSAP::SAPSetOption(TUint /*aLevel*/,TUint /*aName*/,const TDesC8& /*aOption*/) |
|
110 { |
|
111 LOG_FUNC |
|
112 Panic(EBTBaseSAPUnimplementedEvent); |
|
113 return KErrNotSupported; |
|
114 } |
|
115 |
|
116 void CBTBasebandSAP::ActiveOpen() |
|
117 { |
|
118 LOG_FUNC |
|
119 Panic(EBTBaseSAPUnimplementedEvent); |
|
120 } |
|
121 |
|
122 void CBTBasebandSAP::ActiveOpen(const TDesC8& /*aConnectionData*/) |
|
123 { |
|
124 LOG_FUNC |
|
125 Panic(EBTBaseSAPUnimplementedEvent); |
|
126 } |
|
127 |
|
128 TInt CBTBasebandSAP::PassiveOpen(TUint /*aQueSize*/) |
|
129 { |
|
130 LOG_FUNC |
|
131 Panic(EBTBaseSAPUnimplementedEvent); |
|
132 return KErrNotSupported; |
|
133 } |
|
134 |
|
135 TInt CBTBasebandSAP::PassiveOpen(TUint /*aQueSize*/,const TDesC8& /*aConnectionData*/) |
|
136 { |
|
137 LOG_FUNC |
|
138 Panic(EBTBaseSAPUnimplementedEvent); |
|
139 return KErrNotSupported; |
|
140 } |
|
141 |
|
142 void CBTBasebandSAP::Shutdown(TCloseType /*aOption*/) |
|
143 { |
|
144 LOG_FUNC |
|
145 Panic(EBTBaseSAPUnimplementedEvent); |
|
146 } |
|
147 |
|
148 void CBTBasebandSAP::Shutdown(TCloseType /*aOption*/,const TDesC8& /*aDisconnectionData*/) |
|
149 { |
|
150 LOG_FUNC |
|
151 Panic(EBTBaseSAPUnimplementedEvent); |
|
152 } |
|
153 |
|
154 void CBTBasebandSAP::AutoBind() |
|
155 { |
|
156 LOG_FUNC |
|
157 Panic(EBTBaseSAPUnimplementedEvent); |
|
158 } |
|
159 |
|
160 TUint CBTBasebandSAP::Write(const TDesC8& /*aDesc*/,TUint /*aOptions*/, TSockAddr* /*aAddr*/) |
|
161 { |
|
162 LOG_FUNC |
|
163 Panic(EBTBaseSAPUnimplementedEvent); |
|
164 return 0; |
|
165 } |
|
166 |
|
167 void CBTBasebandSAP::GetData(TDes8& /*aDesc*/,TUint /*aOptions*/,TSockAddr* /*aAddr*/) |
|
168 { |
|
169 LOG_FUNC |
|
170 Panic(EBTBaseSAPUnimplementedEvent); |
|
171 } |
|
172 |
|
173 CBTBasebandModel& CBTBasebandSAP::Baseband() const |
|
174 { |
|
175 LOG_FUNC |
|
176 return iLinksMan.Baseband(); |
|
177 } |
|
178 |
|
179 TInt CBTBasebandSAP::BindLink(TLinkType aLinkType, CPhysicalLink& aPhysicalLink) |
|
180 { |
|
181 LOG_FUNC |
|
182 __ASSERT_DEBUG(iPhysicalLink==NULL || iPhysicalLink==&aPhysicalLink, Panic(EBTBasebandSAPTwoPhysicalLinks)); |
|
183 TInt err = aPhysicalLink.AttachLogicalLink(aLinkType, *this); |
|
184 if (err == KErrNone) |
|
185 { |
|
186 iPhysicalLink = &aPhysicalLink; |
|
187 iPhysicalLink->SubscribeLinkObserver(*this); // logical links might want to know about park etc |
|
188 } |
|
189 return err; |
|
190 } |
|
191 |
|
192 void CBTBasebandSAP::UnbindLink(TLinkType aLinkType) |
|
193 { |
|
194 LOG_FUNC |
|
195 if (iPhysicalLink) |
|
196 { |
|
197 iPhysicalLink->UnsubscribeLinkObserver(*this); |
|
198 iPhysicalLink->DetachLogicalLink(aLinkType, *this); |
|
199 iPhysicalLink = NULL; |
|
200 } |
|
201 } |
|
202 |
|
203 void CBTBasebandSAP::RemoveChild(CBTBasebandSAP* __DEBUG_ONLY(aChild)) |
|
204 { |
|
205 LOG_FUNC |
|
206 __ASSERT_DEBUG(aChild == iChild, Panic(EBTBasebandSAPBadChild)); |
|
207 iChild = NULL; |
|
208 } |
|
209 |
|
210 void CBTBasebandSAP::DeleteChild(CBTBasebandSAP* __DEBUG_ONLY(aChild)) |
|
211 { |
|
212 LOG_FUNC |
|
213 __ASSERT_DEBUG(aChild == iChild, Panic(EBTBasebandSAPBadChild)); |
|
214 delete iChild, iChild = NULL; |
|
215 } |
|
216 |
|
217 void CBTBasebandSAP::LinkStateIdle() |
|
218 { |
|
219 LOG_FUNC |
|
220 if (iPhysicalLink) |
|
221 { |
|
222 iPhysicalLink->PhysicalLinkUserIdle(); |
|
223 } |
|
224 } |
|
225 |
|
226 TBool CBTBasebandSAP::IsIdle() const |
|
227 { |
|
228 LOG_FUNC |
|
229 return EFalse; |
|
230 } |
|
231 |
|
232 void CBTBasebandSAP::ParentClosing() |
|
233 { |
|
234 LOG_FUNC |
|
235 //Ignore |
|
236 } |