multimediacommsengine/tsrc/testdriver/siptester/src/TCmdSendSubscribeUsingProfile.cpp
changeset 0 1bce908db942
equal deleted inserted replaced
-1:000000000000 0:1bce908db942
       
     1 /*
       
     2 * Copyright (c) 2008 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 <siprefresh.h>
       
    20 #include <sipmessageelements.h>
       
    21 #include <sipsubscribedialogassoc.h>
       
    22 #include <sipprofile.h>
       
    23 
       
    24 #include "CTcSIPProfileContainer.h"
       
    25 #include "CTcSIPConnectionContainer.h"
       
    26 #include "CTcSIPContext.h"
       
    27 
       
    28 #include "TCmdSendSubscribeUsingProfile.h"
       
    29 #include "SIPConstants.h"
       
    30 
       
    31 /**
       
    32  * INPUT:
       
    33  *   Headers:		Contact*, From*, To*, Event*, Content-Type*
       
    34  *   Parameters:	RemoteUri*, Refresh*
       
    35  *   IDs:			ProfileId*, SubscribeDialogId*
       
    36  *
       
    37  * OUTPUT:
       
    38  *   Parameters:	-
       
    39  *   IDs:			TransactionId, SubscribeDialogId
       
    40  */
       
    41 void TCmdSendSubscribeUsingProfile::ExecuteL()
       
    42 	{
       
    43 	// -- Setup ---------------------------------------------------------------
       
    44 
       
    45 	// Extract required headers
       
    46 	CSIPEventHeader* eventHeader = ExtractEventHeaderLC(true);
       
    47 	// Extract remote URI
       
    48 	CUri8* uri = ExtractRemoteURILC( true );
       
    49 	
       
    50 	//  Extract optional headers
       
    51 	CSIPToHeader* toHeader = ExtractToHeaderLC( EFalse );
       
    52 	CSIPFromHeader* fromHeader = ExtractFromHeaderLC( EFalse );
       
    53     CSIPContactHeader* contactHeader = ExtractContactHeaderLC( EFalse );
       
    54 
       
    55 	// Get selected registry
       
    56     CTcSIPProfileContainer& container = SelectProfileL();
       
    57 
       
    58 	// Get profile from the profile registry
       
    59 	CSIPProfile& profile = GetProfileL( container );
       
    60 	
       
    61 	CSIPConnection* sipConnection = container.ProfileRegistry().ConnectionL( profile );
       
    62 	// Ownership is not really transferred if SIPTester has opened already 
       
    63 	// CSIPConnection for same IAP as profile is using!!
       
    64 	if ( sipConnection != &(iContext.Connection().Connection()) )
       
    65 		{
       
    66 		// Have to store because needs longer lifetime than just current ExecuteL
       
    67 		iContext.Registry().AddObjectL( sipConnection );	
       
    68 		}		
       
    69 
       
    70 	// Create a new dialog association
       
    71 	CSIPSubscribeDialogAssoc* newdialogAssoc =
       
    72 						CSIPSubscribeDialogAssoc::NewL(*sipConnection,
       
    73 														uri,
       
    74 														profile,
       
    75 														eventHeader,
       
    76 														fromHeader,
       
    77 														toHeader,
       
    78 														contactHeader );
       
    79 
       
    80 
       
    81 	// Purge items from cleanup stack, now they are owned by CSIPInviteDialogAssoc
       
    82 	// Some items are optional (i.e. NULL), so we've been tracking the number
       
    83 	// of items in pushed to CleanupStack
       
    84 	CleanupStack::Pop( iPushed );
       
    85 	iPushed = 0;
       
    86 	
       
    87 	CleanupStack::PushL( newdialogAssoc );
       
    88 
       
    89 	// Conditionally create refresh object
       
    90 	CSIPRefresh* refresh = ExtractRefreshLC();
       
    91 
       
    92 	// Extract both headers (that are still left) and content.
       
    93 	CSIPMessageElements* elements = ExtractHeadersAndContentLC();
       
    94 
       
    95 	// -- Execution -----------------------------------------------------------
       
    96 
       
    97 	// Start SIP Subscribe transaction.
       
    98 	CSIPClientTransaction* transaction =
       
    99 							newdialogAssoc->SendSubscribeL( elements, refresh );
       
   100 	CleanupStack::Pop( elements );
       
   101 	if( refresh )
       
   102 		{
       
   103 		CleanupStack::Pop( refresh );
       
   104 		}
       
   105 
       
   106 	// -- Response creation ---------------------------------------------------
       
   107 
       
   108 	AddIdResponseL( KTransactionId, transaction );
       
   109 	CleanupStack::Pop( newdialogAssoc );
       
   110 	AddIdResponseL( KSubscribeDialogId, newdialogAssoc );
       
   111 	}
       
   112 
       
   113 TBool TCmdSendSubscribeUsingProfile::Match( const TTcIdentifier& aId )
       
   114 	{
       
   115 	return TTcSIPCommandBase::Match( aId, _L8("SendSubscribeUsingProfile") );
       
   116 	}
       
   117 
       
   118 TTcCommandBase* TCmdSendSubscribeUsingProfile::CreateL( MTcTestContext& aContext )
       
   119 	{
       
   120 	return new( ELeave ) TCmdSendSubscribeUsingProfile( aContext );
       
   121 	}
       
   122