|
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 // CMTFTESTACTIONREMOVEFILEATTACHMENTWITDESTROY.CPP |
|
15 // __ACTION_INFO_BEGIN__ |
|
16 // [Action Name] |
|
17 // RemoveFileAttachmentWithDestroy |
|
18 // [Action Parameters] |
|
19 // Session <input>: Reference to the session. |
|
20 // MsgId <input>: Value of the message Id. |
|
21 // AttachmentId <input>: Attachment Id of attachment to remove. |
|
22 // [Action Description] |
|
23 // Removes the specified file attachment by its attachment Id. The attachment |
|
24 // is first checked to to ensure that it is a file attachment and then |
|
25 // removes it. The store is then destroyed so that the remove attachment is |
|
26 // never commited. |
|
27 // [APIs Used] |
|
28 // CMsvSession::GetEntryL |
|
29 // CMsvStore::ReadStoreL |
|
30 // CMsvStore::AttachmentManagerL |
|
31 // TODO |
|
32 // __ACTION_INFO_END__ |
|
33 // |
|
34 // |
|
35 |
|
36 |
|
37 #include "CMtfTestActionRemoveFileAttachmentWithDestroy.h" |
|
38 #include "CMtfAsyncWaiter.h" |
|
39 #include "CMtfTestCase.h" |
|
40 #include "CMtfTestActionParameters.h" |
|
41 #include "MtfTestActionUtilsUser.h" |
|
42 |
|
43 #include <miutset.h> |
|
44 #include <mmsvattachmentmanager.h> |
|
45 #include <cmsvattachment.h> |
|
46 |
|
47 CMtfTestAction* CMtfTestActionRemoveFileAttachmentWithDestroy::NewL(CMtfTestCase& aTestCase,CMtfTestActionParameters* aActionParameters) |
|
48 { |
|
49 CMtfTestActionRemoveFileAttachmentWithDestroy* self = new(ELeave) CMtfTestActionRemoveFileAttachmentWithDestroy(aTestCase); |
|
50 CleanupStack::PushL(self); |
|
51 self->ConstructL(aActionParameters); |
|
52 CleanupStack::Pop(); |
|
53 return self; |
|
54 } |
|
55 |
|
56 |
|
57 CMtfTestActionRemoveFileAttachmentWithDestroy::CMtfTestActionRemoveFileAttachmentWithDestroy(CMtfTestCase& aTestCase) |
|
58 : CMtfSynchronousTestAction(aTestCase) |
|
59 { |
|
60 } |
|
61 |
|
62 |
|
63 CMtfTestActionRemoveFileAttachmentWithDestroy::~CMtfTestActionRemoveFileAttachmentWithDestroy() |
|
64 { |
|
65 } |
|
66 |
|
67 void CMtfTestActionRemoveFileAttachmentWithDestroy::ExecuteActionL() |
|
68 { |
|
69 TestCase().INFO_PRINTF2(_L("Test Action %S start..."), &KTestActionRemoveFileAttachmentWithDestroy); |
|
70 CMsvSession* paramSession = ObtainParameterReferenceL<CMsvSession>(TestCase(),ActionParameters().Parameter(0)); |
|
71 TMsvId messageEntry = ObtainValueParameterL<TMsvId>(TestCase(),ActionParameters().Parameter(1)); |
|
72 TMsvAttachmentId attachId = ObtainValueParameterL<TMsvAttachmentId>(TestCase(),ActionParameters().Parameter(2)); |
|
73 |
|
74 CMsvEntry* entry = paramSession->GetEntryL(messageEntry); |
|
75 CleanupStack::PushL(entry); |
|
76 |
|
77 CMsvStore* store = entry->EditStoreL(); |
|
78 CleanupStack::PushL(store); |
|
79 |
|
80 MMsvAttachmentManager& manager = store->AttachmentManagerL(); |
|
81 |
|
82 CMsvAttachment* attachInfo = manager.GetAttachmentInfoL(attachId); |
|
83 CleanupStack::PushL(attachInfo); |
|
84 |
|
85 // First ensure that the attachment is a file attachment |
|
86 if( attachInfo->Type() != CMsvAttachment::EMsvFile ) |
|
87 { |
|
88 User::Leave(KErrGeneral); |
|
89 } |
|
90 |
|
91 CleanupStack::PopAndDestroy(attachInfo); |
|
92 |
|
93 CMtfAsyncWaiter* waiter = CMtfAsyncWaiter::NewL(); |
|
94 CleanupStack::PushL(waiter); |
|
95 manager.RemoveAttachmentL(attachId, waiter->iStatus); |
|
96 waiter->StartAndWait(); |
|
97 User::LeaveIfError(waiter->Result()); |
|
98 CleanupStack::PopAndDestroy(waiter); |
|
99 |
|
100 // destroy the store without commit |
|
101 CleanupStack::PopAndDestroy(2, entry); // store, entry |
|
102 |
|
103 TestCase().INFO_PRINTF2(_L("Test Action %S completed."), &KTestActionRemoveFileAttachmentWithDestroy); |
|
104 TestCase().ActionCompletedL(*this); |
|
105 } |
|
106 |
|
107 |
|
108 |