multimediacommsengine/mmcesrv/mmceevent/src/mceeventreferterminatedstate.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:    Refer is terminated.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 // INCLUDE FILES
       
    23 #include <siprequestelements.h>
       
    24 #include <sipcontenttypeheader.h>
       
    25 #include <sipresponseelements.h>
       
    26 #include <sipdialogassocbase.h>
       
    27 #include "mcesipeventhelper.h"
       
    28 #include "mceeventreferterminatedstate.h"
       
    29 #include "mcesip.h"
       
    30 #include "mceeventslogs.h"
       
    31 
       
    32 // ============================ MEMBER FUNCTIONS ===============================
       
    33 
       
    34 // -----------------------------------------------------------------------------
       
    35 // CMceEventReferTerminatedState::CMceEventReferTerminatedState
       
    36 // C++ default constructor can NOT contain any code, that
       
    37 // might leave.
       
    38 // -----------------------------------------------------------------------------
       
    39 //
       
    40 CMceEventReferTerminatedState::CMceEventReferTerminatedState()
       
    41     {
       
    42     }
       
    43 
       
    44 // -----------------------------------------------------------------------------
       
    45 // CMceEventReferTerminatedState::~CMceEventReferTerminatedState
       
    46 // Destructor
       
    47 // -----------------------------------------------------------------------------
       
    48 //
       
    49 CMceEventReferTerminatedState::~CMceEventReferTerminatedState()
       
    50     {
       
    51     }
       
    52 
       
    53 // -----------------------------------------------------------------------------
       
    54 // CMceEventReferTerminatedState::ProcessReferStateL
       
    55 // Ápply concrete state.
       
    56 // Be noticed that it will be also update, unRefer
       
    57 // -----------------------------------------------------------------------------
       
    58 //
       
    59 void CMceEventReferTerminatedState::HandleL( CMceComEvent& /*aEvent*/ )
       
    60     {
       
    61     User::Leave( KMceEventStateError );
       
    62     }
       
    63 
       
    64 // -----------------------------------------------------------------------------
       
    65 // CMceEventReferTerminatedState::HandleReceiveRequestL
       
    66 // Ápply concrete state.
       
    67 // Be noticed that it will be also update, unRefer
       
    68 // -----------------------------------------------------------------------------
       
    69 //
       
    70 void CMceEventReferTerminatedState::HandleReceiveRequestL( 
       
    71 												CMceComEvent& aEvent )
       
    72 	{
       
    73 	MCEEVENTS_DEBUG("CMceEventReferTerminatedState::HandleReceiveRequestL, Entry");
       
    74 	User::LeaveIfError( aEvent.SIPEvent().Dialog() ?
       
    75 	    KErrNone : KMceEventStateError );
       
    76     
       
    77 	CSIPServerTransaction& serverTran = aEvent.SIPEvent().Request();
       
    78 	CSIPServerTransaction* serverTranCheck = &serverTran;
       
    79 	User::LeaveIfError( serverTranCheck ? KErrNone : KMceEventStateError );
       
    80 	
       
    81 	//Received Subscribe from Mo there is noaction in the previous action
       
    82 	User::LeaveIfError( aEvent.PreviousAction() == KErrNotFound ?
       
    83 	    KErrNone : KMceEventStateError );
       
    84 	
       
    85 	User::LeaveIfError( serverTran.RequestElements() ? KErrNone : KErrCorrupt );	
       
    86     const CSIPMessageElements& msgElem = 
       
    87         serverTran.RequestElements()->MessageElements();
       
    88     
       
    89     if ( !aEvent.SilentSuppression() )
       
    90         {
       
    91         // Notify after received notify
       
    92         CDesC8Array* reqheaders = MceSip::UserHeadersToTextArrayL( 
       
    93                                     serverTran, 
       
    94                                     aEvent.SIPEvent().Dialog()->Dialog() );
       
    95   
       
    96         CleanupStack::PushL( reqheaders );
       
    97         HBufC8* reqcontenttype= NULL;
       
    98         if( msgElem.ContentType() )
       
    99             {
       
   100             reqcontenttype = msgElem.ContentType()->ToTextValueL();	
       
   101             }
       
   102 
       
   103         CleanupStack::PushL( reqcontenttype );
       
   104         HBufC8* reqcontent =
       
   105         		msgElem.Content().AllocLC();
       
   106         aEvent.SIPEvent().NotifyReceivedL( reqheaders,
       
   107         							  	   reqcontenttype,
       
   108         							  	   reqcontent );
       
   109         CleanupStack::Pop( reqcontent );
       
   110         CleanupStack::Pop( reqcontenttype );
       
   111     	CleanupStack::Pop( reqheaders );
       
   112         }
       
   113     
       
   114 	CSIPResponseElements* newresponse = 
       
   115 		MCESIPEventHelper::ReferNotifyRequestReceivedLC( aEvent, msgElem );
       
   116 	if ( newresponse->StatusCode() == KMceSipOK )
       
   117 		{
       
   118     	TBool terminated = EFalse;
       
   119     	MCESIPEventHelper::HandleSubscriptionStateHeaderL( msgElem, 
       
   120     	                                                   terminated );
       
   121     	serverTran.SendResponseL( newresponse );
       
   122     	CleanupStack::Pop( newresponse );
       
   123     	if ( terminated )
       
   124         	{
       
   125         	// when the subscription state is terminated
       
   126         	//receive notify send 200 OK
       
   127             if ( !aEvent.SilentSuppression() )
       
   128                 {
       
   129                 aEvent.SIPEvent().ClientStateChangedL(
       
   130             					                    CMceRefer::ETerminated,
       
   131             					                    EFalse );          
       
   132                 }
       
   133             }
       
   134         else
       
   135             {
       
   136             //the message Notify request is not corrected
       
   137             User::Leave( KErrArgument );	
       
   138             }
       
   139     
       
   140   		}
       
   141   	else
       
   142   		{
       
   143         //when the notify request is bad, state doesnt change
       
   144         serverTran.SendResponseL( newresponse );
       
   145         CleanupStack::Pop( newresponse );
       
   146     	User::Leave( KErrArgument );
       
   147         }
       
   148 	MCEEVENTS_DEBUG("CMceEventReferTerminatedState::HandleReceiveRequestL, Exit");        
       
   149     }
       
   150 	
       
   151 // -----------------------------------------------------------------------------
       
   152 // CMceEventReferTerminatedState::HandleResponseReceivedL
       
   153 // Ápply concrete state.
       
   154 // Be noticed that it will be also update, unRefer
       
   155 // -----------------------------------------------------------------------------
       
   156 //	
       
   157 void CMceEventReferTerminatedState::HandleResponseReceivedL( 
       
   158 												CMceComEvent& /*aEvent*/ )
       
   159 	{
       
   160 	}
       
   161 
       
   162 //  End of File