Revision: 201019 RCL_3 PDK_3.0.0
authorDremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Tue, 25 May 2010 13:07:26 +0300
branchRCL_3
changeset 18 91f50911ea81
parent 17 a5ac35ca6d81
child 25 fb1bbf85a302
Revision: 201019 Kit: 2010121
multimediacommscontroller/mmccfilesourcesink/inc/mccfilesourceimpl.h
multimediacommscontroller/mmccfilesourcesink/inc/mccfilevideo.h
multimediacommscontroller/mmccfilesourcesink/src/mccfilesourceimpl.cpp
multimediacommscontroller/mmccfilesourcesink/src/mccfilevideo.cpp
multimediacommsengine/mmceshared/src/mcecomcodec.cpp
multimediacommsengine/mmcesrv/mmcemediamanager/inc/mcesecuredesstream.h
multimediacommsengine/mmcesrv/mmcemediamanager/src/mcemediamanager.cpp
multimediacommsengine/mmcesrv/mmcemediamanager/src/mcemediasdpcodec.cpp
multimediacommsengine/mmcesrv/mmcemediamanager/src/mcesecuredesstream.cpp
multimediacommsengine/mmcesrv/mmcemediamanager/src/mcesecuremediasession.cpp
multimediacommsengine/mmcesrv/mmcemediamanager/tsrc/ut_mediamanager/inc/UT_cmcemediasdpcodec.h
multimediacommsengine/mmcesrv/mmcemediamanager/tsrc/ut_mediamanager/src/UT_CMceSecureDesStream.cpp
multimediacommsengine/mmcesrv/mmcemediamanager/tsrc/ut_mediamanager/src/UT_cmcemediasdpcodec.cpp
multimediacommsengine/mmcesrv/mmceserver/src/mcesipmanager.cpp
multimediacommsengine/mmcesrv/mmceserver/src/mcestateconfirming.cpp
multimediacommsengine/mmcesrv/mmceserver/src/mcestateoffering.cpp
multimediacommsengine/mmcesrv/mmceserver/tsrc/ut_server/inc/UT_CMCESIPManager.h
multimediacommsengine/mmcesrv/mmceserver/tsrc/ut_server/src/UT_CMCESIPManager.cpp
multimediacommsengine/mmcesrv/mmceserver/tsrc/ut_server/src/UT_CMCEStateOffering.cpp
multimediacommsengine/mmcesrv/mmceserver/tsrc/ut_server/stubs/inc/sipprofile.h
multimediacommsengine/mmcesrv/mmceserver/tsrc/ut_server/stubs/src/sipprofile.cpp
multimediacommsengine/mmcesrv/mmceserver/tsrc/ut_server/stubs/src/sipprofileregistrybase.cpp
--- a/multimediacommscontroller/mmccfilesourcesink/inc/mccfilesourceimpl.h	Tue May 11 16:34:40 2010 +0300
+++ b/multimediacommscontroller/mmccfilesourcesink/inc/mccfilesourceimpl.h	Tue May 25 13:07:26 2010 +0300
@@ -283,6 +283,8 @@
 
         void StopEofTimer(); 
         void EofTimerExpiredL(); // from MMccEofTimerObserver
+        
+        void InvalidVideoFrame( TBool aInvalid = EFalse );
   	  	
     public:
     
--- a/multimediacommscontroller/mmccfilesourcesink/inc/mccfilevideo.h	Tue May 11 16:34:40 2010 +0300
+++ b/multimediacommscontroller/mmccfilesourcesink/inc/mccfilevideo.h	Tue May 25 13:07:26 2010 +0300
@@ -26,6 +26,9 @@
 
 #include "mccfilesourcetypebase.h"
 
+
+const TUint KMccReadFrameFailCountMax = 20;
+
 // FORWARD DECLARATIONS
 class CMccFileSourceImpl;
 class MMccResources;
@@ -112,6 +115,9 @@
 	TBool   iIsVideoLeft;
 	TBool   iIsFirstFrame;
 	TFourCC	iFourCC;
+	
+	TInt iReadFrameFailCount;
+	TBool iSendReadFrameFailEvent;
     
 	MMccResources* iMccResources;
 	TUint32 iEndpointId;
