multimediacommsengine/tsrc/MCETestUI/MCETestUIEngine/src/TMCETestUIEngineCmdSRReqRes.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 
       
    19 
       
    20 
       
    21 // INCLUDES
       
    22 
       
    23 #include "TMCETestUIEngineCmdSRReqRes.h"
       
    24 #include "CMCETestUIQuestionSingleSelection.h"
       
    25 #include "CMCETestUIQuestionDataQuery.h"
       
    26 #include "CMCETestUIEngineSession.h"
       
    27 #include <MCESession.h>
       
    28 
       
    29 
       
    30 
       
    31 
       
    32 // -----------------------------------------------------------------------------
       
    33 // TMCETestUIEngineCmdSendReqRes::TMCETestUIEngineCmdSendInfo 
       
    34 // -----------------------------------------------------------------------------
       
    35 //
       
    36 TMCETestUIEngineCmdSendInfo::TMCETestUIEngineCmdSendInfo( 
       
    37 		            CMCETestUIEngine& aEngine,
       
    38 		            CMCETestUIEngineSession& aSession )
       
    39     : TMCETestUIEngineCmdBase( aEngine ),
       
    40       iSession( aSession )
       
    41     {
       
    42     }
       
    43     
       
    44     
       
    45 // -----------------------------------------------------------------------------
       
    46 // TMCETestUIEngineCmdSendReqRes::TMCETestUIEngineCmdSendDTMFInfo 
       
    47 // -----------------------------------------------------------------------------
       
    48 //
       
    49 TMCETestUIEngineCmdDTMFInfo::TMCETestUIEngineCmdDTMFInfo( 
       
    50 		            CMCETestUIEngine& aEngine,
       
    51 		            CMCETestUIEngineSession& aSession )
       
    52     : TMCETestUIEngineCmdBase( aEngine ),
       
    53       iSession( aSession )
       
    54     {
       
    55     }
       
    56     
       
    57 // -----------------------------------------------------------------------------
       
    58 // TMCETestUIEngineCmdSendReqRes::TMCETestUIEngineCmdSendInfoResponse 
       
    59 // -----------------------------------------------------------------------------
       
    60 //
       
    61 TMCETestUIEngineCmdSendInfoResponse::TMCETestUIEngineCmdSendInfoResponse( 
       
    62 		            CMCETestUIEngine& aEngine,
       
    63 		            CMCETestUIEngineSession& aSession )
       
    64     : TMCETestUIEngineCmdBase( aEngine ),
       
    65       iSession( aSession )
       
    66     {
       
    67     }
       
    68 
       
    69 // -----------------------------------------------------------------------------
       
    70 // TMCETestUIEngineCmdSendInfo::Caption 
       
    71 // -----------------------------------------------------------------------------
       
    72 //
       
    73 EXPORT_C const TDesC& TMCETestUIEngineCmdSendInfo::Caption() const
       
    74 	{
       
    75 	return KUserQuestionSendInfo;
       
    76 	}	
       
    77 
       
    78 
       
    79 // -----------------------------------------------------------------------------
       
    80 // TMCETestUIEngineCmdSendInfo::ExecuteL 
       
    81 // -----------------------------------------------------------------------------
       
    82 //
       
    83 EXPORT_C void TMCETestUIEngineCmdSendInfo::ExecuteL()
       
    84 	{
       
    85 	_LIT8( KInfo,"INFO"); 
       
    86 
       
    87 	TMceTransactionId transactionID = KErrNone;
       
    88 	
       
    89 	CDesC8ArrayFlat* sipHeaders = new (ELeave) CDesC8ArrayFlat( 1 );
       
    90 	CleanupStack::PushL( sipHeaders );
       
    91 	sipHeaders->AppendL( _L8( "User-Agent: MCETestUI/SendInfo" ) );
       
    92 	
       
    93 	
       
    94 	TRAPD( err, transactionID = 
       
    95 			transactionID = iSession.Session().SendRequestL( KInfo, sipHeaders ));
       
    96 	
       
    97 	if ( err != KErrNone )
       
    98 		{
       
    99 		iEngine.NotifyUser( KRequestFailed );
       
   100 		}
       
   101 	
       
   102 	CleanupStack::Pop( sipHeaders );
       
   103 
       
   104 	}
       
   105 	
       
   106 	
       
   107 // -----------------------------------------------------------------------------
       
   108 // TMCETestUIEngineCmdSendInfoDTMF::Caption 
       
   109 // -----------------------------------------------------------------------------
       
   110 //
       
   111 EXPORT_C const TDesC& TMCETestUIEngineCmdDTMFInfo::Caption() const
       
   112 	{
       
   113 	return KUserQuestionSendInfoDTMF;
       
   114 	}	
       
   115 
       
   116 
       
   117 // -----------------------------------------------------------------------------
       
   118 // TMCETestUIEngineCmdSendInfoDTMF::ExecuteL 
       
   119 // -----------------------------------------------------------------------------
       
   120 //
       
   121 EXPORT_C void TMCETestUIEngineCmdDTMFInfo::ExecuteL()
       
   122 	{
       
   123 	_LIT8( KContentX, "Signal= 1\r\n\
       
   124 	Duration= 160\r\n"); 				
       
   125 	_LIT8( KContentTypeX, "application/dtmf-relay");
       
   126 	_LIT8( KInfo,"INFO"); 
       
   127 		
       
   128 	TMceTransactionId transactionID = 0;
       
   129 	
       
   130 	HBufC8* ContentX = KContentX().AllocLC();
       
   131 	HBufC8* ContentTypeX = KContentTypeX().AllocLC();
       
   132 		
       
   133 	CDesC8ArrayFlat* sipHeaders = new (ELeave) CDesC8ArrayFlat( 1 );
       
   134 	CleanupStack::PushL( sipHeaders );
       
   135 	sipHeaders->AppendL( _L8( "User-Agent: MCETestUI/SendDTMFInfo" ) );
       
   136 	
       
   137 	TRAPD( err, transactionID = 
       
   138 			iSession.Session().SendRequestL( KInfo, sipHeaders, ContentTypeX, ContentX ));
       
   139 	
       
   140 	if ( err != KErrNone )
       
   141 		{
       
   142 		iEngine.NotifyUser( KRequestFailed );
       
   143 		}
       
   144 
       
   145 	CleanupStack::Pop( sipHeaders );
       
   146 	CleanupStack::Pop( ContentTypeX );
       
   147 	CleanupStack::Pop( ContentX );
       
   148 	
       
   149 	}
       
   150 
       
   151 
       
   152 
       
   153 
       
   154 
       
   155 EXPORT_C const TDesC& TMCETestUIEngineCmdSendInfoResponse::Caption() const
       
   156 	{
       
   157 	return KUserQuestionSendInfoResponse;
       
   158 	}	
       
   159 
       
   160 
       
   161 // -----------------------------------------------------------------------------
       
   162 // TMCETestUIEngineCmdSendInfoDTMF::ExecuteL 
       
   163 // -----------------------------------------------------------------------------
       
   164 //
       
   165 EXPORT_C void TMCETestUIEngineCmdSendInfoResponse::ExecuteL()
       
   166 	{
       
   167 	const TUint code = 200;
       
   168 	_LIT8( KMceSipOK, "OK" ); 
       
   169 
       
   170 	const RArray< TMceTransactionId > transactionIds = iEngine.TransactionIds();
       
   171 	if ( transactionIds.Count() == 0 )
       
   172 		{
       
   173 		iEngine.NotifyUser( KUserQuestionSendInfoNoTransactions );
       
   174 		return;
       
   175 		}
       
   176 	
       
   177 	CMCETestUIQuestionSingleSelection* transactionQuestion = 
       
   178 		CMCETestUIQuestionSingleSelection::NewLC();
       
   179 	
       
   180 	transactionQuestion->SetCaptionL( KUserQuestionSendInfoResponseCaption );
       
   181 	
       
   182 	_LIT( KFormat, "%u" );
       
   183 	TBuf<32> transaction;
       
   184 	
       
   185 	for( TInt i = transactionIds.Count()-1 ; i >= 0 ; --i )
       
   186 		{
       
   187 		transaction.Format( KFormat, static_cast< TInt >( transactionIds[i] ) );
       
   188 		transactionQuestion->AddChoiceL( transaction );
       
   189 		}
       
   190 	
       
   191 	TInt index = iEngine.AskQuestionL( *transactionQuestion );
       
   192 	
       
   193 	CleanupStack::PopAndDestroy( transactionQuestion );
       
   194 
       
   195 	if ( index >= 0 && index < transactionIds.Count() )
       
   196 		{
       
   197 		CDesC8ArrayFlat* sipHeaders = new (ELeave) CDesC8ArrayFlat( 1 );
       
   198 		CleanupStack::PushL( sipHeaders );
       
   199 		sipHeaders->AppendL( _L8( "User-Agent: MCETestUI/SendInfoResponse" ) );
       
   200 		
       
   201 		iSession.Session().SendResponseL( transactionIds[index],
       
   202 									  KMceSipOK,
       
   203 									  code,
       
   204 									  sipHeaders );
       
   205 		
       
   206 		CleanupStack::Pop( sipHeaders );
       
   207 		
       
   208 		iEngine.RemoveTransactionId( transactionIds[index] );
       
   209 		}
       
   210 
       
   211 	}	
       
   212 
       
   213 // End of File