multimediacommsengine/tsrc/testdriver/siptester/src/TCmdSendRefer.cpp
changeset 0 1bce908db942
equal deleted inserted replaced
-1:000000000000 0:1bce908db942
       
     1 /*
       
     2 * Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Implementation
       
    15 *
       
    16 */
       
    17 
       
    18 #include <sipclienttransaction.h>
       
    19 #include <sipreferdialogassoc.h>
       
    20 #include <sipregistrationbinding.h>
       
    21 #include <sipdialog.h>
       
    22 
       
    23 #include "CTcSIPConnectionContainer.h"
       
    24 #include "TCmdSendRefer.h"
       
    25 #include "SIPConstants.h"
       
    26 
       
    27 /**
       
    28  * INPUT:
       
    29  *   Headers:		From, To*, Contact*, Content-Type*
       
    30  *   Parameters:	Content*, RemoteURI*
       
    31  *   IDs:			RegistrationId*, ConnectionId*
       
    32  *
       
    33  * OUTPUT:
       
    34  *   Parameters:	-
       
    35  *   IDs:			TransactionId, DialogId, ReferDialogId
       
    36  */
       
    37 void TCmdSendRefer::ExecuteL()
       
    38 	{
       
    39 	// -- Setup ---------------------------------------------------------------
       
    40 
       
    41 	// Select connection; either default or user specified (and existing)
       
    42 	CSIPConnection& connection = SelectConnectionL().Connection();
       
    43 
       
    44 	// Get SIP objects from registry
       
    45 	CSIPRegistrationBinding* registration = GetRegistrationL( EFalse );
       
    46 	TBool fromHeaderMandatory( ETrue );
       
    47 	if( registration )
       
    48 		{
       
    49 		fromHeaderMandatory = EFalse;
       
    50 		}
       
    51 
       
    52 	// Extract required headers (From may be either mandatory or optional)	
       
    53 	CSIPFromHeader* fromHeader = ExtractFromHeaderLC( fromHeaderMandatory );
       
    54     CSIPReferToHeader* referToHeader = ExtractReferToHeaderLC();
       
    55 
       
    56 	// Extract optional headers
       
    57 	CSIPToHeader* toHeader = ExtractToHeaderLC( EFalse );
       
    58 	CSIPContactHeader* contactHeader = ExtractContactHeaderLC( EFalse );
       
    59 
       
    60 	// Conditionally create remote URI
       
    61 	CUri8* remoteUri = ExtractRemoteURILC();
       
    62 	
       
    63 	// Construct the dialog object
       
    64 	CSIPReferDialogAssoc* dialogAssoc;
       
    65 	
       
    66 	if( registration )
       
    67 		{
       
    68 		dialogAssoc = CSIPReferDialogAssoc::NewL(
       
    69 								connection, remoteUri, *registration,
       
    70 								referToHeader, fromHeader, toHeader, contactHeader );
       
    71 		}
       
    72 	else
       
    73 		{
       
    74 		dialogAssoc = CSIPReferDialogAssoc::NewL(
       
    75 								connection, fromHeader, remoteUri,
       
    76 								referToHeader, toHeader, contactHeader );
       
    77 		}
       
    78 	
       
    79 	// Purge items from cleanup stack, now they are owned by CSIPInviteDialogAssoc
       
    80 	// Some items are optional (i.e. NULL), so we've been tracking the number
       
    81 	// of items in pushed to CleanupStack
       
    82 	CleanupStack::Pop( iPushed );
       
    83 	iPushed = 0;
       
    84 
       
    85 	CleanupStack::PushL( dialogAssoc );
       
    86 
       
    87 	// Conditionally create refresh object
       
    88 	CSIPRefresh* refresh = ExtractRefreshLC();
       
    89 
       
    90 	// Extract both headers (that are still left) and content.
       
    91 	CSIPMessageElements* elements = ExtractHeadersAndContentLC();
       
    92 
       
    93 	// -- Execution -----------------------------------------------------------
       
    94 
       
    95 	// Start SIP Invite transaction.
       
    96 	CSIPClientTransaction* transaction = dialogAssoc->SendReferL( elements );
       
    97 	CleanupStack::Pop( elements );
       
    98 	if( refresh )
       
    99 		{
       
   100 		CleanupStack::Pop( refresh );
       
   101 		}
       
   102 
       
   103 	// -- Response creation ---------------------------------------------------
       
   104 
       
   105 	AddIdResponseL( KTransactionId, transaction );
       
   106 	AddIdResponseL( KDialogId, dialogAssoc->Dialog() );
       
   107 	CleanupStack::Pop( dialogAssoc );
       
   108 	AddIdResponseL( KReferDialogId, dialogAssoc );
       
   109 	}
       
   110 
       
   111 TBool TCmdSendRefer::Match( const TTcIdentifier& aId )
       
   112 	{
       
   113 	return TTcSIPCommandBase::Match( aId, _L8("SendRefer") );
       
   114 	}
       
   115 
       
   116 TTcCommandBase* TCmdSendRefer::CreateL( MTcTestContext& aContext )
       
   117 	{
       
   118 	return new( ELeave ) TCmdSendRefer( aContext );
       
   119 	}
       
   120