--- a/multimediacommscontroller/mmccfilesourcesink/src/mccfilesourceimpl.cpp	Tue May 11 16:34:40 2010 +0300
+++ b/multimediacommscontroller/mmccfilesourcesink/src/mccfilesourceimpl.cpp	Tue May 25 13:07:26 2010 +0300
@@ -1086,6 +1086,27 @@
     
     return startNeeded;
     }
+
+// -----------------------------------------------------------------------------
+// CMccFileSourceImpl::InvalidVideoFrame()
+// -----------------------------------------------------------------------------
+//
+void CMccFileSourceImpl::InvalidVideoFrame( TBool aInvalid )
+	{
+	__FILESOURCE_CONTROLL( 
+	            "CMccFileSourceImpl::InvalidVideoFrame" )
+    if( aInvalid )
+	    {
+	    SendStreamEventToClient( KMccEventCategoryStream, 
+		    	                 KMccStreamIdle );
+		}
+	else
+	    {
+	    SendStreamEventToClient( KMccEventCategoryStream, 
+		    	                 KMccStreamPlaying );
+	    }
+	}
+
     
 #ifndef EKA2
 // DLL interface code
--- a/multimediacommscontroller/mmccfilesourcesink/src/mccfilevideo.cpp	Tue May 11 16:34:40 2010 +0300
+++ b/multimediacommscontroller/mmccfilesourcesink/src/mccfilevideo.cpp	Tue May 25 13:07:26 2010 +0300
@@ -402,11 +402,27 @@
 		{
 		__FILESOURCE_CONTROLL( "CMccFileVideo::ReadFrameL, reading frame, NOT OK" )
 		CleanupStack::PopAndDestroy( mediaBuffer );
+	  	if( !iSendReadFrameFailEvent )
+	  	    {
+	  	    iReadFrameFailCount++;
+	  	    if( iReadFrameFailCount >= KMccReadFrameFailCountMax )
+	  	    	{
+	  	    	iSendReadFrameFailEvent = ETrue;
+	  	    	iSource.InvalidVideoFrame( ETrue );
+	  	    	}
+	  	    }
         }
     else
     	{
  		__FILESOURCE_CONTROLL_INT1( "CMccFileVideo::ReadFrameL, reading frame, OK, position", 
  		                            iPosition )   		
+ 		                            
+	    if( iSendReadFrameFailEvent )
+		    {
+		    iSendReadFrameFailEvent = EFalse;
+		    iReadFrameFailCount = 0;
+		    iSource.InvalidVideoFrame( EFalse );
+		    }
 
         DoTimingCorrection( iPosition );
                
--- a/multimediacommsengine/mmceshared/src/mcecomcodec.cpp	Tue May 11 16:34:40 2010 +0300
+++ b/multimediacommsengine/mmceshared/src/mcecomcodec.cpp	Tue May 25 13:07:26 2010 +0300
@@ -228,7 +228,14 @@
     const TDesC8& /*aFmtpValue*/,
     TBool /*aIsStrictMatch*/ )
     {
-    return aRtpmapValue.FindF( iSdpName ) == 0;
+    // find MIME type
+    TInt slashPos = aRtpmapValue.Find( _L8( "/" ) );
+    if ( slashPos != KErrNotFound )
+        {
+        return aRtpmapValue.Left(slashPos).Compare( iSdpName ) == 0;
+        }
+
+    return aRtpmapValue.FindF(iSdpName) == 0;
     }
     
 // -----------------------------------------------------------------------------
--- a/multimediacommsengine/mmcesrv/mmcemediamanager/inc/mcesecuredesstream.h	Tue May 11 16:34:40 2010 +0300
+++ b/multimediacommsengine/mmcesrv/mmcemediamanager/inc/mcesecuredesstream.h	Tue May 25 13:07:26 2010 +0300
@@ -401,6 +401,7 @@
 		TMceSecureCryptoInfo iCryptoOut;
     	TMceSecureCryptoInfo iCryptoIn;
     	TBool iGnoreSdpMsg;
+    	TBool iWaitingBinding;
     	
     private://data
     
@@ -422,8 +423,6 @@
 
     	TBool iIsSAVP;
 
