|
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 // |
|
15 |
|
16 /** |
|
17 @file |
|
18 @internalTechnology |
|
19 */ |
|
20 |
|
21 |
|
22 // User include |
|
23 #include "CMtfDoInvokeAsyncFunctionTestAction.h" |
|
24 #include "CMtfTestCase.h" |
|
25 #include "CMtfTestActionParameters.h" |
|
26 #include "TMtfTestParameterType.h" |
|
27 #include "MtfTestActionUtilsUser.h" |
|
28 |
|
29 |
|
30 /** |
|
31 Constructor |
|
32 */ |
|
33 CMtfDoInvokeAsyncFunctionTestAction::CMtfDoInvokeAsyncFunctionTestAction |
|
34 (CMtfTestCase& aTestCase) |
|
35 : CMtfTestAction(aTestCase), iOperation(NULL) |
|
36 { |
|
37 } |
|
38 |
|
39 |
|
40 /** |
|
41 DoCancel |
|
42 Cancels the pending asynchronous operation |
|
43 */ |
|
44 void CMtfDoInvokeAsyncFunctionTestAction::DoCancel() |
|
45 { |
|
46 iOperation->Cancel(); |
|
47 delete iOperation; |
|
48 iOperation = NULL; |
|
49 } |
|
50 |
|
51 |
|
52 /** |
|
53 InvokeAsyncImap4PopulateCommandL |
|
54 Invokes asynchronous IMAP4-specific operation by calling |
|
55 CImap4ClientMtm::InvokeAsyncFunctionL() for the IMAP4 command |
|
56 provided as a input parameter. |
|
57 @internalTechnology |
|
58 @param aImap4Mtm Reference to the IMAP4 Mtm |
|
59 @param aImap4Command IMAP4-specific command |
|
60 @param aMailSelection Reference to the Mail selection |
|
61 @param aDownloadLimits The CMtfTestParameter object holding a pointer of full |
|
62 or partial download limits |
|
63 @pre None |
|
64 @post The asynchronous operation for the IMAP4 command is initiated |
|
65 @leave KErrUnknown If download limits provided is not of type |
|
66 TImImap4GetMailInfo or TImImap4GetPartialMailInfo |
|
67 */ |
|
68 void CMtfDoInvokeAsyncFunctionTestAction::InvokeAsyncImap4PopulateCommandL |
|
69 ( |
|
70 TImap4Cmds aImap4Command, |
|
71 CMsvEntrySelection& aMailSelection |
|
72 ) |
|
73 { |
|
74 /* Set the status to Request Pending before calling the asynchronous |
|
75 function. |
|
76 */ |
|
77 iStatus = KRequestPending; |
|
78 |
|
79 // Obtain input parameter IMAP4 Mtm |
|
80 CImap4ClientMtm* paramMtm = ObtainParameterReferenceL<CImap4ClientMtm> |
|
81 (TestCase(),ActionParameters().Parameter(1)); |
|
82 |
|
83 |
|
84 /********************************************************************* |
|
85 Get the download limits package. The download limits can be of type |
|
86 TImImap4GetMailInfo or TImImap4GetPartialMailInfo. Hence, |
|
87 TestCase.ObtainParameter() is called directly to get the reference to |
|
88 CMtfTestParameter object that stores the type and the address of the |
|
89 download limits that is set. The download limits object is retrieved |
|
90 from the CMtfTestParameter object. |
|
91 **********************************************************************/ |
|
92 |
|
93 const CMtfTestParameter& paramDownloadLimits = TestCase().ObtainParameterL |
|
94 (ActionParameters().Parameter(2)); |
|
95 |
|
96 |
|
97 /************************************************************************* |
|
98 Check if the download limits is of type Full download or Partial download. |
|
99 If it is one of the above 2 types, package the download limits object and |
|
100 pass it to InvokeAsyncFunctionL(). If the type does not match, Leave with |
|
101 error KErrUnknown. |
|
102 *************************************************************************/ |
|
103 |
|
104 /************************************************************************* |
|
105 The CMtfTestParameter stores the TImImap4GetMailInfo or |
|
106 TImImap4GetPartialMailInfo object. To get the object from |
|
107 CMtfTestParameter, the packaged object needs to be unpacked. This operation |
|
108 is usually done in the ObtainValueParameterL(), but we need to perform |
|
109 this operation explicilty as we are retrieving the CMtfTestParameter itself, |
|
110 insted of the specific type of the parameter stored in CMTfTestParameter. |
|
111 ***************************************************************************/ |
|
112 HBufC8* buf=reinterpret_cast<HBufC8*>(paramDownloadLimits.Parameter()); |
|
113 |
|
114 if(paramDownloadLimits.SpecificTypeId() == EMtfTImImap4GetMailInfo) |
|
115 { |
|
116 // Get Full download limits |
|
117 TImImap4GetMailInfo value; |
|
118 TPckgC<TImImap4GetMailInfo> unpack(value); |
|
119 unpack.Set(*buf); |
|
120 TImImap4GetMailInfo fullDownloadLimits = unpack(); |
|
121 |
|
122 // Package of the download limits |
|
123 TPckgBuf<TImImap4GetMailInfo> fullPack (fullDownloadLimits); |
|
124 |
|
125 // Invokes asynchronous IMAP4-specific operation |
|
126 iOperation = paramMtm->InvokeAsyncFunctionL(aImap4Command,aMailSelection, |
|
127 fullPack,iStatus); |
|
128 } |
|
129 else if(paramDownloadLimits.SpecificTypeId() == EMtfTImImap4GetPartialMailInfo) |
|
130 { |
|
131 // Get Parital download limits |
|
132 TImImap4GetPartialMailInfo value; |
|
133 TPckgC<TImImap4GetPartialMailInfo> unpack(value); |
|
134 unpack.Set(*buf); |
|
135 TImImap4GetPartialMailInfo partialDownloadLimits = unpack(); |
|
136 |
|
137 // Package of the download limits |
|
138 TPckgBuf<TImImap4GetPartialMailInfo> partialPack(partialDownloadLimits); |
|
139 |
|
140 // Invokes asynchronous IMAP4-specific operation |
|
141 iOperation = paramMtm->InvokeAsyncFunctionL( aImap4Command, aMailSelection, |
|
142 partialPack, iStatus); |
|
143 } |
|
144 else |
|
145 { |
|
146 // The type of the input parameter does not match |
|
147 User::Leave(KErrUnknown); |
|
148 } |
|
149 |
|
150 CActiveScheduler::Add(this); |
|
151 SetActive(); |
|
152 } |
|
153 |
|
154 /** |
|
155 RunL |
|
156 Handles the asynchronous request completion event. Informs the completion |
|
157 of the Test Action to the Test Case. |
|
158 @internalTechnology |
|
159 @pre None |
|
160 @post None |
|
161 @leave System wide error |
|
162 */ |
|
163 void CMtfDoInvokeAsyncFunctionTestAction::RunL() |
|
164 { |
|
165 TInt err = MtfTestActionUtilsUser::FinalProgressStatus(*iOperation,iStatus); |
|
166 User::LeaveIfError(err); |
|
167 |
|
168 delete iOperation; |
|
169 iOperation = NULL; |
|
170 |
|
171 TestCase().ActionCompletedL(*this); |
|
172 } |