messagingfw/msgtestfw/TestActions/SendAs/src/CMtfTestActionSendAsAddLinkedAttachment.cpp
changeset 62 db3f5fa34ec7
parent 0 8e480a14352b
equal deleted inserted replaced
60:9f5ae1728557 62:db3f5fa34ec7
       
     1 // Copyright (c) 2004-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 // SendAsAddAttachment
       
    17 // [Action Parameters]
       
    18 // RSendAsMessage			sendAsMessage	<input>		: Reference of  the RSendAsMessage object
       
    19 // HBufC						attachmentFile	<input>		: The file to be attached as a linked attachment
       
    20 // HBufC						mimeType		<input>		: MIME type.Default value implies that no MIME type is specified
       
    21 // [Action Description]
       
    22 // SendAsAddLinkedAttachment Test Action is intended to add linked attachment to 
       
    23 // the created message.  The attachment file provided to be added as a linked attachment 
       
    24 // should be present in the public data area.  If MIME type of the attachment is provided 
       
    25 // as an input to the Test Action, the MIME type will be set for the attachment.
       
    26 // [APIs Used]
       
    27 // RSendAsMessage::AddLinkedAttachment(const TDesC& aLinkedAttachmentFile,
       
    28 // const TDesC& aMimeType)
       
    29 // RSendAsMessage::AddLinkedAttachment(const TDesC& aLinkedAttachmentFile)
       
    30 // __ACTION_INFO_END__
       
    31 // 
       
    32 //
       
    33 
       
    34 /**
       
    35  @file 
       
    36  @internalTechnology 
       
    37 */
       
    38 
       
    39 
       
    40 // User include
       
    41 #include "sendas2.h"
       
    42 #include "CMtfTestActionSendAsAddLinkedAttachment.h"
       
    43 #include "CMtfTestCase.h"
       
    44 #include "CMtfTestActionParameters.h"
       
    45 #include "MtfTestActionUtilsUser.h"
       
    46 
       
    47 /**
       
    48   NewL()
       
    49   Constructs a CMtfTestActionSendAsAddLinkedAttachment object.
       
    50   Uses two phase construction and leaves nothing on the CleanupStack.   
       
    51   @internalTechnology
       
    52   @param  aTestCase         Test Case to which this Test Action belongs
       
    53   @param  aActionParameters Action parameters, must not be NULL
       
    54   @return Created object of type CMtfTestActionSendAsAddLinkedAttachment
       
    55   @pre    None
       
    56   @post   CMtfTestActionSendAsAddLinkedAttachment object is created
       
    57 */
       
    58 CMtfTestAction* CMtfTestActionSendAsAddLinkedAttachment::
       
    59 		NewL(CMtfTestCase& aTestCase,CMtfTestActionParameters* aActionParameters)
       
    60 	{
       
    61 	CMtfTestActionSendAsAddLinkedAttachment* self = 
       
    62 							new (ELeave) CMtfTestActionSendAsAddLinkedAttachment(aTestCase);
       
    63 
       
    64 	CleanupStack::PushL(self);
       
    65 	self->ConstructL(aActionParameters);
       
    66 	CleanupStack::Pop(self);
       
    67 	return self;
       
    68 	}
       
    69 	
       
    70 
       
    71 /**
       
    72   CMtfTestActionSendAsAddLinkedAttachment constructor
       
    73   Calls the base class' constructor
       
    74   @internalTechnology  
       
    75   @param  aTestCase  Test Case to which this Test Action belongs
       
    76   @pre    None
       
    77   @post   None
       
    78 */ 
       
    79 CMtfTestActionSendAsAddLinkedAttachment::CMtfTestActionSendAsAddLinkedAttachment(CMtfTestCase& aTestCase)
       
    80 	: CMtfTestAction(aTestCase)
       
    81 	{
       
    82 	}
       
    83 
       
    84 /**
       
    85   Function : ~CMtfTestActionSendAsAddLinkedAttachment
       
    86   Description : Destructor
       
    87   @internalTechnology
       
    88   @param :
       
    89   @return : 
       
    90   @pre 
       
    91   @post 
       
    92 */
       
    93 CMtfTestActionSendAsAddLinkedAttachment::~CMtfTestActionSendAsAddLinkedAttachment()
       
    94 	{
       
    95 	}
       
    96 	
       
    97 /**
       
    98   ExecuteActionL
       
    99 	Obtain the input parameters
       
   100 	1.	sendAsMessage 
       
   101 	2.	attachmentFile
       
   102 	3.	mimeType (Default value implies empty string)
       
   103 	Create a File Server session and create a RFile for the attachment File
       
   104 	IF MIME type is specified 
       
   105 	Call RSendAsMessage:: AddLinkedAttachment(const TDesC& aLinkedAttachmentFile,  const TDesC& aMimeType) providing attachment file and the mimeType as input parameters
       
   106 	Else 
       
   107 	Call RSendAsMessage:: AddLinkedAttachment(const TDesC& aLinkedAttachmentFile), providing attachment file as input parameter
       
   108 
       
   109 
       
   110   @internalTechnology 
       
   111   @pre    None
       
   112   @post   None
       
   113   @leave  System wide errors
       
   114 */
       
   115 void CMtfTestActionSendAsAddLinkedAttachment::ExecuteActionL()
       
   116 	{
       
   117 	TestCase().INFO_PRINTF2(_L("Test Action %S start..."), &KTestActionSendAsAddLinkedAttachment);
       
   118 	if((TestCase().TestStepResult()) == EPass)
       
   119 		{
       
   120 
       
   121 		iSendAsMessage = ObtainValueParameterL<RSendAsMessage>(TestCase(),
       
   122 											ActionParameters().Parameter(0));
       
   123 											
       
   124 		HBufC* linkedAttachmentFile = ObtainParameterReferenceL<HBufC>(TestCase(),
       
   125 											ActionParameters().Parameter(1));
       
   126 											
       
   127 		HBufC8* mimeType = ObtainParameterReferenceL<HBufC8>(TestCase(),
       
   128 											ActionParameters().Parameter(2), NULL);
       
   129 		CActiveScheduler::Add(this);
       
   130 		
       
   131 		if(mimeType != NULL)
       
   132 			{		
       
   133 			iSendAsMessage.AddLinkedAttachment(*linkedAttachmentFile, *mimeType, iStatus);
       
   134 			}
       
   135 		else 
       
   136 			{
       
   137 			iSendAsMessage.AddLinkedAttachment(*linkedAttachmentFile, iStatus);
       
   138 			}	
       
   139 		SetActive();
       
   140 		}
       
   141 	TestCase().INFO_PRINTF2(_L("Test Action %S completed."), &KTestActionSendAsAddLinkedAttachment);
       
   142 	}
       
   143 
       
   144 void CMtfTestActionSendAsAddLinkedAttachment::DoCancel()
       
   145 	{
       
   146 	iSendAsMessage.Cancel();
       
   147 	}
       
   148 
       
   149 
       
   150 void CMtfTestActionSendAsAddLinkedAttachment::RunL()
       
   151 	{
       
   152 	TSendAsProgress		sendAsProgress;
       
   153 	TInt	errorCode = KErrNone;
       
   154 		
       
   155 	if (iStatus == KErrNone)
       
   156 		{
       
   157 		iSendAsMessage.ProgressL(sendAsProgress);
       
   158 		errorCode = sendAsProgress.iError;
       
   159 		}
       
   160 	else
       
   161 		{
       
   162 		errorCode = iStatus.Int();
       
   163 		}
       
   164 
       
   165 	if(ActionParameters().Count() == 4)
       
   166 		{
       
   167 		StoreParameterL<TInt>(TestCase(),errorCode,ActionParameters().Parameter(3));
       
   168 		}
       
   169 	else
       
   170 		{
       
   171 		User::LeaveIfError(errorCode);
       
   172 		}
       
   173 
       
   174 	TestCase().INFO_PRINTF2(_L("Add Linked Attachment completed with Error code: %d"),errorCode );
       
   175 	
       
   176 	TestCase().INFO_PRINTF2(_L("Test Action %S completed."), &KTestActionSendAsAddLinkedAttachment);
       
   177 	TestCase().ActionCompletedL(*this);
       
   178 	}
       
   179