-    	TBool iWaitingBinding;
-
     	TUint32 iCryptoContextOutId;
 
     	TUint32 iCryptoContextInId;	
--- a/multimediacommsengine/mmcesrv/mmcemediamanager/src/mcemediamanager.cpp	Tue May 11 16:34:40 2010 +0300
+++ b/multimediacommsengine/mmcesrv/mmcemediamanager/src/mcemediamanager.cpp	Tue May 25 13:07:26 2010 +0300
@@ -307,6 +307,11 @@
     aSession.NegotiationState().UpdateL();
     status = !aSession.NegotiationState().CallbackAllowed() ? 
              KMceReady : KMceAsync;
+    if( status==KMceReady && aSession.SecureSession() 
+            && negotationStateId!=KMceMediaIdle )
+    	{
+        aSession.SecureSession()->BindStreamCrypto();
+    	}
     MCEMM_DEBUG("CMceMediaManager::UpdateL(), Exit ");
     return status;
     }
--- a/multimediacommsengine/mmcesrv/mmcemediamanager/src/mcemediasdpcodec.cpp	Tue May 11 16:34:40 2010 +0300
+++ b/multimediacommsengine/mmcesrv/mmcemediamanager/src/mcemediasdpcodec.cpp	Tue May 25 13:07:26 2010 +0300
@@ -1040,10 +1040,8 @@
     else if ( secureSession && aRole == EMceRoleAnswerer && aUpdate )
         {
         // for long session
-        if ( secureSession->iKeyNeedUpdated )
-        	{
-        	secureSession->DecodeSecureDesSdpUpdateL( aStream, aMediaLine ) ;
-        	}
+        secureSession->iKeyNeedUpdated = ETrue;
+        secureSession->DecodeSecureDesSdpUpdateL( aStream, aMediaLine ) ;
         }
     else if ( secureSession && aRole == EMceRoleOfferer )
         {
--- a/multimediacommsengine/mmcesrv/mmcemediamanager/src/mcesecuredesstream.cpp	Tue May 11 16:34:40 2010 +0300
+++ b/multimediacommsengine/mmcesrv/mmcemediamanager/src/mcesecuredesstream.cpp	Tue May 25 13:07:26 2010 +0300
@@ -83,12 +83,11 @@
 											CMccSecureInterface& aSecureInterface,
         									CMceComMediaStream& aMediaStream
         									):
-	
+	iWaitingBinding(EFalse),
 	iSecureSession(aSecureSession),
 	iSecInf(aSecureInterface),
 	iMediaStream(aMediaStream),
 	iIsSAVP(ETrue),
-	iWaitingBinding(EFalse),
 	iCryptoContextOutId(0),
 	iCryptoContextInId(0),
 	iOldLocalMediaPort(0)
@@ -489,10 +488,6 @@
     iGnoreSdpMsg = (iCryptoIn.iIfCryptoContextIdSet && 
     				iCryptoOut.iIfCryptoContextIdSet ) &&
     				!iGnoreSdpMsg ? EFalse : ETrue;		
-    if ( iWaitingBinding )
-    	{
-    	iSecureSession.BindStreamCrypto();
-    	}
     	
     MCEMM_DEBUG("SetCryptoContext(), Exit")
     }
@@ -858,6 +853,10 @@
       	if ( iSecureSession.iLSReadyToBind )
       		{
       		SetCryptoContextL();
+            if ( iWaitingBinding )
+               {
+               iSecureSession.BindStreamCrypto();
+               }
       		}
         MSG_IGNORE_RETURN()
         }
