|
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 // SmtpRemoveAllAttachments |
|
17 // [Action Parameters] |
|
18 // Session <input>: Reference to the session. |
|
19 // MsgId <input>: Value of the message Id. |
|
20 // AttachmentIdFlag <input>: Flag to state if attachment is to be removed using attachment Id. |
|
21 // [Action Description] |
|
22 // Removes all the attachments of a specified message. If AttachmentIdFlag is set to ETrue |
|
23 // attachments will be removed using attachment Id, else index value is used. |
|
24 // [APIs Used] |
|
25 // CMsvSession::GetEntryL |
|
26 // CImEmailMessage::AttachmentManagerL |
|
27 // MMsvAttachmentManager::RemoveAttachmentL |
|
28 // MMsvAttachmentManager::AttachmentCountL |
|
29 // __ACTION_INFO_END__ |
|
30 // |
|
31 // |
|
32 |
|
33 |
|
34 #include "CMtfTestActionSmtpRemoveAllAttachments.h" |
|
35 #include "CMtfAsyncWaiter.h" |
|
36 #include "CMtfTestCase.h" |
|
37 #include "CMtfTestActionParameters.h" |
|
38 #include "MtfTestActionUtilsUser.h" |
|
39 |
|
40 #include <miutset.h> |
|
41 #include <mmsvattachmentmanager.h> |
|
42 #include <cmsvattachment.h> |
|
43 #include <miutmsg.h> |
|
44 |
|
45 CMtfTestAction* CMtfTestActionSmtpRemoveAllAttachments::NewL(CMtfTestCase& aTestCase,CMtfTestActionParameters* aActionParameters) |
|
46 { |
|
47 CMtfTestActionSmtpRemoveAllAttachments* self = new(ELeave) CMtfTestActionSmtpRemoveAllAttachments(aTestCase); |
|
48 CleanupStack::PushL(self); |
|
49 self->ConstructL(aActionParameters); |
|
50 CleanupStack::Pop(); |
|
51 return self; |
|
52 } |
|
53 |
|
54 |
|
55 CMtfTestActionSmtpRemoveAllAttachments::CMtfTestActionSmtpRemoveAllAttachments(CMtfTestCase& aTestCase) |
|
56 : CMtfSynchronousTestAction(aTestCase) |
|
57 { |
|
58 } |
|
59 |
|
60 |
|
61 CMtfTestActionSmtpRemoveAllAttachments::~CMtfTestActionSmtpRemoveAllAttachments() |
|
62 { |
|
63 } |
|
64 |
|
65 void CMtfTestActionSmtpRemoveAllAttachments::ExecuteActionL() |
|
66 { |
|
67 TestCase().INFO_PRINTF2(_L("Test Action %S start..."), &KTestActionSmtpRemoveAllAttachments); |
|
68 CMsvSession* paramSession = ObtainParameterReferenceL<CMsvSession>(TestCase(),ActionParameters().Parameter(0)); |
|
69 TMsvId messageEntry = ObtainValueParameterL<TMsvId>(TestCase(),ActionParameters().Parameter(1)); |
|
70 TInt attachIdFlag = ObtainValueParameterL<TInt>(TestCase(),ActionParameters().Parameter(2), 0); |
|
71 |
|
72 CMsvEntry* entry = paramSession->GetEntryL(messageEntry); |
|
73 CleanupStack::PushL(entry); |
|
74 |
|
75 CImEmailMessage* emailMsg = CImEmailMessage::NewL(*entry); |
|
76 CleanupStack::PushL(emailMsg); |
|
77 |
|
78 MMsvAttachmentManager& manager = emailMsg->AttachmentManager(); |
|
79 |
|
80 TInt attachmentCount = manager.AttachmentCount(); |
|
81 |
|
82 for ( ; attachmentCount > 0 ; attachmentCount-- ) |
|
83 { |
|
84 CMtfAsyncWaiter* waiter = CMtfAsyncWaiter::NewL(); |
|
85 CleanupStack::PushL(waiter); |
|
86 |
|
87 if( attachIdFlag == 1 ) |
|
88 { |
|
89 CMsvAttachment* attachmentInfo = manager.GetAttachmentInfoL(0); |
|
90 CleanupStack::PushL(attachmentInfo); |
|
91 manager.RemoveAttachmentL(attachmentInfo->Id(), waiter->iStatus); |
|
92 CleanupStack::PopAndDestroy(attachmentInfo); |
|
93 } |
|
94 else |
|
95 { |
|
96 manager.RemoveAttachmentL(0, waiter->iStatus); |
|
97 } |
|
98 waiter->StartAndWait(); |
|
99 User::LeaveIfError(waiter->Result()); |
|
100 CleanupStack::PopAndDestroy(waiter); |
|
101 } |
|
102 |
|
103 CleanupStack::PopAndDestroy(2, entry); // emailMsg, entry |
|
104 |
|
105 TestCase().INFO_PRINTF2(_L("Test Action %S completed."), &KTestActionSmtpRemoveAllAttachments); |
|
106 |
|
107 TestCase().ActionCompletedL(*this); |
|
108 } |