63
|
1 |
/*
|
|
2 |
* Copyright (c) 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: Active object that reads all the contacts/groups from vpbk
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
#ifndef C_PCS_CONTACT_STORE_H
|
|
20 |
#define C_PCS_CONTACT_STORE_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 <MVPbkContactFindFromStoresObserver.h>
|
|
29 |
#include <MVPbkSingleContactOperationObserver.h>
|
|
30 |
#include <MVPbkContactViewObserver.h>
|
|
31 |
#include <CVPbkContactManager.h>
|
|
32 |
|
|
33 |
// USER INCLUDES
|
|
34 |
#include "mdatastoreobserver.h"
|
|
35 |
#include "PSContactsAdapterInternalCRKeys.h"
|
|
36 |
|
|
37 |
// FORWARD DECLARATIONS
|
|
38 |
class CPsData;
|
|
39 |
class CVPbkContactManager;
|
|
40 |
class CVPbkContactLinkArray;
|
|
41 |
class MVPbkContactOperationBase;
|
|
42 |
class MVPbkBaseContact;
|
|
43 |
class CVPbkFieldTypeRefsList;
|
|
44 |
class MVPbkContactViewObserver;
|
|
45 |
class CPbk2SortOrderManager;
|
|
46 |
|
|
47 |
/**
|
|
48 |
* States involved in fetching the contacts
|
|
49 |
*/
|
|
50 |
enum
|
|
51 |
{
|
|
52 |
ECreateView,
|
|
53 |
EFetchAllLinks,
|
|
54 |
EFetchContactBlock,
|
|
55 |
EComplete
|
|
56 |
};
|
|
57 |
|
|
58 |
/**
|
|
59 |
* This class represents the data store for the contacts
|
|
60 |
* Each data store (phonecontacts, simcontact, group contacts) is an
|
|
61 |
* instance of this class
|
|
62 |
* @lib pscontactsadapter.lib
|
|
63 |
*/
|
|
64 |
class CPcsContactStore: public CActive,
|
|
65 |
public MVPbkSingleContactOperationObserver,
|
|
66 |
public MVPbkContactViewObserver
|
|
67 |
|
|
68 |
{
|
|
69 |
public:
|
|
70 |
|
|
71 |
/**
|
|
72 |
* 2 phase construction
|
|
73 |
* @param aContactManager - the contact manager
|
|
74 |
* @param aObserver - observer for receiving data
|
|
75 |
* @param aUri - the data store uri
|
|
76 |
* @return returns pointer to the constructed object of type CPcsContactStore
|
|
77 |
*/
|
|
78 |
static CPcsContactStore* NewL(CVPbkContactManager& aContactManager,
|
|
79 |
MDataStoreObserver& aObserver,
|
|
80 |
const TDesC& aUri);
|
|
81 |
|
|
82 |
/**
|
|
83 |
* Destructor
|
|
84 |
*/
|
|
85 |
virtual ~CPcsContactStore();
|
|
86 |
|
|
87 |
/**
|
|
88 |
* Handles store events (contact/group addition/modification/deletion etc.)
|
|
89 |
* @param aContactStore - the contact store
|
|
90 |
* @param aStoreEvent - store event
|
|
91 |
*/
|
|
92 |
void HandleStoreEventL(MVPbkContactStore& aContactStore,
|
|
93 |
TVPbkContactStoreEvent aStoreEvent);
|
|
94 |
|
|
95 |
/**
|
|
96 |
* Gets the store Uri
|
|
97 |
* @return - the store uri supported by this instance
|
|
98 |
*/
|
|
99 |
TDesC& GetStoreUri();
|
|
100 |
|
|
101 |
public:
|
|
102 |
|
|
103 |
// From base class MVPbkSingleContactOperationObserver
|
|
104 |
|
|
105 |
/**
|
|
106 |
* From MVPbkSingleContactOperationObserver
|
|
107 |
* Called when operation is completed.
|
|
108 |
*
|
|
109 |
* @param aOperation the completed operation.
|
|
110 |
* @param aContact the contact returned by the operation.
|
|
111 |
* Client must take the ownership immediately.
|
|
112 |
*
|
|
113 |
* !!! NOTICE !!!
|
|
114 |
* If you use Cleanupstack for MVPbkStoreContact
|
|
115 |
* Use MVPbkStoreContact::PushL or
|
|
116 |
* CleanupDeletePushL from e32base.h.
|
|
117 |
* (Do Not Use CleanupStack::PushL(TAny*) because
|
|
118 |
* then the virtual destructor of the M-class
|
|
119 |
* won't be called when the object is deleted).
|
|
120 |
*/
|
|
121 |
void VPbkSingleContactOperationComplete(
|
|
122 |
MVPbkContactOperationBase& aOperation,
|
|
123 |
MVPbkStoreContact* aContact );
|
|
124 |
|
|
125 |
/**
|
|
126 |
* From MVPbkSingleContactOperationObserver
|
|
127 |
* Called if the operation fails.
|
|
128 |
*
|
|
129 |
* @param aOperation the failed operation.
|
|
130 |
* @param aError error code of the failure.
|
|
131 |
*/
|
|
132 |
void VPbkSingleContactOperationFailed(
|
|
133 |
MVPbkContactOperationBase& aOperation,
|
|
134 |
TInt aError );
|
|
135 |
|
|
136 |
public :
|
|
137 |
|
|
138 |
// From base class MVPbkContactViewObserver
|
|
139 |
|
|
140 |
void ContactViewReady(
|
|
141 |
MVPbkContactViewBase& aView );
|
|
142 |
|
|
143 |
void ContactViewUnavailable(
|
|
144 |
MVPbkContactViewBase& aView );
|
|
145 |
|
|
146 |
void ContactAddedToView(
|
|
147 |
MVPbkContactViewBase& aView,
|
|
148 |
TInt aIndex,
|
|
149 |
const MVPbkContactLink& aContactLink );
|
|
150 |
|
|
151 |
void ContactRemovedFromView(
|
|
152 |
MVPbkContactViewBase& aView,
|
|
153 |
TInt aIndex,
|
|
154 |
const MVPbkContactLink& aContactLink );
|
|
155 |
|
|
156 |
void ContactViewError(
|
|
157 |
MVPbkContactViewBase& aView,
|
|
158 |
TInt aError,
|
|
159 |
TBool aErrorNotified );
|
|
160 |
|
|
161 |
protected:
|
|
162 |
|
|
163 |
// From base class CActive
|
|
164 |
|
|
165 |
/**
|
|
166 |
* From CActive
|
|
167 |
* Implements cancellation of an outstanding request.
|
|
168 |
*
|
|
169 |
* This function is called as part of the active object's Cancel().
|
|
170 |
*/
|
|
171 |
void DoCancel();
|
|
172 |
|
|
173 |
/**
|
|
174 |
* From CActive
|
|
175 |
* Handles an active object's request completion event.
|
|
176 |
*
|
|
177 |
* The function is called by the active scheduler when a request
|
|
178 |
* completion event occurs, i.e. after the active scheduler's
|
|
179 |
* WaitForAnyRequest() function completes.
|
|
180 |
*
|
|
181 |
* Before calling this active object's RunL() function, the active scheduler
|
|
182 |
* has:
|
|
183 |
*
|
|
184 |
* 1. decided that this is the highest priority active object with
|
|
185 |
* a completed request
|
|
186 |
*
|
|
187 |
* 2. marked this active object's request as complete (i.e. the request is no
|
|
188 |
* longer outstanding)
|
|
189 |
*
|
|
190 |
* RunL() runs under a trap harness in the active scheduler. If it leaves,
|
|
191 |
* then the active scheduler calls RunError() to handle the leave.
|
|
192 |
*
|
|
193 |
* Note that once the active scheduler's Start() function has been called,
|
|
194 |
* all user code is run under one of the program's active object's RunL() or
|
|
195 |
* RunError() functions.
|
|
196 |
*/
|
|
197 |
void RunL();
|
|
198 |
|
|
199 |
/**
|
|
200 |
* From CActive
|
|
201 |
* If the RunL function leaves,
|
|
202 |
* then the active scheduler calls RunError() to handle the leave.
|
|
203 |
* @param aError - The error code
|
|
204 |
*/
|
|
205 |
TInt RunError( TInt aError );
|
|
206 |
|
|
207 |
private:
|
|
208 |
|
|
209 |
/**
|
|
210 |
* Constructor
|
|
211 |
*/
|
|
212 |
CPcsContactStore();
|
|
213 |
|
|
214 |
/**
|
|
215 |
* 2nd phase constructor
|
|
216 |
*/
|
|
217 |
void ConstructL(CVPbkContactManager& aContactManager, MDataStoreObserver& aObserver,const TDesC& aUri);
|
|
218 |
|
|
219 |
/**
|
|
220 |
* Check next state of state machine for contacts retrieval and perform transition
|
|
221 |
*/
|
|
222 |
void CheckNextState();
|
|
223 |
|
|
224 |
/**
|
|
225 |
* Handles the operations for a single contact after it is fetched
|
|
226 |
* @param aContact - The contact from database
|
|
227 |
*/
|
|
228 |
void HandleRetrievedContactL(MVPbkStoreContact* aContact);
|
|
229 |
|
|
230 |
/**
|
|
231 |
* Fetches the data from a particular contact
|
|
232 |
* @param aContact - The contact from database
|
|
233 |
*
|
|
234 |
*/
|
|
235 |
void GetDataForSingleContactL ( MVPbkBaseContact& aContact, CPsData* aPhoneData );
|
|
236 |
|
|
237 |
/**
|
|
238 |
* Add the data from contact fields
|
|
239 |
* @param aContact - The contact from database
|
|
240 |
* @param afieldtype - Field to be added
|
|
241 |
* @param aPhoneData - the contact data in PS format
|
|
242 |
*/
|
|
243 |
void AddContactFieldsL(MVPbkBaseContact& aContact, TInt afieldtype, CPsData* aPhoneData);
|
|
244 |
|
|
245 |
/**
|
|
246 |
* Fetches the data from contact links from the view
|
|
247 |
*/
|
|
248 |
void FetchAllInitialContactLinksL();
|
|
249 |
void FetchContactsBlockL();
|
|
250 |
|
|
251 |
/**
|
|
252 |
* Reads the fields to cache from the central repository
|
|
253 |
*/
|
|
254 |
void ReadFieldsToCacheFromCenrepL();
|
|
255 |
|
|
256 |
/**
|
|
257 |
* Creates a cacheId corresponding to sim Id Array Index
|
|
258 |
* @param - aSimId - The sim id
|
|
259 |
*/
|
|
260 |
TInt CreateCacheIDfromSimArrayIndex(TInt aSimId);
|
|
261 |
|
|
262 |
/**
|
|
263 |
* Creates the contact fetch view
|
|
264 |
*/
|
|
265 |
void CreateContactFetchViewL();
|
|
266 |
|
|
267 |
/**
|
|
268 |
* Issues request to active object to call RunL method
|
|
269 |
*/
|
|
270 |
void IssueRequest( TInt aTimeDelay );
|
|
271 |
|
|
272 |
/**
|
|
273 |
* Creates a sort order depending on the fields specified in the cenrep
|
|
274 |
* @param aMasterList - aMasterList (i.e list containing all the vpbk fields)
|
|
275 |
*/
|
|
276 |
void CreateSortOrderL(const MVPbkFieldTypeList& aMasterList);
|
|
277 |
|
|
278 |
/**
|
|
279 |
* Checks if contact is my card
|
|
280 |
*/
|
|
281 |
TBool IsMyCard( const MVPbkBaseContact& aContact );
|
|
282 |
|
|
283 |
private:
|
|
284 |
|
|
285 |
RPointerArray<MVPbkContactLink> iInitialContactLinks;
|
|
286 |
|
|
287 |
/**
|
|
288 |
* Flags for store operations
|
|
289 |
*/
|
|
290 |
TInt iInitialContactCount; // Initial contact count in a view
|
|
291 |
TInt iFetchBlockLowerNumber;
|
|
292 |
TInt iFetchBlockUpperNumber;
|
|
293 |
TInt iVPbkCallbackCount;
|
|
294 |
TBool iContactViewReady;
|
|
295 |
TCachingStatus iOngoingCacheUpdate;
|
|
296 |
|
|
297 |
/**
|
|
298 |
* Variable to store the next state for the RunL to take appropriate action
|
|
299 |
*/
|
|
300 |
TInt iNextState;
|
|
301 |
|
|
302 |
/**
|
|
303 |
* The contact manager for accessing the phone contacts
|
|
304 |
* Not Own.
|
|
305 |
*/
|
|
306 |
CVPbkContactManager* iContactManager;
|
|
307 |
|
|
308 |
/**
|
|
309 |
* Holds a view base instance
|
|
310 |
* Own.
|
|
311 |
*/
|
|
312 |
MVPbkContactViewBase* iContactViewBase;
|
|
313 |
|
|
314 |
/**
|
|
315 |
* Holds a contact operation
|
|
316 |
* Own.
|
|
317 |
*/
|
|
318 |
MVPbkContactOperationBase* iOp;
|
|
319 |
|
|
320 |
/**
|
|
321 |
* Owns an instance of active scheduler wait
|
|
322 |
*/
|
|
323 |
CActiveSchedulerWait *iWait;
|
|
324 |
|
|
325 |
/**
|
|
326 |
* data fields to be cached(read from the central repository)
|
|
327 |
*/
|
|
328 |
RArray<TInt> iFieldsToCache;
|
|
329 |
|
|
330 |
/**
|
|
331 |
* Array of contact links
|
|
332 |
*/
|
|
333 |
CVPbkContactLinkArray *iSimContactItems;
|
|
334 |
|
|
335 |
/**
|
|
336 |
* Holds the observer object to communicate add/modify/delete of contacts
|
|
337 |
* Not owned.
|
|
338 |
*/
|
|
339 |
MDataStoreObserver* iObserver;
|
|
340 |
|
|
341 |
/**
|
|
342 |
* Contacts Database URI
|
|
343 |
*/
|
|
344 |
HBufC* iUri;
|
|
345 |
|
|
346 |
/**
|
|
347 |
* File session
|
|
348 |
*/
|
|
349 |
RFs iFs;
|
|
350 |
|
|
351 |
/**
|
|
352 |
* RTimer variable to set the timer before RunL calls any function.
|
|
353 |
* This is required to allow other threads to run since contact fetch
|
|
354 |
* is CPU intensive task.
|
|
355 |
*/
|
|
356 |
RTimer iTimer;
|
|
357 |
|
|
358 |
/**
|
|
359 |
* Holds the sort order fields
|
|
360 |
*/
|
|
361 |
CVPbkFieldTypeRefsList *iSortOrder;
|
|
362 |
|
|
363 |
/**
|
|
364 |
* Holds MyCard supported status
|
|
365 |
*/
|
|
366 |
TBool iMyCardSupported;
|
|
367 |
|
|
368 |
/**
|
|
369 |
* Own. Sort order for all contacts view
|
|
370 |
*/
|
|
371 |
CPbk2SortOrderManager* iSortOrderMan;
|
|
372 |
};
|
|
373 |
|
|
374 |
#endif // C_PCS_CONTACT_STORE_H
|