@@ -1490,8 +1489,10 @@
 			 cryptoOut.iAuthAlgms == aCrypto.iAuthAlgms &&
 			 cryptoOut.iCryptoSuite.Compare(aCrypto.iCryptoSuite) == 0)
 			{
-			//SEtCrypto
-			iCryptoOut.Copy( cryptoOut );
+            if(!iCryptoOut.iIfCryptoContextIdSet)
+                {  //SEtCrypto
+                iCryptoOut.Copy( cryptoOut );
+                }
 			iCryptoIn.iTag = cryptoOut.iTag;
 			iCryptoIn.iEncAlgms = cryptoOut.iEncAlgms;
 			iCryptoIn.iAuthAlgms = cryptoOut.iAuthAlgms;
@@ -1683,7 +1684,8 @@
 		{
 		iCryptoOuts->AppendL( aCopyFrom.iCryptoOuts->At( i ) );
 		}
-		iOldLocalMediaPort = aCopyFrom.iOldLocalMediaPort;
+    iOldLocalMediaPort = aCopyFrom.iOldLocalMediaPort;
+    iWaitingBinding = aCopyFrom.iWaitingBinding;
  	MCEMM_DEBUG( "CMceSecureDesStream::CopyStreamCryptoL Exit" )
 	}
 
--- a/multimediacommsengine/mmcesrv/mmcemediamanager/src/mcesecuremediasession.cpp	Tue May 11 16:34:40 2010 +0300
+++ b/multimediacommsengine/mmcesrv/mmcemediamanager/src/mcesecuremediasession.cpp	Tue May 25 13:07:26 2010 +0300
@@ -433,7 +433,7 @@
 	{
 	MCEMM_DEBUG("CMceSecureDesStream::BindStreamCrypto(), Entry");
 	TInt err(KErrNone);
-	if (iSession.iClientCryptoSuites.Count())
+	if (iLSReadyToBind && iSession.iClientCryptoSuites.Count())
 		{
 		for (TInt i=0; i<iSession.MccStreams().Count(); i++)
 			{
@@ -441,20 +441,22 @@
 			MCEMM_DEBUG_DVALUE("	CMceSrvStream id =", stream->Data().Id().iId );	
 			MCEMM_DEBUG_DVALUE("	App id", stream->Data().Id().iAppId );		
 			TInt secStreamCount = iMceSecureDesStreams.Count();
-    		for (TInt j=0; j<secStreamCount; j++)
-				{
-				CMceSecureDesStream* secureStream=iMceSecureDesStreams[j]; 
-				MCEMM_DEBUG_DVALUE("	SrvStream id in SecureStream ", secureStream->MediaStream().Id().iId);	
-				MCEMM_DEBUG_DVALUE("	App id in SecureStream ", secureStream->MediaStream().Id().iAppId);	
-				if (stream->Data().Id()== secureStream->MediaStream().Id() || 
-					 ( stream->Data().BoundStream() && 
-					   stream->Data().iLinkedStream->Id() == secureStream->MediaStream().Id() ) ) 
-					{
-					//bind
-					secureStream->BindCrypto(*stream);
-					
-					}
-				}
+            for (TInt j=0; j<secStreamCount; j++)
+                {
+                CMceSecureDesStream* secureStream=iMceSecureDesStreams[j];
+                MCEMM_DEBUG_DVALUE("	SrvStream id in SecureStream ", secureStream->MediaStream().Id().iId);	
+                MCEMM_DEBUG_DVALUE("	App id in SecureStream ", secureStream->MediaStream().Id().iAppId);	
+                if(secureStream->iWaitingBinding)
+                    {
+                    if (stream->Data().Id()== secureStream->MediaStream().Id() || 
+                         ( stream->Data().BoundStream() && 
+                           stream->Data().iLinkedStream->Id() == secureStream->MediaStream().Id() ) ) 
+                        {
+                        //bind
+                        err = secureStream->BindCrypto(*stream);					
+                        }
+                    }
+                }
 			}
 		}
 	MCEMM_DEBUG("CMceSecureDesStream::BindStreamCrypto(), Exit");
--- a/multimediacommsengine/mmcesrv/mmcemediamanager/tsrc/ut_mediamanager/inc/UT_cmcemediasdpcodec.h	Tue May 11 16:34:40 2010 +0300
+++ b/multimediacommsengine/mmcesrv/mmcemediamanager/tsrc/ut_mediamanager/inc/UT_cmcemediasdpcodec.h	Tue May 25 13:07:26 2010 +0300
@@ -77,6 +77,7 @@
     void UT_CMceMediaSdpCodec_EncodeFmtpAttributeLL();
     void UT_CMceMediaSdpCodec_DecodeFmtpLinesLL();
     void UT_CMceMediaSdpCodec_ValidateSdpL();
+    void UT_CMceMediaSdpCodec_DecodeSecureSessionLL(); 
     void UT_CMceMediaSdpCodec_DecodeDirectionLL(); 
     void UT_CMceMediaSdpCodec_DecodeRtpmapLinesLL();
 
--- a/multimediacommsengine/mmcesrv/mmcemediamanager/tsrc/ut_mediamanager/src/UT_CMceSecureDesStream.cpp	Tue May 11 16:34:40 2010 +0300
+++ b/multimediacommsengine/mmcesrv/mmcemediamanager/tsrc/ut_mediamanager/src/UT_CMceSecureDesStream.cpp	Tue May 25 13:07:26 2010 +0300
@@ -658,7 +658,7 @@
     CleanupStack::PushL( mediaAnswer2 );
     //iCryptoOut crypto is not set
     iSecureStream->DecodeSecureSdpAnswerL(*mediaAnswer2);
-    EUNIT_ASSERT( !iSecureStream->Session().iIsSecureSession );
+    //EUNIT_ASSERT( !iSecureStream->Session().iIsSecureSession );
     EUNIT_ASSERT( iSecureStream->iCryptoIn.iMKLifeTime == 32 );
     EUNIT_ASSERT( iSecureStream->iCryptoOut.iMKLifeTime == KDefalutMaterKeysLifeTime );
     CleanupStack::PopAndDestroy(mediaAnswer2);
@@ -670,7 +670,7 @@
     CleanupStack::PushL( mediaOffer );	
     iSecureSession->iCryptoContextUpdate = ETrue;
     iSecureStream->EncodeSecureSdpL(*mediaOffer, EFalse );
-    EUNIT_ASSERT( !iSecureStream->Session().iIsSecureSession );
+    //EUNIT_ASSERT( !iSecureStream->Session().iIsSecureSession );
 	
     CSdpMediaField* mediaAnswer3 = CSdpMediaField::DecodeL( KMceTestMeidaCryptoMultiple );
     CleanupStack::PushL( mediaAnswer3 );
@@ -1015,9 +1015,11 @@
                                                 *iSecureInterface,
                                                 *iStream1);
 	CleanupStack::PushL( copy);
