coreapplicationuis/advancedtspcontroller/src/remcontspcontroller.cpp
branchRCL_3
changeset 15 312d2b433792
parent 0 2e3d3ce01487
child 17 5e7d68cc22e0
equal deleted inserted replaced
10:469fa8a78de7 15:312d2b433792
    59 // MACROS
    59 // MACROS
    60 
    60 
    61 // LOCAL CONSTANTS AND MACROS
    61 // LOCAL CONSTANTS AND MACROS
    62 
    62 
    63 const TUint32 KUid3MusicPlayer = 0x102072C3;
    63 const TUint32 KUid3MusicPlayer = 0x102072C3;
       
    64 const TUint32 KUid3PhoneApp = 0x100058B3; 
       
    65 const TUint32 KUid3VoiceCmdApp = 0x102818e7;
    64 
    66 
    65 //#define __MODULE_TEST__
    67 //#define __MODULE_TEST__
    66 
    68 
    67 #ifdef __MODULE_TEST__
    69 #ifdef __MODULE_TEST__
    68 const TUint32 KUid3BTAudioMan = 0x102073E4; // STIF
    70 const TUint32 KUid3BTAudioMan = 0x102073E4; // STIF
   106 // C++ default constructor can NOT contain any code, that
   108 // C++ default constructor can NOT contain any code, that
   107 // might leave.
   109 // might leave.
   108 // -----------------------------------------------------------------------------
   110 // -----------------------------------------------------------------------------
   109 //
   111 //
   110 
   112 
   111 CRemConTspController::CRemConTspController( 
   113 CRemConTspController::CRemConTspController(MRemConTargetSelectorPluginObserver& aObserver )
   112 								MRemConTargetSelectorPluginObserver& aObserver )
   114     : CRemConTargetSelectorPlugin( aObserver )
   113 :	CRemConTargetSelectorPlugin( aObserver )
   115     , iClientObservers(_FOFF(TClientObserver, iClientObserverQueLink))
       
   116     , iAvailableTargets(_FOFF(TClientInfo, iLink))
       
   117     , iTargetsForAddressing(_FOFF(TClientInfo, iLink2))
   114 	{
   118 	{
   115 	}
   119 	}
   116     
   120     
   117 // -----------------------------------------------------------------------------
   121 // -----------------------------------------------------------------------------
   118 // CRemConTspController::NewL
   122 // CRemConTspController::NewL
   152 	    delete iCFClient;
   156 	    delete iCFClient;
   153 	    iCFClient = NULL;
   157 	    iCFClient = NULL;
   154 	    }
   158 	    }
   155     iArrayOfTables.ResetAndDestroy();
   159     iArrayOfTables.ResetAndDestroy();
   156     iArrayOfStoredTables.ResetAndDestroy();
   160     iArrayOfStoredTables.ResetAndDestroy();
       
   161     
       
   162     TClientInfo* clientInfo;
       
   163     while(!iAvailableTargets.IsEmpty())
       
   164         {
       
   165         clientInfo = iAvailableTargets.First();
       
   166         iAvailableTargets.Remove(*clientInfo);
       
   167         delete clientInfo;
       
   168         }
       
   169 
       
   170     TClientObserver* clientObserver;
       
   171     while(!iClientObservers.IsEmpty())
       
   172         {
       
   173         clientObserver = iClientObservers.First();
       
   174         iClientObservers.Remove(*clientObserver);
       
   175         delete clientObserver;
       
   176         }
       
   177     iTargetsForAddressing.Reset(); 
       
   178     delete iTriggerEventsWatcher;
   157 	COM_TRACE_( "[REMCONTSPCONTROLLER] CRemConTspController::~CRemConTspController() - return" );
   179 	COM_TRACE_( "[REMCONTSPCONTROLLER] CRemConTspController::~CRemConTspController() - return" );
   158 	}
   180 	}
   159 
   181 
   160 // -----------------------------------------------------------------------------
   182 // -----------------------------------------------------------------------------
   161 // CRemConTspController::GetInterface
   183 // CRemConTspController::GetInterface
   184 	else if ( aUid == TUid::Uid(KRemConTargetSelectorInterface3) )
   206 	else if ( aUid == TUid::Uid(KRemConTargetSelectorInterface3) )
   185 		{
   207 		{
   186 		ret = reinterpret_cast<TAny*>(
   208 		ret = reinterpret_cast<TAny*>(
   187 			static_cast<MRemConTargetSelectorPluginInterfaceV3*>(this) );
   209 			static_cast<MRemConTargetSelectorPluginInterfaceV3*>(this) );
   188 		}
   210 		}
       
   211     else if ( aUid == TUid::Uid(KRemConTargetSelectorInterface4) )
       
   212         {
       
   213         ret = reinterpret_cast<TAny*>(
       
   214             static_cast<MRemConTargetSelectorPluginInterfaceV4*>(this) );
       
   215         }
       
   216     else if ( aUid == TUid::Uid(KRemConTargetSelectorInterface5) )
       
   217         {
       
   218         ret = reinterpret_cast<TAny*>(
       
   219             static_cast<MRemConTargetSelectorPluginInterfaceV5*>(this) );
       
   220         }
   189 	COM_TRACE_1( "[REMCONTSPCONTROLLER] CRemConTspController::GetInterface() this=%d", ret );
   221 	COM_TRACE_1( "[REMCONTSPCONTROLLER] CRemConTspController::GetInterface() this=%d", ret );
   190 	return ret;
   222 	return ret;
   191 	}
   223 	}
   192 
   224 
   193 // -----------------------------------------------------------------------------
   225 // -----------------------------------------------------------------------------
   336 	COM_TRACE_2( "[REMCONTSPCONTROLLER] aInterfaceUid = %d, aOperationId = %d", aInterfaceUid.iUid, aOperationId );
   368 	COM_TRACE_2( "[REMCONTSPCONTROLLER] aInterfaceUid = %d, aOperationId = %d", aInterfaceUid.iUid, aOperationId );
   337 
   369 
   338 #ifdef _DEBUG	
   370 #ifdef _DEBUG	
   339 	TraceRemconTargets( aClients );
   371 	TraceRemconTargets( aClients );
   340 #endif
   372 #endif
   341 	
   373 	TRAPD( err, GetCorrectClientL( aInterfaceUid, aOperationId, aClients, ETrue ) );
   342 	TRAPD( err, GetCorrectClientL( aInterfaceUid, aOperationId, aClients ) );
       
   343 	
       
   344 	Observer().IncomingCommandAddressed( err );
   374 	Observer().IncomingCommandAddressed( err );
   345 	
   375 	
   346 	COM_TRACE_( "[REMCONTSPCONTROLLER] CRemConTspController::AddressIncomingCommand() ends" );
   376 	COM_TRACE_( "[REMCONTSPCONTROLLER] CRemConTspController::AddressIncomingCommand() ends" );
   347 	}
   377 	}
   348 
   378 
   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++ )
   511             	while( target )
   765             	while( target )
   512 			        {
   766 			        {
   513             	    TProcessId processId = target->ProcessId();
   767             	    TProcessId processId = target->ProcessId();
   514             	    if( iProcessIdForeground == processId )
   768             	    if( iProcessIdForeground == processId )
   515             	        {
   769             	        {
       
   770                         COM_TRACE_( "[REMCONTSPCONTROLLER] CRemConTspController::GetCorrectClientL() Foreground client found" );
   516             	        aClients.Reset();
   771             	        aClients.Reset();
   517             	        aClients.AddFirst( *target );
   772             	        aClients.AddFirst( *target );
   518             	        found = ETrue;
   773             	        found = ETrue;
   519             	        break;
   774             	        break;
   520             	        }
   775             	        }
   611                 break;
   866                 break;
   612                 }
   867                 }
   613             case CRemConEventTable::ELaunchDefaultApp:
   868             case CRemConEventTable::ELaunchDefaultApp:
   614                 {
   869                 {
   615                 COM_TRACE_( "[REMCONTSPCONTROLLER] CRemConTspController::GetCorrectClientL() Launch default application" );                
   870                 COM_TRACE_( "[REMCONTSPCONTROLLER] CRemConTspController::GetCorrectClientL() Launch default application" );                
   616                 if ( !DeviceLocked() )
   871                 if ( !DeviceLocked() && aLaunchingNewApplicationAllowed )
   617                     {
   872                     {
   618                     TUid defaultLaunchAppUid;
   873                     TUid defaultLaunchAppUid;
   619                     
   874                     
   620                     CRemConEventTable* table = FindRoutingTable( iArrayOfTables, numOfTables );
   875                     CRemConEventTable* table = FindRoutingTable( iArrayOfTables, numOfTables );
   621                     if ( table )
   876                     if ( table )
   646             break;
   901             break;
   647             }
   902             }
   648         else if( rulesArray.Count() - 1 == i )
   903         else if( rulesArray.Count() - 1 == i )
   649             {
   904             {
   650             COM_TRACE_( "[REMCONTSPCONTROLLER] CRemConTspController::GetCorrectClientL() No client found");
   905             COM_TRACE_( "[REMCONTSPCONTROLLER] CRemConTspController::GetCorrectClientL() No client found");
       
   906             // Reset the list to reflect the fact that no clients were found. 
       
   907             // The possible transparent clients will be added still. 
       
   908             aClients.Reset();
   651             }
   909             }
   652         }
   910         }
   653 
   911 
   654     // Add transparent clients
   912     // Add transparent clients
   655     for ( TInt i = transparentClients.Count() - 1; i >= 0; --i )
   913     for ( TInt i = transparentClients.Count() - 1; i >= 0; --i )
   656         {
   914         {
   657         TClientInfo* target = transparentClients[ i ];
   915         TClientInfo* target = transparentClients[ i ];
   658         if ( !FindRemconConnection( target->SecureId(), aClients ) ) // Add client only if not already found
   916         if ( !FindRemconConnection( target->SecureId(), aClients ) ) // Add client only if not already found
   659             {
   917             {
   660             aClients.AddFirst( *target );
   918             // Add to the end of the list, any other client should take priority over the transparent clients. 
       
   919             aClients.AddLast( *target );  
   661             COM_TRACE_1( "[REMCONTSPCONTROLLER] CRemConTspController::GetCorrectClientL() transparent client 0x%x added", target->SecureId().iId );
   920             COM_TRACE_1( "[REMCONTSPCONTROLLER] CRemConTspController::GetCorrectClientL() transparent client 0x%x added", target->SecureId().iId );
   662             }
   921             }
   663         }
   922         }
   664     CleanupStack::PopAndDestroy( &transparentClients ); // Pointers are not own
   923     CleanupStack::PopAndDestroy( &transparentClients ); // Pointers are not own
   665     CleanupStack::PopAndDestroy( &rulesArray );
   924     CleanupStack::PopAndDestroy( &rulesArray );
  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 //    
  1483         }
  1776         }
  1484     array.Close();
  1777     array.Close();
  1485     return EFalse;
  1778     return EFalse;
  1486     }
  1779     }
  1487 
  1780 
       
  1781 //----------------------------------------------------------------------------------
       
  1782 // CRemConTspController::GetLocalAddressedClient
       
  1783 // Uses TSP rules to determine what local addressed client should be.
       
  1784 //-----------------------------------------------------------------------------------
       
  1785 TClientInfo* CRemConTspController::GetLocalAddressedClient()
       
  1786     {
       
  1787     COM_TRACE_( "[REMCONTSPCONTROLLER] CRemConTspController::GetLocalAddressedClient() Entry");
       
  1788     // Create list of available clients to allow re-use of existing rule 
       
  1789     // evaluation function, GetCorrectClientL
       
  1790     iTargetsForAddressing.Reset();
       
  1791     TSglQueIter<TClientInfo> iter(iAvailableTargets);
       
  1792     TClientInfo* clientInfo;
       
  1793     while((clientInfo = iter++) != NULL)
       
  1794         {
       
  1795         iTargetsForAddressing.AddLast(*clientInfo);
       
  1796         }
       
  1797     
       
  1798 #ifdef _DEBUG   
       
  1799     TraceRemconTargets( iTargetsForAddressing );
       
  1800 #endif
       
  1801     
       
  1802     TRAPD(err, GetCorrectClientL(TUid::Uid(KRemConCoreApiUid), ERemConCoreApiPlay, iTargetsForAddressing, EFalse));
       
  1803     if(iTargetsForAddressing.IsEmpty() || err)
       
  1804         {
       
  1805         clientInfo = NULL;
       
  1806         COM_TRACE_( "[REMCONTSPCONTROLLER] CRemConTspController::GetLocalAddressedClient() No target Found");
       
  1807         }
       
  1808     else
       
  1809         {
       
  1810         // We don't want to set the phone application or voice command handler as local addressed client. 
       
  1811         // So choose the first item that is neither of those. The clientInfo may be NULL in the end. 
       
  1812         TSglQueIter<TClientInfo> localAddressedIter(iTargetsForAddressing);
       
  1813         while((clientInfo = localAddressedIter++) != NULL)
       
  1814             {
       
  1815             if( clientInfo->SecureId() != TSecureId(KUid3PhoneApp) || 
       
  1816                 clientInfo->SecureId() != TSecureId(KUid3VoiceCmdApp) )
       
  1817                 {
       
  1818                 COM_TRACE_1( "[REMCONTSPCONTROLLER] CRemConTspController::GetLocalAddressedClient() Local addressed client SID = %08x",  clientInfo->SecureId().iId);
       
  1819                 break;
       
  1820                 }
       
  1821             }
       
  1822         }
       
  1823 
       
  1824     return clientInfo;
       
  1825     }
       
  1826 
  1488 // End of file
  1827 // End of file