phoneclientserver/phoneserver/Src/Messenger/CPhSrvMessengerRequestManager.cpp
changeset 46 2fa1fa551b0b
parent 42 35488577e233
child 48 78df25012fda
equal deleted inserted replaced
42:35488577e233 46:2fa1fa551b0b
     1 /*
       
     2 * Copyright (c) 2004 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:  Messenger Request Manager.
       
    15 *                The stub version of this file can be found from file
       
    16 *                CPhSrvMessengerRequestManagerStub.cpp
       
    17 *
       
    18 */
       
    19 
       
    20 
       
    21 
       
    22 // INCLUDES
       
    23 #include "cphsrvmessengerrequestmanager.h" 
       
    24 #include "cphsrvmessengerobject.h" 
       
    25 #include "cphsrvsubsessionbase.h" 
       
    26 #include "phsrvutils.h" 
       
    27 #include "phsrvmessengertypes.h" 
       
    28 #include "phsrvdebuginfo.h" 
       
    29 
       
    30 
       
    31 // CONSTANTS
       
    32 
       
    33 // The default size of the Messenger object storage.
       
    34 const TInt KPhSrvMessengerObjectGranularity = 4;
       
    35 
       
    36 // The size of the Sent message's storage.
       
    37 const TInt KPhSrvMessengerPendingSendRequestGranularity 
       
    38     = KPhSrvMessengerObjectGranularity;
       
    39 
       
    40 
       
    41 
       
    42 
       
    43 // ============================ MEMBER FUNCTIONS ===============================
       
    44 
       
    45 // -----------------------------------------------------------------------------
       
    46 // CPhSrvMessengerRequestManager::CPhSrvMessengerRequestManager
       
    47 // 
       
    48 // Constructor.
       
    49 // -----------------------------------------------------------------------------
       
    50 //
       
    51 CPhSrvMessengerRequestManager::CPhSrvMessengerRequestManager( 
       
    52     CPhSrvServer& aServer )
       
    53 :   iServer( aServer ),
       
    54     iSentDataIdGenerator( 1 ), // Is never 0.
       
    55     iSendProcessOngoing( EFalse )
       
    56     {
       
    57     }
       
    58 
       
    59 
       
    60 // -----------------------------------------------------------------------------
       
    61 // CPhSrvMessengerRequestManager::~CPhSrvMessengerRequestManager
       
    62 // 
       
    63 // Destructor.
       
    64 // -----------------------------------------------------------------------------
       
    65 //
       
    66 CPhSrvMessengerRequestManager::~CPhSrvMessengerRequestManager()
       
    67     {
       
    68     delete iDefaultSizeBuffer;
       
    69 
       
    70     RMessengerArray* array = SendChain();
       
    71     if ( array )
       
    72         {
       
    73         // Objects not deleted, because they are not owned.
       
    74         array->Reset();
       
    75         array->Close();
       
    76         delete array;
       
    77         }
       
    78 
       
    79     array = MessengerArray();
       
    80     if ( array )
       
    81         {
       
    82         array->ResetAndDestroy();
       
    83         array->Close();
       
    84 
       
    85         delete array;
       
    86         }
       
    87     }
       
    88 
       
    89 
       
    90 // -----------------------------------------------------------------------------
       
    91 // CPhSrvMessengerRequestManager::ConstructL
       
    92 // 
       
    93 // Complete construction.
       
    94 // -----------------------------------------------------------------------------
       
    95 //
       
    96 void CPhSrvMessengerRequestManager::ConstructL()
       
    97     {
       
    98     iDefaultSizeBuffer = HBufC8::NewMaxL( KPhCltDefMesSize );
       
    99 
       
   100     // Space for messenger objects (clients)
       
   101     iMessengerObjects = new ( ELeave ) RPointerArray< 
       
   102         CPhSrvMessengerObject >( KPhSrvMessengerObjectGranularity );
       
   103 
       
   104     // Space for the Send queue.
       
   105     iSendChain = new ( ELeave ) RPointerArray< CPhSrvMessengerObject >( 
       
   106         KPhSrvMessengerPendingSendRequestGranularity );
       
   107     }
       
   108 
       
   109 
       
   110 // -----------------------------------------------------------------------------
       
   111 // CPhSrvMessengerRequestManager::NegotiatorRequest
       
   112 // 
       
   113 // Initiate a messenger request - called by the external messenger interface.
       
   114 // -----------------------------------------------------------------------------
       
   115 //
       
   116 void CPhSrvMessengerRequestManager::NegotiatorRequest( 
       
   117     CPhSrvSubSessionBase& aSubSession,
       
   118     const TPhCltMessengerParameters& aParameters,
       
   119     const RMessage2& aMessage )
       
   120     {
       
   121     _DPRINT( 4, "PhSrv.MRM.NegotiatorRequest START" );   // debug print
       
   122 
       
   123     // Panic if this is not the only request from this subsession.
       
   124     if ( RequestAlreadyExists( 
       
   125              aSubSession, 
       
   126              aParameters,
       
   127              aMessage ) )
       
   128         {
       
   129     _DPRINT( 4, "PhSrv.MRM.NegotiatorRequest PANIC" );   // debug print
       
   130 
       
   131         // First delete all data related to this object.
       
   132         NegotiatorRequestDelete( aSubSession );
       
   133 
       
   134         PhoneServerUtils::PanicClient( 
       
   135             EPhoneServerPanicTooManyRequestsOngoing,
       
   136             aMessage );
       
   137         }
       
   138     else
       
   139         {
       
   140     _DPRINT( 4, "PhSrv.MRM.NegotiatorRequest HANDLE" );   // debug print
       
   141 
       
   142         // Request was set successfully, so handle it.
       
   143         TPhCltMessengerCommand command = aParameters.iMessengerCommand;
       
   144 
       
   145         // Update the messenger chain.
       
   146         UpdateMessengerChain( iRequestObject, command );
       
   147 
       
   148         // Clear the request object.
       
   149         iRequestObject = NULL;
       
   150 
       
   151         // Complete Skip request.
       
   152         if ( command == EPhCltMesCommandSkip )
       
   153             {
       
   154             aMessage.Complete( KErrNone );
       
   155             }
       
   156         }
       
   157 
       
   158     _DPRINT( 4, "PhSrv.MRM.NegotiatorRequest END" );   // debug print
       
   159     }
       
   160 
       
   161 
       
   162 // -----------------------------------------------------------------------------
       
   163 // CPhSrvMessengerRequestManager::NegotiatorRequestCancel
       
   164 // 
       
   165 // Cancel a messenger request handling.
       
   166 // -----------------------------------------------------------------------------
       
   167 //
       
   168 void CPhSrvMessengerRequestManager::NegotiatorRequestCancel( 
       
   169     CPhSrvSubSessionBase& aSubSession,
       
   170     const TPhCltMessengerCommand aRequestType )
       
   171     {
       
   172     _DPRINT( 4, "PhSrv.MRM.NegotiatorRequestCancel START" );   // debug print
       
   173 
       
   174     RMessengerArray* messengerObjects = MessengerArray();
       
   175 
       
   176     if ( aRequestType == EPhCltMesCommandSend ||
       
   177          aRequestType == EPhCltMesCommandReceive )
       
   178         {
       
   179         // Obtain the subsession's handle
       
   180         const TInt handle = aSubSession.SubSessionUniqueHandle();
       
   181 
       
   182         // Now look for any object that match.
       
   183         const TInt count = messengerObjects->Count();
       
   184         for( TInt i = 0; i < count; i++ )
       
   185             {
       
   186             CPhSrvMessengerObject* entry = ( *messengerObjects )[i];
       
   187             if ( entry->SubSessionHandle() == handle )
       
   188                 {
       
   189                 // Found matching entry, so cancel it's request.
       
   190                 entry->InformOfMessengerRequest( KErrCancel, aRequestType );
       
   191 
       
   192 
       
   193                 TPhCltMessengerCommand request = aRequestType;
       
   194                 if ( aRequestType == EPhCltMesCommandSend )
       
   195                     {
       
   196                     // Send request is canceled.
       
   197                     request = EPhCltMesCommandCancelSend;
       
   198                     }
       
   199                 else
       
   200                     {
       
   201                     // Receive request is canceled.
       
   202                     request = EPhCltMesCommandCancelReceive;
       
   203                     }
       
   204 
       
   205                 // Update the messenger chain.
       
   206                 UpdateMessengerChain( entry, request );
       
   207                 }
       
   208             }
       
   209         }
       
   210     _DPRINT( 4, "PhSrv.MRM.NegotiatorRequestCancel STOP" );   // debug print
       
   211     }
       
   212 
       
   213 
       
   214 // -----------------------------------------------------------------------------
       
   215 // CPhSrvMessengerRequestManager::NegotiatorRequestConstructL
       
   216 // 
       
   217 // Reserve all space needed for the subsession given as parameter.
       
   218 // -----------------------------------------------------------------------------
       
   219 //
       
   220 void CPhSrvMessengerRequestManager::NegotiatorRequestConstructL( 
       
   221     CPhSrvSubSessionBase& aSubSession,
       
   222     const TPhCltMessengerParameters& aParameters,
       
   223     const RMessage2& aMessage )
       
   224     {
       
   225     _DPRINT( 4, "PhSrv.MRM.NegotiatorRequestConstructL START" ); // debug print
       
   226 
       
   227     // Create pending request
       
   228     CPhSrvMessengerObject* object = CPhSrvMessengerObject::NewLC(
       
   229         aSubSession,
       
   230         aParameters );
       
   231 
       
   232     RMessengerArray* sendArray = SendChain();
       
   233     RMessengerArray* messengerObjects = MessengerArray();
       
   234 
       
   235     /////////////////////////////////////////////////////////////////
       
   236     // First try that there is enough space in send array.
       
   237     /////////////////////////////////////////////////////////////////
       
   238     const CPhSrvMessengerObject* entry = NULL;
       
   239     TInt err = KErrNone;
       
   240     // The number of existing messenger objects + the new one.
       
   241     const TInt count = ( messengerObjects->Count() + 1 );
       
   242 
       
   243     TInt i = 0;
       
   244     for ( i = 0; ( i < count ) && ( err == KErrNone ); i++ )
       
   245         {
       
   246         // If Append failed, there is not enough memory and err != KErrNone.
       
   247         err = sendArray->Append( entry );
       
   248         }
       
   249 
       
   250     // Remove now the added objects -> Buffer remains reserved for them.
       
   251     const TInt sendChainCount = ( sendArray->Count() - 1 );
       
   252     for( i = sendChainCount; i >= 0; i-- )
       
   253         {
       
   254         if( ( * sendArray )[i] == NULL )
       
   255             {
       
   256             // This object was added, so remove it.
       
   257             sendArray->Remove( i );
       
   258             }
       
   259         }
       
   260 
       
   261     // Leave if addition to send chain were not successful.
       
   262     User::LeaveIfError( err );
       
   263 
       
   264     _DPRINT( 4, "PhSrv.MRM.NegotiatorRequestConstructL MIDDLE" ); // debug print
       
   265 
       
   266     /////////////////////////////////////////////////////////////////
       
   267     // There was enough space in send array, so next try to append the 
       
   268     // object to the object array.
       
   269     /////////////////////////////////////////////////////////////////
       
   270     User::LeaveIfError( 
       
   271         messengerObjects->Append( object ) );
       
   272     CleanupStack::Pop( object );
       
   273 
       
   274     aMessage.Complete( KErrNone );
       
   275 
       
   276     _DPRINT( 4, "PhSrv.MRM.NegotiatorRequestConstructL STOP" );  // debug print
       
   277     }
       
   278 
       
   279 
       
   280 // -----------------------------------------------------------------------------
       
   281 // CPhSrvMessengerRequestManager::NegotiatorRequestDelete
       
   282 // 
       
   283 // Delete all space reserved for the subsession given as parameter.
       
   284 // -----------------------------------------------------------------------------
       
   285 //
       
   286 void CPhSrvMessengerRequestManager::NegotiatorRequestDelete( 
       
   287     CPhSrvSubSessionBase& aSubSession )
       
   288     {
       
   289     _DPRINT( 4, "PhSrv.MRM.NegotiatorRequestDelete START" );   // debug print
       
   290 
       
   291     // Obtain the subsessions handle
       
   292     const TInt handle = aSubSession.SubSessionUniqueHandle();
       
   293 
       
   294     RMessengerArray* messengerObjects = MessengerArray();
       
   295 
       
   296     // Now look for any object that match.
       
   297     TInt count = messengerObjects->Count() - 1;
       
   298     for( TInt i = count; i >= 0; i-- )
       
   299         {
       
   300         CPhSrvMessengerObject* entry = ( *messengerObjects )[i];
       
   301         if ( entry->SubSessionHandle() == handle )
       
   302             {
       
   303             // Found matching entry, so cancel it and clean up.
       
   304 
       
   305             // This object is not in handled objects anymore.
       
   306             // This means also that objects receive is also canceled.
       
   307             messengerObjects->Remove( i );
       
   308 
       
   309             // Update the messenger chain, cancel Send.
       
   310             UpdateMessengerChain( entry, EPhCltMesCommandCancelSend );
       
   311 
       
   312             // Send and receive were canceled, so this entry can be destroyed.
       
   313             delete entry;
       
   314             }
       
   315         }
       
   316     _DPRINT( 4, "PhSrv.MRM.NegotiatorRequestDelete STOP" );   // debug print
       
   317     }
       
   318 
       
   319 
       
   320 // -----------------------------------------------------------------------------
       
   321 // CPhSrvMessengerRequestManager::UpdateMessengerChain
       
   322 // 
       
   323 // Update the request objects.
       
   324 // -----------------------------------------------------------------------------
       
   325 //
       
   326 void CPhSrvMessengerRequestManager::UpdateMessengerChain(
       
   327     CPhSrvMessengerObject* aEntry,
       
   328     TPhCltMessengerCommand aCommand )
       
   329     {
       
   330     _DPRINT( 4, "PhSrv.MRM.Negotiator.Update START" );   // debug print
       
   331 
       
   332     TInt err = KErrNone;
       
   333     RMessengerArray* sendArray = SendChain();
       
   334 
       
   335 
       
   336     if ( aEntry )
       
   337         {
       
   338         switch ( aCommand )
       
   339             {
       
   340             case EPhCltMesCommandSend:
       
   341                 {
       
   342                 // If this is new request, append it to send queue.
       
   343                 if( sendArray->Find( aEntry ) == KErrNotFound )
       
   344                     {
       
   345                     err = sendArray->Append( aEntry );
       
   346                     if ( err )
       
   347                         {
       
   348                         // Should never happen because of space pre-reservation
       
   349                         // in construction phase. However, recover.
       
   350 
       
   351                         // If Append did not succeed, inform Sender of failure.
       
   352                         aEntry->InformOfMessengerRequest( 
       
   353                             err,
       
   354                             EPhCltMesCommandSend );
       
   355                         }
       
   356                     }
       
   357 
       
   358                 // If Append was not performed or if it was successful.
       
   359                 if ( !err )
       
   360                     {
       
   361                     // Handle all Send requests that exist.
       
   362                     HandleAllSendRequests( aEntry, sendArray );
       
   363                     }
       
   364                 break;
       
   365                 }
       
   366             case EPhCltMesCommandReceive:
       
   367             case EPhCltMesCommandSkip:
       
   368             case EPhCltMesCommandCancelReceive:
       
   369                 {
       
   370                 // Handle all Send requests that exist.
       
   371                 HandleAllSendRequests( NULL, sendArray );
       
   372                 break;
       
   373                 }
       
   374 
       
   375             case EPhCltMesCommandCancelSend:
       
   376                 {
       
   377                 // Remove this Send object from chain.
       
   378                 // Pending Receive requests not completed.
       
   379                 TInt location = sendArray->Find( aEntry );
       
   380                 if ( location >= 0 )
       
   381                     {
       
   382                     // If this is the first object in Send chain, then
       
   383                     // Send request processing is canceled.
       
   384                     if( aEntry == ( *sendArray )[0] )
       
   385                         {
       
   386                         iSendProcessOngoing = EFalse;
       
   387                         }
       
   388                     sendArray->Remove( location );
       
   389                     }
       
   390 
       
   391                 // Handle all other Send requests that exist.
       
   392                 HandleAllSendRequests( NULL, sendArray );
       
   393                 break;
       
   394                 }
       
   395 
       
   396             default:
       
   397                 // Should never happen!
       
   398                 break;
       
   399             }
       
   400         }
       
   401     _DPRINT( 4, "PhSrv.MRM.Negotiator.Update STOP" );   // debug print
       
   402     }
       
   403 
       
   404 
       
   405 // -----------------------------------------------------------------------------
       
   406 // CPhSrvMessengerRequestManager::HandleAllSendRequests
       
   407 // 
       
   408 // 
       
   409 // -----------------------------------------------------------------------------
       
   410 //
       
   411 void CPhSrvMessengerRequestManager::HandleAllSendRequests(
       
   412     CPhSrvMessengerObject* aEntry,
       
   413     RMessengerArray* aSendArray )
       
   414     {
       
   415     CPhSrvMessengerObject* entry = aEntry;
       
   416 
       
   417     // If aEntry is NULL, try to set it as valid object.
       
   418     if ( !entry )
       
   419         {
       
   420         if ( aSendArray->Count() )
       
   421             {
       
   422             entry = ( *aSendArray )[0]; // Take the first object in send chain.
       
   423             }
       
   424         }
       
   425 
       
   426     // Handle all Send requests that exists.
       
   427     while ( HandleSendRequest( entry, aSendArray ) )
       
   428         {
       
   429         entry = NULL;
       
   430         if ( aSendArray->Count() )
       
   431             {
       
   432             entry = ( *aSendArray )[0]; // Take the first object in send chain.
       
   433             }
       
   434         }
       
   435     }
       
   436 
       
   437 
       
   438 // -----------------------------------------------------------------------------
       
   439 // CPhSrvMessengerRequestManager::HandleSendRequest
       
   440 // 
       
   441 // 
       
   442 // -----------------------------------------------------------------------------
       
   443 //
       
   444 TBool CPhSrvMessengerRequestManager::HandleSendRequest( 
       
   445     CPhSrvMessengerObject* aEntry,
       
   446     RMessengerArray* aSendArray )
       
   447     {
       
   448     TBool ret = EFalse;
       
   449     RMessengerArray* messengerObjects = MessengerArray();
       
   450 
       
   451 
       
   452     // Handling is done only if there is Send request and 
       
   453     // aEntry is valid object.
       
   454     if( aSendArray->Count() && aEntry )
       
   455         {
       
   456         if ( aEntry == ( *aSendArray )[0] )
       
   457             {
       
   458             // This was the first Send operation so complete Receives.
       
   459 
       
   460             // Some pre-work needs to be done if this Send has not been 
       
   461             // handled before.
       
   462             if( !iSendProcessOngoing )
       
   463                 {
       
   464                 // Now this Send request process is ongoing.
       
   465                 iSendProcessOngoing = ETrue;
       
   466 
       
   467                 const TInt sentDataLength = aEntry->GetSendDataLength();
       
   468 
       
   469                 if ( sentDataLength > 
       
   470                      iDefaultSizeBuffer->Des().MaxLength() )
       
   471                     {
       
   472                     // The sent data is longer than the default buffer.
       
   473                     // We need to try reserve bigger buffer. If this does not
       
   474                     // succeed, then only the current size buffer is used in 
       
   475                     // sending.
       
   476 
       
   477                     HBufC8* variableSizeBuffer = NULL;
       
   478                     variableSizeBuffer = HBufC8::New( sentDataLength );
       
   479                     if ( variableSizeBuffer != NULL )
       
   480                         {
       
   481                         // Reservation was successful, so use reserved buffer
       
   482                         // as a new default buffer. 
       
   483                         // But first delete the old buffer.
       
   484                         if( iDefaultSizeBuffer )
       
   485                             {
       
   486                             delete iDefaultSizeBuffer;
       
   487                             iDefaultSizeBuffer = NULL;
       
   488                             }
       
   489                         iDefaultSizeBuffer = variableSizeBuffer;
       
   490                         }
       
   491                     }
       
   492                 // Read the sent message.
       
   493                 TPtr8 ptr = iDefaultSizeBuffer->Des();
       
   494                 aEntry->GetSendData( ptr );
       
   495                 }
       
   496 
       
   497 
       
   498             const TDesC8& sendData = *iDefaultSizeBuffer;
       
   499             const TUid& senderUid = aEntry->GetUid();
       
   500             const TUint sentDataId = aEntry->SentDataId();
       
   501 
       
   502             TBool completeSend = ETrue;
       
   503             TInt interested = 0;
       
   504 
       
   505             TInt count = messengerObjects->Count();
       
   506 
       
   507             ////////////////////////////////////////////////////////
       
   508             // Check that all the objects are ready to receive.
       
   509             ////////////////////////////////////////////////////////
       
   510             for( TInt i = 0; i < count; i++ )
       
   511                 {
       
   512                 CPhSrvMessengerObject* entry = ( *messengerObjects )[i];
       
   513 
       
   514                 // Check only other objects.
       
   515                 if ( aEntry->SubSessionHandle() != entry->SubSessionHandle() )
       
   516                     {
       
   517                     // We need to care only of those objects that want to
       
   518                     // listen messages same type as the sent was.
       
   519                     if( senderUid == entry->GetUid() )
       
   520                         {
       
   521                         // This object wants to receive this sent message.
       
   522                         interested++;
       
   523 
       
   524                         if ( !entry->IsReadyToReceive( sendData, sentDataId ) )
       
   525                             {
       
   526                             // The object was not ready to receive, so Send can 
       
   527                             // not be completed yet.
       
   528                             completeSend = EFalse;
       
   529                             }
       
   530                         }
       
   531                     }
       
   532                 }
       
   533 
       
   534 
       
   535             ////////////////////////////////////////////////////////
       
   536             // If all objects were ready to receive, complete them.
       
   537             // If there were no objects interested of the sent message,
       
   538             // do nothing.
       
   539             ////////////////////////////////////////////////////////
       
   540             if ( completeSend && interested )
       
   541                 {
       
   542                 for( TInt i = 0; i < count; i++ )
       
   543                     {
       
   544                     CPhSrvMessengerObject* entry = ( *messengerObjects )[i];
       
   545 
       
   546                     // Complete only other's Receive requests.
       
   547                     if ( aEntry->SubSessionHandle() != 
       
   548                          entry->SubSessionHandle() )
       
   549                         {
       
   550                         // We complete only those object's receives that have
       
   551                         // the same category UID as the sent was.
       
   552                         if( senderUid == entry->GetUid() )
       
   553                             {
       
   554                             TInt err = entry->CompleteReceive( 
       
   555                                 sendData,
       
   556                                 sentDataId );
       
   557                             if( err )
       
   558                                 {
       
   559                                 // This should never fail because pre-check was
       
   560                                 // successful. However, you can try to recover.
       
   561                                 }
       
   562                             }
       
   563                         }
       
   564                     }
       
   565                 // All receives were compeled, so complete Send.
       
   566                 aEntry->InformOfMessengerRequest( 
       
   567                     KErrNone,
       
   568                     EPhCltMesCommandSend );
       
   569                 // Remove the object whose Send was handled from chain.
       
   570                 aSendArray->Remove( 0 );
       
   571 
       
   572                 // The send process was completed.
       
   573                 iSendProcessOngoing = EFalse;
       
   574 
       
   575                 // Send was fully handled.
       
   576                 ret = ETrue;
       
   577                 }
       
   578             }
       
   579         }
       
   580     return ret;
       
   581     }
       
   582 
       
   583 
       
   584 // -----------------------------------------------------------------------------
       
   585 // CPhSrvMessengerRequestManager::RequestAlreadyExists
       
   586 // 
       
   587 // Check whether there already is request(s) for the subsession given as 
       
   588 // parameter. If not, then sets it active.
       
   589 // -----------------------------------------------------------------------------
       
   590 //
       
   591 TBool CPhSrvMessengerRequestManager::RequestAlreadyExists( 
       
   592     const CPhSrvSubSessionBase& aSubSession,
       
   593     const TPhCltMessengerParameters& aParameters,
       
   594     const RMessage2& aMessage )
       
   595     {
       
   596     TBool isThereRequest = EFalse;
       
   597     const TPhCltMessengerCommand command = aParameters.iMessengerCommand;
       
   598 
       
   599     // Check is only done for Send and Receive and Skip.
       
   600     if ( command == EPhCltMesCommandSend ||
       
   601          command == EPhCltMesCommandReceive ||
       
   602          command == EPhCltMesCommandSkip )
       
   603         {
       
   604         // Obtain the subsessions handle
       
   605         const TInt handle = aSubSession.SubSessionUniqueHandle();
       
   606 
       
   607         RMessengerArray* messengerObjects = MessengerArray();
       
   608 
       
   609         // Look for any pending requests that match the handle.
       
   610         TInt i = 0;
       
   611         for( i = 0; i < messengerObjects->Count(); i++ )
       
   612             {
       
   613             CPhSrvMessengerObject* entry = ( *messengerObjects )[i];
       
   614             if ( entry->SubSessionHandle() == handle )
       
   615                 {
       
   616                 isThereRequest = entry->IsRequestActive( command );
       
   617                 if ( !isThereRequest )
       
   618                     {
       
   619                     TUint sentDataId = 0;
       
   620                     if( command == EPhCltMesCommandSend )
       
   621                         {
       
   622                         // This was sent command, so set ID for it.
       
   623                         sentDataId = iSentDataIdGenerator;
       
   624                         // New Id for next sent message, must never be 0!
       
   625                         iSentDataIdGenerator++;
       
   626                         if( !iSentDataIdGenerator )
       
   627                             {
       
   628                             // Value was 0, so set to 1.
       
   629                             iSentDataIdGenerator++;
       
   630                             }
       
   631                         }
       
   632                     // Request was not active, so set it active.
       
   633                     entry->SetActive( aParameters, aMessage, sentDataId );
       
   634                     }
       
   635 
       
   636                 // Set the object who initiated this request.
       
   637                 iRequestObject = entry;
       
   638                 break;
       
   639                 }
       
   640             }
       
   641         }
       
   642     return isThereRequest;
       
   643     }
       
   644 
       
   645 
       
   646 
       
   647 // -----------------------------------------------------------------------------
       
   648 // CPhSrvMessengerRequestManager::MessengerArray
       
   649 // 
       
   650 // 
       
   651 // -----------------------------------------------------------------------------
       
   652 //
       
   653 RMessengerArray* CPhSrvMessengerRequestManager::MessengerArray()
       
   654     {
       
   655     return iMessengerObjects;
       
   656     }
       
   657 
       
   658 
       
   659 // -----------------------------------------------------------------------------
       
   660 // CPhSrvMessengerRequestManager::SendChain
       
   661 // 
       
   662 // 
       
   663 // -----------------------------------------------------------------------------
       
   664 //
       
   665 RMessengerArray* CPhSrvMessengerRequestManager::SendChain()
       
   666     {
       
   667     return iSendChain;
       
   668     }
       
   669 
       
   670 
       
   671 // End of File