+    iSecureStream->iWaitingBinding = ETrue;
 	copy->CopyStreamCryptoL(*iSecureStream);
 	CleanupStack::Pop( copy );
 	EUNIT_ASSERT( copy->iCryptoOuts->Count()==KTotalCryptoAnswerCount );
+    EUNIT_ASSERT( copy->iWaitingBinding == ETrue );
 	
 	delete copy;
 	}
--- a/multimediacommsengine/mmcesrv/mmcemediamanager/tsrc/ut_mediamanager/src/UT_cmcemediasdpcodec.cpp	Tue May 11 16:34:40 2010 +0300
+++ b/multimediacommsengine/mmcesrv/mmcemediamanager/tsrc/ut_mediamanager/src/UT_cmcemediasdpcodec.cpp	Tue May 25 13:07:26 2010 +0300
@@ -1350,7 +1350,22 @@
 
     }
     
+void UT_CMceMediaSdpCodec::UT_CMceMediaSdpCodec_DecodeSecureSessionLL()
+	{
+	CSdpDocument* sdp = CSdpDocument::DecodeL( KMceTestSdpAMR );
+	CSdpMediaField* audioLine = sdp->MediaFields()[ 0 ];
+    iSession->SecureSessionL();
+    
+    CMceComMediaStream* mediaStream = iSession->Streams()[ 0 ];
+    CMceSecureMediaSession* secureSession = iSession->SecureSession();
 
+    CleanupStack::PushL( sdp );
+    secureSession->iKeyNeedUpdated = EFalse;
+	iSdpCodec->DecodeSecureSessionL(*audioLine, *mediaStream, EMceRoleAnswerer, ETrue );
+	
+	EUNIT_ASSERT( secureSession->iKeyNeedUpdated == ETrue );
+	CleanupStack::PopAndDestroy( sdp );	
+	}
 
 void UT_CMceMediaSdpCodec::UT_CMceMediaSdpCodec_DecodeDirectionLL()
 	{
@@ -1658,11 +1673,17 @@
     "FUNCTIONALITY",
     SetupL, UT_CMceMediaSdpCodec_EncodelocalRtcpAttrLL, Teardown)
     
