|
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 // RemoveAllAttachments |
|
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 // CMsvStore::ReadStoreL |
|
27 // CMsvEntry::SetEntryL |
|
28 // CMsvStore::AttachmentManagerL |
|
29 // MMsvAttachmentManager::RemoveAttachmentL |
|
30 // MMsvAttachmentManager::AttachmentCountL |
|
31 // TODO |
|
32 // __ACTION_INFO_END__ |
|
33 // |
|
34 // |
|
35 |
|
36 |
|
37 #include "CMtfTestActionRemoveAllAttachments.h" |
|
38 #include "CMtfAsyncWaiter.h" |
|
39 #include "CMtfTestCase.h" |
|
40 #include "CMtfTestActionParameters.h" |
|
41 #include "MtfTestActionUtilsUser.h" |
|
42 |
|
43 #include <mmsvattachmentmanager.h> |
|
44 #include <cmsvattachment.h> |
|
45 |
|
46 CMtfTestAction* CMtfTestActionRemoveAllAttachments::NewL(CMtfTestCase& aTestCase,CMtfTestActionParameters* aActionParameters) |
|
47 { |
|
48 CMtfTestActionRemoveAllAttachments* self = new(ELeave) CMtfTestActionRemoveAllAttachments(aTestCase); |
|
49 CleanupStack::PushL(self); |
|
50 self->ConstructL(aActionParameters); |
|
51 CleanupStack::Pop(); |
|
52 return self; |
|
53 } |
|
54 |
|
55 |
|
56 CMtfTestActionRemoveAllAttachments::CMtfTestActionRemoveAllAttachments(CMtfTestCase& aTestCase) |
|
57 : CMtfSynchronousTestAction(aTestCase) |
|
58 { |
|
59 } |
|
60 |
|
61 |
|
62 CMtfTestActionRemoveAllAttachments::~CMtfTestActionRemoveAllAttachments() |
|
63 { |
|
64 } |
|
65 |
|
66 void CMtfTestActionRemoveAllAttachments::ExecuteActionL() |
|
67 { |
|
68 TestCase().INFO_PRINTF2(_L("Test Action %S start..."), &KTestActionRemoveAllAttachments); |
|
69 CMsvSession* paramSession = ObtainParameterReferenceL<CMsvSession>(TestCase(),ActionParameters().Parameter(0)); |
|
70 TMsvId messageEntry = ObtainValueParameterL<TMsvId>(TestCase(),ActionParameters().Parameter(1)); |
|
71 TInt attachIdFlag = ObtainValueParameterL<TInt>(TestCase(),ActionParameters().Parameter(2), 0); |
|
72 |
|
73 CMsvEntry* entry = paramSession->GetEntryL(messageEntry); |
|
74 CleanupStack::PushL(entry); |
|
75 |
|
76 CMsvStore* store = entry->EditStoreL(); |
|
77 CleanupStack::PushL(store); |
|
78 |
|
79 MMsvAttachmentManager& manager = store->AttachmentManagerL(); |
|
80 |
|
81 TInt attachmentCount = manager.AttachmentCount(); |
|
82 |
|
83 for ( ; attachmentCount > 0 ; attachmentCount-- ) |
|
84 { |
|
85 CMtfAsyncWaiter* waiter = CMtfAsyncWaiter::NewL(); |
|
86 CleanupStack::PushL(waiter); |
|
87 |
|
88 if( attachIdFlag == 1 ) |
|
89 { |
|
90 CMsvAttachment* attachInfo = manager.GetAttachmentInfoL(0); |
|
91 CleanupStack::PushL(attachInfo); |
|
92 |
|
93 manager.RemoveAttachmentL(attachInfo->Id(), waiter->iStatus); |
|
94 CleanupStack::PopAndDestroy(attachInfo); |
|
95 } |
|
96 else |
|
97 { |
|
98 manager.RemoveAttachmentL(0, waiter->iStatus); |
|
99 } |
|
100 waiter->StartAndWait(); |
|
101 User::LeaveIfError(waiter->Result()); |
|
102 CleanupStack::PopAndDestroy(waiter); |
|
103 } |
|
104 |
|
105 store->CommitL(); |
|
106 |
|
107 CleanupStack::PopAndDestroy(2, entry); // store, entry |
|
108 |
|
109 TestCase().INFO_PRINTF2(_L("Test Action %S completed."), &KTestActionRemoveAllAttachments); |
|
110 TestCase().ActionCompletedL(*this); |
|
111 } |
|
112 |