|
1 // Copyright (c) 2006-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 the License "Symbian Foundation License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // [TestStep Name] |
|
15 // PopInvokeAsyncFunction |
|
16 // [Parameters] |
|
17 // PopAccountName : Name of the pop account |
|
18 // EmailSize : The maximum emailsize |
|
19 // PopLimit : The population limit |
|
20 // PopCommand : The POP command to be executed |
|
21 // Reads the Pop account name,maximun email size,population limit and the pop command |
|
22 // name to be executed.Based on the command it calls a utility to establish connection |
|
23 // the POP server, executes the POP command and then based on the command again |
|
24 // disconnects with the POP server. |
|
25 // [APIs Used] |
|
26 // CMsvEntry:: GetEntryL |
|
27 // CBaseMtm :: SwitchCurrentEntryL |
|
28 // CMsvEntry:: ChildrenL |
|
29 // CBaseMtm :: InvokeAsyncFunctionL |
|
30 // |
|
31 // |
|
32 |
|
33 |
|
34 |
|
35 /** |
|
36 @file |
|
37 */ |
|
38 |
|
39 |
|
40 |
|
41 // User Includes |
|
42 #include "T_PopInvokeAsyncFunction.h" |
|
43 #include <t_utilsenumconverter.h> |
|
44 #include <t_utilscentralrepository.h> |
|
45 #include "T_PopServer.h" |
|
46 #include "T_MsgSharedDataPop.h" |
|
47 |
|
48 // Epoc includes |
|
49 #include <miutset.h> |
|
50 |
|
51 |
|
52 // Literals Used |
|
53 _LIT(KPopAccountName,"PopAccountName"); |
|
54 _LIT(KEmailSize,"EmailSize"); |
|
55 _LIT(KPopLimit,"PopLimit"); |
|
56 _LIT(KPopCommand,"PopCommand"); |
|
57 |
|
58 |
|
59 typedef TPckgBuf<TImPop3PopulateOptions> TPop3MailInfoBuf; |
|
60 |
|
61 |
|
62 /** |
|
63 CT_MsgModifyPopSettings() |
|
64 Sets the teststep name to KPopInvokeAsyncFunction |
|
65 |
|
66 @param aSharedDataPOP |
|
67 Data shared across the POP test steps. Ex. Session |
|
68 */ |
|
69 CT_MsgPopInvokeAsyncFunction::CT_MsgPopInvokeAsyncFunction(CT_MsgSharedDataPop& aSharedDataPOP) |
|
70 : CT_MsgAsyncStepPOP(aSharedDataPOP) |
|
71 , iOperation(NULL) |
|
72 { |
|
73 SetTestStepName(KPopInvokeAsyncFunction); |
|
74 } |
|
75 |
|
76 |
|
77 /** |
|
78 NewL() |
|
79 Allocates and creates a new CT_MsgPopInvokeAsyncFunction object |
|
80 |
|
81 @param aSharedDataPOP |
|
82 Data shared across the POP test steps. Ex. Session |
|
83 |
|
84 @leave KErrNoMemory |
|
85 @return |
|
86 Returns pointer to an object of CT_MsgPopInvokeAsyncFunction |
|
87 */ |
|
88 CT_MsgPopInvokeAsyncFunction* CT_MsgPopInvokeAsyncFunction::NewL(CT_MsgSharedDataPop& aSharedDataPOP) |
|
89 { |
|
90 CT_MsgPopInvokeAsyncFunction* self = new(ELeave) CT_MsgPopInvokeAsyncFunction(aSharedDataPOP); |
|
91 CleanupStack::PushL(self); |
|
92 self->ConstructL(); // Call CT_AsyncStep::ConstructL() |
|
93 CleanupStack::Pop(self); |
|
94 return self; |
|
95 } |
|
96 |
|
97 |
|
98 /** |
|
99 ~CT_MsgPopInvokeAsyncFunction() |
|
100 Destructor |
|
101 */ |
|
102 CT_MsgPopInvokeAsyncFunction::~CT_MsgPopInvokeAsyncFunction() |
|
103 { |
|
104 delete iOperation; |
|
105 iOperation=NULL; |
|
106 } |
|
107 |
|
108 |
|
109 /** |
|
110 ProgressL() |
|
111 |
|
112 @param |
|
113 */ |
|
114 void CT_MsgPopInvokeAsyncFunction::ProgressL(TBool bFinal) |
|
115 { |
|
116 // TODO |
|
117 if ( bFinal ) |
|
118 { |
|
119 // Display final progress iOperation |
|
120 } |
|
121 else |
|
122 { |
|
123 // Display current progress iOperation |
|
124 } |
|
125 } |
|
126 |
|
127 |
|
128 /** |
|
129 CancelStep() |
|
130 |
|
131 @param |
|
132 */ |
|
133 void CT_MsgPopInvokeAsyncFunction::CancelStep() |
|
134 { |
|
135 iOperation->Cancel(); |
|
136 } |
|
137 |
|
138 |
|
139 /** |
|
140 doTestStepL() |
|
141 Reads the POP account name,population limit,maximum email size from the ini file |
|
142 Based on the command decides whether a connection is required. |
|
143 It then calls the InvokeAsyncFunctionL with the given command. |
|
144 Based on the command again calls the utility to disconnect fromt the POP server |
|
145 |
|
146 @return |
|
147 Returns the test step result |
|
148 */ |
|
149 TVerdict CT_MsgPopInvokeAsyncFunction::doTestStepL() |
|
150 { |
|
151 INFO_PRINTF1(_L("Test Step : Invoke Async Function")); |
|
152 |
|
153 TPtrC popAccountName; |
|
154 if(!GetStringFromConfig(ConfigSection(), KPopAccountName, popAccountName)) |
|
155 { |
|
156 ERR_PRINTF1(_L("Account name not specified")); |
|
157 SetTestStepResult(EFail); |
|
158 } |
|
159 else |
|
160 { |
|
161 |
|
162 // Retrieving the Pop service Id for the given Pop account |
|
163 TMsvId popServiceId = CT_MsgUtilsCentralRepository::GetPopServiceIdL((TDes&)popAccountName); |
|
164 |
|
165 // Read the maximum email size from the ini file |
|
166 TInt maxEmailSize; |
|
167 GetIntFromConfig(ConfigSection(), KEmailSize, maxEmailSize); |
|
168 |
|
169 // Read the population limit from the ini file |
|
170 TInt popLimit; |
|
171 GetIntFromConfig(ConfigSection(), KPopLimit, popLimit); |
|
172 |
|
173 // Read the pop command to be executed from the ini file |
|
174 TPtrC popCmdName; |
|
175 if(!GetStringFromConfig(ConfigSection(),KPopCommand,popCmdName)) |
|
176 { |
|
177 ERR_PRINTF1(_L("Pop command not specified")); |
|
178 SetTestStepResult(EFail); |
|
179 } |
|
180 else |
|
181 { |
|
182 |
|
183 // Changes the entry on which later actions are performed to the entry of the Pop Service Id. |
|
184 iSharedDataPOP.iMtm->SwitchCurrentEntryL(popServiceId); //base Class Member iMtm |
|
185 TPop3Cmds popCommand = CT_MsgUtilsEnumConverter::ConvertDesToTPop3Cmds(popCmdName); |
|
186 // Accesses the entry for the specified Pop Service Id. |
|
187 CMsvEntry* entry = iSharedDataPOP.iSession->GetEntryL(popServiceId); //base Class Member iSession |
|
188 entry->SetEntryL(popServiceId); |
|
189 CleanupStack::PushL(entry); |
|
190 |
|
191 // Create a selection of the children entries |
|
192 CMsvEntrySelection* selection = entry->ChildrenL(); |
|
193 CleanupStack::PushL(selection); |
|
194 |
|
195 |
|
196 //setting the max email size and populationlimit to the values read from the ini file |
|
197 iMailInfo.SetMaxEmailSize(static_cast<TInt32>(maxEmailSize)); |
|
198 iMailInfo.SetPopulationLimit(static_cast<TInt32>(popLimit)); |
|
199 |
|
200 TPop3MailInfoBuf pack(iMailInfo); |
|
201 selection->InsertL(0, popServiceId); |
|
202 |
|
203 CT_MsgActive& active=Active(); |
|
204 iOperation = iSharedDataPOP.iMtm->InvokeAsyncFunctionL( popCommand, |
|
205 *selection, pack, active.iStatus ); //base Class Member iMtm, waiter |
|
206 active.Activate(); |
|
207 CActiveScheduler::Start(); |
|
208 |
|
209 // Get the error code from TPop3Progress |
|
210 TPop3Progress temp; |
|
211 TPckgC<TPop3Progress> paramPack(temp); |
|
212 paramPack.Set(iOperation->ProgressL()); |
|
213 TPop3Progress progress=paramPack(); |
|
214 SetTestStepError(progress.iErrorCode); |
|
215 |
|
216 delete iOperation; |
|
217 iOperation=NULL; |
|
218 CleanupStack::PopAndDestroy(2,entry); // operation,selection,entry |
|
219 User::LeaveIfError(active.Result()); |
|
220 } |
|
221 } |
|
222 return TestStepResult(); |
|
223 } |