|
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 // SmtpGetAttachmentInfoByIndex |
|
17 // [Action Parameters] |
|
18 // Session <input>: Reference to the session. |
|
19 // MsgId <input>: Value of the message Id. |
|
20 // Index <input>: Index value of the attachment. |
|
21 // AttachmentInfo <output>: Reference to the created attachment info |
|
22 // ErrorCode <output>: (Optional) Returned error code, if not requested then code will |
|
23 // leave if not KErrNone |
|
24 // [Action Description] |
|
25 // Creates an attachment info object from the specified index for the |
|
26 // supplied message entry. Will fail if the entry or attachment does |
|
27 // not exist. |
|
28 // [APIs Used] |
|
29 // CMsvSession::GetEntryL |
|
30 // CImEmailMessage::AttachmentManagerL |
|
31 // MMsvAttachmentManager::GetAttachmentInfoL |
|
32 // __ACTION_INFO_END__ |
|
33 // |
|
34 // |
|
35 |
|
36 |
|
37 #include "CMtfTestActionSmtpGetAttachmentInfoByIndex.h" |
|
38 #include "CMtfTestCase.h" |
|
39 #include "CMtfTestActionParameters.h" |
|
40 #include "MtfTestActionUtilsUser.h" |
|
41 |
|
42 #include <miutset.h> |
|
43 #include <cmsvattachment.h> |
|
44 #include <mmsvattachmentmanager.h> |
|
45 #include <miutmsg.h> |
|
46 |
|
47 const TInt KMimeTypeLength = 50; |
|
48 |
|
49 CMtfTestAction* CMtfTestActionSmtpGetAttachmentInfoByIndex::NewL(CMtfTestCase& aTestCase,CMtfTestActionParameters* aActionParameters) |
|
50 { |
|
51 CMtfTestActionSmtpGetAttachmentInfoByIndex* self = new(ELeave) CMtfTestActionSmtpGetAttachmentInfoByIndex(aTestCase); |
|
52 CleanupStack::PushL(self); |
|
53 self->ConstructL(aActionParameters); |
|
54 CleanupStack::Pop(); |
|
55 return self; |
|
56 } |
|
57 |
|
58 |
|
59 CMtfTestActionSmtpGetAttachmentInfoByIndex::CMtfTestActionSmtpGetAttachmentInfoByIndex(CMtfTestCase& aTestCase) |
|
60 : CMtfSynchronousTestAction(aTestCase) |
|
61 { |
|
62 } |
|
63 |
|
64 |
|
65 CMtfTestActionSmtpGetAttachmentInfoByIndex::~CMtfTestActionSmtpGetAttachmentInfoByIndex() |
|
66 { |
|
67 } |
|
68 |
|
69 void CMtfTestActionSmtpGetAttachmentInfoByIndex::ExecuteActionL() |
|
70 { |
|
71 TestCase().INFO_PRINTF2(_L("Test Action %S start..."), &KTestActionSmtpGetAttachmentInfoByIndex); |
|
72 TRAPD(err, RunTestL()); |
|
73 |
|
74 if( ActionParameters().Count() < 5 ) |
|
75 { |
|
76 User::LeaveIfError(err); |
|
77 } |
|
78 else |
|
79 { |
|
80 StoreParameterL<TInt>(TestCase(),err,ActionParameters().Parameter(4)); |
|
81 } |
|
82 |
|
83 TestCase().INFO_PRINTF2(_L("Test Action %S completed."), &KTestActionSmtpGetAttachmentInfoByIndex); |
|
84 TestCase().ActionCompletedL(*this); |
|
85 } |
|
86 |
|
87 void CMtfTestActionSmtpGetAttachmentInfoByIndex::RunTestL() |
|
88 { |
|
89 CMsvSession* paramSession = ObtainParameterReferenceL<CMsvSession>(TestCase(),ActionParameters().Parameter(0)); |
|
90 TMsvId messageEntry = ObtainValueParameterL<TMsvId>(TestCase(),ActionParameters().Parameter(1)); |
|
91 TInt attachIndex = ObtainValueParameterL<TInt>(TestCase(),ActionParameters().Parameter(2)); |
|
92 |
|
93 CMsvEntry* entry = paramSession->GetEntryL(messageEntry); |
|
94 CleanupStack::PushL(entry); |
|
95 |
|
96 CImEmailMessage* emailMsg = CImEmailMessage::NewL(*entry); |
|
97 CleanupStack::PushL(emailMsg); |
|
98 |
|
99 MMsvAttachmentManager& manager = emailMsg->AttachmentManager(); |
|
100 CMsvAttachment* attachInfo = manager.GetAttachmentInfoL(attachIndex); |
|
101 CleanupStack::PushL(attachInfo); |
|
102 |
|
103 PrintAttachmentInfo(*attachInfo); |
|
104 |
|
105 StoreParameterL<CMsvAttachment>(TestCase(),*attachInfo,ActionParameters().Parameter(3)); |
|
106 CleanupStack::Pop(attachInfo); |
|
107 CleanupStack::PopAndDestroy(2, entry); // emailMsg, entry |
|
108 } |
|
109 |
|
110 void CMtfTestActionSmtpGetAttachmentInfoByIndex::PrintAttachmentInfo(CMsvAttachment& aInfo) |
|
111 { |
|
112 TestCase().INFO_PRINTF1(_L("CMsvAttachment Info...")); |
|
113 TestCase().INFO_PRINTF2(_L("ID - %d"), aInfo.Id() ); |
|
114 switch(aInfo.Type()) |
|
115 { |
|
116 case CMsvAttachment::EMsvFile: |
|
117 TestCase().INFO_PRINTF1(_L("Type - EMsvFile")); |
|
118 TestCase().INFO_PRINTF2(_L("Filename - %S"), &aInfo.AttachmentName()); |
|
119 break; |
|
120 case CMsvAttachment::EMsvLinkedFile: |
|
121 TestCase().INFO_PRINTF1(_L("Type - EMsvLinkedFile")); |
|
122 TestCase().INFO_PRINTF2(_L("Filename - %S"), &aInfo.AttachmentName()); |
|
123 break; |
|
124 case CMsvAttachment::EMsvMessageEntry: |
|
125 TestCase().INFO_PRINTF1(_L("Type - EMsvMessageEntry")); |
|
126 TestCase().INFO_PRINTF2(_L("EntryId - %d"), aInfo.EntryAttachmentId()); |
|
127 break; |
|
128 default: |
|
129 User::Invariant(); |
|
130 break; |
|
131 } |
|
132 TestCase().INFO_PRINTF2(_L("Size - %d"), aInfo.Size()); |
|
133 |
|
134 TBuf<KMimeTypeLength> mimeType; |
|
135 mimeType.Copy(aInfo.MimeType()); |
|
136 TestCase().INFO_PRINTF2(_L("MimeType - %S"), &mimeType); |
|
137 |
|
138 } |