|
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 // CreatePartiallyDownloadedMailSelection |
|
17 // [Action Parameters] |
|
18 // CMsvSession Session <input> : Reference to the session |
|
19 // TMsvId ParentId <input> : Value of the parent folder Id. |
|
20 // CMsvEntrySelection MailSelection <output-initiation>: Reference to the |
|
21 // selection of partially |
|
22 // downloded mails. |
|
23 // [Action Description] |
|
24 // Creates a selection of all Partially Downloaded Mails under the parent folder. |
|
25 // [APIs Used] |
|
26 // CMsvEntry::SetSortTypeL |
|
27 // CMsvEntry::GetEntry |
|
28 // CMsvEntrySelection::ChildrenWithMtmL |
|
29 // CMsvEntrySelection::AppendL |
|
30 // __ACTION_INFO_END__ |
|
31 // |
|
32 // |
|
33 |
|
34 /** |
|
35 @file |
|
36 @internalTechnology |
|
37 */ |
|
38 |
|
39 // EPOC include |
|
40 #include <msvapi.h> |
|
41 |
|
42 |
|
43 // User include |
|
44 #include "CMtfTestActionCreatePartiallyDownloadedMailSelection.h" |
|
45 #include "CMtfTestCase.h" |
|
46 #include "CMtfTestActionParameters.h" |
|
47 |
|
48 |
|
49 |
|
50 /** |
|
51 NewL() |
|
52 Constructs a CMtfTestActionCreatePartiallyDownloadedMailSelection object. |
|
53 Uses two phase construction and leaves nothing on the CleanupStack. |
|
54 @internalTechnology |
|
55 @param aTestCase Test Case to which this Test Action belongs |
|
56 @param aActionParameters Action parameters, must not be NULL |
|
57 @return Created object of type CMtfTestActionCreatePartiallyDownloadedMailSelection |
|
58 @pre None |
|
59 @post CMtfTestActionCreatePartiallyDownloadedMailSelection object is created |
|
60 */ |
|
61 CMtfTestAction* CMtfTestActionCreatePartiallyDownloadedMailSelection:: |
|
62 NewL(CMtfTestCase& aTestCase,CMtfTestActionParameters* aActionParameters) |
|
63 { |
|
64 CMtfTestActionCreatePartiallyDownloadedMailSelection* self = |
|
65 new (ELeave) CMtfTestActionCreatePartiallyDownloadedMailSelection(aTestCase); |
|
66 |
|
67 CleanupStack::PushL(self); |
|
68 self->ConstructL(aActionParameters); |
|
69 CleanupStack::Pop(self); |
|
70 return self; |
|
71 } |
|
72 |
|
73 |
|
74 /** |
|
75 CMtfTestActionCreatePartiallyDownloadedMailSelection constructor |
|
76 Calls the base class' constructor |
|
77 @internalTechnology |
|
78 @param aTestCase Test Case to which this Test Action belongs |
|
79 @pre None |
|
80 @post None |
|
81 */ |
|
82 CMtfTestActionCreatePartiallyDownloadedMailSelection:: |
|
83 CMtfTestActionCreatePartiallyDownloadedMailSelection(CMtfTestCase& aTestCase) |
|
84 : CMtfSynchronousTestAction(aTestCase) |
|
85 { |
|
86 } |
|
87 |
|
88 |
|
89 /** |
|
90 ExecuteActionL |
|
91 Creates a selection of all partially downloaded IMAP4 mails present in the parent folder. |
|
92 The created message selection is stored as an output parameter of the Test Action. |
|
93 @internalTechnology |
|
94 @pre None |
|
95 @post None |
|
96 */ |
|
97 void CMtfTestActionCreatePartiallyDownloadedMailSelection::ExecuteActionL() |
|
98 { |
|
99 TestCase().INFO_PRINTF2(_L("Test Action %S start..."), &KTestActionCreatePartiallyDownloadedMailSelection); |
|
100 CMsvSession* paramSession = ObtainParameterReferenceL<CMsvSession>(TestCase(), |
|
101 ActionParameters().Parameter(0)); |
|
102 |
|
103 TMsvId paramParentId = ObtainValueParameterL<TMsvId>(TestCase(), |
|
104 ActionParameters().Parameter(1)); |
|
105 |
|
106 |
|
107 /*********************************************************************************** |
|
108 Create a selection of all IMAP4 messages in the parent folder. Using the message Ids |
|
109 present in the selection, check if the message was partially downloaded. Append the |
|
110 partially downloaded messages' Ids to a new message selection. Store the message |
|
111 selection containig the Ids of partially donwloaded messages as an output parameter |
|
112 of the Test Action. |
|
113 ***********************************************************************************/ |
|
114 |
|
115 // Set the context to parent folder |
|
116 CMsvEntry* entry = CMsvEntry::NewL(*paramSession,paramParentId, |
|
117 TMsvSelectionOrdering(KMsvNoGrouping, |
|
118 EMsvSortByNone,ETrue)); |
|
119 CleanupStack::PushL(entry); |
|
120 |
|
121 // Create a selection of all IMAP4 mails in the parent folder |
|
122 TMsvSelectionOrdering order; |
|
123 order.SetShowInvisibleEntries(ETrue); |
|
124 entry->SetSortTypeL(order); |
|
125 |
|
126 CMsvEntrySelection* selection = entry->ChildrenWithMtmL(KUidMsgTypeIMAP4); |
|
127 CleanupStack::PushL(selection); |
|
128 |
|
129 // Create a new selection to store partially downloaded mails |
|
130 CMsvEntrySelection* paramMailSelection = new (ELeave) CMsvEntrySelection; |
|
131 CleanupStack::PushL(paramMailSelection); |
|
132 |
|
133 TMsvEmailEntry emailEntry; |
|
134 |
|
135 for(TInt i=1;i<selection->Count();i++) |
|
136 { |
|
137 TMsvId messageId = selection->At(i); |
|
138 entry->Session().GetEntry(messageId,paramParentId,emailEntry); |
|
139 |
|
140 // If the mail was partially downloaded, append its Id to the |
|
141 // paritally downloaded mail selection |
|
142 if(emailEntry.PartialDownloaded()) |
|
143 { |
|
144 paramMailSelection->AppendL(messageId); |
|
145 } |
|
146 } |
|
147 |
|
148 // Pop the mail selection object before storing it as ouput parameter |
|
149 CleanupStack::Pop(paramMailSelection); |
|
150 |
|
151 // Store the message selections as output parameters of the Test Action |
|
152 StoreParameterL<CMsvEntrySelection>(TestCase(),*paramMailSelection, |
|
153 ActionParameters().Parameter(2)); |
|
154 |
|
155 CleanupStack::PopAndDestroy(selection); |
|
156 CleanupStack::PopAndDestroy(entry); |
|
157 TestCase().INFO_PRINTF2(_L("Test Action %S completed."), &KTestActionCreatePartiallyDownloadedMailSelection); |
|
158 TestCase().ActionCompletedL(*this); |
|
159 } |