|
1 // Copyright (c) 2008-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 // |
|
15 |
|
16 /** |
|
17 @file |
|
18 @internalComponent |
|
19 */ |
|
20 |
|
21 #include <e32base.h> |
|
22 #include <bttypes.h> |
|
23 #include <bluetooth/pairing.h> |
|
24 #include <bluetooth/pairingservershared.h> |
|
25 |
|
26 #include "pairingserversecuritypolicy.h" |
|
27 #include "oobdata.h" |
|
28 #include "pairingserver.h" |
|
29 |
|
30 #include <bluetooth/logger.h> |
|
31 #ifdef __FLOG_ACTIVE |
|
32 _LIT8(KLogComponent, LOG_COMPONENT_PAIRING_SERVER); |
|
33 #endif |
|
34 |
|
35 #ifdef _DEBUG |
|
36 PANICCATEGORY("pairingsrv"); |
|
37 #endif |
|
38 |
|
39 // These come after the logging to ensure that debug.h knows we're using the |
|
40 // bluetooth logger. |
|
41 #include "physicallinksmanager.h" |
|
42 #include "ProxySAP.h" |
|
43 |
|
44 // |
|
45 // CPairingServer |
|
46 // |
|
47 |
|
48 CPairingServer* CPairingServer::NewL(COobDataManager& aOobDataManager, CSimplePairingResultList& aSimplePairingResultList, CAuthenticationResultList& aAuthenticationResultList) |
|
49 { |
|
50 LOG_STATIC_FUNC |
|
51 |
|
52 CPairingServer* self = new(ELeave) CPairingServer(aOobDataManager, aSimplePairingResultList, aAuthenticationResultList); |
|
53 CleanupStack::PushL(self); |
|
54 // StartL is where the kernel checks that there isn't already an instance |
|
55 // of the same server running, so do it before ConstructL. |
|
56 self->StartL(KPairingServerName); |
|
57 self->ConstructL(); |
|
58 CleanupStack::Pop(self); |
|
59 return self; |
|
60 } |
|
61 |
|
62 CPairingServer::~CPairingServer() |
|
63 { |
|
64 LOG_FUNC |
|
65 delete iContainerIndex; |
|
66 } |
|
67 |
|
68 CPairingServer::CPairingServer(COobDataManager& aOobDataManager, CSimplePairingResultList& aSimplePairingResultList, CAuthenticationResultList& aAuthenticationResultList) |
|
69 : CPolicyServer(CActive::EPriorityStandard, KPairingServerPolicy) |
|
70 , iOobDataManager(aOobDataManager) |
|
71 , iSimplePairingResultList(aSimplePairingResultList) |
|
72 , iAuthenticationResultList(aAuthenticationResultList) |
|
73 { |
|
74 LOG_FUNC |
|
75 } |
|
76 |
|
77 void CPairingServer::ConstructL() |
|
78 { |
|
79 LOG_FUNC |
|
80 iContainerIndex = CObjectConIx::NewL(); |
|
81 } |
|
82 |
|
83 // Callback to LinksMgrProtocol to add a pairing session |
|
84 void CPairingServer::AddSession() |
|
85 { |
|
86 LOG_FUNC |
|
87 if(iSessionCount++ == 0) |
|
88 { |
|
89 // While we have clients we need to make sure that the protocol remains alive. |
|
90 iLinkMgrProtocol->LocalOpen(); |
|
91 } |
|
92 } |
|
93 |
|
94 // Callback to LinksMgrProtocol to remove a pairing session |
|
95 void CPairingServer::DropSession() |
|
96 { |
|
97 LOG_FUNC |
|
98 if(--iSessionCount == 0) |
|
99 { |
|
100 // There are no longer any clients |
|
101 iLinkMgrProtocol->LocalClose(); |
|
102 } |
|
103 } |
|
104 |
|
105 void CPairingServer::SetPhysicalLinksManager(CPhysicalLinksManager& aLinksMan) |
|
106 { |
|
107 LOG_FUNC |
|
108 __ASSERT_DEBUG(!iLinksMan, PANIC(KPairingServerFaultCat, EPairingServerLinkManagerAlreadyProvided)); |
|
109 iLinksMan = &aLinksMan; |
|
110 } |
|
111 |
|
112 void CPairingServer::ClearPhysicalLinkMgr() |
|
113 { |
|
114 LOG_FUNC |
|
115 iLinksMan = NULL; |
|
116 } |
|
117 |
|
118 // Save a reference to the LinksMgrProtocol |
|
119 void CPairingServer::SetLinksMgrProtocol(CLinkMgrProtocol& aLinkMgrProtocol) |
|
120 { |
|
121 LOG_FUNC |
|
122 iLinkMgrProtocol = &aLinkMgrProtocol; |
|
123 } |
|
124 |
|
125 // Clear the reference to the LinksMgrProtocol |
|
126 void CPairingServer::ClearLinksMgrProtocol() |
|
127 { |
|
128 LOG_FUNC |
|
129 iLinkMgrProtocol = NULL; |
|
130 } |
|
131 |
|
132 CSession2* CPairingServer::NewSessionL(const TVersion& aVersion, const RMessage2& /*aMessage*/) const |
|
133 { |
|
134 LOG_FUNC |
|
135 LOG3(_L("aVersion = (%d, %d, %d)"), aVersion.iMajor, aVersion.iMinor, aVersion.iBuild) |
|
136 |
|
137 // Version number check... |
|
138 TVersion v(KPairingServerMajorVersionNumber, |
|
139 KPairingServerMinorVersionNumber, |
|
140 KPairingServerBuildVersionNumber); |
|
141 if(!User::QueryVersionSupported(v, aVersion)) |
|
142 { |
|
143 User::LeaveIfError(KErrNotSupported); |
|
144 } |
|
145 |
|
146 // Ensure that the reference to the LinksMgrProtocol has been receieved |
|
147 if(!iLinkMgrProtocol) |
|
148 { |
|
149 User::Leave(KErrNotReady); |
|
150 } |
|
151 // Cast 'this' to allow use in Constructor |
|
152 CPairingServer* ncThis = const_cast<CPairingServer*>(this); |
|
153 CPairingSession* sess = CPairingSession::NewL(*ncThis); |
|
154 return sess; |
|
155 } |
|
156 |
|
157 CObjectCon* CPairingServer::NewContainerL() |
|
158 { |
|
159 LOG_FUNC |
|
160 return iContainerIndex->CreateL(); |
|
161 } |
|
162 |
|
163 void CPairingServer::DeleteContainer(CObjectCon* aContainer) |
|
164 { |
|
165 LOG_FUNC |
|
166 iContainerIndex->Remove(aContainer); |
|
167 } |
|
168 |
|
169 CPhysicalLinksManager& CPairingServer::LinksManL() const |
|
170 { |
|
171 LOG_FUNC |
|
172 if(!iLinksMan) |
|
173 { |
|
174 LEAVEL(KErrNotReady); |
|
175 } |
|
176 return *iLinksMan; |
|
177 } |
|
178 |
|
179 COobDataManager& CPairingServer::OobDataManager() const |
|
180 { |
|
181 LOG_FUNC |
|
182 return iOobDataManager; |
|
183 } |
|
184 |
|
185 CSimplePairingResultList& CPairingServer::SimplePairingResultList() const |
|
186 { |
|
187 LOG_FUNC |
|
188 return iSimplePairingResultList; |
|
189 } |
|
190 |
|
191 CAuthenticationResultList& CPairingServer::AuthenticationResultList() const |
|
192 { |
|
193 LOG_FUNC |
|
194 return iAuthenticationResultList; |
|
195 } |
|
196 |
|
197 // |
|
198 // CPairingSession |
|
199 // |
|
200 |
|
201 CPairingSession* CPairingSession::NewL(CPairingServer& aPairingServer) |
|
202 { |
|
203 LOG_STATIC_FUNC |
|
204 CPairingSession* self = new(ELeave) CPairingSession(aPairingServer); |
|
205 aPairingServer.AddSession(); |
|
206 return self; |
|
207 } |
|
208 |
|
209 CPairingSession::CPairingSession(CPairingServer& aPairingServer) |
|
210 : iPairingServer(aPairingServer) |
|
211 { |
|
212 LOG_FUNC |
|
213 } |
|
214 |
|
215 CPairingServer& CPairingSession::Server() const |
|
216 { |
|
217 LOG_FUNC |
|
218 return *static_cast<CPairingServer*>(const_cast<CServer2*>(CSession2::Server())); |
|
219 } |
|
220 |
|
221 CPairingSession::~CPairingSession() |
|
222 { |
|
223 LOG_FUNC |
|
224 iPairingServer.DropSession(); |
|
225 delete iSubSessions; // Must be deleted before container to ensure ref counting is correct |
|
226 Server().DeleteContainer(iContainer); |
|
227 } |
|
228 |
|
229 void CPairingSession::CreateL() |
|
230 { |
|
231 LOG_FUNC |
|
232 iSubSessions = CObjectIx::NewL(); |
|
233 iContainer = Server().NewContainerL(); |
|
234 __TEST_INVARIANT; |
|
235 } |
|
236 |
|
237 #ifdef _DEBUG |
|
238 void CPairingSession::__DbgTestInvariant() const |
|
239 { |
|
240 LOG_FUNC |
|
241 __ASSERT_DEBUG(iContainer->Count() == iSubSessions->ActiveCount(), |
|
242 PANIC(KPairingServerFaultCat, EPairingServerSessionContainerAndIndexMismatch)); |
|
243 } |
|
244 #endif // _DEBUG |
|
245 |
|
246 void CPairingSession::ServiceL(const RMessage2& aMessage) |
|
247 { |
|
248 LOG_FUNC |
|
249 LOG1(_L("aMessage.Function() = &d"), aMessage.Function()); |
|
250 // __TEST_INVARIANT; // Not needed as all major functional exits are checked |
|
251 TBool handled = DispatchSessMessageL(aMessage); |
|
252 if(!handled) |
|
253 { |
|
254 // if not handled, it must be a subsession request. |
|
255 DispatchSubSessMessageL(aMessage); |
|
256 } |
|
257 __TEST_INVARIANT; |
|
258 } |
|
259 |
|
260 void CPairingSession::ServiceError(const RMessage2& aMessage, TInt aError) |
|
261 { |
|
262 LOG_FUNC |
|
263 LOG1(_L("aError = %d"), aError); |
|
264 if(aError == KErrBadDescriptor) |
|
265 { |
|
266 // If a KErrBadDescriptor is received then the request is bad so punish. |
|
267 aMessage.Panic(KPairingServerPanicCat, EPairingServerBadDescriptor); |
|
268 } |
|
269 else |
|
270 { |
|
271 aMessage.Complete(aError); |
|
272 } |
|
273 __TEST_INVARIANT; |
|
274 } |
|
275 |
|
276 TBool CPairingSession::DispatchSessMessageL(const RMessage2& aMessage) |
|
277 { |
|
278 LOG_FUNC |
|
279 TBool handled = ETrue; |
|
280 switch(aMessage.Function()) |
|
281 { |
|
282 case EPairingServerCreateOobDataSubSession: |
|
283 NewOobDataSubSessionL(aMessage); |
|
284 break; |
|
285 |
|
286 case EPairingServerCreateDedicatedBondingSubSession: |
|
287 NewDedicatedBondingSubSessionL(aMessage); |
|
288 break; |
|
289 |
|
290 case EPairingServerCreateSimplePairingResultSubSession: |
|
291 NewSimplePairingResultSubSessionL(aMessage); |
|
292 break; |
|
293 |
|
294 case EPairingServerCreateAuthenticationResultSubSession: |
|
295 NewAuthenticationResultSubSessionL(aMessage); |
|
296 break; |
|
297 |
|
298 case EPairingServerCloseSubSession: |
|
299 DeleteSubSession(aMessage); |
|
300 break; |
|
301 |
|
302 default: |
|
303 handled = EFalse; |
|
304 break; |
|
305 } |
|
306 return handled; |
|
307 } |
|
308 |
|
309 void CPairingSession::DispatchSubSessMessageL(const RMessage2& aMessage) |
|
310 { |
|
311 LOG_FUNC |
|
312 CPairingSubSession* ss = SubSessionFromHandle(aMessage.Int3()); |
|
313 if(!ss) |
|
314 { |
|
315 aMessage.Panic(KPairingServerPanicCat, EPairingServerBadSubSessionHandle); |
|
316 } |
|
317 else |
|
318 { |
|
319 ss->DispatchSubSessMessageL(aMessage); |
|
320 } |
|
321 } |
|
322 |
|
323 CPairingSubSession* CPairingSession::SubSessionFromHandle(TInt aHandle) |
|
324 { |
|
325 LOG_FUNC |
|
326 LOG1(_L("aHandle = %d"), aHandle); |
|
327 return static_cast<CPairingSubSession*>(iSubSessions->At(aHandle)); |
|
328 } |
|
329 |
|
330 void CPairingSession::NewOobDataSubSessionL(const RMessage2& aMessage) |
|
331 { |
|
332 LOG_FUNC |
|
333 COobDataSession* oob = COobDataSession::NewLC(*this, Server().OobDataManager()); |
|
334 SubSessionConstructL(aMessage, oob); // handles oob on CleanupStack |
|
335 } |
|
336 |
|
337 void CPairingSession::NewDedicatedBondingSubSessionL(const RMessage2& aMessage) |
|
338 { |
|
339 LOG_FUNC |
|
340 CDedicatedBondingSession* ded = CDedicatedBondingSession::NewLC(*this, Server().LinksManL()); |
|
341 SubSessionConstructL(aMessage, ded); // handles ded on CleanupStack |
|
342 } |
|
343 |
|
344 void CPairingSession::NewSimplePairingResultSubSessionL(const RMessage2& aMessage) |
|
345 { |
|
346 LOG_FUNC |
|
347 CSimplePairingResultSession* sim = CSimplePairingResultSession::NewLC(*this, Server().SimplePairingResultList()); |
|
348 SubSessionConstructL(aMessage, sim); |
|
349 } |
|
350 |
|
351 |
|
352 void CPairingSession::NewAuthenticationResultSubSessionL(const RMessage2& aMessage) |
|
353 { |
|
354 LOG_FUNC |
|
355 CAuthenticationResultSession* aut = CAuthenticationResultSession::NewLC(*this, Server().AuthenticationResultList()); |
|
356 SubSessionConstructL(aMessage, aut); |
|
357 } |
|
358 |
|
359 /** |
|
360 This function handles the subsession handle binding to the subsession that has been |
|
361 created. |
|
362 */ |
|
363 void CPairingSession::SubSessionConstructL(const RMessage2& aMessage, CPairingSubSession* aSubSession) |
|
364 { |
|
365 LOG_FUNC |
|
366 // The subsession is on the cleanup stack when this function is called. |
|
367 TInt subSessionHandleLength = aMessage.GetDesMaxLengthL(3); |
|
368 if(subSessionHandleLength != sizeof(TInt)) |
|
369 { |
|
370 aMessage.Panic(KPairingServerPanicCat, EPairingServerBadDescriptor); |
|
371 CleanupStack::PopAndDestroy(aSubSession); |
|
372 } |
|
373 else |
|
374 { |
|
375 iContainer->AddL(aSubSession); |
|
376 TInt handle = iSubSessions->AddL(aSubSession); |
|
377 CleanupStack::Pop(aSubSession); // Now lifetime is controlled by the binding CObjectIx |
|
378 TPckg<TInt> pckgHandle(handle); |
|
379 TRAPD(err, aMessage.WriteL(3, pckgHandle)); |
|
380 if(err != KErrNone) |
|
381 { |
|
382 iSubSessions->Remove(handle); |
|
383 LEAVEL(err); |
|
384 } |
|
385 aMessage.Complete(KErrNone); |
|
386 } |
|
387 } |
|
388 |
|
389 void CPairingSession::DeleteSubSession(const RMessage2& aMessage) |
|
390 { |
|
391 LOG_FUNC |
|
392 TInt handle = aMessage.Int3(); |
|
393 CPairingSubSession* ss = SubSessionFromHandle(handle); |
|
394 if(!ss) |
|
395 { |
|
396 aMessage.Panic(KPairingServerPanicCat, EPairingServerBadSubSessionHandle); |
|
397 } |
|
398 else |
|
399 { |
|
400 iSubSessions->Remove(handle); |
|
401 aMessage.Complete(KErrNone); |
|
402 } |
|
403 } |
|
404 |
|
405 |
|
406 // |
|
407 // CPairingSubSession |
|
408 // |
|
409 |
|
410 CPairingSubSession::CPairingSubSession(CPairingSession& aSession) |
|
411 : iSession(aSession) |
|
412 { |
|
413 LOG_FUNC |
|
414 } |
|
415 |
|
416 CPairingSubSession::~CPairingSubSession() |
|
417 { |
|
418 LOG_FUNC |
|
419 } |
|
420 |
|
421 void CPairingSubSession::DispatchSubSessMessageL(const RMessage2& /*aMessage*/) |
|
422 { |
|
423 LOG_FUNC |
|
424 LEAVEL(KErrNotSupported); |
|
425 } |
|
426 |
|
427 void CPairingSubSession::ConstructL() |
|
428 { |
|
429 LOG_FUNC |
|
430 } |
|
431 |
|
432 CPairingSession& CPairingSubSession::Session() const |
|
433 { |
|
434 LOG_FUNC |
|
435 return iSession; |
|
436 } |
|
437 |
|
438 |
|
439 // |
|
440 // COobDataSession |
|
441 // |
|
442 |
|
443 COobDataSession* COobDataSession::NewLC(CPairingSession& aSession, COobDataManager& aOobDataManager) |
|
444 { |
|
445 LOG_STATIC_FUNC |
|
446 COobDataSession* self = new(ELeave) COobDataSession(aSession, aOobDataManager); |
|
447 //As its a CObject derived class so we should use CleanupClosePushL |
|
448 CleanupClosePushL(*self); |
|
449 self->ConstructL(); |
|
450 return self; |
|
451 } |
|
452 |
|
453 COobDataSession::COobDataSession(CPairingSession& aSession, COobDataManager& aOobDataManager) |
|
454 : CPairingSubSession(aSession) |
|
455 , iOobDataManager(aOobDataManager) |
|
456 { |
|
457 LOG_FUNC |
|
458 } |
|
459 |
|
460 COobDataSession::~COobDataSession() |
|
461 { |
|
462 LOG_FUNC |
|
463 TryCancelReadLocalOobData(); |
|
464 } |
|
465 |
|
466 COobDataManager& COobDataSession::OobDataManager() const |
|
467 { |
|
468 LOG_FUNC |
|
469 return iOobDataManager; |
|
470 } |
|
471 |
|
472 void COobDataSession::DispatchSubSessMessageL(const RMessage2& aMessage) |
|
473 { |
|
474 LOG_FUNC |
|
475 switch(aMessage.Function()) |
|
476 { |
|
477 case EPairingServerOobDataRefreshLocal: |
|
478 iOobDataManager.RefreshLocalOobData(); |
|
479 aMessage.Complete(KErrNone); |
|
480 break; |
|
481 case EPairingServerOobDataReadLocal: |
|
482 ReadLocalOobDataL(aMessage); |
|
483 break; |
|
484 case EPairingServerOobDataCancelReadLocal: |
|
485 CancelReadLocalOobData(aMessage); |
|
486 break; |
|
487 case EPairingServerOobDataProvideRemoteParsed: |
|
488 ProvideParsedRemoteOobDataL(aMessage); |
|
489 break; |
|
490 case EPairingServerOobDataProvideRemoteRaw: |
|
491 ProvideRawRemoteOobDataL(aMessage); |
|
492 break; |
|
493 case EPairingServerOobDataClearRemote: |
|
494 ClearRemoteOobDataL(aMessage); |
|
495 break; |
|
496 default: |
|
497 CPairingSubSession::DispatchSubSessMessageL(aMessage); |
|
498 break; |
|
499 } |
|
500 } |
|
501 |
|
502 void COobDataSession::ProvideParsedRemoteOobDataL(const RMessage2& aMessage) |
|
503 { |
|
504 LOG_FUNC |
|
505 |
|
506 TPckgBuf<TBTDevAddr> addrBuf; |
|
507 if(aMessage.GetDesLengthL(0) != sizeof(TBTDevAddr)) |
|
508 { |
|
509 LEAVEL(KErrBadDescriptor); |
|
510 } |
|
511 aMessage.ReadL(0, addrBuf); |
|
512 |
|
513 TBluetoothSimplePairingHash hash; |
|
514 if(aMessage.GetDesLengthL(1) != KBluetoothSimplePairingHashSize) |
|
515 { |
|
516 LEAVEL(KErrBadDescriptor); |
|
517 } |
|
518 aMessage.ReadL(1, hash); |
|
519 |
|
520 TBluetoothSimplePairingRandomizer randomizer; |
|
521 TInt len = aMessage.GetDesLength(2); |
|
522 if (len < KErrNone) // The randomizer wasn't available (which is fine...) |
|
523 { |
|
524 randomizer.FillZ(KBluetoothSimplePairingRandomizerSize); |
|
525 } |
|
526 else |
|
527 { |
|
528 if(len != KBluetoothSimplePairingRandomizerSize) |
|
529 { |
|
530 LEAVEL(KErrBadDescriptor); |
|
531 } |
|
532 aMessage.ReadL(2, randomizer); |
|
533 } |
|
534 |
|
535 TOobData oobData(addrBuf(), hash, randomizer); |
|
536 OobDataManager().ProvideRemoteOobDataL(oobData); |
|
537 aMessage.Complete(KErrNone); |
|
538 } |
|
539 |
|
540 void COobDataSession::ProvideRawRemoteOobDataL(const RMessage2& aMessage) |
|
541 { |
|
542 LOG_FUNC |
|
543 //Do a quick check to ensure there is at least enough data to get the BT address out. |
|
544 if(aMessage.GetDesLengthL(0) < KOOBOptionalDataOffset) |
|
545 User::Leave(KErrUnderflow); |
|
546 |
|
547 RBuf8 rawBuf; |
|
548 rawBuf.CreateL(aMessage.GetDesMaxLengthL(0)); |
|
549 rawBuf.CleanupClosePushL(); |
|
550 //Read the optional oob data to rawbuf so it can be parsed to the data block parser |
|
551 aMessage.ReadL(0, rawBuf, KOOBOptionalDataOffset); |
|
552 rawBuf.SetMax(); |
|
553 |
|
554 //We need to get the address out manually, EIR can't parse the address an no EIR device |
|
555 //address tag is defined. We are currently ignoring the length and anything other than |
|
556 //the pairing hash & randomizer. |
|
557 TBuf8<KBTDevAddrSize> addrBuf; |
|
558 aMessage.ReadL(0, addrBuf, KOOBBtAddrOffset); |
|
559 TBTDevAddr addr(addrBuf); |
|
560 |
|
561 //Any remaining data is optional and will be in EIR format so we can use the |
|
562 //EIR object to parse the data properly. |
|
563 TExtendedInquiryResponseDataCodec dataBlockParser(rawBuf); |
|
564 |
|
565 TPtrC8 hashBuf; |
|
566 LEAVEIFERRORL(dataBlockParser.GetData(EEirOobSimplePairingHash, hashBuf)); |
|
567 if(hashBuf.Length() != KBluetoothSimplePairingHashSize) |
|
568 { |
|
569 LEAVEL(KErrCorrupt); |
|
570 } |
|
571 TBluetoothSimplePairingHash hash(hashBuf); |
|
572 |
|
573 TPtrC8 randomizerBuf; |
|
574 TBluetoothSimplePairingRandomizer randomizer; |
|
575 TInt err = dataBlockParser.GetData(EEirOobSimplePairingRandomizerR, randomizerBuf); |
|
576 if(err < KErrNone) // The randomizer wasn't available (which is fine...) |
|
577 { |
|
578 randomizer.FillZ(KBluetoothSimplePairingRandomizerSize); |
|
579 } |
|
580 else |
|
581 { |
|
582 if(randomizerBuf.Length() != KBluetoothSimplePairingRandomizerSize) |
|
583 { |
|
584 LEAVEL(KErrCorrupt); |
|
585 } |
|
586 randomizer.Copy(randomizerBuf); |
|
587 } |
|
588 |
|
589 // Mark this line as intentional as coverity raises a false positive error that hash |
|
590 // has not been initalised even though it is set to hashBuf a few lines above. |
|
591 // coverity[uninit_use_in_call] |
|
592 TOobData oobData(addr, hash, randomizer); |
|
593 OobDataManager().ProvideRemoteOobDataL(oobData); |
|
594 |
|
595 CleanupStack::PopAndDestroy(&rawBuf); // finished with the backing buffer |
|
596 |
|
597 aMessage.Complete(KErrNone); |
|
598 } |
|
599 |
|
600 void COobDataSession::ClearRemoteOobDataL(const RMessage2& aMessage) |
|
601 { |
|
602 LOG_FUNC |
|
603 TPckgBuf<TBTDevAddr> addrBuf; |
|
604 if(aMessage.GetDesLengthL(0) != sizeof(TBTDevAddr)) |
|
605 { |
|
606 LEAVEL(KErrBadDescriptor); |
|
607 } |
|
608 aMessage.ReadL(0, addrBuf); |
|
609 |
|
610 OobDataManager().ClearRemoteOobData(addrBuf()); |
|
611 aMessage.Complete(KErrNone); |
|
612 } |
|
613 |
|
614 void COobDataSession::ReadLocalOobDataL(const RMessage2& aMessage) |
|
615 { |
|
616 LOG_FUNC |
|
617 if(iReadLocalOobDataMsg.Handle()) |
|
618 { |
|
619 aMessage.Panic(KPairingServerPanicCat, EPairingServerReadLocalOobDataOutstanding); |
|
620 return; |
|
621 } |
|
622 iReadLocalOobDataMsg = aMessage; // Remember which request to complete. |
|
623 OobDataManager().ReadLocalOobData(*this); |
|
624 } |
|
625 |
|
626 void COobDataSession::CancelReadLocalOobData(const RMessage2& aMessage) |
|
627 { |
|
628 LOG_FUNC |
|
629 TryCancelReadLocalOobData(); |
|
630 aMessage.Complete(KErrNone); |
|
631 } |
|
632 |
|
633 void COobDataSession::TryCancelReadLocalOobData() |
|
634 { |
|
635 LOG_FUNC |
|
636 if(iReadLocalOobDataMsg.Handle()) |
|
637 { |
|
638 OobDataManager().CancelReadLocalOobData(*this); |
|
639 } |
|
640 } |
|
641 |
|
642 |
|
643 void COobDataSession::XoldoLocalOobDataRetrieved(TInt aResult, const TBluetoothSimplePairingHash& aHash, const TBluetoothSimplePairingRandomizer& aRandomizer) |
|
644 { |
|
645 LOG_FUNC |
|
646 __ASSERT_DEBUG(iReadLocalOobDataMsg.Handle(), |
|
647 PANIC(KPairingServerFaultCat, EPairingServerNoMessageForObserverCompletion)); |
|
648 |
|
649 TInt err = aResult; |
|
650 if(err == KErrNone) |
|
651 { |
|
652 TRAP(err, LocalOobDataRetrievedL(aHash, aRandomizer)); |
|
653 } |
|
654 if(err == KErrBadDescriptor) |
|
655 { |
|
656 iReadLocalOobDataMsg.Panic(KPairingServerPanicCat, EPairingServerBadDescriptor); |
|
657 } |
|
658 else |
|
659 { |
|
660 iReadLocalOobDataMsg.Complete(err); |
|
661 } |
|
662 } |
|
663 |
|
664 void COobDataSession::LocalOobDataRetrievedL(const TBluetoothSimplePairingHash& aHash, const TBluetoothSimplePairingRandomizer& aRandomizer) |
|
665 { |
|
666 LOG_FUNC |
|
667 iReadLocalOobDataMsg.WriteL(0, aHash); |
|
668 iReadLocalOobDataMsg.WriteL(1, aRandomizer); |
|
669 } |
|
670 |
|
671 |
|
672 // |
|
673 // CDedicatedBondingSession |
|
674 // |
|
675 |
|
676 CDedicatedBondingSession* CDedicatedBondingSession::NewLC(CPairingSession& aSession, CPhysicalLinksManager& aPhysicalLinksManager) |
|
677 { |
|
678 LOG_STATIC_FUNC |
|
679 CDedicatedBondingSession* self = new(ELeave) CDedicatedBondingSession(aSession, aPhysicalLinksManager); |
|
680 //As its a CObject derived class so we should use CleanupClosePushL |
|
681 CleanupClosePushL(*self); |
|
682 self->ConstructL(); |
|
683 return self; |
|
684 } |
|
685 |
|
686 CDedicatedBondingSession::CDedicatedBondingSession(CPairingSession& aSession, CPhysicalLinksManager& aPhysicalLinksManager) |
|
687 : CPairingSubSession(aSession) |
|
688 , iPhysicalLinksManager(aPhysicalLinksManager) |
|
689 { |
|
690 LOG_FUNC |
|
691 } |
|
692 |
|
693 void CDedicatedBondingSession::ConstructL() |
|
694 { |
|
695 LOG_FUNC |
|
696 CPairingSubSession::ConstructL(); |
|
697 TCallBack cb(CDedicatedBondingSession::StaticShutdown, this); |
|
698 iAsyncShutdown = new(ELeave) CAsyncCallBack(cb, CActive::EPriorityStandard); |
|
699 } |
|
700 |
|
701 CDedicatedBondingSession::~CDedicatedBondingSession() |
|
702 { |
|
703 LOG_FUNC |
|
704 iPhysicalLinksManager.SecMan().CancelRequest(*this); |
|
705 delete iProxySap; |
|
706 if(iStartBondingMsg.Handle()) |
|
707 { |
|
708 iStartBondingMsg.Complete(KErrCancel); |
|
709 } |
|
710 delete iAsyncShutdown; |
|
711 } |
|
712 |
|
713 void CDedicatedBondingSession::DispatchSubSessMessageL(const RMessage2& aMessage) |
|
714 { |
|
715 LOG_FUNC |
|
716 switch(aMessage.Function()) |
|
717 { |
|
718 case EPairingServerStartDedicatedBond: |
|
719 StartBondingL(aMessage); |
|
720 break; |
|
721 default: |
|
722 CPairingSubSession::DispatchSubSessMessageL(aMessage); |
|
723 break; |
|
724 } |
|
725 } |
|
726 |
|
727 void CDedicatedBondingSession::Complete(TInt aError) |
|
728 { |
|
729 LOG_FUNC |
|
730 iState = EShutdown; |
|
731 iAsyncShutdown->CallBack(); |
|
732 iStartBondingMsg.Complete(aError); |
|
733 } |
|
734 |
|
735 TInt CDedicatedBondingSession::StaticShutdown(TAny* aDedBond) |
|
736 { |
|
737 LOG_STATIC_FUNC |
|
738 reinterpret_cast<CDedicatedBondingSession*>(aDedBond)->Shutdown(); |
|
739 return KErrNone; |
|
740 } |
|
741 |
|
742 void CDedicatedBondingSession::Shutdown() |
|
743 { |
|
744 LOG_FUNC |
|
745 __ASSERT_DEBUG(iState == EShutdown, PANIC(KPairingServerFaultCat, EPairingServerBadShutdownState)); |
|
746 iState = EInvalid; |
|
747 iProxySap->Shutdown(CServProviderBase::ENormal); |
|
748 } |
|
749 |
|
750 void CDedicatedBondingSession::StartBondingL(const RMessage2& aMessage) |
|
751 { |
|
752 LOG_FUNC |
|
753 |
|
754 if(!iStartBondingMsg.IsNull() || iState != EInvalid) |
|
755 { |
|
756 aMessage.Panic(KPairingServerPanicCat, EPairingServerDedicatedBondAlreadyInProgress); |
|
757 return; |
|
758 } |
|
759 |
|
760 TPckgBuf<TBTDevAddr> addrBuf; |
|
761 TInt addrLen = aMessage.GetDesLengthL(0); |
|
762 if(addrLen != sizeof(TBTDevAddr)) |
|
763 { |
|
764 // If the length is correct then the address has been packaged incorrect for the |
|
765 // IPC operation. |
|
766 LEAVEL(KErrBadDescriptor); |
|
767 } |
|
768 aMessage.ReadL(0, addrBuf); |
|
769 |
|
770 iStartBondingMsg = aMessage; |
|
771 CleanupStack::PushL(TCleanupItem(CleanupStartMessage, this)); |
|
772 |
|
773 TBTSockAddr addr; |
|
774 addr.SetBTAddr(addrBuf()); |
|
775 iProxySap = CBTProxySAP::NewL(iPhysicalLinksManager, NULL); |
|
776 |
|
777 CleanupStack::Pop(this); // the start message cleaner |
|
778 |
|
779 iState = EInitialConnectionPending; |
|
780 iProxySap->SetNotify(this); |
|
781 iProxySap->SetRemName(addr); |
|
782 iProxySap->ActiveOpen(); |
|
783 } |
|
784 |
|
785 void CDedicatedBondingSession::CleanupStartMessage(TAny* aPtr) |
|
786 { |
|
787 LOG_STATIC_FUNC |
|
788 CDedicatedBondingSession* session = reinterpret_cast<CDedicatedBondingSession*>(aPtr); |
|
789 session->iStartBondingMsg = RMessage2(); // blat the old one |
|
790 } |
|
791 |
|
792 void CDedicatedBondingSession::DoAccessRequestL() |
|
793 { |
|
794 LOG_FUNC |
|
795 TBTServiceSecurity security; |
|
796 security.SetAuthentication(EMitmDesired); |
|
797 security.SetUid(KBluetoothDedicatedBondingUid); |
|
798 |
|
799 iPhysicalLinksManager.SecMan().AccessRequestL(security, NULL, iProxySap->RemoteAddress(), EDedicatedBonding, *this); |
|
800 } |
|
801 |
|
802 void CDedicatedBondingSession::AccessRequestComplete(TInt aResult) |
|
803 { |
|
804 LOG_FUNC |
|
805 TInt err = aResult; |
|
806 TBool completed = EFalse; |
|
807 TBTSockAddr addr; |
|
808 switch (iState) |
|
809 { |
|
810 case EZombie: |
|
811 // Ready for a retry. |
|
812 if(aResult == EBTSecManAccessDeferred) |
|
813 { |
|
814 iState = EFinalConnectionPending; |
|
815 addr.SetBTAddr(iProxySap->RemoteAddress()); |
|
816 iProxySap->SetRemName(addr); // triggers finding a link again. |
|
817 iProxySap->ActiveOpen(); |
|
818 break; |
|
819 } |
|
820 // else not deferred so complete now.... |
|
821 // fall-through... |
|
822 case EInitialConnection: |
|
823 ASSERT_DEBUG(aResult != EBTSecManAccessDeferred); // Should have been disconnected if we receive |
|
824 // this - I don't expect this to happen. |
|
825 // fall-through... |
|
826 case EFinalConnection: |
|
827 completed = ETrue; // in the final connection any complete is errored. |
|
828 if(aResult == EBTSecManAccessDenied) |
|
829 { |
|
830 err = KErrAccessDenied; |
|
831 } |
|
832 break; |
|
833 default: |
|
834 LOG1(_L("Unexpected Access Request Complete in state %d"), iState); |
|
835 __ASSERT_DEBUG(EFalse, PANIC(KPairingServerFaultCat, EPairingServerUnexpectedAccessCallback)); |
|
836 break; |
|
837 } |
|
838 |
|
839 if (completed) |
|
840 { |
|
841 Complete(err); |
|
842 } |
|
843 } |
|
844 |
|
845 void CDedicatedBondingSession::NewData(TUint /*aCount*/) |
|
846 { |
|
847 LOG_FUNC |
|
848 // We aren't using a raw conduit |
|
849 __ASSERT_DEBUG(EFalse, PANIC(KPairingServerFaultCat, EPairingServerUnexpectedSocketCallback)); |
|
850 } |
|
851 |
|
852 void CDedicatedBondingSession::CanSend() |
|
853 { |
|
854 LOG_FUNC |
|
855 // We aren't using a raw conduit |
|
856 __ASSERT_DEBUG(EFalse, PANIC(KPairingServerFaultCat, EPairingServerUnexpectedSocketCallback)); |
|
857 } |
|
858 |
|
859 void CDedicatedBondingSession::ConnectCompleteL() |
|
860 { |
|
861 LOG_FUNC |
|
862 switch(iState) |
|
863 { |
|
864 case EInitialConnectionPending: |
|
865 iState = EInitialConnection; |
|
866 DoAccessRequestL(); |
|
867 break; |
|
868 case EFinalConnectionPending: |
|
869 iState = EFinalConnection; |
|
870 DoAccessRequestL(); |
|
871 break; |
|
872 case EInitialConnection: |
|
873 case EFinalConnection: |
|
874 // Apparently multiple connect completes are allowed by CSocket |
|
875 break; |
|
876 default: |
|
877 LOG1(_L("Unexpected Connect Complete in state %d"), iState); |
|
878 __ASSERT_DEBUG(EFalse, PANIC(KPairingServerFaultCat, EPairingServerUnexpectedSocketCallback)); |
|
879 break; |
|
880 } |
|
881 } |
|
882 |
|
883 void CDedicatedBondingSession::ConnectComplete() |
|
884 { |
|
885 LOG_FUNC |
|
886 TRAPD(err, ConnectCompleteL()); |
|
887 if(err != KErrNone) |
|
888 { |
|
889 Error(err); |
|
890 } |
|
891 } |
|
892 |
|
893 void CDedicatedBondingSession::ConnectComplete(const TDesC8& /*aConnectData*/) |
|
894 { |
|
895 LOG_FUNC |
|
896 ConnectComplete(); // Connection data isn't useful for us. |
|
897 } |
|
898 |
|
899 void CDedicatedBondingSession::ConnectComplete(CServProviderBase& /*aSSP*/) |
|
900 { |
|
901 LOG_FUNC |
|
902 // ProxySAPs aren't used for passive connections. |
|
903 __ASSERT_DEBUG(EFalse, PANIC(KPairingServerFaultCat, EPairingServerUnexpectedSocketCallback)); |
|
904 } |
|
905 |
|
906 void CDedicatedBondingSession::ConnectComplete(CServProviderBase& /*aSSP*/, const TDesC8& /*aConnectData*/) |
|
907 { |
|
908 LOG_FUNC |
|
909 // ProxySAPs aren't used for passive connections. |
|
910 __ASSERT_DEBUG(EFalse, PANIC(KPairingServerFaultCat, EPairingServerUnexpectedSocketCallback)); |
|
911 } |
|
912 |
|
913 void CDedicatedBondingSession::CanClose(TDelete aDelete) |
|
914 { |
|
915 LOG_FUNC |
|
916 if (aDelete == EDelete) |
|
917 { |
|
918 delete iProxySap; iProxySap = NULL; |
|
919 } |
|
920 } |
|
921 |
|
922 void CDedicatedBondingSession::CanClose(const TDesC8& /*aDisconnectData*/, TDelete aDelete) |
|
923 { |
|
924 LOG_FUNC |
|
925 CanClose(aDelete); |
|
926 } |
|
927 |
|
928 void CDedicatedBondingSession::Error(TInt aError, TUint /*anOperationMask*/) |
|
929 { |
|
930 LOG_FUNC |
|
931 Complete(aError); |
|
932 } |
|
933 |
|
934 void CDedicatedBondingSession::Disconnect() |
|
935 { |
|
936 LOG_FUNC |
|
937 switch (iState) |
|
938 { |
|
939 case EInitialConnection: |
|
940 // enter the zombie state and wait for the access requester to complete. |
|
941 iState = EZombie; |
|
942 break; |
|
943 case EFinalConnection: |
|
944 Error(KErrDisconnected); |
|
945 break; |
|
946 case EShutdown: |
|
947 // Already closing down. |
|
948 break; |
|
949 default: |
|
950 LOG1(_L("Unexpected Disconnect in state %d"), iState); |
|
951 __ASSERT_DEBUG(EFalse, PANIC(KPairingServerFaultCat, EPairingServerUnexpectedSocketCallback)); |
|
952 break; |
|
953 } |
|
954 } |
|
955 |
|
956 void CDedicatedBondingSession::Disconnect(TDesC8& /*aDisconnectData*/) |
|
957 { |
|
958 LOG_FUNC |
|
959 Disconnect(); |
|
960 } |
|
961 |
|
962 void CDedicatedBondingSession::IoctlComplete(TDesC8* /*aBuf*/) |
|
963 { |
|
964 LOG_FUNC |
|
965 __ASSERT_DEBUG(EFalse, PANIC(KPairingServerFaultCat, EPairingServerUnexpectedSocketCallback)); |
|
966 } |
|
967 |
|
968 void CDedicatedBondingSession::NoBearer(const TDesC8& /*aConnectionParams*/) |
|
969 { |
|
970 LOG_FUNC |
|
971 // No idea what this is for and proxy sap never calls it... so as far as I'm concerned it's |
|
972 // unexpected. |
|
973 __ASSERT_DEBUG(EFalse, PANIC(KPairingServerFaultCat, EPairingServerUnexpectedSocketCallback)); |
|
974 } |
|
975 |
|
976 void CDedicatedBondingSession::Bearer(const TDesC8& /*aConnectionInfo*/) |
|
977 { |
|
978 LOG_FUNC |
|
979 // No idea what this is for and proxy sap never calls it... so as far as I'm concerned it's |
|
980 // unexpected. |
|
981 __ASSERT_DEBUG(EFalse, PANIC(KPairingServerFaultCat, EPairingServerUnexpectedSocketCallback)); |
|
982 } |
|
983 |
|
984 |
|
985 // |
|
986 // CSimplePairingResultSession |
|
987 // |
|
988 |
|
989 CSimplePairingResultSession* CSimplePairingResultSession::NewLC(CPairingSession& aSession, CSimplePairingResultList& aResultList) |
|
990 { |
|
991 LOG_STATIC_FUNC |
|
992 CSimplePairingResultSession* self = new(ELeave) CSimplePairingResultSession(aSession, aResultList); |
|
993 //As its a CObject derived class so we should use CleanupClosePushL |
|
994 CleanupClosePushL(*self); |
|
995 self->ConstructL(); |
|
996 return self; |
|
997 } |
|
998 |
|
999 CSimplePairingResultSession::CSimplePairingResultSession(CPairingSession& aSession, CSimplePairingResultList& aResultList) |
|
1000 : CPairingSubSession(aSession) |
|
1001 , iResultList(aResultList) |
|
1002 { |
|
1003 LOG_FUNC |
|
1004 } |
|
1005 |
|
1006 void CSimplePairingResultSession::ConstructL() |
|
1007 { |
|
1008 LOG_FUNC |
|
1009 CPairingSubSession::ConstructL(); |
|
1010 iResultList.RegisterObserverL(*this); |
|
1011 } |
|
1012 |
|
1013 CSimplePairingResultSession::~CSimplePairingResultSession() |
|
1014 { |
|
1015 LOG_FUNC |
|
1016 iResultList.ReleaseObserver(*this); |
|
1017 if(!iResultMsg.IsNull()) |
|
1018 { |
|
1019 iResultMsg.Complete(KErrCancel); |
|
1020 } |
|
1021 } |
|
1022 |
|
1023 void CSimplePairingResultSession::DispatchSubSessMessageL(const RMessage2& aMessage) |
|
1024 { |
|
1025 LOG_FUNC |
|
1026 switch(aMessage.Function()) |
|
1027 { |
|
1028 case EPairingServerSimplePairingResult: |
|
1029 SimplePairingResultL(aMessage); |
|
1030 break; |
|
1031 case EPairingServerCancelSimplePairingResult: |
|
1032 CancelSimplePairingResult(aMessage); |
|
1033 break; |
|
1034 default: |
|
1035 CPairingSubSession::DispatchSubSessMessageL(aMessage); |
|
1036 break; |
|
1037 } |
|
1038 } |
|
1039 |
|
1040 void CSimplePairingResultSession::SimplePairingResultL(const RMessage2& aMessage) |
|
1041 { |
|
1042 LOG_FUNC |
|
1043 |
|
1044 TPckgBuf<TBTDevAddr> addrBuf; |
|
1045 if(aMessage.GetDesMaxLengthL(0) != sizeof(TBTDevAddr)) |
|
1046 { |
|
1047 LEAVEL(KErrBadDescriptor); |
|
1048 } |
|
1049 |
|
1050 if(!iResultMsg.IsNull()) |
|
1051 { |
|
1052 LEAVEL(KErrInUse); |
|
1053 } |
|
1054 |
|
1055 iResultMsg = aMessage; |
|
1056 iResultList.ReturnResult(); |
|
1057 } |
|
1058 |
|
1059 void CSimplePairingResultSession::CancelSimplePairingResult(const RMessage2& aMessage) |
|
1060 { |
|
1061 LOG_FUNC |
|
1062 if(!iResultMsg.IsNull()) |
|
1063 { |
|
1064 iResultList.CancelReturn(); |
|
1065 iResultMsg.Complete(KErrCancel); |
|
1066 } |
|
1067 aMessage.Complete(KErrNone); |
|
1068 } |
|
1069 |
|
1070 TInt CSimplePairingResultSession::MbsroResult(const TBTDevAddr& aDevAddr, TInt aResult) |
|
1071 { |
|
1072 LOG_FUNC |
|
1073 __ASSERT_DEBUG(iResultMsg.Handle(), |
|
1074 PANIC(KPairingServerFaultCat, EPairingServerNoMessageForObserverCompletion)); |
|
1075 |
|
1076 TRAPD(err, ReturnResultL(aDevAddr)); |
|
1077 if(err == KErrBadDescriptor) |
|
1078 { |
|
1079 iResultMsg.Panic(KPairingServerPanicCat, EPairingServerBadDescriptor); |
|
1080 } |
|
1081 else if(err != KErrNone) |
|
1082 { |
|
1083 iResultMsg.Complete(err); |
|
1084 } |
|
1085 else |
|
1086 { |
|
1087 iResultMsg.Complete(aResult); |
|
1088 } |
|
1089 return err; |
|
1090 } |
|
1091 |
|
1092 void CSimplePairingResultSession::ReturnResultL(const TBTDevAddr& aDevAddr) |
|
1093 { |
|
1094 LOG_FUNC |
|
1095 TPckg<TBTDevAddr> pckg(aDevAddr); |
|
1096 iResultMsg.WriteL(0, pckg); |
|
1097 } |
|
1098 |
|
1099 |
|
1100 // |
|
1101 // CAuthenticationResultSession |
|
1102 // |
|
1103 |
|
1104 CAuthenticationResultSession* CAuthenticationResultSession::NewLC(CPairingSession& aSession, CAuthenticationResultList& aResultList) |
|
1105 { |
|
1106 LOG_STATIC_FUNC |
|
1107 CAuthenticationResultSession* self = new(ELeave) CAuthenticationResultSession(aSession, aResultList); |
|
1108 //As its a CObject derived class so we should use CleanupClosePushL |
|
1109 CleanupClosePushL(*self); |
|
1110 self->ConstructL(); |
|
1111 return self; |
|
1112 } |
|
1113 |
|
1114 CAuthenticationResultSession::CAuthenticationResultSession(CPairingSession& aSession, CAuthenticationResultList& aResultList) |
|
1115 : CPairingSubSession(aSession) |
|
1116 , iResultList(aResultList) |
|
1117 { |
|
1118 LOG_FUNC |
|
1119 } |
|
1120 |
|
1121 void CAuthenticationResultSession::ConstructL() |
|
1122 { |
|
1123 LOG_FUNC |
|
1124 CPairingSubSession::ConstructL(); |
|
1125 iResultList.RegisterObserverL(*this); |
|
1126 } |
|
1127 |
|
1128 CAuthenticationResultSession::~CAuthenticationResultSession() |
|
1129 { |
|
1130 LOG_FUNC |
|
1131 iResultList.ReleaseObserver(*this); |
|
1132 if(!iResultMsg.IsNull()) |
|
1133 { |
|
1134 iResultMsg.Complete(KErrCancel); |
|
1135 } |
|
1136 } |
|
1137 |
|
1138 void CAuthenticationResultSession::DispatchSubSessMessageL(const RMessage2& aMessage) |
|
1139 { |
|
1140 LOG_FUNC |
|
1141 switch(aMessage.Function()) |
|
1142 { |
|
1143 case EPairingServerAuthenticationResult: |
|
1144 AuthenticationResultL(aMessage); |
|
1145 break; |
|
1146 case EPairingServerCancelAuthenticationResult: |
|
1147 CancelAuthenticationResult(aMessage); |
|
1148 break; |
|
1149 default: |
|
1150 CPairingSubSession::DispatchSubSessMessageL(aMessage); |
|
1151 break; |
|
1152 } |
|
1153 } |
|
1154 |
|
1155 void CAuthenticationResultSession::AuthenticationResultL(const RMessage2& aMessage) |
|
1156 { |
|
1157 LOG_FUNC |
|
1158 |
|
1159 TPckgBuf<TBTDevAddr> addrBuf; |
|
1160 if(aMessage.GetDesMaxLengthL(0) != sizeof(TBTDevAddr)) |
|
1161 { |
|
1162 LEAVEL(KErrBadDescriptor); |
|
1163 } |
|
1164 |
|
1165 if(!iResultMsg.IsNull()) |
|
1166 { |
|
1167 LEAVEL(KErrInUse); |
|
1168 } |
|
1169 |
|
1170 iResultMsg = aMessage; |
|
1171 iResultList.ReturnResult(); |
|
1172 } |
|
1173 |
|
1174 void CAuthenticationResultSession::CancelAuthenticationResult(const RMessage2& aMessage) |
|
1175 { |
|
1176 LOG_FUNC |
|
1177 if(!iResultMsg.IsNull()) |
|
1178 { |
|
1179 iResultList.CancelReturn(); |
|
1180 iResultMsg.Complete(KErrCancel); |
|
1181 } |
|
1182 aMessage.Complete(KErrNone); |
|
1183 } |
|
1184 |
|
1185 TInt CAuthenticationResultSession::MbsroResult(const TBTDevAddr& aDevAddr, TInt aResult) |
|
1186 { |
|
1187 LOG_FUNC |
|
1188 __ASSERT_DEBUG(iResultMsg.Handle(), |
|
1189 PANIC(KPairingServerFaultCat, EPairingServerNoMessageForObserverCompletion)); |
|
1190 |
|
1191 TRAPD(err, ReturnResultL(aDevAddr)); |
|
1192 if(err == KErrBadDescriptor) |
|
1193 { |
|
1194 iResultMsg.Panic(KPairingServerPanicCat, EPairingServerBadDescriptor); |
|
1195 } |
|
1196 else if(err != KErrNone) |
|
1197 { |
|
1198 iResultMsg.Complete(err); |
|
1199 } |
|
1200 else |
|
1201 { |
|
1202 iResultMsg.Complete(aResult); |
|
1203 } |
|
1204 return err; |
|
1205 } |
|
1206 |
|
1207 void CAuthenticationResultSession::ReturnResultL(const TBTDevAddr& aDevAddr) |
|
1208 { |
|
1209 LOG_FUNC |
|
1210 TPckg<TBTDevAddr> pckg(aDevAddr); |
|
1211 iResultMsg.WriteL(0, pckg); |
|
1212 } |
|
1213 |
|
1214 |