multimediacommsengine/tsrc/testdriver/siptester/src/TCmdChannel.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:  Implementation
       
    15 *
       
    16 */
       
    17 
       
    18 #include "TCmdChannel.h"
       
    19 #include "CTcSIPContext.h"
       
    20 #include "SIPConstants.h"
       
    21 #include "CTcSIPClientDiscoveryContainer.h"
       
    22 #include "CleanupResetAndDestroy.h"
       
    23 
       
    24 #include <sipclientdiscovery.h>
       
    25 #include <sipheaderbase.h>
       
    26 #include <siptoheader.h>
       
    27 #include <sipcontactheader.h>
       
    28 #include <sipfromheader.h>
       
    29 #include <sipcontenttypeheader.h>
       
    30 #include <sipstrings.h>
       
    31 #include <stringpool.h>
       
    32 #include <uri8.h>
       
    33 
       
    34 /**
       
    35  * INPUT:
       
    36  *   Headers: From*, To*, Contact*, Content-Type*
       
    37  *   Parameters: Method, RemoteURI, ApplicationUid*, Content*
       
    38  *   IDs: -
       
    39  *
       
    40  * OUTPUT:
       
    41  *   Parameters: ClientDiscoveryRequestId
       
    42  *   IDs: -
       
    43  */
       
    44 void TCmdChannel::ExecuteL()
       
    45 	{
       
    46 	// Extract optional uid
       
    47 	TUid paramUid = ExtractUidL( KParamApplicationUid, EFalse );
       
    48 	
       
    49 	// Extract method
       
    50 	TPtrC8 method = ExtractTextL( KParamMethod );
       
    51 	RStringF methodStr = SIPStrings::Pool().OpenFStringL( method );
       
    52 	CleanupClosePushL( methodStr );
       
    53 	
       
    54 	// Extract remote URI
       
    55 	CUri8* uri = ExtractRemoteURILC( ETrue );	
       
    56 	
       
    57 	// Extract headers and add them to array if they existed
       
    58 	RPointerArray< CSIPHeaderBase > headers;
       
    59 	CleanupResetAndDestroyPushL( headers );
       
    60 	
       
    61 	CSIPToHeader* toHeader = ExtractToHeaderLC( EFalse );
       
    62 	if ( toHeader )
       
    63 	    {
       
    64 	    headers.AppendL( toHeader );
       
    65 	    CleanupStack::Pop( toHeader );
       
    66 	    }
       
    67 	
       
    68 	CSIPContactHeader* contactHeader = ExtractContactHeaderLC( EFalse );
       
    69 	if ( contactHeader )
       
    70 	    {
       
    71 	    headers.AppendL( contactHeader );
       
    72 	    CleanupStack::Pop( contactHeader );
       
    73 	    }
       
    74 
       
    75 	CSIPFromHeader* fromHeader = ExtractFromHeaderLC( EFalse );
       
    76 	if ( fromHeader )
       
    77 	    {
       
    78 	    headers.AppendL( fromHeader );
       
    79 	    CleanupStack::Pop( fromHeader );
       
    80 	    }
       
    81 	    
       
    82 	// Extract content
       
    83 	HBufC8* content = ExtractHBufLC( KParamContent );
       
    84 	if ( !content )
       
    85 	    {
       
    86 	    // Create dummy zero length content
       
    87 	    content = HBufC8::NewLC( 0 );
       
    88 	    }
       
    89 	    
       
    90 	// Extract content-type header
       
    91 	CSIPContentTypeHeader* contentType = ExtractContentTypeHeaderLC( EFalse );
       
    92 	
       
    93 	// Execute
       
    94 	TUint32 requestId( 0 );
       
    95 	if ( paramUid.iUid > 0 )
       
    96 	    {
       
    97 	    // ApplicationUid param was present, use also it in ChannelL call
       
    98 	    requestId = iContext.ClientDiscoveryL().ClientDiscovery().ChannelL( 
       
    99         	            paramUid, 
       
   100         	            methodStr, 
       
   101         	            uri->Uri().UriDes(),
       
   102         	            headers, 
       
   103         	            *content, 
       
   104         	            contentType );
       
   105 	    }
       
   106 	else
       
   107 	    {
       
   108 	    requestId = iContext.ClientDiscoveryL().ClientDiscovery().ChannelL(
       
   109         	            methodStr, 
       
   110         	            uri->Uri().UriDes(),
       
   111         	            headers, 
       
   112         	            *content, 
       
   113         	            contentType );
       
   114 	    }
       
   115 
       
   116     // Cleanup
       
   117 	if ( contentType )
       
   118 	    {
       
   119 	    CleanupStack::PopAndDestroy( contentType );
       
   120 	    }
       
   121 	CleanupStack::PopAndDestroy( 4 ); // content, headers, uri, methodStr
       
   122 	
       
   123 	AddIntegerResponseL( KParamClientDiscoveryRequestId, requestId );
       
   124 	}
       
   125 
       
   126 TBool TCmdChannel::Match( const TTcIdentifier& aId )
       
   127 	{
       
   128 	return TTcSIPCommandBase::Match( aId, _L8("Channel") );
       
   129 	}
       
   130 
       
   131 TTcCommandBase* TCmdChannel::CreateL( MTcTestContext& aContext )
       
   132 	{
       
   133 	return new ( ELeave ) TCmdChannel( aContext );
       
   134 	}
       
   135