|
1 /* |
|
2 * Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Contacts handler for client API test suite |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef C_PHONE_CONTACTS_FETCHER_H |
|
20 #define C_PHONE_CONTACTS_FETCHER_H |
|
21 |
|
22 //SYSTEM INCLUDES |
|
23 #include <f32file.h> |
|
24 #include <badesca.h> |
|
25 #include <e32std.h> |
|
26 #include <e32cmn.h> |
|
27 #include <mvpbkcontactstorelistobserver.h> |
|
28 #include <MVPbkContactObserver.h> |
|
29 #include <MVPbkBatchOperationObserver.h> |
|
30 #include <CPSRequestHandler.h> |
|
31 #include<eikenv.h> |
|
32 #include<coemain.h> |
|
33 |
|
34 //USER INCLUDES |
|
35 #include "psclienttestsuitedefs.h" |
|
36 |
|
37 // FORWARD DECLARATIONS |
|
38 class CVPbkContactManager; |
|
39 class CVPbkContactStoreUriArray; |
|
40 class CVPbkContactLinkArray; |
|
41 class MVPbkContactOperationBase; |
|
42 class MVPbkContactLinkArray; |
|
43 class MVPbkBaseContact; |
|
44 class CVPbkFieldTypeRefsList; |
|
45 |
|
46 /** |
|
47 * This class performs all the operation related to the virtual phonebook |
|
48 * |
|
49 * @since S60 v3.2 |
|
50 */ |
|
51 class CPcsTestContactsHandler: public CActive, |
|
52 public MVPbkContactStoreListObserver , |
|
53 public MVPbkContactObserver, |
|
54 public MVPbkBatchOperationObserver |
|
55 { |
|
56 public: |
|
57 |
|
58 /** |
|
59 * 1st phase constructor |
|
60 * |
|
61 * @return returns pointer to the constructed object of type CPcsContactFetch |
|
62 */ |
|
63 static CPcsTestContactsHandler* NewL(TBool SimStoreOnly=EFalse); |
|
64 |
|
65 /** |
|
66 * Destructor |
|
67 * |
|
68 */ |
|
69 virtual ~CPcsTestContactsHandler(); |
|
70 |
|
71 public: |
|
72 |
|
73 //From CActive |
|
74 /** |
|
75 * From CActive |
|
76 * Implements cancellation of an outstanding request. |
|
77 * |
|
78 * This function is called as part of the active object's Cancel(). |
|
79 */ |
|
80 void DoCancel(); |
|
81 |
|
82 |
|
83 /** |
|
84 * From CActive |
|
85 * Handles an active object's request completion event. |
|
86 * |
|
87 * The function is called by the active scheduler when a request |
|
88 * completion event occurs, i.e. after the active scheduler's |
|
89 * WaitForAnyRequest() function completes. |
|
90 * |
|
91 * Before calling this active object's RunL() function, the active scheduler |
|
92 * has: |
|
93 * |
|
94 * 1. decided that this is the highest priority active object with |
|
95 * a completed request |
|
96 * |
|
97 * 2. marked this active object's request as complete (i.e. the request is no |
|
98 * longer outstanding) |
|
99 * |
|
100 * RunL() runs under a trap harness in the active scheduler. If it leaves, |
|
101 * then the active scheduler calls RunError() to handle the leave. |
|
102 * |
|
103 * Note that once the active scheduler's Start() function has been called, |
|
104 * all user code is run under one of the program's active object's RunL() or |
|
105 * RunError() functions. |
|
106 */ |
|
107 void RunL() ; |
|
108 |
|
109 |
|
110 /** |
|
111 * From CActive |
|
112 * If the RunL function leaves, |
|
113 * then the active scheduler calls RunError() to handle the leave. |
|
114 * @param aError - The error code |
|
115 */ |
|
116 TInt RunError(TInt aError) ; |
|
117 |
|
118 |
|
119 // From base class MVPbkContactStoreListObserver |
|
120 |
|
121 /** |
|
122 * From MVPbkContactStoreListObserver |
|
123 * Called when the opening process is complete, ie. all stores have been reported |
|
124 * either failed or successfully opened. |
|
125 * |
|
126 */ |
|
127 void OpenComplete(); |
|
128 |
|
129 /** |
|
130 * From MVPbkContactStoreListObserver |
|
131 * Called when a contact store is ready to use. |
|
132 */ |
|
133 void StoreReady(MVPbkContactStore& aContactStore); |
|
134 |
|
135 /** |
|
136 * From MVPbkContactStoreListObserver |
|
137 * Called when a contact store becomes unavailable. |
|
138 * Client may inspect the reason of the unavailability and decide whether or not |
|
139 * it will keep the store opened (ie. listen to the store events). |
|
140 * |
|
141 * @param aContactStore The store that became unavailable. |
|
142 * @param aReason - The reason why the store is unavailable. |
|
143 * This is one of the system wide error codes. |
|
144 */ |
|
145 void StoreUnavailable(MVPbkContactStore& aContactStore, TInt aReason); |
|
146 |
|
147 /** |
|
148 * From MVPbkContactStoreListObserver |
|
149 * Called when changes occur in the contact store. |
|
150 * @see TVPbkContactStoreEvent |
|
151 * |
|
152 * @param aContactStore The store the event occurred in. |
|
153 * @param aStoreEvent Event that has occured. |
|
154 */ |
|
155 void HandleStoreEventL(MVPbkContactStore& aContactStore, TVPbkContactStoreEvent aStoreEvent); |
|
156 |
|
157 /** |
|
158 * From MVPbkContactObserver |
|
159 * Called when a contact operation has succesfully completed. |
|
160 * |
|
161 * @param aResult The result of the operation. |
|
162 */ |
|
163 void ContactOperationCompleted(TContactOpResult aResult); |
|
164 |
|
165 /** |
|
166 * From MVPbkContactObserver |
|
167 * Called when a contact operation has failed. |
|
168 * |
|
169 * @param aOpCode The operation that failed. |
|
170 * @param aErrorCode System error code of the failure. |
|
171 * KErrAccessDenied when EContactCommit |
|
172 * means that contact hasn't been locked. |
|
173 * @param aErrorNotified ETrue if the implementation has already |
|
174 * notified user about the error, |
|
175 * EFalse otherwise. |
|
176 */ |
|
177 void ContactOperationFailed(TContactOp aOpCode, TInt aErrorCode, TBool aErrorNotified); |
|
178 |
|
179 /** |
|
180 * From MVPbkBatchOperationObserver |
|
181 * Called when one step of the operation is completed. |
|
182 * |
|
183 * @param aOperation Operation whose step has completed |
|
184 * @param aStepSize Size of the performed step |
|
185 */ |
|
186 void StepComplete(MVPbkContactOperationBase& aOperation, TInt aStepSize ); |
|
187 |
|
188 |
|
189 // From MVPbkBatchOperationObserver |
|
190 /** |
|
191 * From MVPbkBatchOperationObserver |
|
192 * Called when one step of the operation fails. |
|
193 * |
|
194 * @param aOperation Operation whose step has failed |
|
195 * @param aStepSize Size of the performed step |
|
196 * @param aError Error that occured |
|
197 * @return ETrue if the batch operation should continue, |
|
198 * EFalse otherwise |
|
199 * NOTE! If returning ETrue the operation can NOT be deleted. |
|
200 * Operation should be deleted in OperationCompleted() |
|
201 * function. |
|
202 * If returning EFalse the operation can be deleted |
|
203 * safely. |
|
204 */ |
|
205 TBool StepFailed(MVPbkContactOperationBase& aOperation, TInt aStepSize, TInt aError ); |
|
206 |
|
207 /** |
|
208 * From MVPbkBatchOperationObserver |
|
209 * Called when operation is completed. |
|
210 * This is called when all steps are executed. If EFalse is returned |
|
211 * in StepFailed() call this function is NOT called. |
|
212 * |
|
213 * @param aOperation the completed operation |
|
214 */ |
|
215 void OperationComplete(MVPbkContactOperationBase& aOperation ); |
|
216 |
|
217 public: |
|
218 |
|
219 /** |
|
220 * Creates one contact in the phonebook |
|
221 * |
|
222 * @param aInputCacheData - The contacts data |
|
223 */ |
|
224 void CreateOneContactL(cacheData& aInputCacheData); |
|
225 |
|
226 /** |
|
227 * Deletes one contact in the phonebook |
|
228 * |
|
229 * @param aContactId - The contact id to be deleted |
|
230 */ |
|
231 void DeleteOneContactL(TInt aContactId); |
|
232 |
|
233 /** |
|
234 * Deletes all the contacts from the phonebook |
|
235 * |
|
236 */ |
|
237 void DeleteAllCreatedContactsL(); |
|
238 |
|
239 |
|
240 /** |
|
241 * Adds a group to the phonebook |
|
242 * |
|
243 */ |
|
244 void AddGroupL(const TDesC& aGroupName); |
|
245 |
|
246 |
|
247 /** |
|
248 * Deletes contacts from the phonebook |
|
249 * |
|
250 * @param aContactIdArray - The array of contact ids to be deleted |
|
251 */ |
|
252 void DeleteContactsWithIdsL(RArray<TInt>& aContactIdArray); |
|
253 |
|
254 /** |
|
255 * Tests if Id returns correct vpbklink |
|
256 * |
|
257 * @param aPsClientHandler - PsClientHandler instance |
|
258 * @param srchId - Id to be tested\ |
|
259 * @return - ETrue if Id returns correct link, else EFalse |
|
260 */ |
|
261 TBool TestVpbkLinkForIdL(CPSRequestHandler& aPsClientHandler, |
|
262 const CPsClientData& aSearchResult); |
|
263 /** |
|
264 * Adds contacts to the group |
|
265 * |
|
266 */ |
|
267 |
|
268 void AddCreatedContactsToGroup(); |
|
269 private: |
|
270 /** |
|
271 * Constructor |
|
272 * |
|
273 */ |
|
274 CPcsTestContactsHandler(); |
|
275 |
|
276 /** |
|
277 * 2nd phase constructor |
|
278 * |
|
279 * @param SimStoreOnly |
|
280 */ |
|
281 void ConstructL(TBool SimStoreOnly=EFalse); |
|
282 |
|
283 /** |
|
284 * Stop mail scheduler if all stop conditions are fulfilled |
|
285 */ |
|
286 void StopSchedulerIfNothingToWaitFor(); |
|
287 |
|
288 private: // Data |
|
289 |
|
290 // Flags for store operations |
|
291 TBool iAtLeastOneStoreReady; |
|
292 TBool iOpenComplete; |
|
293 TBool iOperationComplete; |
|
294 |
|
295 /* |
|
296 * The contact manager |
|
297 */ |
|
298 CVPbkContactManager* iContactManager; |
|
299 |
|
300 /* |
|
301 * The store contact |
|
302 */ |
|
303 MVPbkStoreContact* iStoreContact; |
|
304 |
|
305 /* |
|
306 * The contact store |
|
307 */ |
|
308 MVPbkContactStore* iStore; |
|
309 |
|
310 /* |
|
311 * The field type reference list |
|
312 */ |
|
313 CVPbkFieldTypeRefsList* fieldTypeRefList; |
|
314 |
|
315 |
|
316 /* |
|
317 * The array of contactlinks to be deleted |
|
318 */ |
|
319 CVPbkContactLinkArray* iContactLinksToDelete; |
|
320 |
|
321 /* |
|
322 * The contact operation base |
|
323 */ |
|
324 MVPbkContactOperationBase* iOp; |
|
325 |
|
326 /* |
|
327 * The array of contact links of the created contacts |
|
328 */ |
|
329 CVPbkContactLinkArray *iContactsCreatedLinks; |
|
330 CVPbkContactLinkArray * iContactLinksToAddToGroup; |
|
331 |
|
332 /* |
|
333 * The contact group being added |
|
334 */ |
|
335 MVPbkContactGroup* iGroupAdded; |
|
336 |
|
337 /* |
|
338 * The Active scheduler wait |
|
339 */ |
|
340 CActiveSchedulerWait* iWait; |
|
341 |
|
342 /* |
|
343 * Test should be ended if store event in this variable didn't come |
|
344 */ |
|
345 TInt iStoreEventToWaitFor;//will be compared to TVPbkContactStoreEvent::TVPbkContactStoreEventType |
|
346 TBool iExpectedStoreEventReceived; |
|
347 |
|
348 }; |
|
349 |
|
350 #endif //C_PHONE_CONTACTS_FETCHER_H |