multimediacommsengine/tsrc/testdriver/siptester/src/TCmdSendInvite.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 <sipinvitedialogassoc.h>
       
    20 #include <sipregistrationbinding.h>
       
    21 
       
    22 #include "CTcSIPConnectionContainer.h"
       
    23 #include "TCmdSendInvite.h"
       
    24 #include "SIPConstants.h"
       
    25 
       
    26 /**
       
    27  * INPUT:
       
    28  *   Headers:		From, To*, Contact*, Content-Type*
       
    29  *   Parameters:	Content*, RemoteURI*
       
    30  *   IDs:			RegistrationId*, InviteDialogId, ConnectionId*
       
    31  *
       
    32  * OUTPUT:
       
    33  *   Parameters:	-
       
    34  *   IDs:			TransactionId, InviteDialogId
       
    35  */
       
    36 void TCmdSendInvite::ExecuteL()
       
    37 	{
       
    38 	// -- Setup ---------------------------------------------------------------
       
    39 
       
    40 	// Select connection; either default or user specified (and existing)
       
    41 	CSIPConnection& connection = SelectConnectionL().Connection();
       
    42 
       
    43 	// Get SIP objects from registry
       
    44 	CSIPRegistrationBinding* registration = GetRegistrationL( EFalse );
       
    45 	TBool fromHeaderMandatory( ETrue );
       
    46 	if( registration )
       
    47 		{
       
    48 		fromHeaderMandatory = EFalse;
       
    49 		}
       
    50 
       
    51 	// Extract required headers (From may be either mandatory or optional)
       
    52 	CSIPFromHeader* fromHeader = ExtractFromHeaderLC( fromHeaderMandatory );
       
    53 
       
    54 	// Extract optional headers
       
    55 	CSIPToHeader* toHeader = ExtractToHeaderLC( EFalse );
       
    56 	CSIPContactHeader* contactHeader = ExtractContactHeaderLC( EFalse );
       
    57 
       
    58 	// Conditionally create remote URI
       
    59 	CUri8* remoteUri = ExtractRemoteURILC();
       
    60 
       
    61 	// Construct the dialog association object
       
    62 	CSIPInviteDialogAssoc* dialogAssoc;
       
    63 
       
    64 	if( registration )
       
    65 		{
       
    66 		dialogAssoc = CSIPInviteDialogAssoc::NewL(
       
    67 								connection, remoteUri, *registration,
       
    68 								fromHeader, toHeader, contactHeader );
       
    69 		}
       
    70 	else
       
    71 		{
       
    72 		dialogAssoc = CSIPInviteDialogAssoc::NewL(
       
    73 								connection, fromHeader,
       
    74 								remoteUri, toHeader, contactHeader );
       
    75 		}
       
    76 	
       
    77 	// Purge items from cleanup stack, now they are owned by CSIPInviteDialogAssoc
       
    78 	// Some items are optional (i.e. NULL), so we've been tracking the number
       
    79 	// of items in pushed to CleanupStack
       
    80 	CleanupStack::Pop( iPushed );
       
    81 	iPushed = 0;
       
    82 
       
    83 	CleanupStack::PushL( dialogAssoc );
       
    84 
       
    85 	// Extract both headers (that are still left) and content.
       
    86 	CSIPMessageElements* elements = ExtractHeadersAndContentLC();
       
    87 
       
    88 	// -- Execution -----------------------------------------------------------
       
    89 
       
    90 	// Start SIP Invite transaction.
       
    91 	CSIPClientTransaction* transaction = dialogAssoc->SendInviteL( elements );
       
    92 	CleanupStack::Pop( elements );
       
    93 
       
    94 	// -- Response creation ---------------------------------------------------
       
    95 
       
    96 	AddIdResponseL( KTransactionId, transaction );
       
    97 	CleanupStack::Pop( dialogAssoc );
       
    98 	AddIdResponseL( KInviteDialogId, dialogAssoc );
       
    99 	}
       
   100 
       
   101 TBool TCmdSendInvite::Match( const TTcIdentifier& aId )
       
   102 	{
       
   103 	return TTcSIPCommandBase::Match( aId, _L8("SendInvite") );
       
   104 	}
       
   105 
       
   106 TTcCommandBase* TCmdSendInvite::CreateL( MTcTestContext& aContext )
       
   107 	{
       
   108 	return new( ELeave ) TCmdSendInvite( aContext );
       
   109 	}
       
   110