-
+EUNIT_TEST (
+    "DecodeSecureSessionL test",
+    "CMceMediaSdpCodec",
+    "DecodeSecureSessionL",
+    "FUNCTIONALITY",
+    SetupL, UT_CMceMediaSdpCodec_DecodeSecureSessionLL, Teardown)
+    
 EUNIT_TEST (
     "DecodeDirection test",
     "CMceMediaSdpCodec",
-    "DecodeDirectionAttribute",
+    "DecodeDirectionL",
     "FUNCTIONALITY",
     SetupL, UT_CMceMediaSdpCodec_DecodeDirectionLL, Teardown)        
     
--- a/multimediacommsengine/mmcesrv/mmceserver/src/mcesipmanager.cpp	Tue May 11 16:34:40 2010 +0300
+++ b/multimediacommsengine/mmcesrv/mmceserver/src/mcesipmanager.cpp	Tue May 25 13:07:26 2010 +0300
@@ -1084,5 +1084,21 @@
 				}
 			}
 		}
+
+	// Update orphan subsessions
+    RPointerArray<CMceCsSubSession>& orphanSubSessions = iOrphanSubSessions->SubSessions();
+    TInt orphanSubSessionCount = orphanSubSessions.Count();
+	
+    for ( TInt j = 0; j < orphanSubSessionCount; ++j )
+        {
+        CSIPProfile& subSessionProfile = orphanSubSessions[ j ]->Profile();
+        if ( &subSessionProfile == &aOldProfile )
+            {
+            MCESRV_DEBUG_DVALUE("update orphan subsession profile, j", j )
+            MCESRV_DEBUG_DVALUES("oldProfile", (TInt)&aOldProfile,
+                                 "newProfile", (TInt)&aNewProfile )
+            orphanSubSessions[ j ]->SetProfile( aNewProfile );
+            }
+        }
 	MCESRV_DEBUG("CMceSipManager::UpdateProfileToSubSessions, Exit")
 	}
--- a/multimediacommsengine/mmcesrv/mmceserver/src/mcestateconfirming.cpp	Tue May 11 16:34:40 2010 +0300
+++ b/multimediacommsengine/mmcesrv/mmceserver/src/mcestateconfirming.cpp	Tue May 25 13:07:26 2010 +0300
@@ -242,9 +242,11 @@
             NAT_WAIT_NO_EXEC( session, (status = session.Actions().CreateSDP( response )));
             if ( !MCE_IS_ERROR( status ) && MCE_NEED_TO_SEND( session, NULL ) )
                 {
-                if ( session.ActiveBody().SecureSession() )
+                CMceSecureMediaSession* secSession = session.ActiveBody().SecureSession();
+                if ( secSession )
                 	{
-                	session.ActiveBody().SecureSession()->iLSReadyToBind = ETrue;
+                    secSession->iLSReadyToBind = ETrue;
+                    secSession->iKeyNeedUpdated = ETrue;
                 	}
                 session.SetFirstOffer();
                 status = session.Actions().DecodeL();
--- a/multimediacommsengine/mmcesrv/mmceserver/src/mcestateoffering.cpp	Tue May 11 16:34:40 2010 +0300
+++ b/multimediacommsengine/mmcesrv/mmceserver/src/mcestateoffering.cpp	Tue May 25 13:07:26 2010 +0300
@@ -465,10 +465,12 @@
                     //update FC
                     session.FCActions().PeekFCDocumentL( *session.Offer() );
                 	
+                    CMceSecureMediaSession* secSession = session.ActiveBody().SecureSession();
             	    //decode answer, ignore warning code 
-                    if ( session.ActiveBody().SecureSession())
+                    if ( secSession )
                     	{
-                    	session.ActiveBody().SecureSession()->iLSReadyToBind = ETrue;
+                        secSession->iLSReadyToBind = ETrue;
+                        secSession->iKeyNeedUpdated = ETrue;
                     	}
                     status = session.Actions().Decode();
 
--- a/multimediacommsengine/mmcesrv/mmceserver/tsrc/ut_server/inc/UT_CMCESIPManager.h	Tue May 11 16:34:40 2010 +0300
+++ b/multimediacommsengine/mmcesrv/mmceserver/tsrc/ut_server/inc/UT_CMCESIPManager.h	Tue May 25 13:07:26 2010 +0300
@@ -102,6 +102,8 @@
         void UT_CMceSipManager_SIPClientL();
 
         void UT_CMceSipManager_OrphanSubSessionCountL();
+        
+        void UT_CMceSipManager_UpdateProfileToSubSessionsL();
          
 
     private:    // Data
--- a/multimediacommsengine/mmcesrv/mmceserver/tsrc/ut_server/src/UT_CMCESIPManager.cpp	Tue May 11 16:34:40 2010 +0300
+++ b/multimediacommsengine/mmcesrv/mmceserver/tsrc/ut_server/src/UT_CMCESIPManager.cpp	Tue May 25 13:07:26 2010 +0300
@@ -480,6 +480,43 @@
   	EUNIT_ASSERT( iManager->OrphanSubSessionCount() == 0 );
     }
 
