63
|
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 |
/**
|
|
76 |
* From CActive
|
|
77 |
* Implements cancellation of an outstanding request.
|
|
78 |
*
|
|
79 |
* This function is called as part of the active object's Cancel().
|
|
80 |
*/
|
|
81 |
void DoCancel();
|
|
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 |
* From CActive
|
|
111 |
* If the RunL function leaves,
|
|
112 |
* then the active scheduler calls RunError() to handle the leave.
|
|
113 |
* @param aError - The error code
|
|
114 |
*/
|
|
115 |
TInt RunError(TInt aError) ;
|
|
116 |
|
|
117 |
// From base class MVPbkContactStoreListObserver
|
|
118 |
|
|
119 |
/**
|
|
120 |
* From MVPbkContactStoreListObserver
|
|
121 |
* Called when the opening process is complete, ie. all stores have been reported
|
|
122 |
* either failed or successfully opened.
|
|
123 |
*
|
|
124 |
*/
|
|
125 |
void OpenComplete();
|
|
126 |
|
|
127 |
/**
|
|
128 |
* From MVPbkContactStoreListObserver
|
|
129 |
* Called when a contact store is ready to use.
|
|
130 |
*/
|
|
131 |
void StoreReady(MVPbkContactStore& aContactStore);
|
|
132 |
|
|
133 |
/**
|
|
134 |
* From MVPbkContactStoreListObserver
|
|
135 |
* Called when a contact store becomes unavailable.
|
|
136 |
* Client may inspect the reason of the unavailability and decide whether or not
|
|
137 |
* it will keep the store opened (ie. listen to the store events).
|
|
138 |
*
|
|
139 |
* @param aContactStore The store that became unavailable.
|
|
140 |
* @param aReason - The reason why the store is unavailable.
|
|
141 |
* This is one of the system wide error codes.
|
|
142 |
*/
|
|
143 |
void StoreUnavailable(MVPbkContactStore& aContactStore, TInt aReason);
|
|
144 |
|
|
145 |
/**
|
|
146 |
* From MVPbkContactStoreListObserver
|
|
147 |
* Called when changes occur in the contact store.
|
|
148 |
* @see TVPbkContactStoreEvent
|
|
149 |
*
|
|
150 |
* @param aContactStore The store the event occurred in.
|
|
151 |
* @param aStoreEvent Event that has occured.
|
|
152 |
*/
|
|
153 |
void HandleStoreEventL(MVPbkContactStore& aContactStore, TVPbkContactStoreEvent aStoreEvent);
|
|
154 |
|
|
155 |
/**
|
|
156 |
* From MVPbkContactObserver
|
|
157 |
* Called when a contact operation has succesfully completed.
|
|
158 |
*
|
|
159 |
* @param aResult The result of the operation.
|
|
160 |
*/
|
|
161 |
void ContactOperationCompleted(TContactOpResult aResult);
|
|
162 |
|
|
163 |
/**
|
|
164 |
* From MVPbkContactObserver
|
|
165 |
* Called when a contact operation has failed.
|
|
166 |
*
|
|
167 |
* @param aOpCode The operation that failed.
|
|
168 |
* @param aErrorCode System error code of the failure.
|
|
169 |
* KErrAccessDenied when EContactCommit
|
|
170 |
* means that contact hasn't been locked.
|
|
171 |
* @param aErrorNotified ETrue if the implementation has already
|
|
172 |
* notified user about the error,
|
|
173 |
* EFalse otherwise.
|
|
174 |
*/
|
|
175 |
void ContactOperationFailed(TContactOp aOpCode, TInt aErrorCode, TBool aErrorNotified);
|
|
176 |
|
|
177 |
/**
|
|
178 |
* From MVPbkBatchOperationObserver
|
|
179 |
* Called when one step of the operation is completed.
|
|
180 |
*
|
|
181 |
* @param aOperation Operation whose step has completed
|
|
182 |
* @param aStepSize Size of the performed step
|
|
183 |
*/
|
|
184 |
void StepComplete(MVPbkContactOperationBase& aOperation, TInt aStepSize );
|
|
185 |
|
|
186 |
// From MVPbkBatchOperationObserver
|
|
187 |
|
|
188 |
/**
|
|
189 |
* From MVPbkBatchOperationObserver
|
|
190 |
* Called when one step of the operation fails.
|
|
191 |
*
|
|
192 |
* @param aOperation Operation whose step has failed
|
|
193 |
* @param aStepSize Size of the performed step
|
|
194 |
* @param aError Error that occured
|
|
195 |
* @return ETrue if the batch operation should continue,
|
|
196 |
* EFalse otherwise
|
|
197 |
* NOTE! If returning ETrue the operation can NOT be deleted.
|
|
198 |
* Operation should be deleted in OperationCompleted()
|
|
199 |
* function.
|
|
200 |
* If returning EFalse the operation can be deleted
|
|
201 |
* safely.
|
|
202 |
*/
|
|
203 |
TBool StepFailed(MVPbkContactOperationBase& aOperation, TInt aStepSize, TInt aError );
|
|
204 |
|
|
205 |
/**
|
|
206 |
* From MVPbkBatchOperationObserver
|
|
207 |
* Called when operation is completed.
|
|
208 |
* This is called when all steps are executed. If EFalse is returned
|
|
209 |
* in StepFailed() call this function is NOT called.
|
|
210 |
*
|
|
211 |
* @param aOperation the completed operation
|
|
212 |
*/
|
|
213 |
void OperationComplete(MVPbkContactOperationBase& aOperation );
|
|
214 |
|
|
215 |
public:
|
|
216 |
|
|
217 |
/**
|
|
218 |
* Creates one contact in the phonebook
|
|
219 |
*
|
|
220 |
* @param aInputCacheData - The contacts data
|
|
221 |
*/
|
|
222 |
void CreateOneContactL(cacheData& aInputCacheData);
|
|
223 |
|
|
224 |
/**
|
|
225 |
* Deletes one contact in the phonebook
|
|
226 |
*
|
|
227 |
* @param aContactId - The contact id to be deleted
|
|
228 |
*/
|
|
229 |
void DeleteOneContactL(TInt aContactId);
|
|
230 |
|
|
231 |
/**
|
|
232 |
* Deletes all the contacts from the phonebook
|
|
233 |
*
|
|
234 |
*/
|
|
235 |
void DeleteAllCreatedContactsL();
|
|
236 |
|
|
237 |
/**
|
|
238 |
* Adds a group to the phonebook
|
|
239 |
*
|
|
240 |
*/
|
|
241 |
void AddGroupL(const TDesC& aGroupName);
|
|
242 |
|
|
243 |
/**
|
|
244 |
* Deletes contacts from the phonebook
|
|
245 |
*
|
|
246 |
* @param aContactIdArray - The array of contact ids to be deleted
|
|
247 |
*/
|
|
248 |
void DeleteContactsWithIdsL(RArray<TInt>& aContactIdArray);
|
|
249 |
|
|
250 |
/**
|
|
251 |
* Tests if Id returns correct vpbklink
|
|
252 |
*
|
|
253 |
* @param aPsClientHandler - PsClientHandler instance
|
|
254 |
* @param srchId - Id to be tested\
|
|
255 |
* @return - ETrue if Id returns correct link, else EFalse
|
|
256 |
*/
|
|
257 |
TBool TestVpbkLinkForIdL(CPSRequestHandler& aPsClientHandler,
|
|
258 |
const CPsClientData& aSearchResult);
|
|
259 |
/**
|
|
260 |
* Adds contacts to the group
|
|
261 |
*
|
|
262 |
*/
|
|
263 |
|
|
264 |
void AddCreatedContactsToGroup();
|
|
265 |
|
|
266 |
private:
|
|
267 |
|
|
268 |
/**
|
|
269 |
* Constructor
|
|
270 |
*/
|
|
271 |
CPcsTestContactsHandler();
|
|
272 |
|
|
273 |
/**
|
|
274 |
* 2nd phase constructor
|
|
275 |
*
|
|
276 |
* @param SimStoreOnly
|
|
277 |
*/
|
|
278 |
void ConstructL(TBool SimStoreOnly=EFalse);
|
|
279 |
|
|
280 |
/**
|
|
281 |
* Stop mail scheduler if all stop conditions are fulfilled
|
|
282 |
*/
|
|
283 |
void StopSchedulerIfNothingToWaitFor();
|
|
284 |
|
|
285 |
private: // Data
|
|
286 |
|
|
287 |
// Flags for store operations
|
|
288 |
TBool iAtLeastOneStoreReady;
|
|
289 |
TBool iOpenComplete;
|
|
290 |
TBool iOperationComplete;
|
|
291 |
|
|
292 |
/*
|
|
293 |
* The contact manager
|
|
294 |
*/
|
|
295 |
CVPbkContactManager* iContactManager;
|
|
296 |
|
|
297 |
/*
|
|
298 |
* The store contact
|
|
299 |
*/
|
|
300 |
MVPbkStoreContact* iStoreContact;
|
|
301 |
|
|
302 |
/*
|
|
303 |
* The contact store
|
|
304 |
*/
|
|
305 |
MVPbkContactStore* iStore;
|
|
306 |
|
|
307 |
/*
|
|
308 |
* The field type reference list
|
|
309 |
*/
|
|
310 |
CVPbkFieldTypeRefsList* fieldTypeRefList;
|
|
311 |
|
|
312 |
/*
|
|
313 |
* The array of contactlinks to be deleted
|
|
314 |
*/
|
|
315 |
CVPbkContactLinkArray* iContactLinksToDelete;
|
|
316 |
|
|
317 |
/*
|
|
318 |
* The contact operation base
|
|
319 |
*/
|
|
320 |
MVPbkContactOperationBase* iOp;
|
|
321 |
|
|
322 |
/*
|
|
323 |
* The array of contact links of the created contacts
|
|
324 |
*/
|
|
325 |
CVPbkContactLinkArray *iContactsCreatedLinks;
|
|
326 |
CVPbkContactLinkArray * iContactLinksToAddToGroup;
|
|
327 |
|
|
328 |
/*
|
|
329 |
* The contact group being added
|
|
330 |
*/
|
|
331 |
MVPbkContactGroup* iGroupAdded;
|
|
332 |
|
|
333 |
/*
|
|
334 |
* The Active scheduler wait
|
|
335 |
*/
|
|
336 |
CActiveSchedulerWait* iWait;
|
|
337 |
|
|
338 |
/*
|
|
339 |
* Test should be ended if store event in this variable didn't come
|
|
340 |
*/
|
|
341 |
TInt iStoreEventToWaitFor;//will be compared to TVPbkContactStoreEvent::TVPbkContactStoreEventType
|
|
342 |
TBool iExpectedStoreEventReceived;
|
|
343 |
|
|
344 |
};
|
|
345 |
|
|
346 |
#endif //C_PHONE_CONTACTS_FETCHER_H
|