messagingfw/msgtestfw/TestActions/SendAs/src/CMtfTestActionSendAsSendMessageNew.cpp
changeset 0 8e480a14352b
equal deleted inserted replaced
-1:000000000000 0:8e480a14352b
       
     1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // __ACTION_INFO_BEGIN__ 
       
    15 // [Action Name]
       
    16 // SendAsSendMessage
       
    17 // [Action Parameters]
       
    18 // RSendAsMessage	paramSendAsMessage			<input>:	Reference to  the RSendAsMessage object
       
    19 // TInt				paramSendMessageConfirmed	<input>:	0 if the send operation is not a confirmed operation, 1 if the send operation has to be a confirmed operation.  Default value is 0.
       
    20 // TInt				paramCancelSendMessage		<input>:	0 if the send operation need not be canceled, 1 if the send operation has to be canceled.  Default value is 0.
       
    21 // [Action Description]
       
    22 // SendAsSendMessage Test Action is intended to request the Send-As server to send the message.
       
    23 // [APIs Used]
       
    24 // RSendAsMessage::SendMessage (TRequestStatus& aStatus)
       
    25 // RSendAsMessage::SendMessageConfirmed (TRequestStatus& aStatus)
       
    26 // __ACTION_INFO_END__
       
    27 // 
       
    28 //
       
    29 
       
    30 /**
       
    31  @file
       
    32 */
       
    33 
       
    34 #include "sendas2.h"
       
    35 #include "CMtfTestActionSendAsSendMessageNew.h"
       
    36 #include "CMtfTestCase.h"
       
    37 #include "CMtfTestActionParameters.h"
       
    38 #include "MtfTestActionUtilsUser.h"
       
    39 
       
    40 CMtfTestAction* CMtfTestActionSendAsSendMessageNew::NewL(CMtfTestCase& aTestCase,CMtfTestActionParameters* aActionParameters)
       
    41 	{
       
    42 	CMtfTestActionSendAsSendMessageNew* self = new (ELeave) CMtfTestActionSendAsSendMessageNew(aTestCase);
       
    43 	CleanupStack::PushL(self);
       
    44 	self->ConstructL(aActionParameters);
       
    45 	CleanupStack::Pop();
       
    46 	return self;
       
    47 	}
       
    48 	
       
    49 
       
    50 CMtfTestActionSendAsSendMessageNew::CMtfTestActionSendAsSendMessageNew(CMtfTestCase& aTestCase)
       
    51 	: CMtfTestAction(aTestCase)
       
    52 	{
       
    53 	}
       
    54 
       
    55 
       
    56 CMtfTestActionSendAsSendMessageNew::~CMtfTestActionSendAsSendMessageNew()
       
    57 	{
       
    58 	}
       
    59 
       
    60 
       
    61 void CMtfTestActionSendAsSendMessageNew::ExecuteActionL()
       
    62 	{	
       
    63 	TestCase().INFO_PRINTF2(_L("Test Action %S start..."), &KTestActionSendAsSendMessageNew);
       
    64 	iSendAsMessage  = ObtainValueParameterL<RSendAsMessage>(TestCase(),ActionParameters().Parameter(0));
       
    65 	TInt	paramConfirmedSend = ObtainValueParameterL<TInt>(TestCase(),ActionParameters().Parameter(1), EFalse);
       
    66 	TInt	paramCancelSend = ObtainValueParameterL<TInt>(TestCase(),ActionParameters().Parameter(2), EFalse);
       
    67 	TInt	paramSetCharacterSet = ObtainValueParameterL<TInt>(TestCase(),ActionParameters().Parameter(4), EFalse);
       
    68 	
       
    69 	CActiveScheduler::Add (this);
       
    70 	
       
    71 	TInt	err = KErrNone;
       
    72 	
       
    73 	// Sets the characterset for a message,it could be 8 bit or 16 bit (UCS2) Unicode value
       
    74 	if(paramSetCharacterSet == TSmsDataCodingScheme::ESmsAlphabet8Bit || paramSetCharacterSet == TSmsDataCodingScheme::ESmsAlphabetUCS2 || paramSetCharacterSet == TSmsDataCodingScheme::ESmsAlphabet7Bit)
       
    75 		{
       
    76 		TRAP(err, iSendAsMessage.SetCharacterSetL(paramSetCharacterSet));
       
    77 		TestCase().INFO_PRINTF2(_L("SetCharacterSetL completed with error %d"), err);
       
    78 		}
       
    79 		
       
    80 	if(err == -47)
       
    81 		{
       
    82 		iStatus = KRequestPending;
       
    83 		TRequestStatus *status = &iStatus;
       
    84 		User::RequestComplete(status, err);
       
    85 		}
       
    86 	else
       
    87 		{
       
    88 		if(paramConfirmedSend)
       
    89 			{
       
    90 			TRAP(err, iSendAsMessage.SendMessageConfirmed(iStatus));
       
    91 			}
       
    92 		else
       
    93 			{
       
    94 			TRAP(err, iSendAsMessage.SendMessage(iStatus));
       
    95 			}
       
    96 
       
    97 		if(paramCancelSend)
       
    98 			{
       
    99 			TRAP(err, iSendAsMessage.Cancel());
       
   100 			}
       
   101 		}
       
   102 	TestCase().INFO_PRINTF2(_L("Test Action %S completed."), &KTestActionSendAsSendMessageNew);
       
   103 	SetActive();
       
   104 	}
       
   105 
       
   106 void CMtfTestActionSendAsSendMessageNew::DoCancel()
       
   107 	{
       
   108 	iSendAsMessage.Cancel();
       
   109 	}
       
   110 
       
   111 void CMtfTestActionSendAsSendMessageNew::RunL()
       
   112 	{
       
   113 	TSendAsProgress		sendAsProgress;
       
   114 	TInt	errorCode = KErrNone;
       
   115 	if (iStatus == KErrNone)
       
   116 		{
       
   117 		iSendAsMessage.ProgressL(sendAsProgress);
       
   118 		errorCode = sendAsProgress.iError;
       
   119 		}
       
   120 	else
       
   121 		{
       
   122 		errorCode = iStatus.Int();
       
   123 		}
       
   124 
       
   125 	if(ActionParameters().Count() == 5 || ActionParameters().Count() == 4)
       
   126 		{
       
   127 		StoreParameterL<TInt>(TestCase(),errorCode,ActionParameters().Parameter(3));
       
   128 		}
       
   129 	else
       
   130 		{
       
   131 		User::LeaveIfError(errorCode);
       
   132 		}
       
   133 
       
   134 	TestCase().INFO_PRINTF2(_L("Test Action %S completed."), &KTestActionSendAsSendMessageNew);
       
   135 	TestCase().ActionCompletedL(*this);
       
   136 	}
       
   137