|
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 // SmtpModifyAttachmentInfo |
|
17 // [Action Parameters] |
|
18 // Session <input>: Reference to the session. |
|
19 // MsgId <input>: Value of the message Id. |
|
20 // AttachmentId <input>: Attachment to add the mime headers to. |
|
21 // [Action Description] |
|
22 // Creates a set of test mime headers |
|
23 // [APIs Used] |
|
24 // CMsvSession::GetEntryL |
|
25 // CImEmailMessage::AttachmentManagerL |
|
26 // MMsvAttachmentManager::AttachmentCount |
|
27 // MMsvAttachmentManager::ModifyAttachmentInfoL |
|
28 // __ACTION_INFO_END__ |
|
29 // |
|
30 // |
|
31 |
|
32 |
|
33 #include "CMtfTestActionSmtpModifyAttachmentInfo.h" |
|
34 #include "CMtfTestCase.h" |
|
35 #include "CMtfAsyncWaiter.h" |
|
36 #include "CMtfTestActionParameters.h" |
|
37 #include "MtfTestActionUtilsUser.h" |
|
38 |
|
39 #include <miutset.h> |
|
40 #include <mmsvattachmentmanager.h> |
|
41 #include <cmsvmimeheaders.h> |
|
42 #include <miutmsg.h> |
|
43 |
|
44 _LIT8(KTxtContentDescription, "Attachment API Modify Attachment"); |
|
45 _LIT8(KTxtContentBase, "TestContentBase"); |
|
46 _LIT(KTxtContentLocation, "http://attachmentTest.AttachmentAPI/TestImage.jpg"); |
|
47 _LIT8(KTxtContentId, "attachmentPart@attachmentTest.AttachmentAPI"); |
|
48 _LIT8(KTxtContentType, "image"); |
|
49 _LIT8(KTxtContentSubType, "jpg"); |
|
50 _LIT8(KTxtContentDisposition, "Attachment"); |
|
51 _LIT8(KTxtParam1, "Param1"); |
|
52 _LIT8(KTxtParam2, "Param2"); |
|
53 _LIT8(KTxtParam3, "Param3"); |
|
54 _LIT8(KTxtParam4, "Param4"); |
|
55 _LIT8(KTxtParam5, "Param5"); |
|
56 _LIT8(KTxtParam6, "Param6"); |
|
57 _LIT8(KTxtParam7, "Param7"); |
|
58 _LIT8(KTxtParam8, "Param8"); |
|
59 _LIT8(KTxtParam9, "Param9"); |
|
60 |
|
61 CMtfTestAction* CMtfTestActionSmtpModifyAttachmentInfo::NewL(CMtfTestCase& aTestCase,CMtfTestActionParameters* aActionParameters) |
|
62 { |
|
63 CMtfTestActionSmtpModifyAttachmentInfo* self = new(ELeave) CMtfTestActionSmtpModifyAttachmentInfo(aTestCase); |
|
64 CleanupStack::PushL(self); |
|
65 self->ConstructL(aActionParameters); |
|
66 CleanupStack::Pop(); |
|
67 return self; |
|
68 } |
|
69 |
|
70 |
|
71 CMtfTestActionSmtpModifyAttachmentInfo::CMtfTestActionSmtpModifyAttachmentInfo(CMtfTestCase& aTestCase) |
|
72 : CMtfSynchronousTestAction(aTestCase) |
|
73 { |
|
74 } |
|
75 |
|
76 |
|
77 CMtfTestActionSmtpModifyAttachmentInfo::~CMtfTestActionSmtpModifyAttachmentInfo() |
|
78 { |
|
79 } |
|
80 |
|
81 void CMtfTestActionSmtpModifyAttachmentInfo::ExecuteActionL() |
|
82 { |
|
83 TestCase().INFO_PRINTF2(_L("Test Action %S start..."), &KTestActionSmtpModifyAttachmentInfo); |
|
84 CMsvSession* paramSession = ObtainParameterReferenceL<CMsvSession>(TestCase(),ActionParameters().Parameter(0)); |
|
85 TMsvId messageEntry = ObtainValueParameterL<TMsvId>(TestCase(),ActionParameters().Parameter(1)); |
|
86 TMsvAttachmentId attachmentId = ObtainValueParameterL<TMsvAttachmentId>(TestCase(),ActionParameters().Parameter(2)); |
|
87 |
|
88 CMsvEntry* entry = paramSession->GetEntryL(messageEntry); |
|
89 CleanupStack::PushL(entry); |
|
90 |
|
91 CImEmailMessage* emailMsg = CImEmailMessage::NewL(*entry); |
|
92 CleanupStack::PushL(emailMsg); |
|
93 |
|
94 MMsvAttachmentManager& manager = emailMsg->AttachmentManager(); |
|
95 |
|
96 CMsvMimeHeaders* mimeHeaders = CMsvMimeHeaders::NewL(); |
|
97 CleanupStack::PushL(mimeHeaders); |
|
98 |
|
99 mimeHeaders->SetContentDescriptionL(KTxtContentDescription()); |
|
100 mimeHeaders->SetContentBaseL(KTxtContentBase()); |
|
101 mimeHeaders->SetContentLocationL(KTxtContentLocation()); |
|
102 mimeHeaders->SetContentIdL(KTxtContentId()); |
|
103 mimeHeaders->SetContentTypeL(KTxtContentType()); |
|
104 mimeHeaders->SetContentSubTypeL(KTxtContentSubType()); |
|
105 mimeHeaders->SetContentDispositionL(KTxtContentDisposition()); |
|
106 mimeHeaders->ContentTypeParams().AppendL(KTxtParam1()); |
|
107 mimeHeaders->ContentTypeParams().AppendL(KTxtParam2()); |
|
108 mimeHeaders->ContentTypeParams().AppendL(KTxtParam3()); |
|
109 mimeHeaders->ContentDispositionParams().AppendL(KTxtParam4()); |
|
110 mimeHeaders->ContentDispositionParams().AppendL(KTxtParam5()); |
|
111 mimeHeaders->ContentDispositionParams().AppendL(KTxtParam6()); |
|
112 mimeHeaders->XTypeParams().AppendL(KTxtParam7()); |
|
113 mimeHeaders->XTypeParams().AppendL(KTxtParam8()); |
|
114 mimeHeaders->XTypeParams().AppendL(KTxtParam9()); |
|
115 |
|
116 CMtfAsyncWaiter* waiter = CMtfAsyncWaiter::NewL(); |
|
117 CleanupStack::PushL(waiter); |
|
118 CMsvAttachment* attachment = manager.GetAttachmentInfoL(attachmentId); |
|
119 CleanupStack::PushL(attachment); |
|
120 mimeHeaders->StoreL(*attachment); |
|
121 manager.ModifyAttachmentInfoL(attachment, waiter->iStatus); |
|
122 CleanupStack::Pop(attachment); |
|
123 waiter->StartAndWait(); |
|
124 User::LeaveIfError(waiter->Result()); |
|
125 |
|
126 CleanupStack::PopAndDestroy(2, mimeHeaders); // waiter, mimeHeaders |
|
127 |
|
128 CompareMimeHeadersL(*emailMsg, attachmentId); |
|
129 |
|
130 CleanupStack::PopAndDestroy(2, entry);//emailMsg, entry |
|
131 |
|
132 TestCase().INFO_PRINTF2(_L("Test Action %S completed."), &KTestActionSmtpModifyAttachmentInfo); |
|
133 TestCase().ActionCompletedL(*this); |
|
134 } |
|
135 |
|
136 |
|
137 void CMtfTestActionSmtpModifyAttachmentInfo::CompareMimeHeadersL(CImEmailMessage& imEmailMsg, TMsvAttachmentId aAttachId) |
|
138 { |
|
139 CMsvAttachment* attachment = imEmailMsg.AttachmentManager().GetAttachmentInfoL(aAttachId); |
|
140 CleanupStack::PushL(attachment); |
|
141 |
|
142 CMsvMimeHeaders* mimeHeaders = CMsvMimeHeaders::NewL(); |
|
143 CleanupStack::PushL(mimeHeaders); |
|
144 |
|
145 mimeHeaders->RestoreL(*attachment); |
|
146 if( mimeHeaders->ContentDescription().Compare(KTxtContentDescription()) != 0 ) |
|
147 User::Leave(KErrNotFound); |
|
148 if( mimeHeaders->ContentBase().Compare(KTxtContentBase()) != 0 ) |
|
149 User::Leave(KErrNotFound); |
|
150 if( mimeHeaders->ContentLocation().Compare(KTxtContentLocation()) != 0 ) |
|
151 User::Leave(KErrNotFound); |
|
152 if( mimeHeaders->ContentId().Compare(KTxtContentId()) != 0 ) |
|
153 User::Leave(KErrNotFound); |
|
154 if( mimeHeaders->ContentType().Compare(KTxtContentType()) != 0 ) |
|
155 User::Leave(KErrNotFound); |
|
156 if( mimeHeaders->ContentSubType().Compare(KTxtContentSubType()) != 0 ) |
|
157 User::Leave(KErrNotFound); |
|
158 if( mimeHeaders->ContentDisposition().Compare(KTxtContentDisposition()) != 0 ) |
|
159 User::Leave(KErrNotFound); |
|
160 |
|
161 CDesC8Array& desArray1 = mimeHeaders->ContentTypeParams(); |
|
162 if( desArray1.Count() == 3 ) |
|
163 { |
|
164 if( desArray1[0].Compare(KTxtParam1()) != 0 ) |
|
165 User::Leave(KErrNotFound); |
|
166 if( desArray1[1].Compare(KTxtParam2()) != 0 ) |
|
167 User::Leave(KErrNotFound); |
|
168 if( desArray1[2].Compare(KTxtParam3()) != 0 ) |
|
169 User::Leave(KErrNotFound); |
|
170 } |
|
171 else |
|
172 User::Leave(KErrNotFound); |
|
173 |
|
174 CDesC8Array& desArray2 = mimeHeaders->ContentDispositionParams(); |
|
175 if( desArray2.Count() == 3 ) |
|
176 { |
|
177 if( desArray2[0].Compare(KTxtParam4()) != 0 ) |
|
178 User::Leave(KErrNotFound); |
|
179 if( desArray2[1].Compare(KTxtParam5()) != 0 ) |
|
180 User::Leave(KErrNotFound); |
|
181 if( desArray2[2].Compare(KTxtParam6()) != 0 ) |
|
182 User::Leave(KErrNotFound); |
|
183 } |
|
184 else |
|
185 User::Leave(KErrNotFound); |
|
186 |
|
187 CDesC8Array& desArray3 = mimeHeaders->XTypeParams(); |
|
188 if( desArray3.Count() == 3 ) |
|
189 { |
|
190 if( desArray3[0].Compare(KTxtParam7()) != 0 ) |
|
191 User::Leave(KErrNotFound); |
|
192 if( desArray3[1].Compare(KTxtParam8()) != 0 ) |
|
193 User::Leave(KErrNotFound); |
|
194 if( desArray3[2].Compare(KTxtParam9()) != 0 ) |
|
195 User::Leave(KErrNotFound); |
|
196 } |
|
197 else |
|
198 User::Leave(KErrNotFound); |
|
199 |
|
200 CleanupStack::PopAndDestroy(2, attachment); // mimeHeaders, attachment |
|
201 } |