41 |
40 |
42 #ifdef _DEBUG |
41 #ifdef _DEBUG |
43 PANICCATEGORY("session"); |
42 PANICCATEGORY("session"); |
44 #endif |
43 #endif |
45 |
44 |
46 CRemConSession* CRemConSession::NewL(CRemConServer& aServer, |
|
47 CBearerManager& aBearerManager, |
|
48 const RMessage2& aMessage, |
|
49 TUint aId) |
|
50 { |
|
51 LOG_STATIC_FUNC |
|
52 CRemConSession* self = new(ELeave) CRemConSession(aServer, aBearerManager, aId); |
|
53 CleanupStack::PushL(self); |
|
54 self->ConstructL(aMessage); |
|
55 CLEANUPSTACK_POP1(self); |
|
56 return self; |
|
57 } |
|
58 |
45 |
59 CRemConSession::CRemConSession(CRemConServer& aServer, |
46 CRemConSession::CRemConSession(CRemConServer& aServer, |
60 CBearerManager& aBearerManager, |
47 CBearerManager& aBearerManager, |
61 TUint aId) |
48 TUint aId) |
62 : iServer(aServer), |
49 : iServer(aServer), |
63 iBearerManager(aBearerManager), |
50 iBearerManager(aBearerManager), |
64 iId(aId) |
51 iId(aId) |
65 { |
52 { |
66 LOG_FUNC |
53 LOG_FUNC; |
67 } |
54 } |
68 |
55 |
69 void CRemConSession::ConstructL(const RMessage2& aMessage) |
56 void CRemConSession::BaseConstructL(const TClientInfo& aClientInfo) |
70 { |
57 { |
71 LOG_FUNC; |
58 LOG_FUNC; |
72 |
59 |
73 // Get the client's process ID. |
60 iClientInfo = aClientInfo; |
74 RThread thread; |
|
75 LEAVEIFERRORL(aMessage.Client(thread)); |
|
76 CleanupClosePushL(thread); |
|
77 RProcess process; |
|
78 LEAVEIFERRORL(thread.Process(process)); |
|
79 iClientInfo.ProcessId() = process.Id(); |
|
80 process.Close(); |
|
81 iClientInfo.SecureId() = thread.SecureId(); |
|
82 CleanupStack::PopAndDestroy(&thread); |
|
83 |
61 |
84 iSendQueue = CMessageQueue::NewL(); |
62 iSendQueue = CMessageQueue::NewL(); |
85 |
63 |
|
64 // The send callback is used by the base class to handle queued sends. |
|
65 iSendNextCallBack = new(ELeave) CAsyncCallBack(CActive::EPriorityStandard); |
86 TCallBack cb(SendNextCb, this); |
66 TCallBack cb(SendNextCb, this); |
87 |
67 iSendNextCallBack->Set(cb); |
88 iSendNextCallBack = new(ELeave) CAsyncCallBack(cb, CActive::EPriorityStandard); |
68 |
89 |
|
90 // Tell the server about us. |
|
91 LEAVEIFERRORL(iServer.ClientOpened(*this)); |
|
92 |
|
93 // Set our pointer into the connection history at the current/'Last' item. |
|
94 iServer.SetConnectionHistoryPointer(Id()); |
|
95 |
|
96 iPendingMsgProcessor = new (ELeave) CActiveHelper(*this); |
|
97 } |
69 } |
98 |
70 |
99 CRemConSession::~CRemConSession() |
71 CRemConSession::~CRemConSession() |
100 { |
72 { |
101 LOG(KNullDesC8); |
73 LOG(KNullDesC8); |
102 LOG_FUNC; |
74 LOG_FUNC; |
103 |
75 |
104 delete iPendingMsgProcessor; |
|
105 delete iSendNextCallBack; |
76 delete iSendNextCallBack; |
106 delete iSendQueue; |
77 delete iSendQueue; |
107 // we will need to tell the server which bearer this used to be connected to |
|
108 // this enables the server to not inform a bearer that is already connected |
|
109 // that its been connected |
|
110 // Tell the server we've gone away- it may start its shutdown timer. |
|
111 iServer.ClientClosed(*this, iRemoteAddress.BearerUid()); |
|
112 delete iInterestedAPIs; |
78 delete iInterestedAPIs; |
113 iPlayerName.Close(); |
|
114 } |
79 } |
115 |
80 |
116 void CRemConSession::ServiceL(const RMessage2& aMessage) |
81 void CRemConSession::ServiceL(const RMessage2& aMessage) |
117 { |
82 { |
118 LOG(KNullDesC8); |
83 LOG(KNullDesC8); |
119 LOG_FUNC; |
84 LOG_FUNC; |
120 LOG1(_L("\taMessage.Function() = %d"), aMessage.Function()); |
85 LOG1(_L("\taMessage.Function() = %d"), aMessage.Function()); |
121 |
|
122 // Switch on the IPC number and call a 'message handler'. Message handlers |
86 // Switch on the IPC number and call a 'message handler'. Message handlers |
123 // complete aMessage (either with Complete or Panic), or make a note of |
87 // complete aMessage (either with Complete or Panic), or make a note of |
124 // the message for later asynchronous completion. |
88 // the message for later asynchronous completion. |
125 // Message handlers should not leave- the server does not have an Error |
89 // Message handlers should not leave- the server does not have an Error |
126 // function. |
90 // function. |
271 { |
235 { |
272 iClientInfo.Message() = RMessage2(); |
236 iClientInfo.Message() = RMessage2(); |
273 } |
237 } |
274 } |
238 } |
275 |
239 |
276 void CRemConSession::SetClientType(const RMessage2& aMessage) |
240 void CRemConSession::GetPlayerTypeAndNameL(const RMessage2& aMessage, TPlayerTypeInformation& aPlayerType, RBuf8& aPlayerName) |
277 { |
241 { |
278 LOG_FUNC; |
242 // check validity of descriptors |
279 |
243 if (aMessage.GetDesLength(1) < 0 || aMessage.GetDesLength(2) < 0) |
280 if ( iType != ERemConClientTypeUndefined ) |
244 { |
281 { |
245 LEAVEL(KErrBadDescriptor); |
282 PANIC_MSG(aMessage, KRemConClientPanicCat, ERemConClientPanicClientTypeAlreadySet); |
246 } |
283 return; |
247 |
284 } |
248 // Retrieve and validate the client type information |
285 |
249 TPckg<TPlayerTypeInformation> pckg(aPlayerType); |
286 const TRemConClientType type = static_cast<TRemConClientType>(aMessage.Int0()); |
250 aMessage.ReadL(1, pckg); |
287 LOG1(_L("\trequested (TRemConClientType) type = %d"), type); |
251 switch (aPlayerType.iPlayerType) |
288 |
252 { |
289 TInt err = aMessage.GetDesLength(1); |
253 case ERemConAudioPlayer: |
290 if(err >= 0) |
254 // Valid |
291 { |
255 case ERemConVideoPlayer: |
292 TRAP(err, DoSetClientTypeL(aMessage)); |
256 // Valid |
293 if(err == KErrBadDescriptor) |
257 case ERemConBroadcastingAudioPlayer: |
294 { |
258 // Valid |
295 PANIC_MSG(aMessage, KRemConClientPanicCat, ERemConClientPanicBadDescriptor); |
259 case ERemConBroadcastingVideoPlayer: |
296 return; |
260 // Valid |
297 } |
261 break; |
298 } |
262 default: |
299 else if(err == KErrBadDescriptor) |
263 // Invalid |
300 { |
264 LEAVEL(KErrArgument); |
301 // The additional parameters are optional (i.e. old or controller clients won't provide them). |
265 } |
302 err = KErrNone; |
266 switch (aPlayerType.iPlayerSubType) |
303 } |
267 { |
304 |
268 case ERemConNoSubType: |
305 if(err != KErrNone) |
269 // Valid |
306 { |
270 case ERemConAudioBook: |
307 CompleteClient(aMessage, err); |
271 // Valid |
308 } |
272 case ERemConPodcast: |
309 else |
273 // Valid |
310 { |
274 break; |
311 switch ( type ) |
275 default: |
312 { |
276 // Invalid |
313 case ERemConClientTypeController: |
277 LEAVEL(KErrArgument); |
314 iType = type; |
278 } |
315 CompleteClient(aMessage, KErrNone); |
279 |
316 break; |
|
317 |
|
318 case ERemConClientTypeTarget: |
|
319 // Check that there aren't already any target clients with the |
|
320 // same process ID. |
|
321 if ( !iServer.TargetClientWithSameProcessId(iClientInfo.ProcessId()) ) |
|
322 { |
|
323 iType = type; |
|
324 CompleteClient(aMessage, KErrNone); |
|
325 } |
|
326 else |
|
327 { |
|
328 CompleteClient(aMessage, KErrInUse); |
|
329 } |
|
330 break; |
|
331 |
|
332 default: |
|
333 PANIC_MSG(aMessage, KRemConClientPanicCat, ERemConClientPanicBadType); |
|
334 break; |
|
335 } |
|
336 } |
|
337 |
|
338 if ( iType != ERemConClientTypeUndefined ) |
|
339 { |
|
340 // The type got set, so tell the server, so it can tell the bearers if |
|
341 // necessary. |
|
342 iServer.ClientTypeSet(*this); |
|
343 } |
|
344 } |
|
345 |
|
346 void CRemConSession::DoSetClientTypeL(const RMessage2& aMessage) |
|
347 { |
|
348 // Retrieve the client type information |
|
349 RBuf8 typeBuf; |
|
350 typeBuf.CreateL(sizeof(TPlayerTypeInformation)); |
|
351 CleanupClosePushL(typeBuf); |
|
352 aMessage.ReadL(1, typeBuf); |
|
353 |
|
354 const TPlayerTypeInformation* Ptr = reinterpret_cast<const TPlayerTypeInformation*> (typeBuf.Ptr()); |
|
355 iPlayerType.iPlayerType = (*Ptr).iPlayerType; |
|
356 iPlayerType.iPlayerSubType = (*Ptr).iPlayerSubType; |
|
357 // Retrieve the client player name inforamtion |
280 // Retrieve the client player name inforamtion |
358 iPlayerName.CreateL(aMessage.Int2()); |
281 aPlayerName.CreateL(aMessage.GetDesLengthL(2)); |
359 CleanupClosePushL(iPlayerName); |
282 CleanupClosePushL(aPlayerName); |
360 aMessage.ReadL(3, iPlayerName); |
283 aMessage.ReadL(2, aPlayerName); |
361 CleanupStack::Pop(&iPlayerName); |
284 CleanupStack::Pop(&aPlayerName); |
362 |
|
363 CleanupStack::PopAndDestroy(&typeBuf); |
|
364 } |
|
365 void CRemConSession::GoConnectionOriented(const RMessage2& aMessage) |
|
366 { |
|
367 LOG_FUNC; |
|
368 |
|
369 // Check we've had our type set... |
|
370 if ( iType != ERemConClientTypeController ) |
|
371 { |
|
372 PANIC_MSG(aMessage, KRemConClientPanicCat, ERemConClientPanicBadType); |
|
373 return; |
|
374 } |
|
375 |
|
376 if ( !iRemoteAddress.IsNull() ) |
|
377 { |
|
378 PANIC_MSG(aMessage, KRemConClientPanicCat, ERemConClientPanicAlreadyConnectionOriented); |
|
379 return; |
|
380 } |
|
381 |
|
382 if ( iConnectBearerMsg.Handle() || iDisconnectBearerMsg.Handle() || iSendMsg.Handle()) |
|
383 { |
|
384 PANIC_MSG(aMessage, KRemConClientPanicCat, ERemConClientPanicBearerControlOutstanding); |
|
385 return; |
|
386 } |
|
387 if (iSending != ENotSending) |
|
388 { |
|
389 DoSendCancel(); |
|
390 } |
|
391 EmptySendQueue(); |
|
392 |
|
393 // Get the desired address from the message and check it. |
|
394 const TUid uid = TUid::Uid(aMessage.Int0()); |
|
395 LOG1(_L("\tuid = 0x%08x"), uid); |
|
396 // Check the requested bearer exists. |
|
397 TBool bearerExists = iBearerManager.BearerExists(uid); |
|
398 if ( !bearerExists) |
|
399 { |
|
400 PANIC_MSG(aMessage, KRemConClientPanicCat, ERemConClientPanicBearerPluginIncorrectInterface); |
|
401 return; |
|
402 } |
|
403 // Check the bearer-specific part of the address. |
|
404 TBuf8<TRemConAddress::KMaxAddrSize> buf; |
|
405 TInt err = aMessage.Read(1, buf); |
|
406 if ( err != KErrNone ) |
|
407 { |
|
408 PANIC_MSG(aMessage, KRemConClientPanicCat, ERemConClientPanicBadDescriptor); |
|
409 return; |
|
410 } |
|
411 |
|
412 // Do security check- if this client won't be allowed to use the bearer |
|
413 // then fail the request. |
|
414 // NB This security check (repeated in debug at ConnectBearer and |
|
415 // DisconnectBearer time) is all that stands between a connection-oriented |
|
416 // client and the bearer, and is all the caps checking that RemCon does! |
|
417 err = KErrPermissionDenied; |
|
418 if ( iBearerManager.CheckPolicy(uid, aMessage) ) |
|
419 { |
|
420 err = KErrNone; |
|
421 } |
|
422 |
|
423 |
|
424 // if alls well and we're connection oriented then set up as such |
|
425 if (KErrNone == err) |
|
426 { |
|
427 // The client has passed all our checks- set our data member. |
|
428 iRemoteAddress.BearerUid() = uid; |
|
429 iRemoteAddress.Addr() = buf; |
|
430 // tell the server |
|
431 iServer.ClientGoConnectionOriented(*this,uid); |
|
432 } |
|
433 |
|
434 CompleteClient(aMessage, err); |
|
435 } |
|
436 |
|
437 void CRemConSession::GoConnectionless(const RMessage2& aMessage) |
|
438 { |
|
439 LOG_FUNC; |
|
440 |
|
441 // Check we've had our type set... |
|
442 if ( iType != ERemConClientTypeController ) |
|
443 { |
|
444 PANIC_MSG(aMessage, KRemConClientPanicCat, ERemConClientPanicBadType); |
|
445 return; |
|
446 } |
|
447 |
|
448 if ( iRemoteAddress.IsNull() ) |
|
449 { |
|
450 PANIC_MSG(aMessage, KRemConClientPanicCat, ERemConClientPanicNotConnectionOriented); |
|
451 return; |
|
452 } |
|
453 |
|
454 if ( iConnectBearerMsg.Handle() || iDisconnectBearerMsg.Handle() || iSendMsg.Handle()) |
|
455 { |
|
456 PANIC_MSG(aMessage, KRemConClientPanicCat, ERemConClientPanicBearerControlOutstanding); |
|
457 return; |
|
458 } |
|
459 |
|
460 if (iSending != ENotSending) |
|
461 { |
|
462 DoSendCancel(); |
|
463 } |
|
464 EmptySendQueue(); |
|
465 |
|
466 // we will need to tell the server which bearer this used to be connected to |
|
467 // this enables the server to not inform a bearer that is already connected |
|
468 // that its been connected |
|
469 TUid oldUid = iRemoteAddress.BearerUid(); |
|
470 |
|
471 iRemoteAddress.BearerUid() = KNullUid; |
|
472 |
|
473 // tell the server |
|
474 iServer.ClientGoConnectionless(*this, oldUid); |
|
475 |
|
476 CompleteClient(aMessage, KErrNone); |
|
477 } |
|
478 |
|
479 void CRemConSession::ConnectBearer(const RMessage2& aMessage) |
|
480 { |
|
481 LOG_FUNC; |
|
482 |
|
483 if ( iType != ERemConClientTypeController ) |
|
484 { |
|
485 PANIC_MSG(aMessage, KRemConClientPanicCat, ERemConClientPanicBadType); |
|
486 return; |
|
487 } |
|
488 |
|
489 if ( iConnectBearerMsg.Handle() || iDisconnectBearerMsg.Handle() ) |
|
490 { |
|
491 PANIC_MSG(aMessage, KRemConClientPanicCat, ERemConClientPanicBearerControlOutstanding); |
|
492 return; |
|
493 } |
|
494 |
|
495 if ( iRemoteAddress.IsNull() ) |
|
496 { |
|
497 PANIC_MSG(aMessage, KRemConClientPanicCat, ERemConClientPanicNotConnectionOriented); |
|
498 return; |
|
499 } |
|
500 |
|
501 // Check the requested bearer exists. |
|
502 TBool bearerExists = iBearerManager.BearerExists(iRemoteAddress.BearerUid()); |
|
503 // This check was done at GoConnectionOriented time. |
|
504 ASSERT_DEBUG(bearerExists); |
|
505 // So was this one. |
|
506 ASSERT_DEBUG(iBearerManager.CheckPolicy(iRemoteAddress.BearerUid(), aMessage)); |
|
507 |
|
508 // Check the state of our given connection at the bearer level. If it is: |
|
509 // -) disconnected request the connection to come up, |
|
510 // -) connecting or disconnecting, add message to the queue of pending |
|
511 // messages, and process it once connecting/disconnecting has been completed |
|
512 // -) connected, complete the client's message, |
|
513 |
|
514 TConnectionState conState; |
|
515 conState = iServer.ConnectionState(iRemoteAddress); |
|
516 |
|
517 if ( conState == EDisconnected ) |
|
518 { |
|
519 // The bearer may indicate connection synchronously, so set this |
|
520 // message _before_ we ask them |
|
521 iConnectBearerMsg = aMessage; |
|
522 TInt err = iBearerManager.Connect(iRemoteAddress); |
|
523 if ( err != KErrNone ) |
|
524 { |
|
525 CompleteClient(iConnectBearerMsg, err); |
|
526 } |
|
527 } |
|
528 else if ( conState == EDisconnecting || conState == EConnecting ) |
|
529 { |
|
530 if ( iPendingMsg.Handle() ) |
|
531 { |
|
532 PANIC_MSG(aMessage, KRemConClientPanicCat, ERemConClientPanicBearerControlOutstanding); |
|
533 return; |
|
534 } |
|
535 // Store the message, it will get processed later. |
|
536 iPendingMsg = aMessage; |
|
537 } |
|
538 else // EConnected |
|
539 { |
|
540 CompleteClient(aMessage, KErrNone); |
|
541 } |
|
542 |
|
543 } |
|
544 |
|
545 void CRemConSession::ConnectBearerCancel(const RMessage2& aMessage) |
|
546 { |
|
547 LOG_FUNC; |
|
548 |
|
549 // Check we've had our type set... |
|
550 if ( iType != ERemConClientTypeController ) |
|
551 { |
|
552 PANIC_MSG(aMessage, KRemConClientPanicCat, ERemConClientPanicBadType); |
|
553 return; |
|
554 } |
|
555 |
|
556 if ( iConnectBearerMsg.Handle() ) |
|
557 { |
|
558 CompleteClient(iConnectBearerMsg, KErrCancel); |
|
559 } |
|
560 else if ( iPendingMsg.Handle() && ( iPendingMsg.Function() == ERemConConnectBearer )) |
|
561 { |
|
562 CompleteClient(iPendingMsg, KErrCancel); |
|
563 } |
|
564 |
|
565 CompleteClient(aMessage, KErrNone); |
|
566 // At no point do we make any change to the processes going on underneath |
|
567 // us- 'Cancel' APIs are just for cancelling interest in an async |
|
568 // operation. |
|
569 } |
|
570 |
|
571 void CRemConSession::DisconnectBearer(const RMessage2& aMessage) |
|
572 { |
|
573 LOG_FUNC; |
|
574 |
|
575 if ( iType != ERemConClientTypeController ) |
|
576 { |
|
577 PANIC_MSG(aMessage, KRemConClientPanicCat, ERemConClientPanicBadType); |
|
578 return; |
|
579 } |
|
580 |
|
581 if ( iDisconnectBearerMsg.Handle() || iConnectBearerMsg.Handle() || iSendMsg.Handle()) |
|
582 { |
|
583 PANIC_MSG(aMessage, KRemConClientPanicCat, ERemConClientPanicBearerControlOutstanding); |
|
584 return; |
|
585 } |
|
586 |
|
587 if ( iRemoteAddress.IsNull() ) |
|
588 { |
|
589 PANIC_MSG(aMessage, KRemConClientPanicCat, ERemConClientPanicNotConnectionOriented); |
|
590 return; |
|
591 } |
|
592 |
|
593 if (iSending != ENotSending) |
|
594 { |
|
595 DoSendCancel(); |
|
596 } |
|
597 EmptySendQueue(); |
|
598 |
|
599 // Check the requested bearer exists. |
|
600 TBool bearerExists = iBearerManager.BearerExists(iRemoteAddress.BearerUid()); |
|
601 // This check was done at GoConnectionOriented time. |
|
602 ASSERT_DEBUG(bearerExists); |
|
603 // So was this one. |
|
604 ASSERT_DEBUG(iBearerManager.CheckPolicy(iRemoteAddress.BearerUid(), aMessage)); |
|
605 |
|
606 // Check the state of the given connection. If it is: |
|
607 // -) connected, request connection to go away, |
|
608 // -) disconnected, compete the client's message, |
|
609 // -) connecting or disconnecting, add message to the queue of pending |
|
610 // messages, and process it once connecting/disconnecting has been completed |
|
611 |
|
612 TInt err; |
|
613 TConnectionState conState; |
|
614 conState = iServer.ConnectionState(iRemoteAddress); |
|
615 |
|
616 if ( conState == EConnected ) |
|
617 { |
|
618 // The bearer may indicate disconnection synchronously, so set this |
|
619 // message _before_ we ask them |
|
620 iDisconnectBearerMsg = aMessage; |
|
621 err = iBearerManager.Disconnect(iRemoteAddress); |
|
622 if ( err != KErrNone ) |
|
623 { |
|
624 CompleteClient(iDisconnectBearerMsg, err); |
|
625 } |
|
626 } |
|
627 else if ( conState == EDisconnecting || conState == EConnecting ) |
|
628 { |
|
629 if ( iPendingMsg.Handle() ) |
|
630 { |
|
631 PANIC_MSG(aMessage, KRemConClientPanicCat, ERemConClientPanicBearerControlOutstanding); |
|
632 return; |
|
633 } |
|
634 // Store the message, it will get processed later. |
|
635 iPendingMsg = aMessage; |
|
636 } |
|
637 else //disconnected |
|
638 { |
|
639 CompleteClient(aMessage, KErrNone); |
|
640 } |
|
641 } |
|
642 |
|
643 void CRemConSession::DisconnectBearerCancel(const RMessage2& aMessage) |
|
644 { |
|
645 LOG_FUNC; |
|
646 |
|
647 // Check we've had our type set... |
|
648 if ( iType != ERemConClientTypeController ) |
|
649 { |
|
650 PANIC_MSG(aMessage, KRemConClientPanicCat, ERemConClientPanicBadType); |
|
651 return; |
|
652 } |
|
653 |
|
654 if ( iDisconnectBearerMsg.Handle() ) |
|
655 { |
|
656 CompleteClient(iDisconnectBearerMsg, KErrCancel); |
|
657 } |
|
658 else if ( iPendingMsg.Handle() && (iPendingMsg.Function() == ERemConDisconnectBearer )) |
|
659 { |
|
660 CompleteClient(iPendingMsg, KErrCancel); |
|
661 } |
|
662 |
|
663 CompleteClient(aMessage, KErrNone); |
|
664 } |
285 } |
665 |
286 |
666 void CRemConSession::Send(const RMessage2& aMessage) |
287 void CRemConSession::Send(const RMessage2& aMessage) |
667 { |
288 { |
668 LOG_FUNC; |
289 LOG_FUNC; |
674 return; |
295 return; |
675 } |
296 } |
676 |
297 |
677 iSendMsg = aMessage; |
298 iSendMsg = aMessage; |
678 |
299 |
679 // Check we've had our type set... |
300 // Check we've had our features set... |
680 if ( Type() != ERemConClientTypeController |
301 if (!ClientAvailable()) |
681 && Type() != ERemConClientTypeTarget |
302 { |
682 ) |
303 PANIC_MSG(aMessage, KRemConClientPanicCat, ERemConClientPanicClientFeaturesNotSet); |
683 { |
304 return; |
684 PANIC_MSG(aMessage, KRemConClientPanicCat, ERemConClientPanicClientTypeNotSet); |
305 } |
685 return; |
|
686 } |
|
687 |
|
688 // Check we don't have a disconnect outstanding- this makes no sense from |
|
689 // a client viewpoint (they should cancel the disconnect first). |
|
690 // [The client is allowed to have a connect request outstanding- the |
|
691 // bearer manager makes sure a bearer-level connect is not posted on the |
|
692 // same address twice.] |
|
693 if ( iDisconnectBearerMsg.Handle() ) |
|
694 { |
|
695 PANIC_MSG(aMessage, KRemConClientPanicCat, ERemConClientPanicBearerControlOutstanding); |
|
696 return; |
|
697 } |
|
698 |
|
699 TRAPD(err, DoSendL(aMessage)); |
|
700 if ( err != KErrNone ) |
|
701 { |
|
702 CompleteClient(aMessage, err); |
|
703 } |
|
704 } |
|
705 |
|
706 /** |
|
707 Sends a notify message to the remote device. |
|
708 |
|
709 This function is intended for the RemCon controller client to send a notify |
|
710 command to the remote device. |
|
711 */ |
|
712 void CRemConSession::SendNotify(const RMessage2& aMessage) |
|
713 { |
|
714 LOG_FUNC; |
|
715 |
|
716 // Check we're not already sending... |
|
717 if ( iSendMsg.Handle()) |
|
718 { |
|
719 PANIC_MSG(aMessage, KRemConClientPanicCat, ERemConClientPanicSendAlreadyOutstanding); |
|
720 return; |
|
721 } |
|
722 |
|
723 iSendMsg = aMessage; |
|
724 |
|
725 // Check we've had our type set... |
|
726 if (Type() != ERemConClientTypeController) |
|
727 { |
|
728 PANIC_MSG(aMessage, KRemConClientPanicCat, ERemConClientPanicClientTypeNotSet); |
|
729 return; |
|
730 } |
|
731 |
|
732 // Check we don't have a disconnect outstanding- this makes no sense from |
|
733 // a client viewpoint (they should cancel the disconnect first). |
|
734 // [The client is allowed to have a connect request outstanding- the |
|
735 // bearer manager makes sure a bearer-level connect is not posted on the |
|
736 // same address twice.] |
|
737 if ( iDisconnectBearerMsg.Handle() ) |
|
738 { |
|
739 PANIC_MSG(aMessage, KRemConClientPanicCat, ERemConClientPanicBearerControlOutstanding); |
|
740 return; |
|
741 } |
|
742 |
|
743 TRAPD(err, DoSendNotifyL(aMessage)); |
|
744 if ( err != KErrNone ) |
|
745 { |
|
746 CompleteClient(aMessage, err); |
|
747 } |
|
748 } |
|
749 |
|
750 void CRemConSession::DoSendL(const RMessage2& aMessage) |
|
751 { |
|
752 LOG_FUNC; |
|
753 |
|
754 // Get the data the client wants to send. |
|
755 const TUid interfaceUid = TUid::Uid(aMessage.Int0()); |
|
756 LOG1(_L("\tinterfaceUid = 0x%08x"), interfaceUid); |
|
757 |
|
758 if (aMessage.GetDesLengthL(1) != sizeof(TOperationInformation)) |
|
759 { |
|
760 PANIC_MSG(aMessage, KRemConClientPanicCat, ERemConClientPanicBadDescriptor); |
|
761 return; |
|
762 } |
|
763 |
|
764 TPckgBuf<TOperationInformation> opInfoPckg; |
|
765 |
|
766 TInt err= aMessage.Read( |
|
767 1, // location of the descriptor in the client's message (as we expect them to have set it up) |
|
768 opInfoPckg, // descriptor to write to from client memory space |
|
769 0 // offset into our descriptor to put the client's data |
|
770 ); |
|
771 |
|
772 if ( err != KErrNone ) |
|
773 { |
|
774 LOG1(_L("\taMessage.Read = %d"), err); |
|
775 PANIC_MSG(aMessage, KRemConClientPanicCat, ERemConClientPanicBadDescriptor); |
|
776 return; |
|
777 } |
|
778 |
|
779 const TUint operationId = opInfoPckg().iOperationId; |
|
780 LOG1(_L("\toperationId = 0x%02x"), operationId); |
|
781 |
|
782 const TRemConMessageSubType messageSubType = opInfoPckg().iMessageSubType; |
|
783 LOG1(_L("\tmessageSubType = 0x%02x"), messageSubType); |
|
784 |
|
785 |
|
786 const TUint dataLength = (TUint)aMessage.GetDesLengthL(3); |
|
787 LOG1(_L("\tdataLength = %d"), dataLength); |
|
788 |
|
789 // If the client wanted to send some operation-associated data, read it |
|
790 // from them. |
|
791 RBuf8 sendDes; |
|
792 if ( dataLength != 0 ) |
|
793 { |
|
794 sendDes.CreateL(dataLength); |
|
795 TInt err = aMessage.Read( |
|
796 3, // location of the descriptor in the client's message (as we expect them to have set it up) |
|
797 sendDes, // descriptor to write to from client memory space |
|
798 0 // offset into our descriptor to put the client's data |
|
799 ); |
|
800 // NB We don't do LEAVEIFERRORL(aMessage.Read) because a bad client |
|
801 // descriptor is a panicking offence for them, not an 'error the |
|
802 // request' offence. |
|
803 if ( err != KErrNone ) |
|
804 { |
|
805 LOG1(_L("\taMessage.Read = %d"), err); |
|
806 sendDes.Close(); |
|
807 PANIC_MSG(aMessage, KRemConClientPanicCat, ERemConClientPanicBadDescriptor); |
|
808 return; |
|
809 } |
|
810 } |
|
811 CleanupClosePushL(sendDes); |
|
812 |
306 |
813 // Before we ask the server to send, we must set our ClientInfo |
307 // Before we ask the server to send, we must set our ClientInfo |
814 // correctly so the TSP can get information about the client. |
308 // correctly so the TSP can get information about the client. |
815 iClientInfo.Message() = aMessage; |
309 iClientInfo.Message() = aMessage; |
816 |
310 |
|
311 // Prepare the message for send. If DoPrepareSendMessageL() returns |
|
312 // NULL, it panicked the client. |
817 CRemConMessage* msg = NULL; |
313 CRemConMessage* msg = NULL; |
818 |
314 TRAPD(err, msg = DoPrepareSendMessageL(aMessage)); |
819 // Examine the session type. |
315 |
820 switch ( iType ) |
|
821 { |
|
822 case ERemConClientTypeTarget: |
|
823 { |
|
824 LOG(_L("\tTARGET send")); |
|
825 |
|
826 msg = CRemConMessage::NewL( |
|
827 TRemConAddress(), // we don't know which remotes it's going to yet |
|
828 ERemConResponse, // targets can only send responses |
|
829 messageSubType, |
|
830 interfaceUid, |
|
831 operationId, |
|
832 sendDes, // msg takes ownership |
|
833 Id(), // session id to match this response against the originating command |
|
834 0, // transaction id not yet known |
|
835 ETrue); |
|
836 CLEANUPSTACK_POP1(&sendDes); // now owned by msg |
|
837 |
|
838 } |
|
839 break; |
|
840 |
|
841 case ERemConClientTypeController: |
|
842 { |
|
843 LOG(_L("\tCONTROLLER send")); |
|
844 if ( (messageSubType == ERemConNotifyCommandAwaitingInterim) |
|
845 || (messageSubType == ERemConNotifyCommandAwaitingChanged) |
|
846 ) |
|
847 { |
|
848 LOG(_L("\terror, not allowed to use Send() to send notify command")); |
|
849 CleanupStack::PopAndDestroy(&sendDes); |
|
850 PANIC_MSG(aMessage, KRemConClientPanicCat, ERemConClientPanicIllegalIpc); |
|
851 return; |
|
852 } |
|
853 else |
|
854 { |
|
855 msg = CRemConMessage::NewL( |
|
856 iRemoteAddress, // either specified (if we're connection-oriented) or null (we're connectionless- this field will be filled in by the TSP) |
|
857 ERemConCommand, |
|
858 messageSubType, |
|
859 interfaceUid, |
|
860 operationId, |
|
861 sendDes, // msg takes ownership |
|
862 Id(), // session id for when the response comes back |
|
863 0, // we let the bearer manager invent a new transaction id when the message gets to it |
|
864 ETrue); |
|
865 } |
|
866 CLEANUPSTACK_POP1(&sendDes); // now owned by msg |
|
867 |
|
868 } |
|
869 break; |
|
870 |
|
871 default: |
|
872 DEBUG_PANIC_LINENUM; |
|
873 break; |
|
874 } |
|
875 |
|
876 ASSERT_DEBUG(iSendQueue); |
|
877 // We know msg is valid at this stage as the code would leave or panic earlier if msg was |
|
878 // not set. |
|
879 ASSERT_DEBUG(msg); |
|
880 |
|
881 if (iSending != ENotSending || !iSendQueue->IsEmpty()) |
|
882 { |
|
883 iSendQueue->Append(*msg); |
|
884 } |
|
885 else |
|
886 { |
|
887 // we know msg cannot be null here as said above. |
|
888 SendToServer(*msg); |
|
889 } |
|
890 } |
|
891 |
|
892 /** |
|
893 @see CRemConSession::SendNotify |
|
894 */ |
|
895 void CRemConSession::DoSendNotifyL(const RMessage2& aMessage) |
|
896 { |
|
897 LOG_FUNC; |
|
898 |
|
899 // Get the data the client wants to send. |
|
900 const TUid interfaceUid = TUid::Uid(aMessage.Int0()); |
|
901 LOG1(_L("\tinterfaceUid = 0x%08x"), interfaceUid); |
|
902 |
|
903 if (aMessage.GetDesLengthL(1) != sizeof(TOperationInformation)) |
|
904 { |
|
905 PANIC_MSG(aMessage, KRemConClientPanicCat, ERemConClientPanicBadDescriptor); |
|
906 return; |
|
907 } |
|
908 |
|
909 TPckgBuf<TOperationInformation> opInfoPckg; |
|
910 TInt err= aMessage.Read( |
|
911 1, // location of the descriptor in the client's message (as we expect them to have set it up) |
|
912 opInfoPckg, // descriptor to write to from client memory space |
|
913 0 // offset into our descriptor to put the client's data |
|
914 ); |
|
915 |
|
916 if ( err != KErrNone ) |
316 if ( err != KErrNone ) |
917 { |
317 { |
918 LOG1(_L("\taMessage.Read = %d"), err); |
318 CompleteClient(aMessage, err); |
919 PANIC_MSG(aMessage, KRemConClientPanicCat, ERemConClientPanicBadDescriptor); |
319 } |
920 return; |
320 else if (msg) |
921 } |
|
922 |
|
923 const TUint operationId = opInfoPckg().iOperationId; |
|
924 LOG1(_L("\toperationId = 0x%02x"), operationId); |
|
925 |
|
926 const TRemConMessageSubType messageSubType = opInfoPckg().iMessageSubType; |
|
927 LOG1(_L("\tmessageSubType = 0x%02x"), messageSubType); |
|
928 |
|
929 const TUint dataLength = (TUint)aMessage.GetDesLengthL(2); |
|
930 LOG1(_L("\tdataLength = %d"), dataLength); |
|
931 |
|
932 // If the client wanted to send some operation-associated data, read it |
|
933 // from them. |
|
934 RBuf8 sendDes; |
|
935 if ( dataLength != 0 ) |
|
936 { |
|
937 sendDes.CreateL(dataLength); |
|
938 TInt err = aMessage.Read( |
|
939 2, // location of the descriptor in the client's message (as we expect them to have set it up) |
|
940 sendDes, // descriptor to write to from client memory space |
|
941 0 // offset into our descriptor to put the client's data |
|
942 ); |
|
943 // NB We don't do LEAVEIFERRORL(aMessage.Read) because a bad client |
|
944 // descriptor is a panicking offence for them, not an 'error the |
|
945 // request' offence. |
|
946 if ( err != KErrNone ) |
|
947 { |
|
948 LOG1(_L("\taMessage.Read = %d"), err); |
|
949 sendDes.Close(); |
|
950 PANIC_MSG(aMessage, KRemConClientPanicCat, ERemConClientPanicBadDescriptor); |
|
951 return; |
|
952 } |
|
953 } |
|
954 |
|
955 // Before we ask the server to send, we must set our ClientInfo |
|
956 // correctly so the TSP can get information about the client. |
|
957 iClientInfo.Message() = aMessage; |
|
958 |
|
959 CRemConMessage* msg = NULL; |
|
960 |
|
961 if (messageSubType != ERemConNotifyCommandAwaitingInterim) |
|
962 { |
|
963 sendDes.Close(); |
|
964 PANIC_MSG(aMessage, KRemConClientPanicCat, ERemConClientPanicIllegalIpc); |
|
965 return; |
|
966 } |
|
967 |
|
968 CleanupClosePushL(sendDes); |
|
969 msg = CRemConMessage::NewL( |
|
970 iRemoteAddress, // either specified (if we're connection-oriented) or null (we're connectionless- this field will be filled in by the TSP) |
|
971 ERemConNotifyCommand, |
|
972 messageSubType, |
|
973 interfaceUid, |
|
974 operationId, |
|
975 sendDes, // msg takes ownership |
|
976 Id(), // session id for when the response comes back |
|
977 0, // we let the bearer manager invent a new transaction id when the message gets to it |
|
978 ETrue); |
|
979 CLEANUPSTACK_POP1(&sendDes); // now owned by msg |
|
980 |
|
981 LOG(_L("\tCONTROLLER send")); |
|
982 ASSERT_DEBUG(iSendQueue); |
|
983 if (iSending != ENotSending || !iSendQueue->IsEmpty()) |
|
984 { |
|
985 iSendQueue->Append(*msg); |
|
986 } |
|
987 else |
|
988 { |
|
989 SendToServer(*msg); |
|
990 } |
|
991 } |
|
992 |
|
993 void CRemConSession::SendUnreliable(const RMessage2& aMessage) |
|
994 { |
|
995 LOG_FUNC; |
|
996 |
|
997 // Check we've had our type set... |
|
998 if ( Type() != ERemConClientTypeController |
|
999 && Type() != ERemConClientTypeTarget |
|
1000 ) |
|
1001 { |
|
1002 PANIC_MSG(aMessage, KRemConClientPanicCat, ERemConClientPanicClientTypeNotSet); |
|
1003 return; |
|
1004 } |
|
1005 |
|
1006 // Check we don't have a disconnect outstanding- this makes no sense from |
|
1007 // a client viewpoint (they should cancel the disconnect first). |
|
1008 // [The client is allowed to have a connect request outstanding- the |
|
1009 // bearer manager makes sure a bearer-level connect is not posted on the |
|
1010 // same address twice.] |
|
1011 if ( iDisconnectBearerMsg.Handle() ) |
|
1012 { |
|
1013 PANIC_MSG(aMessage, KRemConClientPanicCat, ERemConClientPanicBearerControlOutstanding); |
|
1014 return; |
|
1015 } |
|
1016 |
|
1017 CRemConMessage* msg = NULL; |
|
1018 TRAPD(err, msg = DoCreateUnreliableMessageL(aMessage)); |
|
1019 CompleteClient(aMessage, err); |
|
1020 if (err == KErrNone) |
|
1021 { |
321 { |
1022 ASSERT_DEBUG(iSendQueue); |
322 ASSERT_DEBUG(iSendQueue); |
1023 if (iSending || !iSendQueue->IsEmpty()) |
323 |
|
324 if (iSending != ENotSending || !iSendQueue->IsEmpty()) |
1024 { |
325 { |
1025 iSendQueue->Append(*msg); |
326 iSendQueue->Append(*msg); |
1026 } |
327 } |
1027 else |
328 else |
1028 { |
329 { |
|
330 // we know msg cannot be null here as said above. |
1029 SendToServer(*msg); |
331 SendToServer(*msg); |
1030 } |
332 } |
1031 } |
333 } |
1032 } |
334 } |
1033 |
335 |
1034 CRemConMessage* CRemConSession::DoCreateUnreliableMessageL(const RMessage2& aMessage) |
|
1035 { |
|
1036 LOG_FUNC; |
|
1037 |
|
1038 // Get the data the client wants to send. |
|
1039 const TUid interfaceUid = TUid::Uid(aMessage.Int0()); |
|
1040 LOG1(_L("\tinterfaceUid = 0x%08x"), interfaceUid); |
|
1041 |
|
1042 if (aMessage.GetDesLengthL(1) != sizeof(TOperationInformation)) |
|
1043 { |
|
1044 PANIC_MSG(aMessage, KRemConClientPanicCat, ERemConClientPanicBadDescriptor); |
|
1045 LEAVEL(KErrBadDescriptor); |
|
1046 } |
|
1047 |
|
1048 TPckgBuf<TOperationInformation> opInfoPckg; |
|
1049 |
|
1050 TInt err= aMessage.Read( |
|
1051 1, // location of the descriptor in the client's message (as we expect them to have set it up) |
|
1052 opInfoPckg, // descriptor to write to from client memory space |
|
1053 0 // offset into our descriptor to put the client's data |
|
1054 ); |
|
1055 |
|
1056 if ( err != KErrNone ) |
|
1057 { |
|
1058 LOG1(_L("\taMessage.Read = %d"), err); |
|
1059 PANIC_MSG(aMessage, KRemConClientPanicCat, ERemConClientPanicBadDescriptor); |
|
1060 LEAVEL(KErrBadDescriptor); |
|
1061 } |
|
1062 |
|
1063 const TUint operationId = opInfoPckg().iOperationId; |
|
1064 LOG1(_L("\toperationId = 0x%02x"), operationId); |
|
1065 |
|
1066 const TRemConMessageSubType messageSubType = opInfoPckg().iMessageSubType; |
|
1067 LOG1(_L("\tmessageSubType = 0x%02x"), messageSubType); |
|
1068 |
|
1069 |
|
1070 const TUint dataLength = (TUint)aMessage.GetDesLengthL(2); |
|
1071 LOG1(_L("\tdataLength = %d"), dataLength); |
|
1072 |
|
1073 // If the client wanted to send some operation-associated data, read it |
|
1074 // from them. |
|
1075 RBuf8 sendDes; |
|
1076 if ( dataLength != 0 ) |
|
1077 { |
|
1078 sendDes.CreateL(dataLength); |
|
1079 TInt err = aMessage.Read( |
|
1080 2, // location of the descriptor in the client's message (as we expect them to have set it up) |
|
1081 sendDes, // descriptor to write to from client memory space |
|
1082 0 // offset into our descriptor to put the client's data |
|
1083 ); |
|
1084 // NB We don't do LEAVEIFERRORL(aMessage.Read) because a bad client |
|
1085 // descriptor is a panicking offence for them, not an 'error the |
|
1086 // request' offence. |
|
1087 if ( err != KErrNone ) |
|
1088 { |
|
1089 LOG1(_L("\taMessage.Read = %d"), err); |
|
1090 sendDes.Close(); |
|
1091 PANIC_MSG(aMessage, KRemConClientPanicCat, ERemConClientPanicBadDescriptor); |
|
1092 LEAVEL(KErrBadDescriptor); |
|
1093 } |
|
1094 } |
|
1095 CleanupClosePushL(sendDes); |
|
1096 |
|
1097 // Before we ask the server to send, we must set our ClientInfo |
|
1098 // correctly so the TSP can get information about the client. |
|
1099 iClientInfo.Message() = aMessage; |
|
1100 |
|
1101 CRemConMessage* msg = NULL; |
|
1102 |
|
1103 // Examine the session type. |
|
1104 switch ( iType ) |
|
1105 { |
|
1106 case ERemConClientTypeTarget: |
|
1107 { |
|
1108 LOG(_L("\tTARGET send")); |
|
1109 |
|
1110 msg = CRemConMessage::NewL( |
|
1111 TRemConAddress(), // we don't know which remotes it's going to yet |
|
1112 ERemConResponse, // targets can only send responses |
|
1113 messageSubType, |
|
1114 interfaceUid, |
|
1115 operationId, |
|
1116 sendDes, // msg takes ownership |
|
1117 Id(), // session id to match this response against the originating command |
|
1118 0, // transaction id not yet known |
|
1119 EFalse); |
|
1120 CLEANUPSTACK_POP1(&sendDes); // now owned by msg |
|
1121 break; |
|
1122 } |
|
1123 |
|
1124 case ERemConClientTypeController: |
|
1125 { |
|
1126 LOG(_L("\tCONTROLLER send")); |
|
1127 |
|
1128 // A client is not allowed to send an unreliable notify command. |
|
1129 if ( (messageSubType == ERemConNotifyCommandAwaitingInterim) |
|
1130 || (messageSubType == ERemConNotifyCommandAwaitingChanged) |
|
1131 ) |
|
1132 { |
|
1133 LOG(_L8("\tNot allowed to send unreliable notify command")); |
|
1134 CleanupStack::PopAndDestroy(&sendDes); |
|
1135 PANIC_MSG(aMessage, KRemConClientPanicCat, ERemConClientPanicIllegalIpc); |
|
1136 LEAVEL(KErrBadDescriptor); |
|
1137 } |
|
1138 |
|
1139 msg = CRemConMessage::NewL( |
|
1140 iRemoteAddress, // either specified (if we're connection-oriented) or null (we're connectionless- this field will be filled in by the TSP) |
|
1141 ERemConCommand, // controllers can only send commands |
|
1142 messageSubType, |
|
1143 interfaceUid, |
|
1144 operationId, |
|
1145 sendDes, // msg takes ownership |
|
1146 Id(), // session id for when the response comes back |
|
1147 0, // we let the bearer manager invent a new transaction id when the message gets to it |
|
1148 EFalse); |
|
1149 CLEANUPSTACK_POP1(&sendDes); // now owned by msg |
|
1150 |
|
1151 } |
|
1152 break; |
|
1153 |
|
1154 default: |
|
1155 DEBUG_PANIC_LINENUM; |
|
1156 break; |
|
1157 } |
|
1158 |
|
1159 return msg; |
|
1160 } |
|
1161 |
|
1162 void CRemConSession::SendToServer(CRemConMessage& aMsg) |
|
1163 { |
|
1164 LOG_FUNC; |
|
1165 |
|
1166 // Set our completion members. |
|
1167 NumRemotes() = 0; |
|
1168 NumRemotesToTry() = 0; |
|
1169 SendError() = KErrNone; |
|
1170 |
|
1171 |
|
1172 iSending = (aMsg.IsReliableSend()) ? ESendingReliable: ESendingUnreliable; |
|
1173 switch ( iType ) |
|
1174 { |
|
1175 case ERemConClientTypeTarget: |
|
1176 { |
|
1177 iServer.SendResponse(aMsg, *this); |
|
1178 break; |
|
1179 } |
|
1180 case ERemConClientTypeController: |
|
1181 { |
|
1182 iServer.SendCommand(aMsg); |
|
1183 break; |
|
1184 } |
|
1185 default: |
|
1186 DEBUG_PANIC_LINENUM; |
|
1187 break; |
|
1188 } |
|
1189 } |
|
1190 |
|
1191 |
|
1192 void CRemConSession::SendCancel(const RMessage2& aMessage) |
336 void CRemConSession::SendCancel(const RMessage2& aMessage) |
1193 { |
337 { |
1194 LOG_FUNC; |
338 LOG_FUNC; |
1195 |
339 |
1196 // Check we've had our type set... |
340 // Check we've had our features set... |
1197 if ( Type() != ERemConClientTypeController |
341 if (!ClientAvailable()) |
1198 && Type() != ERemConClientTypeTarget |
342 { |
1199 ) |
343 PANIC_MSG(aMessage, KRemConClientPanicCat, ERemConClientPanicClientFeaturesNotSet); |
1200 { |
|
1201 PANIC_MSG(aMessage, KRemConClientPanicCat, ERemConClientPanicClientTypeNotSet); |
|
1202 return; |
344 return; |
1203 } |
345 } |
1204 |
346 |
1205 // See comments in ConnectBearerCancel. |
347 // See comments in ConnectBearerCancel. |
1206 if ( iSendMsg.Handle() ) |
348 if ( iSendMsg.Handle() ) |
1461 CompleteClient(iNotifyConnectionsChangeMsg, KErrCancel); |
551 CompleteClient(iNotifyConnectionsChangeMsg, KErrCancel); |
1462 } |
552 } |
1463 CompleteClient(aMessage, KErrNone); |
553 CompleteClient(aMessage, KErrNone); |
1464 } |
554 } |
1465 |
555 |
1466 void CRemConSession::RegisterInterestedAPIs(const RMessage2& aMessage) |
556 CRemConInterfaceDetailsArray* CRemConSession::ExtractInterestedAPIsL(const RMessage2& aMessage) |
1467 { |
557 { |
1468 LOG_FUNC; |
558 LOG_FUNC; |
1469 |
559 |
1470 if(iType == ERemConClientTypeUndefined) |
560 CRemConInterfaceDetailsArray* result; |
1471 { |
|
1472 PANIC_MSG(aMessage, KRemConClientPanicCat, ERemConClientPanicRegisterInterestedAPIsInNonTargetSession); |
|
1473 } |
|
1474 |
|
1475 TRAPD(err, DoRegisterInterestedAPIsL(aMessage)); |
|
1476 |
|
1477 if(iType == ERemConClientTypeController) |
|
1478 { |
|
1479 iServer.ControllerClientAvailable(); |
|
1480 } |
|
1481 else if(err == KErrNone) // must be target |
|
1482 { |
|
1483 iServer.TargetClientAvailable(*this); |
|
1484 |
|
1485 TInt count = iInterestedAPIs->Array().Count(); |
|
1486 for(TInt ix=0; ix<count; ++ix) |
|
1487 { |
|
1488 CRemConInterfaceDetails* details = iInterestedAPIs->Array()[ix]; |
|
1489 ASSERT_DEBUG(details); |
|
1490 if(details->IsBulk()) |
|
1491 { |
|
1492 iServer.BulkServerRequired(); |
|
1493 break; |
|
1494 } |
|
1495 } |
|
1496 } |
|
1497 |
|
1498 CompleteClient(aMessage, err); |
|
1499 } |
|
1500 |
|
1501 void CRemConSession::DoRegisterInterestedAPIsL(const RMessage2& aMessage) |
|
1502 { |
|
1503 LOG_FUNC; |
|
1504 |
561 |
1505 RBuf8 buf; |
562 RBuf8 buf; |
1506 buf.CreateL(aMessage.GetDesLengthL(0)); |
563 buf.CreateL(aMessage.GetDesLengthL(0)); |
1507 CleanupClosePushL(buf); |
564 CleanupClosePushL(buf); |
1508 |
565 |
1509 aMessage.ReadL(0, buf); |
566 aMessage.ReadL(0, buf); |
1510 RDesReadStream ipcStream(buf); |
567 RDesReadStream ipcStream(buf); |
1511 |
568 |
1512 iInterestedAPIs = CRemConInterfaceDetailsArray::InternalizeL(ipcStream); |
569 result = CRemConInterfaceDetailsArray::InternalizeL(ipcStream); |
1513 |
570 |
1514 ipcStream.Close(); |
571 ipcStream.Close(); |
1515 CleanupStack::PopAndDestroy(&buf); |
572 CleanupStack::PopAndDestroy(&buf); |
1516 } |
573 |
1517 |
574 return result; |
1518 void CRemConSession::CompleteConnect(const TRemConAddress& aAddr, TInt aError) |
575 } |
1519 { |
576 |
1520 LOG_FUNC; |
577 TBool CRemConSession::DoGetSendInfoLC(const RMessage2& aMessage, |
1521 LOG2(_L("\taError = %d, aAddr.BearerUid = 0x%08x"), aError, aAddr.BearerUid()); |
578 TUid& aInterfaceUid, |
1522 |
579 TUint& aOperationId, |
1523 LOG1(_L("\tiRemoteAddress.BearerUid = 0x%08x"), iRemoteAddress.BearerUid()); |
580 TRemConMessageSubType& aMessageSubType, |
1524 LOG1(_L("\tiConnectBearerMsg.Handle = %d"), iConnectBearerMsg.Handle()); |
581 RBuf8& aSendDes) |
1525 |
582 { |
1526 if ( iRemoteAddress == aAddr ) |
583 // Get the data the client wants to send. |
1527 { |
584 aInterfaceUid = TUid::Uid(aMessage.Int0()); |
1528 if ( iConnectBearerMsg.Handle() ) |
585 LOG1(_L("\taInterfaceUid = 0x%08x"), aInterfaceUid); |
1529 { |
586 |
1530 // We are a session that has an outstanding request on this specific |
587 if (aMessage.GetDesLengthL(1) != sizeof(TOperationInformation)) |
1531 // connection address. |
588 { |
1532 CompleteClient(iConnectBearerMsg, aError); |
589 PANIC_MSG(aMessage, KRemConClientPanicCat, ERemConClientPanicBadDescriptor); |
1533 } |
590 return EFalse; |
1534 else |
591 } |
1535 { |
592 |
1536 // Connect bearer message is not valid. |
593 TPckgBuf<TOperationInformation> opInfoPckg; |
1537 // Check for pending messages. |
594 |
1538 CheckForPendingMsg(); |
595 TInt err= aMessage.Read( |
1539 } |
596 1, // location of the descriptor in the client's message (as we expect them to have set it up) |
1540 } |
597 opInfoPckg, // descriptor to write to from client memory space |
1541 } |
598 0 // offset into our descriptor to put the client's data |
1542 |
599 ); |
1543 void CRemConSession::CompleteDisconnect(const TRemConAddress& aAddr, TInt aError) |
600 |
1544 { |
601 if ( err != KErrNone ) |
1545 LOG_FUNC; |
602 { |
1546 LOG2(_L("\taError = %d, aAddr.BearerUid = 0x%08x"), aError, aAddr.BearerUid()); |
603 LOG1(_L("\taMessage.Read = %d"), err); |
1547 |
604 PANIC_MSG(aMessage, KRemConClientPanicCat, ERemConClientPanicBadDescriptor); |
1548 LOG1(_L("\tiRemoteAddress.BearerUid = 0x%08x"), iRemoteAddress.BearerUid()); |
605 return EFalse; |
1549 LOG1(_L("\tiDisconnectBearerMsg.Handle = %d"), iDisconnectBearerMsg.Handle()); |
606 } |
1550 |
607 |
1551 if ( iRemoteAddress == aAddr ) |
608 aOperationId = opInfoPckg().iOperationId; |
1552 { |
609 LOG1(_L("\taOperationId = 0x%02x"), aOperationId); |
1553 if ( iDisconnectBearerMsg.Handle() ) |
610 |
1554 { |
611 aMessageSubType = opInfoPckg().iMessageSubType; |
1555 // We are a session that has an outstanding request on this specific |
612 LOG1(_L("\taMessageSubType = 0x%02x"), aMessageSubType); |
1556 // connection address. |
613 |
1557 CompleteClient(iDisconnectBearerMsg, aError); |
614 const TUint dataLength = (TUint)aMessage.GetDesLengthL(3); |
1558 } |
615 LOG1(_L("\tdataLength = %d"), dataLength); |
1559 else |
616 |
1560 { |
617 // If the client wanted to send some operation-associated data, read it |
1561 // Diconnect bearer message is not valid. |
618 // from them. |
1562 // Check for pending messages. |
619 if ( dataLength != 0 ) |
1563 CheckForPendingMsg(); |
620 { |
1564 } |
621 aSendDes.CreateL(dataLength); |
1565 |
622 TInt err = aMessage.Read( |
1566 } |
623 3, // location of the descriptor in the client's message (as we expect them to have set it up) |
|
624 aSendDes, // descriptor to write to from client memory space |
|
625 0 // offset into our descriptor to put the client's data |
|
626 ); |
|
627 // NB We don't do LEAVEIFERRORL(aMessage.Read) because a bad client |
|
628 // descriptor is a panicking offence for them, not an 'error the |
|
629 // request' offence. |
|
630 if ( err != KErrNone ) |
|
631 { |
|
632 LOG1(_L("\taMessage.Read = %d"), err); |
|
633 aSendDes.Close(); |
|
634 PANIC_MSG(aMessage, KRemConClientPanicCat, ERemConClientPanicBadDescriptor); |
|
635 return EFalse; |
|
636 } |
|
637 } |
|
638 CleanupClosePushL(aSendDes); |
|
639 return ETrue; |
|
640 } |
|
641 |
|
642 void CRemConSession::GoConnectionOriented(const RMessage2& aMessage) |
|
643 { |
|
644 PANIC_MSG(aMessage, KRemConClientPanicCat, ERemConClientPanicBadType); |
|
645 } |
|
646 |
|
647 void CRemConSession::GoConnectionless(const RMessage2& aMessage) |
|
648 { |
|
649 PANIC_MSG(aMessage, KRemConClientPanicCat, ERemConClientPanicBadType); |
|
650 } |
|
651 |
|
652 void CRemConSession::ConnectBearer(const RMessage2& aMessage) |
|
653 { |
|
654 PANIC_MSG(aMessage, KRemConClientPanicCat, ERemConClientPanicBadType); |
|
655 } |
|
656 |
|
657 void CRemConSession::ConnectBearerCancel(const RMessage2& aMessage) |
|
658 { |
|
659 PANIC_MSG(aMessage, KRemConClientPanicCat, ERemConClientPanicBadType); |
|
660 } |
|
661 |
|
662 void CRemConSession::DisconnectBearer(const RMessage2& aMessage) |
|
663 { |
|
664 PANIC_MSG(aMessage, KRemConClientPanicCat, ERemConClientPanicBadType); |
|
665 } |
|
666 |
|
667 void CRemConSession::DisconnectBearerCancel(const RMessage2& aMessage) |
|
668 { |
|
669 PANIC_MSG(aMessage, KRemConClientPanicCat, ERemConClientPanicBadType); |
|
670 } |
|
671 |
|
672 void CRemConSession::SendNotify(const RMessage2& aMessage) |
|
673 { |
|
674 PANIC_MSG(aMessage, KRemConClientPanicCat, ERemConClientPanicBadType); |
1567 } |
675 } |
1568 |
676 |
1569 void CRemConSession::ConnectionsChanged() |
677 void CRemConSession::ConnectionsChanged() |
1570 { |
678 { |
1571 LOG_FUNC; |
679 LOG_FUNC; |