+void UT_CMceSipManager::UT_CMceSipManager_UpdateProfileToSubSessionsL()
+    {
+    iIds.iProfileID = 1;
+    iIds.iManagerType = KMceCSSIPSession;
+    iIds.iDialogType = KMceDlgTypeInvite;
+    
+	CDesC8ArrayFlat* params = new (ELeave) CDesC8ArrayFlat( KMceArrayGranularity );
+	CleanupStack::PushL( params );
+	params->AppendL( _L8("User <user2@host>") );
+	params->AppendL( _L8("User <user@host>") );
+    
+    CMceCsSubSession* subsession = 
+        iManager->CreateSubSessionL( *iSession, iIds, *params );
+    CleanupStack::PushL( subsession );
+    
+    CSIPProfile& profileOld = subsession->Profile();
+  	EUNIT_ASSERT( &profileOld != NULL );
+    CSIPProfile& profileNew = iManager->ProfileL( 2 );
+  	EUNIT_ASSERT( &profileNew != NULL );
+
+  	CMceCsSessionImplementation& session = iManager->iClients[ 0 ]->Implementation();
+  	RPointerArray<CMceCsSubSession>& subSessions = session.SubSessions();
+  	subSessions.AppendL(subsession);
+  	
+  	iManager->UpdateProfileToSubSessions(profileNew, profileOld);
+  	EUNIT_ASSERT(&subsession->Profile() == &profileNew)
+  	subSessions.Remove(0);
+
+  	iManager->AddOrphanSubSessionL( subsession );
+  	iManager->UpdateProfileToSubSessions(profileOld, profileNew);
+  	RPointerArray<CMceCsSubSession>& orphanSubSessions = iManager->iOrphanSubSessions->SubSessions();
+  	EUNIT_ASSERT(&subsession->Profile() == &profileOld)
+
+  	CleanupStack::Pop( subsession );
+  	CleanupStack::PopAndDestroy( params );
+    }
+
 
 //  TEST TABLE
 
@@ -621,6 +658,12 @@
     "FUNCTIONALITY",
     SetupL, UT_CMceSipManager_OrphanSubSessionCountL, Teardown)
 
+EUNIT_TEST(
+    "UpdateProfileToSubSessions - test ",
+    "CMceSipManager",
+    "UpdateProfileToSubSessions",
+    "FUNCTIONALITY",
+    SetupL, UT_CMceSipManager_UpdateProfileToSubSessionsL, Teardown)
 
 EUNIT_END_TEST_TABLE
 
--- a/multimediacommsengine/mmcesrv/mmceserver/tsrc/ut_server/src/UT_CMCEStateOffering.cpp	Tue May 11 16:34:40 2010 +0300
+++ b/multimediacommsengine/mmcesrv/mmceserver/tsrc/ut_server/src/UT_CMCEStateOffering.cpp	Tue May 25 13:07:26 2010 +0300
@@ -374,6 +374,7 @@
     EUNIT_ASSERT ( !iSipSession->WaitingMediaCallback() );
 	EUNIT_ASSERT ( body.iSipContactAddrSecure == CMceSession::EControlPathUnsecure );
 	EUNIT_ASSERT ( body.SecureSession()->iLSReadyToBind == ETrue );
