messagingfw/msgtestfw/TestActions/Drm/src/CMtfTestActionCheckDrmReceipt.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 // CheckDrmReceipt
       
    17 // [Action Parameters]
       
    18 // session				input 			CMsvSession
       
    19 // messageId			input			TMsvId, ID of message to check	
       
    20 // numberOfReceipts		input			TInt, number of expected DRM receipts
       
    21 // [Action Description]
       
    22 // CheckDrmReceipt Test Action is intended to look for DRM receipt attachments
       
    23 // in an email message.
       
    24 // [APIs Used]	
       
    25 // CMsvSession::GetEntry
       
    26 // CImEmailMessage::AttachmentManager
       
    27 // MMsvAttachmentManager::AttachmentCount
       
    28 // MMsvAttachmentManager::GetAttachmentInfoL
       
    29 // CMsvAttachment::MimeType
       
    30 // __ACTION_INFO_END__
       
    31 //
       
    32 //! @file
       
    33 
       
    34 #include "CMtfTestActionCheckDrmReceipt.h"
       
    35 
       
    36 #include "CMtfTestCase.h"
       
    37 #include "CMtfTestActionParameters.h"
       
    38 
       
    39 #include <e32cmn.h>
       
    40 #include <msvapi.h>
       
    41 #include <msvstore.h>
       
    42 #include <txtrich.h>
       
    43 #include <miutmsg.h>
       
    44 #include <cmsvattachment.h>
       
    45 #include <mmsvattachmentmanager.h>
       
    46 #include <tmsvpackednotifierrequest.h>
       
    47 
       
    48 /**
       
    49   Function : NewL
       
    50   Description : 
       
    51   @internalTechnology
       
    52   @param : aTestCase - CMtfTestCase for the CMtfTestAction base class
       
    53   @param : aActionParams - CMtfTestActionParameters 
       
    54   @return : CMtfTestAction* - a base class pointer to the newly created CMtfTestActionCheckDrmReceipt object
       
    55   @pre none
       
    56   @post none
       
    57 */
       
    58 CMtfTestAction* CMtfTestActionCheckDrmReceipt::NewL(CMtfTestCase& aTestCase,CMtfTestActionParameters* aActionParameters)
       
    59 {
       
    60 	CMtfTestActionCheckDrmReceipt* self = new (ELeave) CMtfTestActionCheckDrmReceipt(aTestCase);
       
    61 	CleanupStack::PushL(self);
       
    62 	self->ConstructL(aActionParameters);
       
    63 	CleanupStack::Pop(self);
       
    64 	return self;
       
    65 }
       
    66 
       
    67 /**
       
    68   Function : CMtfTestActionCheckDrmReceipt
       
    69   Description : Constructor
       
    70   @internalTechnology
       
    71   @param : aTestCase - CMtfTestCase for the CMtfTestAction base class
       
    72   @return : N/A
       
    73   @pre none
       
    74   @post none
       
    75 */
       
    76 CMtfTestActionCheckDrmReceipt::CMtfTestActionCheckDrmReceipt(CMtfTestCase& aTestCase) : CMtfSynchronousTestAction(aTestCase)
       
    77 {
       
    78 }
       
    79 	
       
    80 /**
       
    81   Function : ~CMtfTestActionSendEMsvGetEntry
       
    82   Description : Destructor
       
    83   @internalTechnology
       
    84   @param :
       
    85   @return : 
       
    86   @pre 
       
    87   @post 
       
    88 */
       
    89 CMtfTestActionCheckDrmReceipt::~CMtfTestActionCheckDrmReceipt()
       
    90 {
       
    91 }
       
    92 
       
    93 /**
       
    94   Function : ExecuteActionL
       
    95   Description : Entry point for the this test action in the test framework
       
    96   @internalTechnology
       
    97   @param : none
       
    98   @return : void
       
    99   @pre none 
       
   100   @post none
       
   101 */
       
   102 void CMtfTestActionCheckDrmReceipt::ExecuteActionL()
       
   103 {
       
   104 	TestCase().INFO_PRINTF2(_L("Test Action %S start..."), &KTestActionCheckDrmReceipt);
       
   105 	CMsvSession* session = ObtainParameterReferenceL<CMsvSession>(TestCase(),ActionParameters().Parameter(0));
       
   106 	TMsvId messageId = ObtainValueParameterL<TMsvId>(TestCase(),ActionParameters().Parameter(1));
       
   107 	TInt numberOfReceipts = ObtainValueParameterL<TInt>(TestCase(),ActionParameters().Parameter(2));
       
   108 	
       
   109 	// Get the entry
       
   110 	CMsvEntry* entry = session->GetEntryL(messageId);
       
   111 	CleanupStack::PushL(entry);
       
   112 
       
   113 	CImEmailMessage* msg = CImEmailMessage::NewLC(*entry);
       
   114 
       
   115 	// loop through the attachments looking for DRM receipt attachments
       
   116 	TInt foundReceipts = 0;
       
   117 	TInt count = msg->AttachmentManager().AttachmentCount();
       
   118 	for (TInt index = 0; index < count; index++)
       
   119 	{
       
   120 		CMsvAttachment* att = msg->AttachmentManager().GetAttachmentInfoL(index);
       
   121 		if (att->MimeType().Length() > 0)
       
   122 		{
       
   123 			// mime type is set
       
   124 			if (att->MimeType().CompareF(KEpocMimeTypeDrm) == 0)
       
   125 			{
       
   126 				// this is the receipt attachment, break out
       
   127 				foundReceipts++;
       
   128 			}
       
   129 		}
       
   130 		delete att;
       
   131 	}
       
   132 	
       
   133 	if (foundReceipts == numberOfReceipts)
       
   134 	{
       
   135 		// found it!
       
   136 		TestCase().INFO_PRINTF1(_L("CMtfTestActionCheckDrmReceipt: SUCCESS! Receipts correct!"));
       
   137 		TestCase().SetTestStepResult(EPass);
       
   138 	}
       
   139 	else
       
   140 	{
       
   141 		// ok, no receipt
       
   142 		TestCase().ERR_PRINTF3(_L("CMtfTestActionCheckDrmReceipt: FAILED! Receipts incorrect! Expected [%d], found [%d]."), numberOfReceipts, foundReceipts);
       
   143 		TestCase().SetTestStepResult(EFail);
       
   144 	}
       
   145 
       
   146 	CleanupStack::PopAndDestroy(2); // entry, msg
       
   147 	TestCase().INFO_PRINTF2(_L("Test Action %S completed."), &KTestActionCheckDrmReceipt);
       
   148 	TestCase().ActionCompletedL(*this);
       
   149 }