accessoryservices/tspclientmapper/src/tspclientmapperimpl.cpp
changeset 0 4e1aa6a622a0
child 10 66ecddbca914
equal deleted inserted replaced
-1:000000000000 0:4e1aa6a622a0
       
     1 /*
       
     2 * Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  This interface is used to add mappings between the process
       
    15 *                that listens the remote control and is assosiated with
       
    16 *                another function.
       
    17 *
       
    18 */
       
    19 
       
    20 
       
    21 // INCLUDE FILES
       
    22 #include <e32property.h>
       
    23 #include "RemConDebug.h"
       
    24 #include "tspclientmapperimpl.h"
       
    25 #include "tspclientmapperprivatepskeys.h"
       
    26 
       
    27 _LIT( KTspClientMapperSynch, "TspClientMapperSynch_10282CD6" );
       
    28 // ============================ MEMBER FUNCTIONS ===============================
       
    29 _LIT_SECURITY_POLICY_C1(KNoCapability, ECapability_None);
       
    30 
       
    31 // -----------------------------------------------------------------------------
       
    32 // CTspClientMapperImpl::CRemConTspController
       
    33 // C++ default constructor can NOT contain any code, that
       
    34 // might leave.
       
    35 // -----------------------------------------------------------------------------
       
    36 //
       
    37 
       
    38 CTspClientMapperImpl::CTspClientMapperImpl()
       
    39 	{
       
    40 	COM_TRACE_( "[TspClientMapperImpl] CTspClientMapperImpl::CTspClientMapperImpl()" );
       
    41     COM_TRACE_( "[TspClientMapperImpl] CTspClientMapperImpl::CTspClientMapperImpl() - return" );
       
    42 	}
       
    43 
       
    44 // Destructor
       
    45 CTspClientMapperImpl::~CTspClientMapperImpl()
       
    46 	{
       
    47 	COM_TRACE_( "[TspClientMapperImpl] CTspClientMapperImpl::~CTspClientMapperImpl()" );
       
    48     CloseMutex();
       
    49     }
       
    50 
       
    51 // -----------------------------------------------------------------------------
       
    52 // CTspClientMapperImpl::NewL
       
    53 // -----------------------------------------------------------------------------
       
    54 //
       
    55 CTspClientMapperImpl* CTspClientMapperImpl::NewL()
       
    56     {
       
    57 	COM_TRACE_( "[TspClientMapperImpl] CTspClientMapperImpl::NewL()" );
       
    58 	CTspClientMapperImpl* self = new( ELeave ) CTspClientMapperImpl();
       
    59 	CleanupStack::PushL( self );
       
    60     self->ConstructL();
       
    61     CleanupStack::Pop( self );
       
    62     COM_TRACE_( "[TspClientMapperImpl] CTspClientMapperImpl::NewL() - return" );
       
    63     
       
    64     return self;
       
    65     }
       
    66     
       
    67 // -----------------------------------------------------------------------------
       
    68 // CTspClientMapperImpl::ConstructL
       
    69 // Constructor function. 
       
    70 // (other items were commented in a header).
       
    71 // -----------------------------------------------------------------------------
       
    72 //
       
    73 void CTspClientMapperImpl::ConstructL()
       
    74     {
       
    75     COM_TRACE_( "[TspClientMapperImpl] CTspClientMapperImpl::ConstructL()" );
       
    76     
       
    77     OpenMutexL();
       
    78     
       
    79     TTspClientMapperSynch synchObj( iMutex );
       
    80     
       
    81     TFixedArray< TProcessId, 10 > arrayCheck;
       
    82     TPckg< TFixedArray< TProcessId, 10 > > bufCheck( arrayCheck );
       
    83     TInt err = RProperty::Get(
       
    84                 KTspClientMapperProperty,
       
    85                 KTspClientMapperKeyPlaying,
       
    86                 bufCheck );
       
    87     if( err == KErrNotFound )
       
    88         {
       
    89         COM_TRACE_( "[TspClientMapperImpl] CTspClientMapperImpl::ConstructL() - Define the P&S keys, this should only be done in the boot" );
       
    90         RProperty::Define(
       
    91                     KTspClientMapperProperty,
       
    92                     KTspClientMapperKeyPlaying,
       
    93                     RProperty::EByteArray,
       
    94                     KNoCapability, 
       
    95                     KNoCapability,
       
    96                     RProperty::KMaxPropertySize );
       
    97         RProperty::Define(
       
    98                         KTspClientMapperProperty,
       
    99                         KTspClientMapperKeyRegistered,
       
   100                         RProperty::EByteArray,
       
   101                         KNoCapability, 
       
   102                         KNoCapability,
       
   103                         RProperty::KMaxPropertySize );
       
   104         RProperty::Define(
       
   105                         KTspClientMapperProperty,
       
   106                         KTspClientMapperKeyStopped,
       
   107                         RProperty::EByteArray,
       
   108                         KNoCapability, 
       
   109                         KNoCapability,
       
   110                         RProperty::KMaxPropertySize );
       
   111         
       
   112         TFixedArray< TProcessId, 10 > array;
       
   113         TPckg< TFixedArray< TProcessId, 10 > > buf( array );
       
   114         const TProcessId processIdNull( 0 );
       
   115         for( TInt i = 0; i != 10; i++ )
       
   116             {
       
   117             array[ i ] = processIdNull;
       
   118             }
       
   119         err = RProperty::Set(
       
   120                     KTspClientMapperProperty,
       
   121                     KTspClientMapperKeyPlaying,
       
   122                     buf );
       
   123         err = RProperty::Set(
       
   124                     KTspClientMapperProperty,
       
   125                     KTspClientMapperKeyRegistered,
       
   126                     buf );
       
   127         err = RProperty::Set(
       
   128                     KTspClientMapperProperty,
       
   129                     KTspClientMapperKeyStopped,
       
   130                     buf );
       
   131         }
       
   132     
       
   133     COM_TRACE_( "[TspClientMapperImpl] CTspClientMapperImpl::ConstructL() - return" );
       
   134     }
       
   135 
       
   136 
       
   137 // -----------------------------------------------------------------------------
       
   138 // CTspClientMapperImpl::SetTargetClient
       
   139 // Provides implementation of this (TSP) interface. 
       
   140 // (other items were commented in a header).
       
   141 // -----------------------------------------------------------------------------
       
   142 //
       
   143 void CTspClientMapperImpl::SetTspTargetClient(
       
   144     TTspClientMappingType aMappingType,
       
   145     TProcessId aProcessId )
       
   146 	{
       
   147     COM_TRACE_2( "[TspClientMapperImpl] CTspClientMapperImpl::SetTspTargetClient() aMappingType=%d, aProcessId=%d", aMappingType, (TInt)aProcessId );
       
   148     
       
   149     if( aMappingType > EStoppedClients )
       
   150         {
       
   151         COM_TRACE_( "[TspClientMapperImpl] CTspClientMapperImpl::SetTspTargetClient() EPlayingClients - Enumeration not in range" );
       
   152         return;
       
   153         }
       
   154     
       
   155     TTspClientMapperSynch synchObj( iMutex );
       
   156     
       
   157     TFixedArray< TProcessId, 10 > array;
       
   158     TPckg< TFixedArray< TProcessId, 10 > > buf( array );
       
   159     TFixedArray< TProcessId, 10 > array1;
       
   160     const TProcessId processIdNull( 0 );
       
   161     switch( aMappingType )
       
   162         {
       
   163         case EPlayingClients:
       
   164             {
       
   165             COM_TRACE_( "[TspClientMapperImpl] CTspClientMapperImpl::SetTspTargetClient() EPlayingClients " );
       
   166             
       
   167             TInt err = RProperty::Get(
       
   168                 KTspClientMapperProperty,
       
   169                 KTspClientMapperKeyPlaying,
       
   170                 buf );
       
   171             COM_TRACE_1( "Error in get play is %d ", err );
       
   172             if( err == KErrNotFound )
       
   173                 {
       
   174                 // Hasn't been set yet so define the key
       
   175                 TInt err1 = RProperty::Define(
       
   176                     KTspClientMapperProperty,
       
   177                     KTspClientMapperKeyPlaying,
       
   178                     RProperty::EByteArray,
       
   179                     KNoCapability, 
       
   180                     KNoCapability,
       
   181                     RProperty::KMaxPropertySize  );
       
   182                 COM_TRACE_1( "[TspClientMapperImpl] CTspClientMapperImpl::SetTspTargetClient() Error in play define is %d ", err1 );
       
   183                 }
       
   184             COM_TRACE_( "[TspClientMapperImpl] CTspClientMapperImpl::SetTspTargetClient() Before append " );
       
   185             
       
   186             array1.Reset();
       
   187             array1[ 0 ] = aProcessId;
       
   188             if( err != KErrNotFound )
       
   189                 {
       
   190                 for( TInt i = 0; i != buf().Count() - 1; i++ )
       
   191                     {
       
   192                     if( ( aProcessId != buf().operator[]( i ) )
       
   193                      || ( aProcessId == processIdNull ) )
       
   194                         {
       
   195                         array1[ i + 1 ] = buf().operator[]( i );
       
   196                         }
       
   197                     else
       
   198                         {
       
   199                         buf().operator[]( i ) = processIdNull;
       
   200                         i--;
       
   201                         }
       
   202                     }
       
   203                 }
       
   204             TPckg< TFixedArray< TProcessId, 10 > > buf1( array1 );
       
   205             COM_TRACE_1( "Appended process id %d ", (TInt)buf1().operator[]( 0 ) );
       
   206             err = RProperty::Set(
       
   207                 KTspClientMapperProperty,
       
   208                 KTspClientMapperKeyPlaying,
       
   209                 buf1 );
       
   210             if( err != KErrNone )
       
   211                 {
       
   212                 COM_TRACE_1( "Error in play set is %d ", err );
       
   213                 }
       
   214             COM_TRACE_( "[TspClientMapperImpl] CTspClientMapperImpl::SetTspTargetClient() EPlayingClients Set " );
       
   215             break;
       
   216             }
       
   217         case ERegisteredClients:
       
   218             {
       
   219             COM_TRACE_( "[TspClientMapperImpl] CTspClientMapperImpl::SetTspTargetClient() ERegisteredClients " );
       
   220             
       
   221             TInt err = RProperty::Get(
       
   222                 KTspClientMapperProperty,
       
   223                 KTspClientMapperKeyRegistered,
       
   224                 buf );
       
   225             if( err == KErrNotFound )
       
   226                 {
       
   227                 // Hasn't been set yet so define the key
       
   228                 err = RProperty::Define(
       
   229                     KTspClientMapperProperty,
       
   230                     KTspClientMapperKeyRegistered,
       
   231                     RProperty::EByteArray,
       
   232                     KNoCapability, 
       
   233                     KNoCapability,
       
   234                     RProperty::KMaxPropertySize  );
       
   235                 COM_TRACE_1( "Error in register define is %d ", err );
       
   236                 }
       
   237             array1.Reset();
       
   238             array1[ 0 ] = aProcessId;
       
   239             if( err != KErrNotFound )
       
   240                 {
       
   241                 for( TInt i = 0; i != buf().Count() - 1; i++ )
       
   242                     {
       
   243                     if( ( aProcessId != buf().operator[]( i ) )
       
   244                      || ( aProcessId == processIdNull ) )
       
   245                         {
       
   246                         array1[ i + 1 ] = buf().operator[]( i );
       
   247                         }
       
   248                     else
       
   249                         {
       
   250                         buf().operator[]( i ) = processIdNull;
       
   251                         i--;
       
   252                         }
       
   253                     }
       
   254                 }
       
   255             TPckg< TFixedArray< TProcessId, 10 > > buf1( array1 );
       
   256             RProperty::Set(
       
   257                 KTspClientMapperProperty,
       
   258                 KTspClientMapperKeyRegistered,
       
   259                 buf1 );
       
   260             COM_TRACE_( "[TspClientMapperImpl] CTspClientMapperImpl::SetTspTargetClient() ERegisteredClients Set " );
       
   261             break;
       
   262             }
       
   263         case EStoppedClients:
       
   264             {
       
   265             COM_TRACE_( "[TspClientMapperImpl] CTspClientMapperImpl::SetTspTargetClient() EStoppedClients " );
       
   266             TInt err = RProperty::Get(
       
   267                 KTspClientMapperProperty,
       
   268                 KTspClientMapperKeyStopped,
       
   269                 buf );
       
   270             if( err == KErrNotFound )
       
   271                 {
       
   272                 // Hasn't been set yet so define the key
       
   273                 err = RProperty::Define(
       
   274                     KTspClientMapperProperty,
       
   275                     KTspClientMapperKeyStopped,
       
   276                     RProperty::EByteArray,
       
   277                     KNoCapability, 
       
   278                     KNoCapability,
       
   279                     RProperty::KMaxPropertySize  );
       
   280                 COM_TRACE_1( "Error in stop define is %d ", err );
       
   281                 }
       
   282             array1.Reset();
       
   283             array1[ 0 ] = aProcessId;
       
   284             if( err != KErrNotFound )
       
   285                 {
       
   286                 for( TInt i = 0; i != buf().Count() - 1; i++ )
       
   287                     {
       
   288                     if( ( aProcessId != buf().operator[]( i ) )
       
   289                      || ( aProcessId == processIdNull ) )
       
   290                         {
       
   291                         array1[ i + 1 ] = buf().operator[]( i );
       
   292                         }
       
   293                     else
       
   294                         {
       
   295                         buf().operator[]( i ) = processIdNull;
       
   296                         i--;
       
   297                         }
       
   298                     }
       
   299                 }
       
   300             TPckg< TFixedArray< TProcessId, 10 > > buf1( array1 );
       
   301             RProperty::Set(
       
   302                 KTspClientMapperProperty,
       
   303                 KTspClientMapperKeyStopped,
       
   304                 buf1 );
       
   305             COM_TRACE_( "[TspClientMapperImpl] CTspClientMapperImpl::SetTspTargetClient() EStoppedClients Set " );
       
   306             break;
       
   307             }
       
   308         default:
       
   309             {
       
   310             COM_TRACE_( "[TspClientMapperImpl] CTspClientMapperImpl::SetTspTargetClient() Switch case - Default " );
       
   311             }
       
   312         }
       
   313     
       
   314     COM_TRACE_( "[TspClientMapperImpl] CTspClientMapperImpl::SetTspTargetClient() - return" );
       
   315 	}
       
   316 	
       
   317 // -----------------------------------------------------------------------------
       
   318 // CTspClientMapperImpl::SetTspTargetClientToOtherType
       
   319 // Provides implementation of this (TSP) interface. 
       
   320 // (other items were commented in a header).
       
   321 // -----------------------------------------------------------------------------
       
   322 //
       
   323 TInt CTspClientMapperImpl::SetTspTargetClientToOtherType( 
       
   324     TTspClientMappingType aMappingType,
       
   325     TProcessId aProcessId )
       
   326 	{
       
   327     COM_TRACE_2( "[TspClientMapperImpl] CTspClientMapperImpl::SetTspTargetClientToOtherType() aMappingType=%d, aProcessId=%d", aMappingType, (TInt)aProcessId );
       
   328     TInt returnErr( KErrNone );
       
   329     if( aMappingType > EStoppedClients )
       
   330         {
       
   331         returnErr = KErrNotSupported;
       
   332         return returnErr;
       
   333         }
       
   334     
       
   335     TTspClientMapperSynch synchObj( iMutex );
       
   336     
       
   337     TInt err = RemoveTspTargetClient( EPlayingClients, aProcessId );
       
   338     if( err == KErrNotFound )
       
   339         {
       
   340         err = RemoveTspTargetClient( ERegisteredClients, aProcessId );
       
   341         if( err == KErrNotFound )
       
   342             {
       
   343             err = RemoveTspTargetClient( EStoppedClients, aProcessId );
       
   344             if( err == KErrNotFound )
       
   345                 {
       
   346                 return err;
       
   347                 }
       
   348             }
       
   349         }
       
   350     
       
   351     SetTspTargetClient( aMappingType, aProcessId );
       
   352     
       
   353 	COM_TRACE_( "[TspClientMapperImpl] CTspClientMapperImpl::SetTspTargetClientToOtherType() - return" );
       
   354 	return returnErr;
       
   355 	}	
       
   356 
       
   357 // -----------------------------------------------------------------------------
       
   358 // CTspClientMapperImpl::RemoveTspTargetClientL
       
   359 // Provides implementation of this (TSP) interface. 
       
   360 // (other items were commented in a header).
       
   361 // -----------------------------------------------------------------------------
       
   362 //
       
   363 TInt CTspClientMapperImpl::RemoveTspTargetClient(
       
   364     TTspClientMappingType aMappingType,
       
   365     TProcessId aProcessId )
       
   366 	{
       
   367 	const TProcessId processIdNull( 0 );
       
   368 	TInt returnErr( KErrNone ); 
       
   369 	COM_TRACE_2( "[TspClientMapperImpl] CTspClientMapperImpl::RemoveTspTargetClientL() aMappingType=%d, aProcessId=%d", aMappingType, (TInt)aProcessId );
       
   370     if( aMappingType > EStoppedClients )
       
   371         {
       
   372         returnErr = KErrNotSupported;
       
   373         }
       
   374     TFixedArray< TProcessId, 10 > array;
       
   375     array.Reset();
       
   376     TPckg< TFixedArray< TProcessId, 10 > > buf( array );
       
   377     TInt position( KErrNotFound );
       
   378     
       
   379     TTspClientMapperSynch synchObj( iMutex );
       
   380     
       
   381     switch( aMappingType )
       
   382         {
       
   383         case EPlayingClients:
       
   384             {
       
   385             COM_TRACE_( "[TspClientMapperImpl] CTspClientMapperImpl::RemoveTspTargetClientL() EPlayingClients " );
       
   386             
       
   387             returnErr = RProperty::Get(
       
   388                 KTspClientMapperProperty,
       
   389                 KTspClientMapperKeyPlaying,
       
   390                 buf );
       
   391             if( returnErr != KErrNotFound )
       
   392                 {
       
   393                 for( TInt aaa = 0; aaa != buf().Count(); aaa++ )
       
   394                     {
       
   395                     if( aProcessId == buf().operator[]( aaa ) )
       
   396                         {
       
   397                         position = aaa;
       
   398                         buf().operator[]( aaa ) = processIdNull;
       
   399                         }
       
   400                     }
       
   401                 if( position != KErrNotFound )
       
   402                     {
       
   403                     returnErr = RProperty::Set(
       
   404                         KTspClientMapperProperty,
       
   405                         KTspClientMapperKeyPlaying,
       
   406                         buf );
       
   407                     }
       
   408                 else
       
   409                     {
       
   410                     returnErr = KErrNotFound;
       
   411                     }
       
   412                 }
       
   413             break;
       
   414             }
       
   415         case ERegisteredClients:
       
   416             {
       
   417             COM_TRACE_( "[TspClientMapperImpl] CTspClientMapperImpl::RemoveTspTargetClientL() ERegisteredClients " );
       
   418             
       
   419             returnErr = RProperty::Get(
       
   420                 KTspClientMapperProperty,
       
   421                 KTspClientMapperKeyRegistered,
       
   422                 buf );
       
   423             if( returnErr != KErrNotFound )
       
   424                 {
       
   425                 for( TInt aaa = 0; aaa != buf().Count(); aaa++ )
       
   426                     {
       
   427                     if( aProcessId == buf().operator[]( aaa ) )
       
   428                         {
       
   429                         position = aaa;
       
   430                         buf().operator[]( aaa ) = processIdNull;
       
   431                         }
       
   432                     }
       
   433                 if( position != KErrNotFound )
       
   434                     {
       
   435                     returnErr = RProperty::Set(
       
   436                         KTspClientMapperProperty,
       
   437                         KTspClientMapperKeyRegistered,
       
   438                         buf );
       
   439                     }
       
   440                 else
       
   441                     {
       
   442                     returnErr = KErrNotFound;
       
   443                     }
       
   444                 }
       
   445             break;
       
   446             }
       
   447         case EStoppedClients:
       
   448             {
       
   449             
       
   450             COM_TRACE_( "[TspClientMapperImpl] CTspClientMapperImpl::RemoveTspTargetClientL() EStoppedClients " );
       
   451             returnErr = RProperty::Get(
       
   452                 KTspClientMapperProperty,
       
   453                 KTspClientMapperKeyStopped,
       
   454                 buf );
       
   455             if( returnErr != KErrNotFound )
       
   456                 {
       
   457                 for( TInt aaa = 0; aaa != buf().Count(); aaa++ )
       
   458                     {
       
   459                     if( aProcessId == buf().operator[]( aaa ) )
       
   460                         {
       
   461                         position = aaa;
       
   462                         buf().operator[]( aaa ) = processIdNull;
       
   463                         }
       
   464                     }
       
   465                 if( position != KErrNotFound )
       
   466                     {
       
   467                     returnErr = RProperty::Set(
       
   468                         KTspClientMapperProperty,
       
   469                         KTspClientMapperKeyStopped,
       
   470                         buf );
       
   471                     }
       
   472                 else
       
   473                     {
       
   474                     returnErr = KErrNotFound;
       
   475                     }
       
   476                 }
       
   477             break;
       
   478             }
       
   479         default:
       
   480             {
       
   481             
       
   482             COM_TRACE_( "[TspClientMapperImpl] CTspClientMapperImpl::RemoveTspTargetClientL() Default - LEAVE " );
       
   483             returnErr = KErrGeneral;
       
   484             }
       
   485         }
       
   486 	COM_TRACE_( "[TspClientMapperImpl] CTspClientMapperImpl::RemoveTspTargetClientL() - return" );
       
   487 	return returnErr;
       
   488 	}
       
   489 	
       
   490 // -----------------------------------------------------------------------------
       
   491 // CTspClientMapperImpl::GetTspTargetClientsL
       
   492 // Provides implementation of this (TSP) interface. 
       
   493 // (other items were commented in a header).
       
   494 // -----------------------------------------------------------------------------
       
   495 //
       
   496 TInt CTspClientMapperImpl::GetTspTargetClients( 
       
   497     TTspClientMappingType aMappingType,
       
   498     RArray< TProcessId >& aPidArray )
       
   499 	{
       
   500 	TInt returnErr( KErrNone );
       
   501 	if( aMappingType > EStoppedClients )
       
   502         {
       
   503         returnErr = KErrNotSupported;
       
   504         }
       
   505     TFixedArray< TProcessId, 10 > array;
       
   506     TPckg< TFixedArray< TProcessId, 10 > > buf( array );
       
   507     COM_TRACE_1( "[TspClientMapperImpl] CTspClientMapperImpl::GetTspTargetClientsL() aMappingType = %d", aMappingType );
       
   508 	TInt count( 0 );
       
   509     
       
   510 	TTspClientMapperSynch synchObj( iMutex );
       
   511 	
       
   512     if( aMappingType == EPlayingClients )
       
   513         {
       
   514         COM_TRACE_( "[TspClientMapperImpl] CTspClientMapperImpl::GetTspTargetClientsL() - Getting playing clients" );
       
   515         returnErr = RProperty::Get(
       
   516             KTspClientMapperProperty,
       
   517             KTspClientMapperKeyPlaying,
       
   518             buf );
       
   519         COM_TRACE_1( "[TspClientMapperImpl] CTspClientMapperImpl::GetTspTargetClientsL() playing clients count = %d", buf().Count() );
       
   520         count = buf().Count();
       
   521         }
       
   522    if( aMappingType == ERegisteredClients )
       
   523         {
       
   524         COM_TRACE_( "[TspClientMapperImpl] CTspClientMapperImpl::GetTspTargetClientsL() - Getting registered clients" );
       
   525         returnErr = RProperty::Get(
       
   526             KTspClientMapperProperty,
       
   527             KTspClientMapperKeyRegistered,
       
   528             buf );
       
   529         COM_TRACE_1( "[TspClientMapperImpl] CTspClientMapperImpl::GetTspTargetClientsL() registered clients count = %d", buf().Count() );
       
   530         count = buf().Count();
       
   531         }
       
   532     if( aMappingType == EStoppedClients )
       
   533         {
       
   534         COM_TRACE_( "[TspClientMapperImpl] CTspClientMapperImpl::GetTspTargetClientsL() - Getting stopped clients" );
       
   535         returnErr = RProperty::Get(
       
   536             KTspClientMapperProperty,
       
   537             KTspClientMapperKeyStopped,
       
   538             buf );
       
   539         COM_TRACE_1( "[TspClientMapperImpl] CTspClientMapperImpl::GetTspTargetClientsL() stopped clients count = %d", buf().Count() );
       
   540         count = buf().Count();
       
   541         }
       
   542         
       
   543     for ( TInt i = 0; i < count; i++ )
       
   544         {
       
   545         if ( (TInt)buf().operator[]( i ) != 0 ) // count of registered clients is lost with TFixedArray, so rely on id being different from 0
       
   546             {
       
   547             COM_TRACE_1( "[TspClientMapperImpl] CTspClientMapperImpl::GetTspTargetClientsL() first client's Pid = %d", (TInt)buf().operator[]( i ) );
       
   548             aPidArray.Append( buf().operator[]( i ) );
       
   549             }
       
   550         }
       
   551 	COM_TRACE_( "[TspClientMapperImpl] CTspClientMapperImpl::GetTspTargetClientsL() - return" );
       
   552 	return returnErr;
       
   553 	
       
   554 	}
       
   555 
       
   556 // -----------------------------------------------------------------------------
       
   557 // CTspClientMapperImpl::OpenMutexL
       
   558 // (other items were commented in a header).
       
   559 // -----------------------------------------------------------------------------
       
   560 //
       
   561 void CTspClientMapperImpl::OpenMutexL()
       
   562     {
       
   563     COM_TRACE_( "[TspClientMapperImpl] CTspClientMapperImpl::InitilizeMutexL()" );
       
   564     
       
   565     TInt err( iMutex.CreateGlobal( KTspClientMapperSynch ) );
       
   566     
       
   567     if ( err != KErrNone )
       
   568         {
       
   569         if ( err == KErrAlreadyExists )
       
   570             {
       
   571             err = iMutex.OpenGlobal( KTspClientMapperSynch );
       
   572             
       
   573             if ( err != KErrNone )
       
   574                 {
       
   575                 COM_TRACE_1( "[TspClientMapperImpl] CTspClientMapperImpl::InitilizeMutexL(): OpenGlobal err=%d", err );
       
   576                 User::Leave( err );
       
   577                 }
       
   578             }
       
   579         }
       
   580     }
       
   581 
       
   582 // -----------------------------------------------------------------------------
       
   583 // CTspClientMapperImpl::CloseMutex
       
   584 // (other items were commented in a header).
       
   585 // -----------------------------------------------------------------------------
       
   586 //
       
   587 void CTspClientMapperImpl::CloseMutex()
       
   588     {
       
   589     COM_TRACE_( "[TspClientMapperImpl] CTspClientMapperImpl::CloseMutexL()" );
       
   590     
       
   591     if ( iMutex.IsHeld() )
       
   592             {
       
   593             iMutex.Signal();
       
   594             }
       
   595     iMutex.Close();
       
   596     }
       
   597 
       
   598 // -----------------------------------------------------------------------------
       
   599 // TTspClientMapperSynch::TTspClientMapperSynch
       
   600 // (other items were commented in a header).
       
   601 // -----------------------------------------------------------------------------
       
   602 //
       
   603 CTspClientMapperImpl::TTspClientMapperSynch::TTspClientMapperSynch( RMutex& aMutex ) : iMutex( aMutex )
       
   604     {
       
   605     COM_TRACE_( "[TspClientMapperImpl] TTspClientMapperSynch::TTspClientMapperSynch()" );
       
   606     iMutex.Wait();
       
   607     }
       
   608 // -----------------------------------------------------------------------------
       
   609 // TTspClientMapperSynch::TTspClientMapperSynch
       
   610 // (other items were commented in a header).
       
   611 // -----------------------------------------------------------------------------
       
   612 //
       
   613 CTspClientMapperImpl::TTspClientMapperSynch::~TTspClientMapperSynch()
       
   614     {
       
   615     COM_TRACE_( "[TspClientMapperImpl] TTspClientMapperSynch::~TTspClientMapperSynch()" );
       
   616     iMutex.Signal();
       
   617     }
       
   618 
       
   619 // End of file