395 |
425 |
396 COM_TRACE_( "[REMCONTSPCONTROLLER] CRemConTspController::PermitOutgoingNotifyCommand() ends" ); |
426 COM_TRACE_( "[REMCONTSPCONTROLLER] CRemConTspController::PermitOutgoingNotifyCommand() ends" ); |
397 } |
427 } |
398 |
428 |
399 // ----------------------------------------------------------------------------- |
429 // ----------------------------------------------------------------------------- |
|
430 // CRemConTspController::PermitIncomingCommand |
|
431 // By default, permit all incoming addressed commands. Check if the command |
|
432 // comes from the AVRCP bearer an if so launch the music player. |
|
433 // ----------------------------------------------------------------------------- |
|
434 void CRemConTspController::PermitIncomingCommand( |
|
435 TUid aInterfaceUid, |
|
436 TUint aOperationId, |
|
437 const TClientInfo& aClient) |
|
438 { |
|
439 (void) aClient; // Not used. |
|
440 // Here we need to check the incoming command. If it is an AVRCP play |
|
441 // command and there is no sensible handler running we should launch the |
|
442 // MPX Music Player. This is the same as for AddressIncomingCommand. |
|
443 // Check if appropriate handler running |
|
444 if ((aInterfaceUid != TUid::Uid(KRemConCoreApiUid)) || |
|
445 (aOperationId != ERemConCoreApiPlay) || |
|
446 GetLocalAddressedClient()) |
|
447 { |
|
448 // no action needed, allow commmand |
|
449 Observer().IncomingCommandPermitted(ETrue); |
|
450 } |
|
451 else |
|
452 { |
|
453 // Launch an appropriate player in playing state. |
|
454 TRAPD(err, ActivateApplicationL(TUid::Uid(KUid3MusicPlayer))) |
|
455 if(err != KErrNone) |
|
456 { |
|
457 |
|
458 } |
|
459 |
|
460 //deny this command |
|
461 Observer().IncomingCommandPermitted(EFalse); |
|
462 |
|
463 // We will be informed when the MPX music player connects its client |
|
464 // session. That will trigger a rules evaluation which will result in |
|
465 // us informing interested bearers of the new local addressed player. |
|
466 } |
|
467 } |
|
468 |
|
469 // ----------------------------------------------------------------------------- |
|
470 // CRemConTspController::PermitIncomingNotify |
|
471 // By default, permit all incoming addressed commands. Check if the command |
|
472 // comes from the AVRCP bearer an if so launch the music player. |
|
473 // ----------------------------------------------------------------------------- |
|
474 void CRemConTspController::PermitIncomingNotify( |
|
475 TUid /*aInterfaceUid*/, |
|
476 TUint /*aOperationId*/, |
|
477 const TClientInfo& /*aClient*/) |
|
478 { |
|
479 // No reason to stop these, just allow all |
|
480 Observer().IncomingNotifyPermitted(ETrue); |
|
481 } |
|
482 |
|
483 // ----------------------------------------------------------------------------- |
|
484 // CRemConTspController::SetRemoteAddressedClient |
|
485 // Ignore this event. We don't use what the remote has selected to influence |
|
486 // our routing policy. |
|
487 // ----------------------------------------------------------------------------- |
|
488 void CRemConTspController::SetRemoteAddressedClient(const TUid& /*aBearerUid*/, |
|
489 const TClientInfo& /*aClient*/) |
|
490 { |
|
491 } |
|
492 |
|
493 // ----------------------------------------------------------------------------- |
|
494 // CRemConTspController::TargetClientAvailable |
|
495 // A new client has connected. Trigger a rule evaluation to see if we want to switch |
|
496 // to this client. |
|
497 // ----------------------------------------------------------------------------- |
|
498 void CRemConTspController::TargetClientAvailable(const TClientInfo& aClientInfo) |
|
499 { |
|
500 COM_TRACE_1("[REMCONTSPCONTROLLER] CRemConTspController::TargetClientAvailable aClientInfo.SecureId=0x%x", aClientInfo.SecureId().iId); |
|
501 |
|
502 TClientInfo* clientInfo; |
|
503 TSglQueIter<TClientInfo> iter(iAvailableTargets); |
|
504 |
|
505 while((clientInfo = iter++) != NULL) |
|
506 { |
|
507 if(clientInfo->SecureId() == aClientInfo.SecureId()) |
|
508 { |
|
509 // Found a client and clientInfo points to that now. |
|
510 break; |
|
511 } |
|
512 } |
|
513 |
|
514 // If clientInfo was not found, create it and add to the available targets queue. |
|
515 if(!clientInfo) |
|
516 { |
|
517 TClientInfo* newTarget = new TClientInfo(); |
|
518 if(newTarget) |
|
519 { |
|
520 newTarget->ProcessId() = aClientInfo.ProcessId(); |
|
521 newTarget->SecureId() = aClientInfo.SecureId(); |
|
522 |
|
523 // Add to our list of available targets |
|
524 iAvailableTargets.AddLast(*newTarget); |
|
525 } |
|
526 } |
|
527 |
|
528 // Re-evaluate what the default addressed player should be if someone is interested to know |
|
529 if(!iClientObservers.IsEmpty()) |
|
530 { |
|
531 MtrtoEvaluateRoutingRules(); |
|
532 } |
|
533 } |
|
534 |
|
535 // ----------------------------------------------------------------------------- |
|
536 // CRemConTspController::TargetClientUnavailable |
|
537 // A client has disconnected. Trigger a rule evaluation to see if our default |
|
538 // player has changed. |
|
539 // ----------------------------------------------------------------------------- |
|
540 void CRemConTspController::TargetClientUnavailable(const TClientInfo& aClientInfo) |
|
541 { |
|
542 COM_TRACE_1("[REMCONTSPCONTROLLER] CRemConTspController::TargetClientUnavailable aClientInfo.SecureId=0x%x", aClientInfo.SecureId().iId); |
|
543 |
|
544 // Remove this from our list of available targets |
|
545 if(!iAvailableTargets.IsEmpty()) |
|
546 { |
|
547 TClientInfo* clientInfo; |
|
548 TSglQueIter<TClientInfo> iter(iAvailableTargets); |
|
549 while((clientInfo = iter++) != NULL) |
|
550 { |
|
551 if(clientInfo->SecureId() == aClientInfo.SecureId()) |
|
552 { |
|
553 iAvailableTargets.Remove(*clientInfo); |
|
554 delete clientInfo; |
|
555 break; |
|
556 } |
|
557 } |
|
558 } |
|
559 |
|
560 if(!iClientObservers.IsEmpty()) |
|
561 { |
|
562 // Re-evaluate what the default addressed player should be if someone is listening. |
|
563 MtrtoEvaluateRoutingRules(); |
|
564 } |
|
565 } |
|
566 |
|
567 // ----------------------------------------------------------------------------- |
|
568 // CRemConTspController::RegisterLocalAddressedClientObserver |
|
569 // A bearer is interested in what the local addressed player is. Start observing. |
|
570 // ----------------------------------------------------------------------------- |
|
571 TInt CRemConTspController::RegisterLocalAddressedClientObserver(const TUid& aBearerUid) |
|
572 { |
|
573 COM_TRACE_1("[REMCONTSPCONTROLLER] CRemConTspController::RegisterLocalAddressedClientObserver aBearerUid.SecureId=0x%x", aBearerUid.iUid); |
|
574 TInt err = KErrNone; |
|
575 // Add this to our list of bearers interested in the default addressed player |
|
576 TClientObserver* clientObserver = new TClientObserver(aBearerUid); |
|
577 |
|
578 if(!clientObserver) |
|
579 { |
|
580 err = KErrNoMemory; |
|
581 } |
|
582 |
|
583 // If this is our first interested bearer kick off the trigger events watcher. |
|
584 // This will let us know if any event occurs that should trigger us to re-evaluate |
|
585 // our addressing rules |
|
586 if(!iTriggerEventsWatcher && err == KErrNone) |
|
587 { |
|
588 TRAP(err, iTriggerEventsWatcher = CTspTriggerEventsWatcher::NewL(*this)); |
|
589 if(err != KErrNone) |
|
590 { |
|
591 // If we couldn't create the events watcher the client Observer is not needed either. |
|
592 delete clientObserver; |
|
593 } |
|
594 } |
|
595 |
|
596 if(err == KErrNone) |
|
597 { |
|
598 // Finally add the observer to the queue if it's not there yet. |
|
599 TSglQueIter<TClientObserver> iter(iClientObservers); |
|
600 TClientObserver* obsInQueue; |
|
601 while((obsInQueue = iter++) != NULL) |
|
602 { |
|
603 if(obsInQueue->iBearerUid == aBearerUid) |
|
604 { |
|
605 err = KErrAlreadyExists; |
|
606 break; |
|
607 } |
|
608 } |
|
609 |
|
610 if(!obsInQueue) |
|
611 { |
|
612 iClientObservers.AddLast(*clientObserver); |
|
613 MtrtoEvaluateRoutingRules(); |
|
614 } |
|
615 } |
|
616 |
|
617 return err; |
|
618 } |
|
619 |
|
620 // ----------------------------------------------------------------------------- |
|
621 // CRemConTspController::UnregisterLocalAddressedClientObserver |
|
622 // The bearer is no longer interested in observering default client changes. |
|
623 // ----------------------------------------------------------------------------- |
|
624 TInt CRemConTspController::UnregisterLocalAddressedClientObserver(const TUid& aBearerUid) |
|
625 { |
|
626 COM_TRACE_1("[REMCONTSPCONTROLLER] CRemConTspController::UnregisterLocalAddressedClientObserver aBearerUid.SecureId=0x%x", aBearerUid.iUid); |
|
627 // Remove this from our list of bearers interested in the default addressed player. |
|
628 // If there are no interested bearers left then we can stop watching for rules |
|
629 // triggers. |
|
630 TSglQueIter<TClientObserver> iter(iClientObservers); |
|
631 TClientObserver* clientObserver; |
|
632 while((clientObserver = iter++) != NULL) |
|
633 { |
|
634 if(clientObserver->iBearerUid == aBearerUid) |
|
635 { |
|
636 iClientObservers.Remove(*clientObserver); |
|
637 delete clientObserver; |
|
638 break; |
|
639 } |
|
640 } |
|
641 |
|
642 if(iClientObservers.IsEmpty()) |
|
643 { |
|
644 delete iTriggerEventsWatcher; |
|
645 iTriggerEventsWatcher = NULL; |
|
646 } |
|
647 |
|
648 return KErrNone; |
|
649 } |
|
650 |
|
651 // ----------------------------------------------------------------------------- |
400 // CRemConTspController::GetCorrectClientL |
652 // CRemConTspController::GetCorrectClientL |
401 // Defines remote targets to which command will be sent. |
653 // Defines remote targets to which command will be sent. |
402 // (other items were commented in a header). |
654 // (other items were commented in a header). |
403 // ----------------------------------------------------------------------------- |
655 // ----------------------------------------------------------------------------- |
404 // |
656 // |
405 void CRemConTspController::GetCorrectClientL( |
657 void CRemConTspController::GetCorrectClientL( |
406 TUid aInterfaceUid, |
658 TUid aInterfaceUid, |
407 TUint aKeyEvent, |
659 TUint aKeyEvent, |
408 TSglQue<TClientInfo>& aClients ) |
660 TSglQue<TClientInfo>& aClients, |
|
661 TBool aLaunchingNewApplicationAllowed) |
409 { |
662 { |
410 COM_TRACE_1( "[REMCONTSPCONTROLLER] CRemConTspController::GetCorrectClientL() Start aInterfaceUid %d", aInterfaceUid ); |
663 COM_TRACE_1( "[REMCONTSPCONTROLLER] CRemConTspController::GetCorrectClientL() Start aInterfaceUid %d", aInterfaceUid ); |
411 COM_TRACE_1( "[REMCONTSPCONTROLLER] CRemConTspController::GetCorrectClientL() Start aKeyEvent %d", aKeyEvent ); |
664 COM_TRACE_1( "[REMCONTSPCONTROLLER] CRemConTspController::GetCorrectClientL() Start aKeyEvent %d", aKeyEvent ); |
|
665 |
412 TInt numOfTables = iArrayOfTables.Count(); |
666 TInt numOfTables = iArrayOfTables.Count(); |
413 RArray<TInt> rulesArray; |
667 RArray<TInt> rulesArray; |
414 CleanupClosePushL( rulesArray ); |
668 CleanupClosePushL( rulesArray ); |
415 COM_TRACE_1( "[REMCONTSPCONTROLLER] CRemConTspController::GetCorrectClientL() Get Correct Table, table count %d", numOfTables ); |
669 COM_TRACE_1( "[REMCONTSPCONTROLLER] CRemConTspController::GetCorrectClientL() Get Correct Table, table count %d", numOfTables ); |
416 for( TInt i = 0; i != numOfTables; i++ ) |
670 for( TInt i = 0; i != numOfTables; i++ ) |
1057 { |
1316 { |
1058 return NULL; |
1317 return NULL; |
1059 } |
1318 } |
1060 |
1319 |
1061 // ----------------------------------------------------------------------------- |
1320 // ----------------------------------------------------------------------------- |
|
1321 // CRemConTspController::MtrtoEvaluateRoutingRules |
|
1322 // Evaluates the TSP's routing rules to determine if the local addressed player |
|
1323 // has changed, and if so informs interested bearers |
|
1324 // ----------------------------------------------------------------------------- |
|
1325 void CRemConTspController::MtrtoEvaluateRoutingRules() |
|
1326 { |
|
1327 COM_TRACE_( "[REMCONTSPCONTROLLER] CRemConTspController::MtrtoEvaluateRoutingRules() - Enter" ); |
|
1328 TClientInfo* localAddressedClient = GetLocalAddressedClient(); |
|
1329 |
|
1330 if(!localAddressedClient) |
|
1331 { |
|
1332 // If there's no suitable client, then there's nothing to do here. |
|
1333 COM_TRACE_( "[REMCONTSPCONTROLLER] CRemConTspController::MtrtoEvaluateRoutingRules() No local addressed client found" ); |
|
1334 return; |
|
1335 } |
|
1336 |
|
1337 if(!iLocalAddressedClient || (localAddressedClient->SecureId() != iLocalAddressedClient->SecureId())) |
|
1338 { |
|
1339 // Local addressed player has changed (or wasn't set before). |
|
1340 iLocalAddressedClient = localAddressedClient; |
|
1341 COM_TRACE_( "[REMCONTSPCONTROLLER] CRemConTspController::MtrtoEvaluateRoutingRules() Local addressed client has changed" ); |
|
1342 TSglQueIter<TClientObserver> iter(iClientObservers); |
|
1343 TClientObserver* clientObserver; |
|
1344 while((clientObserver = iter++) != NULL) |
|
1345 { |
|
1346 COM_TRACE_( "[REMCONTSPCONTROLLER] CRemConTspController::MtrtoEvaluateRoutingRules() - informing observer" ); |
|
1347 Observer().SetLocalAddressedClient(clientObserver->iBearerUid, *iLocalAddressedClient); |
|
1348 } |
|
1349 } |
|
1350 COM_TRACE_1( "[REMCONTSPCONTROLLER] CRemConTspController::MtrtoEvaluateRoutingRules() Local addressed client SID = 0x%x", iLocalAddressedClient->SecureId().iId); |
|
1351 COM_TRACE_( "[REMCONTSPCONTROLLER] CRemConTspController::MtrtoEvaluateRoutingRules() - Return" ); |
|
1352 } |
|
1353 |
|
1354 // ----------------------------------------------------------------------------- |
1062 // CRemConTspController::CreateAfterIdleL |
1355 // CRemConTspController::CreateAfterIdleL |
1063 // Define the contexts when idle state has been loaded. |
1356 // Define the contexts when idle state has been loaded. |
1064 // (other items were commented in a header). |
1357 // (other items were commented in a header). |
1065 // ----------------------------------------------------------------------------- |
1358 // ----------------------------------------------------------------------------- |
1066 // |
1359 // |