multimediacommsengine/tsrc/ututils/src/MCETestHelper.cpp
changeset 0 1bce908db942
equal deleted inserted replaced
-1:000000000000 0:1bce908db942
       
     1 /*
       
     2 * Copyright (c) 2005 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:  
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 #include "MCETestHelper.h"
       
    23 #include "mcesipsession.h"
       
    24 #include "mcesipevent.h"
       
    25 #include "mcecssession.h"
       
    26 #include "mcecssessionimplementation.h"
       
    27 #include "mceservercore.h"
       
    28 #include "SIPExpiresHeader.h"
       
    29 #include "SIPEventHeader.h"
       
    30 #include "mcereliablesender.h"
       
    31 #include "sipsupportedheader.h"
       
    32 #include "siprackheader.h"
       
    33 #include <siprequireheader.h>
       
    34 #include <siprseqheader.h>
       
    35 #include <sipcontactheader.h>
       
    36 
       
    37 _LIT8(KFmtAttribute,"a=fmtp:TBCP format parameters\r\n");
       
    38 _LIT8(KFmtAttribute2,"a=fmtp:TestPlugIn format parameters\r\n");
       
    39 
       
    40 
       
    41 // -----------------------------------------------------------------------------
       
    42 // MCETestHelper::ClientCreateSessionL()
       
    43 // -----------------------------------------------------------------------------
       
    44 //
       
    45 CMceSipSession* MCETestHelper::ClientCreateSessionL( CMceCsSession* aClient, 
       
    46                                                      const TDesC8& aParam1, 
       
    47                                                      const TDesC8& aParam2 )
       
    48     {
       
    49     
       
    50     TMceIds& ids = CMCETls::Storage()->iIds;
       
    51     
       
    52 	CDesC8ArrayFlat* params = new (ELeave) CDesC8ArrayFlat( KMceArrayGranularity );
       
    53 	CleanupStack::PushL( params );
       
    54 	params->AppendL( aParam1 );
       
    55 	params->AppendL( aParam2 );
       
    56     
       
    57     CMceMsgTextArray* msgParams = new (ELeave) CMceMsgTextArray( *params );
       
    58     CleanupStack::PushL( msgParams );
       
    59     CMCETls::Storage()->StoreL( ids, *msgParams );
       
    60     CleanupStack::PopAndDestroy( msgParams );
       
    61     CleanupStack::PopAndDestroy( params );
       
    62     
       
    63     TInt count = aClient->Implementation().SubSessions().Count();
       
    64     
       
    65     aClient->CreateSubSessionL(ids, RMessage2() );
       
    66     
       
    67     return static_cast<CMceSipSession*>(aClient->Implementation().SubSessions()[ count ]);
       
    68     
       
    69     }
       
    70     
       
    71 
       
    72 // -----------------------------------------------------------------------------
       
    73 // MCETestHelper::ManagerReadyToReceiveL()
       
    74 // -----------------------------------------------------------------------------
       
    75 //
       
    76 void MCETestHelper::ManagerReadyToReceiveL( CMceCsSession* aClient )
       
    77     {
       
    78     TMceIds& ids = CMCETls::Storage()->iManagerIds;
       
    79     
       
    80     CMCETls::Storage()->iIdsIndex = 1;
       
    81     aClient->ClientReadyToReceiveL( ids, RMessage2() );
       
    82     CMCETls::Storage()->iIdsIndex = 0;
       
    83     }
       
    84     
       
    85 
       
    86 // -----------------------------------------------------------------------------
       
    87 // MCETestHelper::ClientReadyToReceiveL()
       
    88 // -----------------------------------------------------------------------------
       
    89 //
       
    90 void MCETestHelper::ClientReadyToReceiveL( CMceSipSession* aSession )
       
    91     {
       
    92     TMceIds& ids = CMCETls::Storage()->iIds;
       
    93 
       
    94 	delete CMCETls::Storage()->iContextServer;
       
    95 	delete CMCETls::Storage()->iContentServer;
       
    96 	CMCETls::Storage()->iContextServer = NULL;
       
    97 	CMCETls::Storage()->iContentServer = NULL;
       
    98 	CMCETls::Storage()->iMessageSizes = TMceMessageBufSizes();
       
    99     
       
   100     //client ready to receive
       
   101     ids.iSessionID = reinterpret_cast<TUint32>( aSession );
       
   102     aSession->ServiceL( ids, EMceItcClientReadyToReceive, RMessage2() );
       
   103 
       
   104     }
       
   105 
       
   106 // -----------------------------------------------------------------------------
       
   107 // MCETestHelper::ClientReceiveLC()
       
   108 // -----------------------------------------------------------------------------
       
   109 //
       
   110 CMceMsgBase* MCETestHelper::ClientReceiveLC( CMceSipSession* aSession, TMceIds& aIds )
       
   111     {
       
   112     CMceMsgBase* message = NULL;
       
   113     TMceIds& ids = CMCETls::Storage()->iIds;
       
   114     aIds = ids;
       
   115     
       
   116     if ( CMCETls::Storage()->iMessageSizes.iContextBufSize > 0 )
       
   117         {
       
   118         
       
   119         //client receive
       
   120         aSession->ServiceL( ids, EMceItcReceive, RMessage2() );
       
   121         
       
   122         //client code
       
   123     	RDesReadStream readStream( *CMCETls::Storage()->iContextServer );
       
   124         CleanupClosePushL( readStream );
       
   125         
       
   126         message = TMceComFactory().CreateL( (TMceItcDataType)ids.iMsgType,
       
   127                                                          readStream );
       
   128     	CleanupStack::PopAndDestroy(); // readStream
       
   129     	
       
   130         }
       
   131         
       
   132     ClientReadyToReceiveL( aSession );
       
   133 	
       
   134 	if ( message )
       
   135 	    {
       
   136     	CleanupStack::PushL( message );
       
   137 	    
       
   138 	    message->PushL();
       
   139 	    }
       
   140 	
       
   141     return message;    
       
   142     }
       
   143 
       
   144 // -----------------------------------------------------------------------------
       
   145 // MCETestHelper::ClientEstablishL()
       
   146 // -----------------------------------------------------------------------------
       
   147 //
       
   148 CMceComSession* MCETestHelper::ClientEstablishL( CMceSipSession* aSession,
       
   149                                                  const TDesC8& aHeader,
       
   150                                                  const TDesC8& aContentType,
       
   151                                                  const TDesC8& aContent,
       
   152                                                  TBool aRequire100rel )
       
   153     {
       
   154     TMceIds& ids = CMCETls::Storage()->iIds;
       
   155 
       
   156     CMceComSession* clientSession = ComSessionL( ids.iSessionID, aRequire100rel );
       
   157     CleanupStack::PushL( clientSession );
       
   158     
       
   159     if ( clientSession->iSIPHeaders->MdcaCount() > 0 && aHeader.Length() == 0 )
       
   160         {
       
   161         clientSession->iSIPHeaders->Delete( 0, clientSession->iSIPHeaders->MdcaCount() );
       
   162         }
       
   163         
       
   164     if ( aHeader.Length() > 0 )
       
   165         {
       
   166         clientSession->iSIPHeaders->AppendL( aHeader );
       
   167         }
       
   168     
       
   169     MCE_TH_SET( clientSession->iSIPContentType, NULL );
       
   170     clientSession->iSIPContentType = aContentType.AllocL();
       
   171     
       
   172     CMceMsgObject<CMceComSession>* clientSessionMsg = 
       
   173         new (ELeave) CMceMsgObject<CMceComSession>( *clientSession, EMceItcMsgTypeSession );
       
   174     CleanupStack::PushL( clientSessionMsg );
       
   175 
       
   176     HBufC8* content = aContent.AllocLC();
       
   177     
       
   178     CMCETls::Storage()->StoreL( ids, *clientSessionMsg, content );
       
   179     CleanupStack::Pop( content );
       
   180     
       
   181 
       
   182     CleanupStack::PopAndDestroy( clientSessionMsg );
       
   183 
       
   184     //establish
       
   185     aSession->ServiceL( ids, EMceItcEstablishSession, RMessage2() );
       
   186     CMCETls* storage = CMCETls::Storage();
       
   187   	MCE_CHECK_MEMORY_LEAVE( storage->iSipSentResponse && 
       
   188   	   ( storage->iSipSentResponse->StatusCode() == KMceSipServerInternalError || 
       
   189   	     storage->iSipSentResponse->StatusCode() == KMceSipDecline ) )
       
   190     
       
   191     CleanupStack::Pop( clientSession );
       
   192     
       
   193     return clientSession;
       
   194     }
       
   195 
       
   196 // -----------------------------------------------------------------------------
       
   197 // MCETestHelper::ClientTerminateL()
       
   198 // -----------------------------------------------------------------------------
       
   199 //
       
   200 void MCETestHelper::ClientTerminateL( CMceSipSession* aSession, 
       
   201                                       const TDesC8& aHeader,
       
   202                                       const TDesC8& aContentType,
       
   203                                       const TDesC8& aContent )
       
   204     {
       
   205     TMceIds& ids = CMCETls::Storage()->iIds;
       
   206     ids.iSessionID = aSession->Body()->Id();
       
   207 
       
   208     
       
   209     if ( aHeader.Length() == 0 && aContentType.Length() == 0 && aContent.Length() == 0 )
       
   210         {
       
   211         ids.iMsgType = KMceNotAssigned;
       
   212         aSession->ServiceL( ids, EMceItcTerminateSession, RMessage2() );
       
   213         return;
       
   214         }
       
   215         
       
   216     HBufC8* content = aContent.AllocLC();
       
   217     HBufC8* contentType = aContentType.AllocLC();
       
   218     CDesC8Array* headers = NULL;
       
   219     if ( aHeader.Length() > 0 )
       
   220         {
       
   221         headers = new (ELeave) CDesC8ArrayFlat( KMceArrayGranularity );
       
   222         CleanupStack::PushL( headers );
       
   223         headers->AppendL( aHeader );
       
   224         }
       
   225     
       
   226     CMceMsgSIPData* sipData = new (ELeave) CMceMsgSIPData( SipStrConsts::EBye,
       
   227                                                            *headers, *contentType );
       
   228 
       
   229     CleanupStack::PushL( sipData );
       
   230     
       
   231     CMCETls::Storage()->StoreL( ids, *sipData, content );
       
   232     CleanupStack::PopAndDestroy( sipData );
       
   233     
       
   234     if ( headers )
       
   235         CleanupStack::PopAndDestroy( headers );
       
   236     
       
   237     CleanupStack::PopAndDestroy( contentType );
       
   238     CleanupStack::Pop( content );
       
   239 
       
   240     //reject session
       
   241     aSession->ServiceL( ids, EMceItcTerminateSession, RMessage2() );
       
   242     CMCETls* storage = CMCETls::Storage();
       
   243   	MCE_CHECK_MEMORY_LEAVE( storage->iSipSentResponse && 
       
   244   	   ( storage->iSipSentResponse->StatusCode() == KMceSipServerInternalError || 
       
   245   	     storage->iSipSentResponse->StatusCode() == KMceSipDecline ) )
       
   246     }
       
   247 
       
   248 // -----------------------------------------------------------------------------
       
   249 // MCETestHelper::ClientAcceptL()
       
   250 // -----------------------------------------------------------------------------
       
   251 //
       
   252 void MCETestHelper::ClientAcceptL( CMceSipSession* aSession,
       
   253                                     const TDesC8& aReason, 
       
   254                                     TInt aReasonCode )
       
   255     {
       
   256     TMceIds& ids = CMCETls::Storage()->iIds;
       
   257     ids.iSessionID = aSession->Body()->Id();
       
   258     
       
   259     CDesC8Array* headers = NULL;
       
   260     HBufC8* reason = NULL;
       
   261     HBufC8* ctype = NULL;
       
   262     
       
   263     if ( aReasonCode == -1 )
       
   264         {
       
   265         ids.iMsgType = KMceNotAssigned;
       
   266         aSession->ServiceL( ids, EMceItcAcceptSession, RMessage2() );
       
   267         CMCETls* storage = CMCETls::Storage();
       
   268       	MCE_CHECK_MEMORY_LEAVE( storage->iSipSentResponse && 
       
   269       	   ( storage->iSipSentResponse->StatusCode() == KMceSipServerInternalError || 
       
   270       	     storage->iSipSentResponse->StatusCode() == KMceSipDecline ) )
       
   271         return;
       
   272         }
       
   273         
       
   274     if ( aReasonCode == 0 )
       
   275         {
       
   276         aReasonCode = KMceSipOK;
       
   277         }
       
   278         
       
   279     if ( aReason.Length() > 0 )
       
   280         {
       
   281         reason = aReason.AllocLC();
       
   282         }
       
   283     else
       
   284         {
       
   285         reason = SIPStrings::StringF( SipStrConsts::EPhraseOk ).DesC().AllocLC();
       
   286         }
       
   287     
       
   288     CMceMsgSIPReply* reply = new (ELeave) CMceMsgSIPReply( *reason, (TUint32)aReasonCode, *headers, *ctype );
       
   289     CleanupStack::PushL( reply );
       
   290     
       
   291     CMCETls::Storage()->StoreL( ids, *reply, NULL );
       
   292     CleanupStack::PopAndDestroy( reply );
       
   293     CleanupStack::PopAndDestroy( reason );
       
   294 
       
   295     aSession->ServiceL( ids, EMceItcAcceptSession, RMessage2() );
       
   296     CMCETls* storage = CMCETls::Storage();
       
   297   	MCE_CHECK_MEMORY_LEAVE( storage->iSipSentResponse && 
       
   298   	   ( storage->iSipSentResponse->StatusCode() == KMceSipServerInternalError || 
       
   299   	     storage->iSipSentResponse->StatusCode() == KMceSipDecline ) )
       
   300     }
       
   301 
       
   302 // -----------------------------------------------------------------------------
       
   303 // MCETestHelper::ClientDeclineL()
       
   304 // -----------------------------------------------------------------------------
       
   305 //
       
   306 void MCETestHelper::ClientDeclineL( CMceSipSession* aSession, 
       
   307                                     const TDesC8& aHeader, 
       
   308                                     const TDesC8& aContent,
       
   309                                     const TDesC8& aContentType,
       
   310                                     const TDesC8& aReason, 
       
   311                                     TInt aReasonCode )
       
   312     {
       
   313     TMceIds& ids = CMCETls::Storage()->iIds;
       
   314     ids.iSessionID = aSession->Body()->Id();
       
   315     
       
   316     if ( aReasonCode == -1 )
       
   317         {
       
   318         ids.iMsgType = KMceNotAssigned;
       
   319         aSession->ServiceL( ids, EMceItcRejectSession, RMessage2() );
       
   320         return;
       
   321         }
       
   322         
       
   323     if ( aReasonCode == 0 )
       
   324         {
       
   325         aReasonCode = KMceSipDecline;
       
   326         }
       
   327         
       
   328         
       
   329     HBufC8* content = NULL;
       
   330     HBufC8* reason = NULL;
       
   331     HBufC8* ctype = NULL;
       
   332     CDesC8Array* headers = NULL;
       
   333 
       
   334     if ( aContent.Length() > 0 )
       
   335         {
       
   336         content = aContent.AllocLC();
       
   337         }
       
   338     if ( aReason.Length() > 0 )
       
   339         {
       
   340         reason = aReason.AllocLC();
       
   341         }
       
   342     else
       
   343         {
       
   344         reason = SIPStrings::StringF( SipStrConsts::EPhraseDecline ).DesC().AllocLC();
       
   345         }
       
   346     
       
   347     if ( aHeader.Length() > 0 )
       
   348         {
       
   349         headers = new (ELeave) CDesC8ArrayFlat( KMceArrayGranularity );
       
   350         CleanupStack::PushL( headers );
       
   351         headers->AppendL( aHeader );
       
   352         }
       
   353     
       
   354     if ( aContentType.Length() > 0 )
       
   355         {
       
   356         ctype = aContentType.AllocLC();
       
   357         }
       
   358     
       
   359     CMceMsgSIPReply* reply = new (ELeave) CMceMsgSIPReply( *reason, (TUint32)aReasonCode, *headers, *ctype );
       
   360     CleanupStack::PushL( reply );
       
   361     
       
   362     CMCETls::Storage()->StoreL( ids, *reply, content );
       
   363     CleanupStack::PopAndDestroy( reply );
       
   364     if ( ctype )
       
   365         CleanupStack::PopAndDestroy( ctype );
       
   366     
       
   367     if ( headers )
       
   368         CleanupStack::PopAndDestroy( headers );
       
   369     
       
   370     if ( reason )
       
   371         CleanupStack::PopAndDestroy( reason );
       
   372     
       
   373     if ( content )
       
   374         CleanupStack::Pop( content );
       
   375 
       
   376     //reject session
       
   377     aSession->ServiceL( ids, EMceItcRejectSession, RMessage2() );
       
   378     }
       
   379 
       
   380 // -----------------------------------------------------------------------------
       
   381 // MCETestHelper::ClientRingL()
       
   382 // -----------------------------------------------------------------------------
       
   383 //
       
   384 void MCETestHelper::ClientRingL( CMceSipSession* aSession, 
       
   385                                     const TDesC8& aHeader, 
       
   386                                     const TDesC8& aContent,
       
   387                                     const TDesC8& aContentType )
       
   388     {
       
   389     TMceIds& ids = CMCETls::Storage()->iIds;
       
   390     ids.iSessionID = aSession->Body()->Id();
       
   391 
       
   392 
       
   393     if ( aHeader.Length() == 0 && aContentType.Length() == 0 && aContent.Length() == 0 )
       
   394         {
       
   395         ids.iMsgType = KMceNotAssigned;
       
   396         aSession->ServiceL( ids, EMceItcRing, RMessage2() );
       
   397         CMCETls* storage = CMCETls::Storage();
       
   398       	MCE_CHECK_MEMORY_LEAVE( storage->iSipSentResponse && 
       
   399       	   ( storage->iSipSentResponse->StatusCode() == KMceSipServerInternalError || 
       
   400       	     storage->iSipSentResponse->StatusCode() == KMceSipDecline ) )
       
   401         return;
       
   402         }
       
   403     
       
   404     TUint32 reasonCode = KMceSipRinging;
       
   405     HBufC8* content = NULL;
       
   406     HBufC8* reason = NULL;
       
   407     HBufC8* ctype = NULL;
       
   408     CDesC8Array* headers = NULL;
       
   409 
       
   410     content = aContent.AllocLC();
       
   411     reason = SIPStrings::StringF( SipStrConsts::EPhraseRinging ).DesC().AllocLC();
       
   412     
       
   413     if ( aHeader.Length() > 0 )
       
   414         {
       
   415         headers = new (ELeave) CDesC8ArrayFlat( KMceArrayGranularity );
       
   416         CleanupStack::PushL( headers );
       
   417         headers->AppendL( aHeader );
       
   418         }
       
   419     
       
   420     ctype = aContentType.AllocLC();
       
   421     
       
   422     CMceMsgSIPReply* reply = new (ELeave) CMceMsgSIPReply( *reason, reasonCode, *headers, *ctype );
       
   423     CleanupStack::PushL( reply );
       
   424     
       
   425     CMCETls::Storage()->StoreL( ids, *reply, content );
       
   426     CleanupStack::PopAndDestroy( reply );
       
   427     CleanupStack::PopAndDestroy( ctype );
       
   428     
       
   429     if ( headers )
       
   430         CleanupStack::PopAndDestroy( headers );
       
   431     
       
   432     CleanupStack::PopAndDestroy( reason );
       
   433     CleanupStack::Pop( content );
       
   434 
       
   435     aSession->ServiceL( ids, EMceItcRing, RMessage2() );
       
   436     CMCETls* storage = CMCETls::Storage();
       
   437   	MCE_CHECK_MEMORY_LEAVE( storage->iSipSentResponse && 
       
   438   	   ( storage->iSipSentResponse->StatusCode() == KMceSipServerInternalError || 
       
   439   	     storage->iSipSentResponse->StatusCode() == KMceSipDecline ) )
       
   440     }
       
   441 
       
   442 // -----------------------------------------------------------------------------
       
   443 // MCETestHelper::ClientCancelL()
       
   444 // -----------------------------------------------------------------------------
       
   445 //
       
   446 void MCETestHelper::ClientCancelL( CMceSipSession* aSession )
       
   447     {
       
   448     TMceIds& ids = CMCETls::Storage()->iIds;
       
   449     ids.iSessionID = aSession->Body()->Id();
       
   450     ids.iMsgType = KMceNotAssigned;
       
   451     aSession->ServiceL( ids, EMceItcCancel, RMessage2() );
       
   452     CMCETls* storage = CMCETls::Storage();
       
   453   	MCE_CHECK_MEMORY_LEAVE( storage->iSipSentResponse && 
       
   454   	   ( storage->iSipSentResponse->StatusCode() == KMceSipServerInternalError || 
       
   455   	     storage->iSipSentResponse->StatusCode() == KMceSipDecline ) )
       
   456     }
       
   457     
       
   458 // -----------------------------------------------------------------------------
       
   459 // MCETestHelper::ClientIncomingSessionL()
       
   460 // -----------------------------------------------------------------------------
       
   461 //
       
   462 CMceSipSession* MCETestHelper::ClientIncomingSessionL( CMceCsSession* aClient, 
       
   463                                                        TBool aInvalid,
       
   464                                                        TBool aSupported100rel )
       
   465     {
       
   466     CMceSipSession* session = NULL;
       
   467     TUint32 iapId = 1;
       
   468     
       
   469     //invite
       
   470     CSIPServerTransaction* invite = NULL;
       
   471     
       
   472     if ( !aInvalid )
       
   473         {
       
   474         RPointerArray<CSIPHeaderBase> hdrs;
       
   475         CSIPHeaderBase::PushLC( &hdrs );
       
   476         
       
   477         if ( aSupported100rel )
       
   478             {
       
   479             RStringF supp100rel = SIPStrings::Pool().OpenFStringL( KMceSip100Rel );
       
   480             CleanupClosePushL( supp100rel );
       
   481             CSIPSupportedHeader* supported = 
       
   482                 CSIPSupportedHeader::NewLC( supp100rel );
       
   483             hdrs.AppendL( supported );
       
   484             CleanupStack::Pop( supported );
       
   485             CleanupStack::PopAndDestroy(); // supp100rel
       
   486             }
       
   487         invite = ServerTransactionL( SipStrConsts::EInvite, hdrs, ETrue );
       
   488         CleanupStack::Pop( &hdrs );
       
   489         }
       
   490     else
       
   491         {
       
   492         invite = ServerTransactionBadSDPL( SipStrConsts::EInvite );
       
   493         }
       
   494     
       
   495   	aClient->ServerCore().Manager().IncomingRequest( iapId, invite );
       
   496   	CMCETls* storage = CMCETls::Storage();
       
   497   	MCE_CHECK_MEMORY_LEAVE( storage->iSipSentResponse && 
       
   498   	   ( storage->iSipSentResponse->StatusCode() == KMceSipServerInternalError || 
       
   499   	     storage->iSipSentResponse->StatusCode() == KMceSipDecline ) )
       
   500   	storage->ExecuteCallback();
       
   501   	MCE_CHECK_MEMORY_LEAVE( storage->iSipSentResponse && 
       
   502   	   ( storage->iSipSentResponse->StatusCode() == KMceSipServerInternalError || 
       
   503   	     storage->iSipSentResponse->StatusCode() == KMceSipDecline ) )
       
   504 
       
   505     TInt count = aClient->Implementation().SubSessions().Count();
       
   506     if ( count > 0 )
       
   507         {
       
   508         session = static_cast<CMceSipSession*>(aClient->Implementation().SubSessions()[ count - 1 ]);
       
   509         }
       
   510     if ( session )
       
   511         {
       
   512         
       
   513         TMceIds ids = CMCETls::Storage()->iManagerIds;
       
   514         //receive
       
   515         aClient->ReceiveL( ids , RMessage2() );
       
   516         //client code
       
   517     	RDesReadStream readStream( *CMCETls::Storage()->iContextServer );
       
   518         CleanupClosePushL( readStream );
       
   519         
       
   520         CMceMsgObject<CMceComSession>* message = static_cast<CMceMsgObject<CMceComSession>*>
       
   521             (TMceComFactory().CreateL( (TMceItcDataType)ids.iMsgType,
       
   522                                                             readStream ) );
       
   523     	CleanupStack::PopAndDestroy(); // readStream
       
   524         
       
   525         CleanupStack::PushL( message );
       
   526         message->PushL();
       
   527         CleanupStack::PopAndDestroy( message );
       
   528         
       
   529         CMCETls::Storage()->iIds = TMceIds();
       
   530         CMCETls::Storage()->iIds.iAppUID = CMCETls::Storage()->iManagerIds.iAppUID;
       
   531         CMCETls::Storage()->iIds.iManagerType = CMCETls::Storage()->iManagerIds.iManagerType;
       
   532         CMCETls::Storage()->iIds.iDialogType = CMCETls::Storage()->iManagerIds.iDialogType;
       
   533         CMCETls::Storage()->iIds.iDialogID = CMCETls::Storage()->iManagerIds.iDialogID;
       
   534         CMCETls::Storage()->iIds.iProfileID = CMCETls::Storage()->iManagerIds.iProfileID;
       
   535         
       
   536         ManagerReadyToReceiveL( aClient );
       
   537         }
       
   538         
       
   539     return session;
       
   540     }
       
   541 
       
   542 // -----------------------------------------------------------------------------
       
   543 // MCETestHelper::ClientIncomingEventL()
       
   544 // -----------------------------------------------------------------------------
       
   545 //
       
   546 CMceSipEvent* MCETestHelper::ClientIncomingEventL( CMceCsSession* aClient, 
       
   547                                                    TInt aMethod )
       
   548     {
       
   549     CMceSipEvent* event = NULL;
       
   550     TUint32 iapId = 1;
       
   551     TUint32 profileId = 1;
       
   552     
       
   553     RPointerArray<CSIPHeaderBase> sipHdrs;
       
   554     CSIPHeaderBase::PushLC( &sipHdrs );
       
   555     
       
   556     if ( aMethod == SipStrConsts::ESubscribe )
       
   557         {
       
   558         CSIPExpiresHeader* ex = new( ELeave ) CSIPExpiresHeader( 180 );
       
   559         CleanupStack::PushL( ex );
       
   560         sipHdrs.AppendL( ex );
       
   561         CleanupStack::Pop( ex );
       
   562         
       
   563         CSIPEventHeader* eve = CSIPEventHeader::DecodeL( KEvent );
       
   564         CleanupStack::PushL( eve );
       
   565         sipHdrs.AppendL( eve );
       
   566         CleanupStack::Pop( eve );
       
   567         }
       
   568     
       
   569     CSIPServerTransaction* sta = NULL;
       
   570     
       
   571     
       
   572     sta = ServerTransactionL( aMethod, sipHdrs, ETrue );
       
   573     CleanupStack::Pop( &sipHdrs );
       
   574     CMceSipManager& manager = aClient->ServerCore().Manager();
       
   575     CSIPProfile& profile = manager.ProfileL( profileId );
       
   576     
       
   577     CMceSipConnection& connection = manager.ConnectionL( profile );
       
   578     
       
   579     manager.CreateSubSessionL( sta, *aClient, connection );
       
   580   	
       
   581   	TInt count = aClient->Implementation().SubSessions().Count();
       
   582     if ( count > 0 )
       
   583         {
       
   584         event = static_cast<CMceSipEvent*>(aClient->Implementation().SubSessions()[ count - 1 ]);
       
   585         }
       
   586     
       
   587     return event;
       
   588     }
       
   589 
       
   590 // -----------------------------------------------------------------------------
       
   591 // MCETestHelper::ClientUpdateSessionL()
       
   592 // -----------------------------------------------------------------------------
       
   593 //
       
   594 void MCETestHelper::ClientUpdateSessionL( CMceSipSession* aSession,
       
   595                                           CMceComSession& aUpdate,
       
   596                                           TUint32 aTimeout,
       
   597                                           const TDesC8& aHeader, 
       
   598                                           const TDesC8& aContentType,
       
   599                                           const TDesC8& aContent,
       
   600                                           const TDesC8& aContentHeader ) 
       
   601     {
       
   602     TMceIds& ids = CMCETls::Storage()->iIds;
       
   603 
       
   604     aUpdate.iTimeout = aTimeout;
       
   605     MCE_DELETE( aUpdate.iSIPHeaders );
       
   606     MCE_DELETE( aUpdate.iSIPContentType );
       
   607     MCE_DELETE( aUpdate.iSIPContentHeaders );
       
   608     
       
   609     if ( aHeader.Length() > 0 )
       
   610         {
       
   611         aUpdate.iSIPHeaders = new (ELeave) CDesC8ArrayFlat( KMceArrayGranularity );
       
   612         aUpdate.iSIPHeaders->AppendL( aHeader );
       
   613         }
       
   614     if ( aContentHeader.Length() > 0 )
       
   615         {
       
   616         aUpdate.iSIPContentHeaders = new (ELeave) CDesC8ArrayFlat( KMceArrayGranularity );
       
   617         aUpdate.iSIPContentHeaders->AppendL( aContentHeader );
       
   618         }
       
   619     aUpdate.iSIPContentType = aContentType.AllocL();
       
   620      
       
   621     
       
   622     CMceMsgObject<CMceComSession>* clientSessionMsg = 
       
   623         new (ELeave) CMceMsgObject<CMceComSession>( aUpdate, EMceItcMsgTypeSession );
       
   624     CleanupStack::PushL( clientSessionMsg );
       
   625 
       
   626     HBufC8* content = aContent.AllocLC();
       
   627     
       
   628     ids.iSessionID = aSession->Body()->Id();
       
   629     CMCETls::Storage()->StoreL( ids, *clientSessionMsg, content );
       
   630 
       
   631     CleanupStack::Pop( content );
       
   632     CleanupStack::PopAndDestroy( clientSessionMsg );
       
   633     
       
   634     //update
       
   635     aSession->ServiceL( ids, EMceItcUpdate, RMessage2() );
       
   636     
       
   637     CMCETls* storage = CMCETls::Storage();
       
   638     MCE_CHECK_MEMORY_LEAVE( storage->iMediaManagerUpdateStatus >= KErrNone &&
       
   639          storage->iSipSentResponse && 
       
   640   	   ( storage->iSipSentResponse->StatusCode() == KMceSipServerInternalError || 
       
   641   	     storage->iSipSentResponse->StatusCode() == KMceSipDecline ) )
       
   642     }
       
   643     
       
   644 // -----------------------------------------------------------------------------
       
   645 // MCETestHelper::ClientGetSessionL()
       
   646 // -----------------------------------------------------------------------------
       
   647 //
       
   648 CMceComSession* MCETestHelper::ClientGetSessionL( CMceSipSession* aSession )
       
   649     {
       
   650     TMceIds& ids = CMCETls::Storage()->iIds;
       
   651     ids.iSessionID = aSession->Body()->Id();
       
   652     ids.iMsgType = KMceNotAssigned;
       
   653     aSession->ServiceL( ids, EMceItcGetSession, RMessage2() );
       
   654 
       
   655     CMceComSession* session = NULL;
       
   656     CMceMsgObject<CMceComSession>* clientSessionMsg = 
       
   657             new (ELeave) CMceMsgObject<CMceComSession>();
       
   658     CleanupStack::PushL( clientSessionMsg );
       
   659     
       
   660     clientSessionMsg->DecodeL( *CMCETls::Storage()->iContextServer );
       
   661     session = clientSessionMsg->Object();
       
   662     
       
   663     CleanupStack::PopAndDestroy( clientSessionMsg );
       
   664     
       
   665     return session;
       
   666     }
       
   667 
       
   668 // -----------------------------------------------------------------------------
       
   669 // MCETestHelper::MediaManagerCallBack()
       
   670 // -----------------------------------------------------------------------------
       
   671 //
       
   672 void MCETestHelper::MediaManagerCallBack( CMceSipSession* aSession, 
       
   673                                           TMceMediaEventCode aEvent,
       
   674                                           TInt aError )
       
   675     {
       
   676     switch ( aEvent )
       
   677         {
       
   678         case EMceMediaUpdated:
       
   679             {
       
   680             aSession->Updated( *aSession->Body() );
       
   681             MCE_CHECK_MEMORY_LEAVE( CMCETls::Storage()->iCompletionCode == KErrNoMemory )
       
   682             break;
       
   683             }
       
   684         case EMceMediaSessionStopped:
       
   685             {
       
   686             aSession->SessionClosed( *aSession->Body() );
       
   687             MCE_CHECK_MEMORY_LEAVE( CMCETls::Storage()->iCompletionCode == KErrNoMemory )
       
   688             break;
       
   689             }
       
   690         case EMceMediaError:
       
   691             {
       
   692             TMceMccComEvent event( KMccStreamError );
       
   693             event.iError = aError;
       
   694             aSession->MediaError( event );
       
   695             MCE_CHECK_MEMORY_LEAVE( CMCETls::Storage()->iCompletionCode == KErrNoMemory )
       
   696             break;
       
   697             }
       
   698         default:
       
   699             {
       
   700             break;
       
   701             }
       
   702         }
       
   703     }
       
   704     
       
   705 // -----------------------------------------------------------------------------
       
   706 // MCETestHelper::MediaManagerSinkCallBack()
       
   707 // -----------------------------------------------------------------------------
       
   708 //
       
   709 void MCETestHelper::MediaManagerSinkCallBack( CMceSipSession* aSession, 
       
   710                                               TMceItcFunctions aEventTo,
       
   711                                               TInt aStream,
       
   712                                               TInt aSink )
       
   713     {
       
   714     switch( aEventTo )
       
   715         {
       
   716         case EMceItcDisable:
       
   717             {
       
   718             TMceMccComEvent event( KMccStreamPaused );
       
   719             SinkEvent( event, aSession, aStream, aSink  );
       
   720             aSession->EventReceived( event );
       
   721             break;
       
   722             }
       
   723         case EMceItcEnable:
       
   724             {
       
   725             TMceMccComEvent event( KMccStreamResumed );
       
   726             SinkEvent( event, aSession, aStream, aSink );
       
   727             aSession->EventReceived( event );
       
   728             break;
       
   729             }
       
   730         }
       
   731     }
       
   732 
       
   733 // -----------------------------------------------------------------------------
       
   734 // MCETestHelper::MediaManagerSourceCallBack()
       
   735 // -----------------------------------------------------------------------------
       
   736 //
       
   737 void MCETestHelper::MediaManagerSourceCallBack( CMceSipSession* aSession, 
       
   738                                               TMceItcFunctions aEventTo,
       
   739                                               TInt aStream )
       
   740     {
       
   741     switch( aEventTo )
       
   742         {
       
   743         case EMceItcDisable:
       
   744             {
       
   745             TMceMccComEvent event( KMccStreamPaused );
       
   746             SourceEvent( event, aSession, aStream );
       
   747             aSession->EventReceived( event );
       
   748             break;
       
   749             }
       
   750         case EMceItcEnable:
       
   751             {
       
   752             TMceMccComEvent event( KMccStreamResumed );
       
   753             SourceEvent( event, aSession, aStream );
       
   754             aSession->EventReceived( event );
       
   755             break;
       
   756             }
       
   757         case EMceItcEnableInactivityTimer:
       
   758             {
       
   759             TMceMccComEvent event( KMccInactivityEvent );
       
   760             SourceEvent( event, aSession, aStream );
       
   761             aSession->EventReceived( event );
       
   762             break;
       
   763             }
       
   764         }    
       
   765     }
       
   766 
       
   767 // -----------------------------------------------------------------------------
       
   768 // MCETestHelper::Sink()
       
   769 // -----------------------------------------------------------------------------
       
   770 //
       
   771 CMceComMediaSink*
       
   772 MCETestHelper::Sink( CMceSipSession* aSession, TInt aStream, TInt aSink )
       
   773     {
       
   774 
       
   775     CMceComMediaSink* sink = NULL;
       
   776     
       
   777     if ( aStream >= 0 )
       
   778         {
       
   779         sink = aSession->Body()->Streams()[ aStream ]->Sinks()[ aSink ];
       
   780         }
       
   781     else
       
   782         {
       
   783         sink = aSession->Body()->Streams()[ 0 ]->BoundStreamL().Sinks()[ aSink ];
       
   784         }
       
   785         
       
   786     return sink;
       
   787     }
       
   788 
       
   789 // -----------------------------------------------------------------------------
       
   790 // MCETestHelper::Source()
       
   791 // -----------------------------------------------------------------------------
       
   792 //
       
   793 CMceComMediaSource*
       
   794 MCETestHelper::Source( CMceSipSession* aSession, TInt aStream )
       
   795     {
       
   796     CMceComMediaSource* source = NULL;
       
   797     
       
   798     if ( aStream >= 0 )
       
   799         {
       
   800         source = aSession->Body()->Streams()[ aStream ]->Source();
       
   801         }
       
   802     else
       
   803         {
       
   804         source = aSession->Body()->Streams()[ 0 ]->BoundStreamL().Source();
       
   805         }
       
   806         
       
   807     return source;    
       
   808     }
       
   809 
       
   810 // -----------------------------------------------------------------------------
       
   811 // MCETestHelper::SinkEvent()
       
   812 // -----------------------------------------------------------------------------
       
   813 //
       
   814 void MCETestHelper::SinkEvent( TMceMccComEvent& aEvent,
       
   815 							   CMceSipSession* aSession,
       
   816 							   TInt aStream,
       
   817 							   TInt aSink )
       
   818     {
       
   819     CMceComMediaSink* sink = Sink( aSession, aStream, aSink );
       
   820 
       
   821     aEvent.iStream = sink->MediaStream();
       
   822     aEvent.iSink = sink;
       
   823     switch( aEvent.iEvent )
       
   824         {
       
   825         case KMccStreamPaused:
       
   826             {
       
   827             aEvent.iItcEvent = EMceItcStateChanged;
       
   828             aEvent.iItcData = 0;
       
   829             break;
       
   830             }
       
   831         case KMccStreamResumed:
       
   832             {
       
   833             aEvent.iItcEvent = EMceItcStateChanged;
       
   834             aEvent.iItcData = 1;
       
   835             break;
       
   836             }
       
   837         case KMccInactivityEvent:
       
   838             {
       
   839             aEvent.iItcEvent = EMceItcInactivityTimeout;
       
   840             break;
       
   841             }
       
   842         case KMccRtcpReceived:
       
   843             {
       
   844             if ( aEvent.iEventSubType == KRtcpRrPacket )
       
   845                 {
       
   846                 aEvent.iItcEvent = EMceItcRRReceived;
       
   847                 }
       
   848             else if ( aEvent.iEventSubType == KRtcpSrPacket )
       
   849                 {
       
   850                 aEvent.iItcEvent = EMceItcSRReceived;
       
   851                 }
       
   852             else if ( aEvent.iEventSubType == KRtcpPacketUndefined )
       
   853                 {
       
   854                 aEvent.iItcEvent = EMceItcFCMsgReceived;
       
   855                 }
       
   856             break;
       
   857             }
       
   858         default:
       
   859             {
       
   860             aEvent.iItcEvent = EMceItcInProgress;
       
   861             break;
       
   862             }
       
   863         }
       
   864     }
       
   865 
       
   866 // -----------------------------------------------------------------------------
       
   867 // MCETestHelper::SourceEvent()
       
   868 // -----------------------------------------------------------------------------
       
   869 //
       
   870 void MCETestHelper::SourceEvent( TMceMccComEvent& aEvent,
       
   871 								 CMceSipSession* aSession,
       
   872 								 TInt aStream )
       
   873     {
       
   874     CMceComMediaSource* source = Source( aSession, aStream );
       
   875 
       
   876     aEvent.iStream = source->MediaStream();
       
   877     aEvent.iSource = source;
       
   878     switch( aEvent.iEvent )
       
   879         {
       
   880         case KMccStreamPaused:
       
   881             {
       
   882             aEvent.iItcEvent = EMceItcStateChanged;
       
   883             aEvent.iItcData = 0;
       
   884             break;
       
   885             }
       
   886         case KMccStreamResumed:
       
   887             {
       
   888             aEvent.iItcEvent = EMceItcStateChanged;
       
   889             aEvent.iItcData = 1;
       
   890             break;
       
   891             }
       
   892         case KMccInactivityEvent:
       
   893             {
       
   894             aEvent.iItcEvent = EMceItcInactivityTimeout;
       
   895             break;
       
   896             }
       
   897         case KMccRtcpReceived:
       
   898             {
       
   899             if ( aEvent.iEventSubType == KRtcpRrPacket )
       
   900                 {
       
   901                 aEvent.iItcEvent = EMceItcRRReceived;
       
   902                 }
       
   903             else if ( aEvent.iEventSubType == KRtcpSrPacket )
       
   904                 {
       
   905                 aEvent.iItcEvent = EMceItcSRReceived;
       
   906                 }
       
   907             else if ( aEvent.iEventSubType == KRtcpPacketUndefined )
       
   908                 {
       
   909                 aEvent.iItcEvent = EMceItcFCMsgReceived;
       
   910                 }
       
   911             break;
       
   912             }
       
   913         default:
       
   914             {
       
   915             aEvent.iItcEvent = EMceItcInProgress;
       
   916             break;
       
   917             }
       
   918         }
       
   919     }
       
   920 
       
   921 // -----------------------------------------------------------------------------
       
   922 // MCETestHelper::ResponseL()
       
   923 // -----------------------------------------------------------------------------
       
   924 //
       
   925 CSIPClientTransaction& MCETestHelper::ResponseL( CMceSipSession* aSession,
       
   926                                TUint aReasonCode, 
       
   927                                TInt aReasonPhrase, 
       
   928                                TInt aTrx,
       
   929                                TBool aSDPContent,
       
   930                                TBool aRequire100rel,
       
   931                                TUint aRSeqV,
       
   932                                TBool aExpectOkStateChange )
       
   933     {    
       
   934     CSIPClientTransaction* trx = aSession->PendingTransactions()[ aTrx ];
       
   935 
       
   936     SetResponseL( *trx, aReasonCode, aReasonPhrase, aSDPContent, aRequire100rel, aRSeqV );
       
   937     
       
   938     if ( MceSip::ResponseType( *trx ) == E1XX )
       
   939         {
       
   940         trx->iState = CSIPTransactionBase::EProceeding;
       
   941         }
       
   942     else
       
   943         {
       
   944         if ( MceSip::ResponseType( *trx ) == E2XX )
       
   945             {
       
   946             aSession->Dialog()->Dialog().iState = CSIPDialog::EConfirmed;
       
   947             }
       
   948         else
       
   949             {
       
   950             aSession->Dialog()->Dialog().iState = CSIPDialog::ETerminated;
       
   951             }
       
   952         trx->iState = CSIPTransactionBase::ETerminated;
       
   953         }
       
   954 
       
   955 	aSession->DialogResponseReceived( *trx );
       
   956 	
       
   957 	CMCETls* storage = CMCETls::Storage();
       
   958 	if ( aExpectOkStateChange &&
       
   959 	     ( aReasonCode == KMceSipOK ||
       
   960 	   	   aReasonCode == KMceSipRinging ||
       
   961 	   	   aReasonCode == KMceSipTrying ) )
       
   962 	    {
       
   963         MCE_CHECK_MEMORY_LEAVE( storage->iMediaManagerUpdateStatus >= KErrNone &&
       
   964              storage->iMediaManagerAction == CMCETls::ECloseSession )
       
   965 	    }
       
   966 
       
   967     return *trx;
       
   968     }
       
   969 
       
   970 // -----------------------------------------------------------------------------
       
   971 // MCETestHelper::ForkedResponseL()
       
   972 // -----------------------------------------------------------------------------
       
   973 //
       
   974 CSIPClientTransaction& MCETestHelper::ForkedResponseL( 
       
   975                                CMceSipSession* aSession,
       
   976                                CSIPInviteDialogAssoc* dialog,
       
   977                                TUint aReasonCode, 
       
   978                                TInt aReasonPhrase, 
       
   979                                TInt aTrx,
       
   980                                TBool aSDPContent )
       
   981     {
       
   982     CleanupStack::PushL( dialog );
       
   983     CSIPClientTransaction* trx = aSession->PendingTransactions()[ aTrx ];
       
   984 
       
   985     SetResponseL( *trx, aReasonCode, aReasonPhrase, aSDPContent );
       
   986     
       
   987     if ( MceSip::ResponseType( *trx ) == E1XX )
       
   988         {
       
   989         trx->iState = CSIPTransactionBase::EProceeding;
       
   990         }
       
   991     else
       
   992         {
       
   993         if ( MceSip::ResponseType( *trx ) == E2XX )
       
   994             {
       
   995             aSession->Dialog()->Dialog().iState = CSIPDialog::EConfirmed;
       
   996             }
       
   997         else
       
   998             {
       
   999             aSession->Dialog()->Dialog().iState = CSIPDialog::ETerminated;
       
  1000             }
       
  1001         trx->iState = CSIPTransactionBase::ETerminated;
       
  1002         }
       
  1003 
       
  1004 	aSession->InviteForkedL( *trx, dialog );
       
  1005 	CleanupStack::Pop( dialog );
       
  1006 
       
  1007     CMCETls* storage = CMCETls::Storage();
       
  1008 	if ( aReasonCode == KMceSipOK || aReasonCode == KMceSipRinging || aReasonCode == KMceSipTrying )
       
  1009 	    {
       
  1010         MCE_CHECK_MEMORY_LEAVE( storage->iMediaManagerUpdateStatus >= KErrNone &&
       
  1011              storage->iMediaManagerAction == CMCETls::ECloseSession )
       
  1012 	    }
       
  1013     return *trx;
       
  1014     }
       
  1015 
       
  1016 // -----------------------------------------------------------------------------
       
  1017 // MCETestHelper::RequestL()
       
  1018 // -----------------------------------------------------------------------------
       
  1019 //
       
  1020 CSIPServerTransaction& MCETestHelper::RequestL( CMceSipSession* aSession, 
       
  1021                                                 TInt aRequest,
       
  1022                                                 TInt aSDPContent,
       
  1023                                                 TBool aExpectOkStateChange )
       
  1024     {
       
  1025     CSIPServerTransaction* trx = NULL;
       
  1026     RPointerArray<CSIPHeaderBase> hdrs;
       
  1027     CSIPHeaderBase::PushLC( &hdrs );
       
  1028     if ( aRequest == SipStrConsts::EPrack )
       
  1029         {
       
  1030         CSIPRAckHeader* rack = CSIPRAckHeader::NewLC( aSession->ReliableSender().iSequenceNumber, 
       
  1031                                                       KInviteCSeq, 
       
  1032                                                       SIPStrings::StringF( SipStrConsts::EInvite ) );
       
  1033         hdrs.AppendL( rack );
       
  1034         CleanupStack::Pop( rack );                    
       
  1035         }
       
  1036         
       
  1037     if ( aSDPContent == 0 )
       
  1038         {
       
  1039         trx = MCETestHelper::ServerTransactionL( aRequest, hdrs );
       
  1040         }
       
  1041     else if ( aSDPContent == 1 )
       
  1042         {
       
  1043         trx = MCETestHelper::ServerTransactionL( aRequest, hdrs, ETrue );
       
  1044         }
       
  1045     else
       
  1046         {
       
  1047         trx = MCETestHelper::ServerTransaction2L( aRequest );
       
  1048         }
       
  1049         
       
  1050     if ( aRequest == SipStrConsts::EAck )
       
  1051         {
       
  1052         trx->iState = CSIPTransactionBase::ETerminated;
       
  1053         }
       
  1054     CleanupStack::Pop( &hdrs );    
       
  1055 
       
  1056 	TBool consumed = aSession->DialogRequestReceived( trx, aSession->Dialog()->Dialog() );
       
  1057 	CleanupStack::PushL( trx );
       
  1058     User::LeaveIfError( consumed ? KErrNone : KErrNoMemory );
       
  1059     CleanupStack::Pop( trx );
       
  1060 
       
  1061  	if ( aExpectOkStateChange )
       
  1062         {
       
  1063         CMCETls* storage = CMCETls::Storage();
       
  1064         MCE_CHECK_MEMORY_LEAVE( storage->iSipSentResponse && 
       
  1065       	   ( storage->iSipSentResponse->StatusCode() == KMceSipServerInternalError || 
       
  1066       	     storage->iSipSentResponse->StatusCode() == KMceSipDecline ) )
       
  1067         }
       
  1068 
       
  1069     return *trx;    
       
  1070     }
       
  1071 
       
  1072 // -----------------------------------------------------------------------------
       
  1073 // MCETestHelper::ServerTransactionL()
       
  1074 // -----------------------------------------------------------------------------
       
  1075 //
       
  1076 CSIPServerTransaction* MCETestHelper::ServerTransactionL( TInt aMethod, 
       
  1077                                                           TBool aContent,
       
  1078                                                           TBool aToAndFromHeaders )
       
  1079     {
       
  1080     CSIPServerTransaction* srvtransaction = 
       
  1081         CSIPServerTransaction::NewL( SIPStrings::StringF( aMethod )); 
       
  1082     CleanupStack::PushL( srvtransaction );
       
  1083     
       
  1084   	CUri8* uri = CUri8::NewLC(); //OK
       
  1085     MCE_SET_URIL( uri );
       
  1086   	
       
  1087     CSIPRequestElements* requestelements = CSIPRequestElements::NewL( uri ); 
       
  1088     CleanupStack::Pop( uri );
       
  1089     CleanupStack::PushL( requestelements );
       
  1090 
       
  1091     if ( aToAndFromHeaders )
       
  1092         {
       
  1093         CSIPToHeader* toheader = CSIPToHeader::DecodeL( KSIPProfileDefAOR );
       
  1094         CleanupStack::PushL( toheader );
       
  1095         CSIPFromHeader* fromheader = CSIPFromHeader::DecodeL(_L8("User <user2@host>")); 
       
  1096         CleanupStack::PushL( fromheader );
       
  1097         
       
  1098         requestelements->SetFromHeaderL(fromheader); 
       
  1099         CleanupStack::Pop( fromheader );
       
  1100         requestelements->SetToHeaderL(toheader); 
       
  1101         CleanupStack::Pop( toheader );
       
  1102         }
       
  1103     
       
  1104     CSIPMessageElements& msgelements = requestelements->MessageElements();
       
  1105     
       
  1106     if ( aContent )
       
  1107         {
       
  1108         SetMessageElementsL( msgelements );
       
  1109         }
       
  1110     
       
  1111     requestelements->SetMethodL( SIPStrings::StringF( aMethod ));
       
  1112     
       
  1113     srvtransaction->SetRequestElements( requestelements );
       
  1114     CleanupStack::Pop( requestelements );
       
  1115     CleanupStack::Pop( srvtransaction );
       
  1116 
       
  1117     return srvtransaction;
       
  1118     }
       
  1119 
       
  1120 // -----------------------------------------------------------------------------
       
  1121 // MCETestHelper::ServerTransaction2L()
       
  1122 // -----------------------------------------------------------------------------
       
  1123 //
       
  1124 CSIPServerTransaction* MCETestHelper::ServerTransaction2L( TInt aMethod )
       
  1125     {
       
  1126     CSIPServerTransaction* srvtransaction = 
       
  1127         CSIPServerTransaction::NewL( SIPStrings::StringF( aMethod )); 
       
  1128     CleanupStack::PushL( srvtransaction );
       
  1129     
       
  1130   	CUri8* uri = CUri8::NewLC(); //OK
       
  1131     MCE_SET_URIL( uri );
       
  1132   	
       
  1133     CSIPRequestElements* requestelements = CSIPRequestElements::NewL( uri ); 
       
  1134     CleanupStack::Pop( uri );
       
  1135     CleanupStack::PushL( requestelements );
       
  1136 
       
  1137     CSIPToHeader* toheader = CSIPToHeader::DecodeL( KSIPProfileDefAOR );
       
  1138     CleanupStack::PushL( toheader );
       
  1139     CSIPFromHeader* fromheader = CSIPFromHeader::DecodeL(_L8("User <user2@host>")); 
       
  1140     CleanupStack::PushL( fromheader );
       
  1141     
       
  1142     requestelements->SetFromHeaderL(fromheader); 
       
  1143     CleanupStack::Pop( fromheader );
       
  1144     requestelements->SetToHeaderL(toheader); 
       
  1145     CleanupStack::Pop( toheader );
       
  1146     
       
  1147     CSIPMessageElements& msgelements = requestelements->MessageElements();
       
  1148     
       
  1149     SetMessageElementsL( msgelements, 2 );
       
  1150     
       
  1151     requestelements->SetMethodL( SIPStrings::StringF( aMethod ));
       
  1152     
       
  1153     srvtransaction->SetRequestElements( requestelements );
       
  1154     CleanupStack::Pop( requestelements );
       
  1155     CleanupStack::Pop( srvtransaction );
       
  1156 
       
  1157     return srvtransaction;
       
  1158     }
       
  1159 
       
  1160 // -----------------------------------------------------------------------------
       
  1161 // MCETestHelper::ServerTransactionBadSDPL()
       
  1162 // -----------------------------------------------------------------------------
       
  1163 //
       
  1164 CSIPServerTransaction* MCETestHelper::ServerTransactionBadSDPL( TInt aMethod )
       
  1165     {
       
  1166     CSIPServerTransaction* srvtransaction = 
       
  1167         CSIPServerTransaction::NewL( SIPStrings::StringF( aMethod )); 
       
  1168     CleanupStack::PushL( srvtransaction );
       
  1169     
       
  1170   	CUri8* uri = CUri8::NewLC(); //OK
       
  1171     MCE_SET_URIL( uri );
       
  1172   	
       
  1173     CSIPRequestElements* requestelements = CSIPRequestElements::NewL( uri ); 
       
  1174     CleanupStack::Pop( uri );
       
  1175     CleanupStack::PushL( requestelements );
       
  1176 
       
  1177     CSIPToHeader* toheader = CSIPToHeader::DecodeL( KSIPProfileDefAOR );
       
  1178     CleanupStack::PushL( toheader );
       
  1179     CSIPFromHeader* fromheader = CSIPFromHeader::DecodeL(_L8("User <user2@host>")); 
       
  1180     CleanupStack::PushL( fromheader );
       
  1181     
       
  1182     requestelements->SetFromHeaderL(fromheader); 
       
  1183     CleanupStack::Pop( fromheader );
       
  1184     requestelements->SetToHeaderL(toheader); 
       
  1185     CleanupStack::Pop( toheader );
       
  1186     
       
  1187     CSIPMessageElements& msgelements = requestelements->MessageElements();
       
  1188     
       
  1189     SetMessageElementsL( msgelements, 3 );
       
  1190     
       
  1191     requestelements->SetMethodL( SIPStrings::StringF( aMethod ));
       
  1192     
       
  1193     srvtransaction->SetRequestElements( requestelements );
       
  1194     CleanupStack::Pop( requestelements );
       
  1195     CleanupStack::Pop( srvtransaction );
       
  1196 
       
  1197     return srvtransaction;
       
  1198     }
       
  1199 
       
  1200 // -----------------------------------------------------------------------------
       
  1201 // MCETestHelper::ServerTransactionL()
       
  1202 // -----------------------------------------------------------------------------
       
  1203 //
       
  1204 CSIPServerTransaction* MCETestHelper::ServerTransactionL( TInt aMethod, 
       
  1205                                                           RPointerArray<CSIPHeaderBase>& aSipHeaders, 
       
  1206                                                           TBool aContent )
       
  1207     {
       
  1208     CSIPServerTransaction* srvtransaction = 
       
  1209         CSIPServerTransaction::NewL( SIPStrings::StringF( aMethod )); 
       
  1210     CleanupStack::PushL( srvtransaction );
       
  1211     
       
  1212   	CUri8* uri = CUri8::NewLC(); //OK
       
  1213     MCE_SET_URIL( uri );
       
  1214   	
       
  1215     CSIPRequestElements* requestelements = CSIPRequestElements::NewL( uri ); 
       
  1216     CleanupStack::Pop( uri );
       
  1217     CleanupStack::PushL( requestelements );
       
  1218 
       
  1219     CSIPToHeader* toheader = CSIPToHeader::DecodeL( KSIPProfileDefAOR );
       
  1220     CleanupStack::PushL( toheader );
       
  1221     CSIPFromHeader* fromheader = CSIPFromHeader::DecodeL(_L8("User <user2@host>")); 
       
  1222     CleanupStack::PushL( fromheader );
       
  1223     
       
  1224     requestelements->SetFromHeaderL(fromheader); 
       
  1225     CleanupStack::Pop( fromheader );
       
  1226     requestelements->SetToHeaderL(toheader); 
       
  1227     CleanupStack::Pop( toheader );
       
  1228     
       
  1229     CSIPMessageElements& msgelements = requestelements->MessageElements();
       
  1230     
       
  1231     if ( aContent )
       
  1232         {
       
  1233         SetMessageElementsL( msgelements );
       
  1234         }
       
  1235     
       
  1236     requestelements->SetMethodL( SIPStrings::StringF( aMethod ));
       
  1237     msgelements.SetUserHeadersL( aSipHeaders );
       
  1238 
       
  1239     srvtransaction->SetRequestElements( requestelements );
       
  1240     CleanupStack::Pop( requestelements );
       
  1241     CleanupStack::Pop( srvtransaction );
       
  1242 
       
  1243     return srvtransaction;
       
  1244     }
       
  1245 
       
  1246 // -----------------------------------------------------------------------------
       
  1247 // MCETestHelper::ClientTransactionLC()
       
  1248 // -----------------------------------------------------------------------------
       
  1249 //
       
  1250 CSIPClientTransaction* MCETestHelper::ClientTransactionLC( TInt aToMethod, 
       
  1251                                                            TUint aResponse, 
       
  1252                                                            TInt aPhrase,
       
  1253                                                            TBool aContent )
       
  1254     {
       
  1255     CSIPResponseElements* response = NULL;
       
  1256     
       
  1257     CSIPClientTransaction* clitransaction = 
       
  1258       CSIPClientTransaction::NewL( SIPStrings::StringF( aToMethod ));
       
  1259     CleanupStack::PushL( clitransaction );
       
  1260 
       
  1261     if ( aResponse > 0 )
       
  1262         {
       
  1263         response = SetResponseL( *clitransaction, aResponse, aPhrase );
       
  1264         
       
  1265         if ( aContent )
       
  1266             {
       
  1267             CSIPMessageElements& msgelements = response->MessageElements();
       
  1268             SetMessageElementsL( msgelements );
       
  1269             }
       
  1270         if ( aResponse >= KMceSipOK )
       
  1271             {
       
  1272             clitransaction->SetState( CSIPTransactionBase::ETerminated );
       
  1273             }
       
  1274         }
       
  1275         
       
  1276     return clitransaction;    
       
  1277     }
       
  1278 
       
  1279 // -----------------------------------------------------------------------------
       
  1280 // MCETestHelper::ClientTransactionLC()
       
  1281 // -----------------------------------------------------------------------------
       
  1282 //
       
  1283 CSIPClientTransaction* MCETestHelper::ClientTransactionLC( TInt aToMethod, 
       
  1284                                                            RPointerArray<CSIPHeaderBase>& aSipHeaders, 
       
  1285                                                            TUint aResponse, 
       
  1286                                                            TInt aPhrase,
       
  1287                                                            TBool aContent )
       
  1288     {
       
  1289     CSIPResponseElements* response = NULL;
       
  1290     
       
  1291     CSIPClientTransaction* clitransaction = 
       
  1292       CSIPClientTransaction::NewL( SIPStrings::StringF( aToMethod ));
       
  1293     CleanupStack::PushL( clitransaction );
       
  1294 
       
  1295     if ( aResponse > 0 )
       
  1296         {
       
  1297         response = SetResponseL( *clitransaction, aResponse, aPhrase );
       
  1298         CSIPMessageElements& msgelements = response->MessageElements();
       
  1299         
       
  1300         if ( aContent )
       
  1301             {
       
  1302             CSIPMessageElements& msgelements = response->MessageElements();
       
  1303             SetMessageElementsL( msgelements );
       
  1304             }
       
  1305 
       
  1306         msgelements.SetUserHeadersL( aSipHeaders );    
       
  1307         }
       
  1308         
       
  1309     return clitransaction;
       
  1310     }
       
  1311 
       
  1312 // -----------------------------------------------------------------------------
       
  1313 // MCETestHelper::SetResponseL()
       
  1314 // -----------------------------------------------------------------------------
       
  1315 //
       
  1316 CSIPResponseElements* MCETestHelper::SetResponseL( CSIPClientTransaction& aTrx, 
       
  1317                                                    TUint aResponse, 
       
  1318                                                    TInt aPhrase, 
       
  1319                                                    TBool aContent,
       
  1320                                                    TBool aRequire100rel, 
       
  1321                                                    TUint aRSeqValue )                               
       
  1322     {
       
  1323     CSIPResponseElements* response = 
       
  1324         CSIPResponseElements::NewLC( aResponse, 
       
  1325                                      SIPStrings::StringF( aPhrase ) );
       
  1326     
       
  1327     CSIPMessageElements& msgelements = response->MessageElements();
       
  1328     
       
  1329     CSIPFromHeader* from = CSIPFromHeader::DecodeL( KFrom );
       
  1330     CleanupStack::PushL( from );
       
  1331     msgelements.SetFromL( from );
       
  1332     CleanupStack::Pop( from );
       
  1333     
       
  1334     CSIPToHeader* to = CSIPToHeader::DecodeL( KTo );
       
  1335     CleanupStack::PushL( to );
       
  1336     msgelements.SetToL( to );
       
  1337     CleanupStack::Pop( to );
       
  1338     
       
  1339     RPointerArray<CSIPHeaderBase> usrhdrs;
       
  1340     CSIPHeaderBase::PushLC( &usrhdrs );
       
  1341     CSIPContactHeader* contact = MceSip::ToContactHeaderL( KContactValue );
       
  1342     CleanupStack::PushL( contact );
       
  1343     usrhdrs.AppendL( contact );
       
  1344     CleanupStack::Pop( contact );
       
  1345     msgelements.SetUserHeadersL( usrhdrs );
       
  1346     CleanupStack::Pop( &usrhdrs );
       
  1347     
       
  1348     if ( aResponse == KMceSipSessionProgress || aRequire100rel )
       
  1349         {
       
  1350         // Require: 100rel
       
  1351         RPointerArray<CSIPHeaderBase> hdrs;
       
  1352         CSIPHeaderBase::PushLC( &hdrs );
       
  1353         RStringF require = SIPStrings::Pool().OpenFStringL( KMceSip100Rel );
       
  1354         CleanupClosePushL( require );
       
  1355         CSIPRequireHeader* require100rel = CSIPRequireHeader::NewLC( require );
       
  1356         hdrs.AppendL( require100rel );
       
  1357         CleanupStack::Pop( require100rel );
       
  1358         CleanupStack::PopAndDestroy(); // require
       
  1359         
       
  1360         // RSeq
       
  1361         CSIPRSeqHeader* rseq = new( ELeave ) CSIPRSeqHeader( aRSeqValue );
       
  1362         CleanupStack::PushL( rseq );
       
  1363         hdrs.AppendL( rseq );
       
  1364         CleanupStack::Pop( rseq );
       
  1365         
       
  1366         msgelements.SetUserHeadersL( hdrs );
       
  1367         CleanupStack::Pop( &hdrs );
       
  1368         }
       
  1369     else if ( aResponse == KMceSipExtensionRequired )
       
  1370     	{
       
  1371     	// This branch is special for UT_MCEUsesCases::UT_MCEUsesCases_TestIMSR6toR5IOPL()
       
  1372     	//
       
  1373         // Require: precondition
       
  1374     	// if response is the kind of KMceSipExtensionRequired, then, response must have
       
  1375     	// "Require: precondition" field.
       
  1376         RPointerArray<CSIPHeaderBase> hdrs;
       
  1377         CSIPHeaderBase::PushLC( &hdrs );
       
  1378         RStringF require = SIPStrings::Pool().OpenFStringL( KMceSipPrecondition );
       
  1379         CleanupClosePushL( require );
       
  1380         CSIPRequireHeader* requireProcond = CSIPRequireHeader::NewLC( require );
       
  1381         hdrs.AppendL( requireProcond );
       
  1382         CleanupStack::Pop( requireProcond );
       
  1383         CleanupStack::PopAndDestroy(); // require
       
  1384         
       
  1385         msgelements.SetUserHeadersL( hdrs );
       
  1386         CleanupStack::Pop( &hdrs );
       
  1387     	}
       
  1388     
       
  1389     if ( aContent )
       
  1390         {
       
  1391         SetMessageElementsL( msgelements );
       
  1392         }
       
  1393         
       
  1394     aTrx.SetResponseElements( response );
       
  1395     CleanupStack::Pop( response );
       
  1396     
       
  1397     return response;    
       
  1398     }
       
  1399 
       
  1400 // -----------------------------------------------------------------------------
       
  1401 // MCETestHelper::SetResponse2L()
       
  1402 // -----------------------------------------------------------------------------
       
  1403 //
       
  1404 CSIPResponseElements* MCETestHelper::SetResponse2L( CSIPClientTransaction& aTrx,
       
  1405 													TUint aResponse,
       
  1406 													TInt aPhrase )
       
  1407     {
       
  1408     CSIPResponseElements* response = 
       
  1409         CSIPResponseElements::NewLC( aResponse, 
       
  1410                                      SIPStrings::StringF( aPhrase ) );
       
  1411     
       
  1412     CSIPMessageElements& msgelements = response->MessageElements();
       
  1413     
       
  1414     SetMessageElementsL( msgelements, 2 );
       
  1415         
       
  1416     aTrx.SetResponseElements( response );
       
  1417     CleanupStack::Pop( response );
       
  1418     
       
  1419     return response;
       
  1420     }
       
  1421 
       
  1422 // -----------------------------------------------------------------------------
       
  1423 // MCETestHelper::SetResponseBADL()
       
  1424 // -----------------------------------------------------------------------------
       
  1425 //
       
  1426 CSIPResponseElements*
       
  1427 MCETestHelper::SetResponseBADL( CSIPClientTransaction& aTrx,
       
  1428 								TUint aResponse,
       
  1429 								TInt aPhrase )
       
  1430     {
       
  1431     CSIPResponseElements* response = 
       
  1432         CSIPResponseElements::NewLC( aResponse, 
       
  1433                                      SIPStrings::StringF( aPhrase ) );
       
  1434     
       
  1435     CSIPMessageElements& msgelements = response->MessageElements();
       
  1436     
       
  1437     SetMessageElementsL( msgelements, 3 );
       
  1438         
       
  1439     aTrx.SetResponseElements( response );
       
  1440     CleanupStack::Pop( response );
       
  1441     
       
  1442     return response;
       
  1443     }
       
  1444 
       
  1445 // -----------------------------------------------------------------------------
       
  1446 // MCETestHelper::SetMessageElementsL()
       
  1447 // -----------------------------------------------------------------------------
       
  1448 //
       
  1449 void MCETestHelper::SetMessageElementsL( CSIPMessageElements& aElements,
       
  1450 										 TInt sdpId )
       
  1451     {
       
  1452     CSIPContentTypeHeader* contenttype = 
       
  1453         CSIPContentTypeHeader::NewL( _L8("application"), _L8("sdp") ); //OK
       
  1454     CleanupStack::PushL( contenttype );
       
  1455         
       
  1456     HBufC8* content = NULL;
       
  1457     if ( sdpId == 1 )
       
  1458         {
       
  1459         content = KSDPMessage_OK1().AllocLC();
       
  1460         }
       
  1461     else if ( sdpId == 2 )
       
  1462         {
       
  1463         content = KSDPMessage_OK2().AllocLC();
       
  1464         }
       
  1465     else
       
  1466         {
       
  1467         content = KSDPMessage_BAD().AllocLC();
       
  1468         }
       
  1469         
       
  1470     aElements.SetContentL( content, contenttype );
       
  1471     CleanupStack::Pop( content );
       
  1472     CleanupStack::Pop( contenttype );
       
  1473     }
       
  1474 
       
  1475 // -----------------------------------------------------------------------------
       
  1476 // MCETestHelper::AppendContactToUserHeaders
       
  1477 // -----------------------------------------------------------------------------
       
  1478 //
       
  1479 void MCETestHelper::AppendContactToUserHeaders(
       
  1480 	RPointerArray<CSIPHeaderBase>& aSipHeaders, const TDesC8& aContact )
       
  1481     {
       
  1482     CSIPContactHeader* contact = MceSip::ToContactHeaderL( aContact );
       
  1483     CleanupStack::PushL( contact );
       
  1484     aSipHeaders.AppendL( contact );
       
  1485     CleanupStack::Pop( contact );
       
  1486     }
       
  1487 
       
  1488 // -----------------------------------------------------------------------------
       
  1489 // MCETestHelper::OfferL()
       
  1490 // -----------------------------------------------------------------------------
       
  1491 //
       
  1492 CSdpDocument* MCETestHelper::OfferL()
       
  1493     {
       
  1494     return CSdpDocument::DecodeL( KSDPMessage_OK1 );
       
  1495     }    
       
  1496     
       
  1497 // -----------------------------------------------------------------------------
       
  1498 // MCETestHelper::ComSessionL()
       
  1499 // -----------------------------------------------------------------------------
       
  1500 //
       
  1501 CMceComSession* MCETestHelper::ComSessionL( TUint32 aSessionId, 
       
  1502                                             TBool aRequire100rel )
       
  1503     {
       
  1504     _LIT8( originator, "sip:originator@foo.bar" );
       
  1505     _LIT8( recipient, "sip:recipient@foo.bar" );
       
  1506     _LIT8( contentType, "contenttype" );
       
  1507     _LIT8( header, "header" );
       
  1508     _LIT8( amr, "AMR" );
       
  1509     
       
  1510     
       
  1511     TBuf8<KMceMaxSdpNameLength> amrName;
       
  1512     amrName.Append( amr );
       
  1513     
       
  1514     CMceComSession* clientSession = CMceComSession::NewL( CMceComSession::EOutSession );
       
  1515     CleanupStack::PushL( clientSession );
       
  1516     
       
  1517     
       
  1518     CMceComAudioStream* inStream = CMceComAudioStream::NewLC();
       
  1519     CMceComAudioStream* outStream = CMceComAudioStream::NewLC();
       
  1520     inStream->BindL( outStream );
       
  1521     CleanupStack::Pop( outStream );
       
  1522     
       
  1523     CMceComAMRCodec* codec1 = CMceComAMRCodec::NewLC( amrName );
       
  1524     inStream->AddCodecL( codec1 );
       
  1525     CleanupStack::Pop( codec1 );
       
  1526 
       
  1527     CMceComAMRCodec* codec2 = CMceComAMRCodec::NewLC( amrName );
       
  1528     outStream->AddCodecL( codec2 );
       
  1529     CleanupStack::Pop( codec2 );
       
  1530         
       
  1531     CMceComRtpSource* rtpSource = CMceComRtpSource::NewLC();
       
  1532     inStream->SetSourceL( rtpSource );
       
  1533     CleanupStack::Pop( rtpSource );
       
  1534     
       
  1535     CMceComSpeakerSink* speaker = CMceComSpeakerSink::NewLC();
       
  1536     inStream->AddSinkL( speaker );
       
  1537     CleanupStack::Pop( speaker );
       
  1538     
       
  1539 
       
  1540     CMceComRtpSink* rtpSink = CMceComRtpSink::NewLC();
       
  1541     outStream->AddSinkL( rtpSink );
       
  1542     CleanupStack::Pop( rtpSink );
       
  1543     
       
  1544     CMceComMicSource* mic = CMceComMicSource::NewLC();
       
  1545     outStream->SetSourceL( mic );
       
  1546     CleanupStack::Pop( mic );
       
  1547     
       
  1548     clientSession->AddStreamL( inStream );
       
  1549     CleanupStack::Pop( inStream );
       
  1550     clientSession->InitializeL();
       
  1551     
       
  1552     //set ids
       
  1553     TUid appUid = TUid::Uid( 10 );
       
  1554     clientSession->iID = aSessionId;
       
  1555     inStream->iID   = TMceMediaId(appUid,1);
       
  1556     outStream->iID  = TMceMediaId(appUid,2);
       
  1557     rtpSource->iID  = TMceMediaId(appUid,3);
       
  1558     speaker->iID    = TMceMediaId(appUid,4);
       
  1559     rtpSink->iID    = TMceMediaId(appUid,5);
       
  1560     mic->iID        = TMceMediaId(appUid,6);
       
  1561     
       
  1562     
       
  1563     //set session
       
  1564     clientSession->iIsConnectionActive = ETrue;
       
  1565     clientSession->iDialogId = 434;
       
  1566     clientSession->iIapId = 4;
       
  1567     clientSession->iMccID = 101;
       
  1568     clientSession->iMinSE = 200;
       
  1569     clientSession->iTimeout = 30;
       
  1570     clientSession->iLocalIpAddress = TInetAddr( 5005 );
       
  1571     clientSession->iRemoteIpAddress = TInetAddr( 5010 );
       
  1572     clientSession->SetOriginatorL( originator );
       
  1573     clientSession->SetRecipientL( recipient );
       
  1574     MCE_TH_SET( clientSession->iSIPContentType, contentType().AllocL() );
       
  1575     MCE_TH_SET( clientSession->iSIPHeaders, new (ELeave) CDesC8ArrayFlat( KMceArrayGranularity ) );
       
  1576     MCE_TH_SET( clientSession->iLocalSessionSDPLines, new (ELeave) CDesC8ArrayFlat( KMceArrayGranularity ) );
       
  1577     MCE_TH_SET( clientSession->iRemoteSessionSDPLines, new (ELeave) CDesC8ArrayFlat( KMceArrayGranularity ) );
       
  1578 	clientSession->iSIPHeaders->AppendL( header );
       
  1579     if ( aRequire100rel )
       
  1580         {
       
  1581         clientSession->Modifier( KMce100Rel ) = KMce100RelRequired;
       
  1582         }
       
  1583     
       
  1584 	inStream->iLocalMediaPort = 5001;
       
  1585 	inStream->iIsEnabled = ETrue;
       
  1586 	inStream->iRemoteMediaPort = 5002;
       
  1587 	inStream->iLinkId = 31;
       
  1588 	inStream->iRemoteRtcpAddress = TInetAddr( 3004 );
       
  1589     MCE_TH_SET( inStream->iLocalMediaSDPLines, new (ELeave) CDesC8ArrayFlat( KMceArrayGranularity ) );
       
  1590     MCE_TH_SET( inStream->iRemoteMediaSDPLines, new (ELeave) CDesC8ArrayFlat( KMceArrayGranularity ) );
       
  1591 	inStream->iLocalMediaSDPLines->AppendL( KFmtAttribute );
       
  1592 
       
  1593 	outStream->iLocalMediaPort = 521;
       
  1594 	outStream->iRemoteMediaPort = 554;
       
  1595 	outStream->iLinkId = 51;
       
  1596 	outStream->iIsEnabled = EFalse;
       
  1597 	outStream->iRemoteRtcpAddress = TInetAddr( 5004 );
       
  1598     MCE_TH_SET( outStream->iLocalMediaSDPLines, new (ELeave) CDesC8ArrayFlat( KMceArrayGranularity ) );
       
  1599     MCE_TH_SET( outStream->iRemoteMediaSDPLines, new (ELeave) CDesC8ArrayFlat( KMceArrayGranularity ) );
       
  1600 	outStream->iRemoteMediaSDPLines->AppendL( KFmtAttribute );
       
  1601 	
       
  1602 	
       
  1603     codec1->iEnableVAD = ETrue;
       
  1604     codec1->iSamplingFreq = 111;
       
  1605     codec1->iPTime = 150;
       
  1606     codec1->iMaxPTime = 190;
       
  1607     codec1->iBitrate = 1122;
       
  1608     codec1->iAllowedBitrates = 11111;
       
  1609     codec1->iPayloadType = 197;
       
  1610     codec1->iCodecMode = 12;
       
  1611     codec1->iFourCC = 1567;
       
  1612     codec1->iFrameSize = 165;
       
  1613     MCE_TH_SET( codec1->iFmtpAttr, KFmtAttribute().AllocL() );
       
  1614     
       
  1615     codec2->iEnableVAD = ETrue;
       
  1616     codec2->iSamplingFreq = 211;
       
  1617     codec2->iPTime = 250;
       
  1618     codec2->iMaxPTime = 290;
       
  1619     codec2->iBitrate = 2122;
       
  1620     codec2->iAllowedBitrates = 21111;
       
  1621     codec2->iPayloadType = 297;
       
  1622     codec2->iCodecMode = 22;
       
  1623     codec2->iFourCC = 2567;
       
  1624     codec2->iFrameSize = 265;
       
  1625     MCE_TH_SET( codec2->iFmtpAttr, KFmtAttribute().AllocL() );
       
  1626     
       
  1627     
       
  1628     mic->Enabled( ETrue );
       
  1629     rtpSource->Enabled( EFalse );
       
  1630     rtpSink->Enabled( ETrue );
       
  1631     speaker->Enabled( EFalse );
       
  1632     
       
  1633     rtpSource->iInactivityTimer = 999;
       
  1634     rtpSource->iBufferLength = 999;
       
  1635     rtpSource->iBufferTreshold = 999;
       
  1636     MCE_TH_SET( rtpSource->iTalkBurstIndicator, KFmtAttribute().AllocL() );
       
  1637 
       
  1638 
       
  1639     rtpSink->iSuppressRTCP = ETrue;
       
  1640     rtpSink->iSSRC = 888;
       
  1641     rtpSink->iLastPacket = 8899;
       
  1642     
       
  1643     CleanupStack::Pop( clientSession );
       
  1644     
       
  1645     return clientSession;
       
  1646     }
       
  1647 
       
  1648 // -----------------------------------------------------------------------------
       
  1649 // MCETestHelper::EventMsg()
       
  1650 // -----------------------------------------------------------------------------
       
  1651 //
       
  1652 CMceMsgBase* MCETestHelper::EventMsg( TInt aEventType )
       
  1653     {
       
  1654     HBufC8* recipient = KRecipient().AllocLC();
       
  1655     HBufC8* originator = KFrom().AllocLC();
       
  1656     CDesC8Array* headers = new( ELeave ) CDesC8ArrayFlat( KMceArrayGranularity );
       
  1657     CleanupStack::PushL( headers );
       
  1658     HBufC8* contentType = KContentType().AllocLC();
       
  1659     TInt interval = 0;
       
  1660     HBufC8* event = NULL;
       
  1661     HBufC8* referTo = NULL;
       
  1662     
       
  1663     if ( aEventType == EMceItcEventTypeRefer )
       
  1664         {
       
  1665         event = KNullDesC8().AllocLC();
       
  1666         referTo = KReferTo().AllocLC();
       
  1667         }
       
  1668     else if ( aEventType == EMceItcEventTypeSubscribe )
       
  1669         {
       
  1670         event = KEvent().AllocLC();
       
  1671         referTo = KNullDesC8().AllocLC();
       
  1672         interval = 180;
       
  1673         }
       
  1674     else if ( EMceItcEventTypeEither )
       
  1675         {
       
  1676         event = KNullDesC8().AllocLC();
       
  1677         referTo = KNullDesC8().AllocLC();
       
  1678         }
       
  1679     CMceMsgSIPEvent* msg = new( ELeave ) CMceMsgSIPEvent( 1, // aId 
       
  1680                                          1, // aDialogId
       
  1681                                          (TMceItcEventType) aEventType,
       
  1682                                          recipient,
       
  1683                                          originator,
       
  1684                                          event,
       
  1685                                          referTo,
       
  1686                                          CMceRefer::ENoSuppression,
       
  1687                                          interval,
       
  1688                                          headers,
       
  1689                                          contentType );
       
  1690 
       
  1691     CleanupStack::Pop( referTo );
       
  1692     CleanupStack::Pop( event );
       
  1693     CleanupStack::Pop( contentType );
       
  1694     CleanupStack::Pop( headers );
       
  1695     CleanupStack::Pop( originator );
       
  1696     CleanupStack::Pop( recipient );
       
  1697     return msg;
       
  1698     }
       
  1699 
       
  1700 // -----------------------------------------------------------------------------
       
  1701 // MCETestHelper::ReplyMsg()
       
  1702 // -----------------------------------------------------------------------------
       
  1703 //
       
  1704 CMceMsgBase* MCETestHelper::ReplyMsg( TUint aReasonCode )
       
  1705     {
       
  1706     HBufC8* reason = KReason().AllocLC();
       
  1707     CDesC8Array* headers = new( ELeave ) CDesC8ArrayFlat( KMceArrayGranularity );
       
  1708     CleanupStack::PushL( headers );
       
  1709     HBufC8* contentType = KContentType().AllocLC();
       
  1710     
       
  1711     CMceMsgSIPReply* reply = new (ELeave) CMceMsgSIPReply( *reason, 
       
  1712                                                            aReasonCode, 
       
  1713                                                           *headers, 
       
  1714                                                           *contentType );
       
  1715     CleanupStack::Pop( contentType );
       
  1716     CleanupStack::Pop( headers );
       
  1717     CleanupStack::Pop( reason );
       
  1718     
       
  1719     return reply;
       
  1720     }
       
  1721 
       
  1722 // -----------------------------------------------------------------------------
       
  1723 // MCETestHelper::RequestMsg()
       
  1724 // -----------------------------------------------------------------------------
       
  1725 //
       
  1726 CMceMsgBase* MCETestHelper::RequestMsg( const TDesC8& aMethod )
       
  1727     {
       
  1728     HBufC8* method = aMethod.AllocLC(); 
       
  1729     
       
  1730     CDesC8Array* hdrs = new( ELeave ) CDesC8ArrayFlat( KMceArrayGranularity );
       
  1731     CleanupStack::PushL( hdrs );
       
  1732     
       
  1733     HBufC8* ct = KContentType().AllocLC();
       
  1734 
       
  1735 	CMceMsgSIPRequest* msg = new (ELeave) CMceMsgSIPRequest( *method, *hdrs, 
       
  1736 																	*ct );
       
  1737 	CleanupStack::Pop( ct );
       
  1738 	CleanupStack::Pop( hdrs );
       
  1739 	CleanupStack::Pop( method ) ;
       
  1740     
       
  1741     return msg;
       
  1742     }
       
  1743     
       
  1744 
       
  1745 // -----------------------------------------------------------------------------
       
  1746 // MCETestHelper::ChangeResponseTypeL()
       
  1747 // -----------------------------------------------------------------------------
       
  1748 //
       
  1749 void MCETestHelper::ChangeResponseTypeL( const CSIPResponseElements& aResponse, 
       
  1750                                          TUint aResponseCode,
       
  1751                                          TInt aReasonPhrase )
       
  1752     {
       
  1753     CSIPResponseElements& response = 
       
  1754         const_cast< CSIPResponseElements& >( aResponse );
       
  1755     response.SetStatusCodeL( aResponseCode );
       
  1756     response.SetReasonPhraseL( SIPStrings::StringF( aReasonPhrase ) );
       
  1757     }