+    EUNIT_ASSERT ( body.SecureSession()->iKeyNeedUpdated == ETrue );
 
     iSipSession->iSubState = CMceSipSession::EOffering;
     MCE_RESET_STUBS();
--- a/multimediacommsengine/mmcesrv/mmceserver/tsrc/ut_server/stubs/inc/sipprofile.h	Tue May 11 16:34:40 2010 +0300
+++ b/multimediacommsengine/mmcesrv/mmceserver/tsrc/ut_server/stubs/inc/sipprofile.h	Tue May 25 13:07:26 2010 +0300
@@ -325,6 +325,11 @@
 		*/
 		void ClearRegistry();
 		
+		/**
+		* Set context id
+		*/
+		void SetContextId(TInt aContextId);
+		
 	public: // for unittesting
 	    
 	    void SetParam( TUint aParam, HBufC8* aValue );
@@ -377,6 +382,8 @@
         HBufC8* iRequestUriUser;
         HBufC8* iContactHeader;
         
+        TInt	iContextId;
+        
     	//definitions for unit testing
     	MCESRV_UT_DEFINITIONS
 
--- a/multimediacommsengine/mmcesrv/mmceserver/tsrc/ut_server/stubs/src/sipprofile.cpp	Tue May 11 16:34:40 2010 +0300
+++ b/multimediacommsengine/mmcesrv/mmceserver/tsrc/ut_server/stubs/src/sipprofile.cpp	Tue May 25 13:07:26 2010 +0300
@@ -191,7 +191,7 @@
 	    }
 	if( aParam == KSIPProfileId )
 		{
-		aVal = 1;
+		aVal = ContextId();
 		}
 	return ret;
 	}	
@@ -279,7 +279,7 @@
 // -----------------------------------------------------------------------------
 //	
 CSIPProfile::CSIPProfile():
-	iEnabled(EFalse)
+	iEnabled(EFalse), iContextId(1)
 	{
 	}
 
@@ -307,6 +307,11 @@
 	{
 	return ETrue;
 	}
+
+void CSIPProfile::SetContextId(TInt aContextId)
+	{
+	iContextId = aContextId;
+	}
 	
 // -----------------------------------------------------------------------------
 // CSIPProfile::ContextId
@@ -314,7 +319,7 @@
 //	
 TUint32 CSIPProfile::ContextId() const
 	{
-	return 1;
+	return iContextId;
 	}
 
 // -----------------------------------------------------------------------------
--- a/multimediacommsengine/mmcesrv/mmceserver/tsrc/ut_server/stubs/src/sipprofileregistrybase.cpp	Tue May 11 16:34:40 2010 +0300
+++ b/multimediacommsengine/mmcesrv/mmceserver/tsrc/ut_server/stubs/src/sipprofileregistrybase.cpp	Tue May 25 13:07:26 2010 +0300
@@ -52,9 +52,13 @@
 	// stubs
 	CSIPProfileRegistry* reg = (CSIPProfileRegistry*) this;
 	CSIPProfile* profile = CSIPProfile::NewLC(reg);
+	CSIPProfile* profile2 = CSIPProfile::NewLC(reg);
+	profile2->SetContextId(2);
 	
 	aProfiles.AppendL ( profile  );
+	aProfiles.AppendL ( profile2  );
 	
+	CleanupStack::Pop( profile2 );
 	CleanupStack::Pop( profile );
 
 	
@@ -72,8 +76,12 @@
 	CSIPProfileRegistry* reg = (CSIPProfileRegistry*) this;
 	
 	CSIPProfile* profile = CSIPProfile::NewLC( reg );
+	CSIPProfile* profile2 = CSIPProfile::NewLC(reg);
+	profile2->SetContextId(2);
 	aProfiles.AppendL ( profile  );
+	aProfiles.AppendL ( profile2  );
 
+	CleanupStack::Pop( profile2 );
 	CleanupStack::Pop( profile );
 	
 	}