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 from the database
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
#ifndef C_PCS_CONTACT_FETCH_H
|
|
20 |
#define C_PCS_CONTACT_FETCH_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 |
|
|
31 |
// USER INCLUDES
|
|
32 |
#include "mdatastoreobserver.h"
|
|
33 |
#include "cpcscontactstore.h"
|
|
34 |
#include "PSContactsAdapterInternalCRKeys.h"
|
|
35 |
|
|
36 |
// FORWARD DECLARATIONS
|
|
37 |
class CVPbkContactManager;
|
|
38 |
|
|
39 |
|
|
40 |
/**
|
|
41 |
* This class is the contact fetch class.
|
|
42 |
* This class manages all the data stores defined.
|
|
43 |
* @lib pscontactsadapter.lib
|
|
44 |
*/
|
|
45 |
class CPcsContactFetch: public CActive,
|
|
46 |
public MVPbkContactStoreListObserver
|
|
47 |
|
|
48 |
|
|
49 |
{
|
|
50 |
public:
|
|
51 |
|
|
52 |
/**
|
|
53 |
* 1st phase constructor
|
|
54 |
* @return returns pointer to the constructed object of type CPcsContactFetch
|
|
55 |
*/
|
|
56 |
static CPcsContactFetch* NewL();
|
|
57 |
|
|
58 |
/**
|
|
59 |
* Destructor
|
|
60 |
*/
|
|
61 |
virtual ~CPcsContactFetch();
|
|
62 |
|
|
63 |
public:
|
|
64 |
|
|
65 |
// From base class MVPbkContactStoreListObserver
|
|
66 |
|
|
67 |
/**
|
|
68 |
* From MVPbkContactStoreListObserver
|
|
69 |
* Called when the opening process is complete, ie. all stores have been reported
|
|
70 |
* either failed or successfully opened.
|
|
71 |
*/
|
|
72 |
void OpenComplete();
|
|
73 |
|
|
74 |
/**
|
|
75 |
* From MVPbkContactStoreListObserver
|
|
76 |
* Called when a contact store is ready to use.
|
|
77 |
* @param aContactStore - The store that became available.
|
|
78 |
*/
|
|
79 |
void StoreReady(MVPbkContactStore& aContactStore);
|
|
80 |
|
|
81 |
/**
|
|
82 |
* From MVPbkContactStoreListObserver
|
|
83 |
* Called when a contact store becomes unavailable.
|
|
84 |
* Client may inspect the reason of the unavailability and decide whether or not
|
|
85 |
* it will keep the store opened (ie. listen to the store events).
|
|
86 |
* @param aContactStore - The store that became unavailable.
|
|
87 |
* @param aReason - The reason why the store is unavailable.
|
|
88 |
* This is one of the system wide error codes.
|
|
89 |
*/
|
|
90 |
void StoreUnavailable(MVPbkContactStore& aContactStore, TInt aReason);
|
|
91 |
|
|
92 |
/**
|
|
93 |
* From MVPbkContactStoreListObserver
|
|
94 |
* Called when changes occur in the contact store i.e contact
|
|
95 |
* added/deleted, group added/deleted etc.
|
|
96 |
* @see TVPbkContactStoreEvent
|
|
97 |
* @param aContactStore - The store the event occurred in.
|
|
98 |
* @param aStoreEvent - Event that has occured.
|
|
99 |
*/
|
|
100 |
void HandleStoreEventL(
|
|
101 |
MVPbkContactStore& aContactStore,
|
|
102 |
TVPbkContactStoreEvent aStoreEvent);
|
|
103 |
|
|
104 |
public:
|
|
105 |
/**
|
|
106 |
* Gets the supported data stores URIs
|
|
107 |
* @param aDataStoresURIs supported data stores URIs
|
|
108 |
*/
|
|
109 |
void GetSupportedDataStoresL( RPointerArray<TDesC> &aDataStoresURIs );
|
|
110 |
|
|
111 |
/**
|
|
112 |
* Checks if the data store is supported by this adapter
|
|
113 |
* @param aDataStoreURI - The datastore to be checked
|
|
114 |
* @return ETrue if this store is supported
|
|
115 |
*/
|
|
116 |
TBool IsDataStoresSupportedL( TDesC& aDataStoreURI );
|
|
117 |
|
|
118 |
/**
|
|
119 |
* Initiate data fetch from the contacts adapter
|
|
120 |
* @param aDataStoreURI - The store from which data is requested
|
|
121 |
*/
|
|
122 |
void RequestForDataL(TDesC& aDataStoreURI);
|
|
123 |
|
|
124 |
/**
|
|
125 |
* Set the observer to receive the fetched results
|
|
126 |
* @param aObserver - Observer to receive the contacts data
|
|
127 |
*/
|
|
128 |
void SetObserver(MDataStoreObserver& aObserver);
|
|
129 |
|
|
130 |
public:
|
|
131 |
/**
|
|
132 |
* Gets the supported data fields
|
|
133 |
* @param aDataFields - supported data fields
|
|
134 |
*/
|
|
135 |
void GetSupportedDataFieldsL(RArray<TInt> &aDataFields );
|
|
136 |
|
|
137 |
protected:
|
|
138 |
|
|
139 |
// From base class CActive
|
|
140 |
|
|
141 |
/**
|
|
142 |
* From CActive
|
|
143 |
* Implements cancellation of an outstanding request.
|
|
144 |
* This function is called as part of the active object's Cancel().
|
|
145 |
*/
|
|
146 |
void DoCancel();
|
|
147 |
|
|
148 |
/**
|
|
149 |
* From CActive
|
|
150 |
* Handles an active object's request completion event.
|
|
151 |
*
|
|
152 |
* The function is called by the active scheduler when a request
|
|
153 |
* completion event occurs, i.e. after the active scheduler's
|
|
154 |
* WaitForAnyRequest() function completes.
|
|
155 |
*
|
|
156 |
* Before calling this active object's RunL() function, the active scheduler
|
|
157 |
* has:
|
|
158 |
*
|
|
159 |
* 1. decided that this is the highest priority active object with
|
|
160 |
* a completed request
|
|
161 |
*
|
|
162 |
* 2. marked this active object's request as complete (i.e. the request is no
|
|
163 |
* longer outstanding)
|
|
164 |
*
|
|
165 |
* RunL() runs under a trap harness in the active scheduler. If it leaves,
|
|
166 |
* then the active scheduler calls RunError() to handle the leave.
|
|
167 |
*
|
|
168 |
* Note that once the active scheduler's Start() function has been called,
|
|
169 |
* all user code is run under one of the program's active object's RunL() or
|
|
170 |
* RunError() functions.
|
|
171 |
*/
|
|
172 |
void RunL();
|
|
173 |
|
|
174 |
|
|
175 |
/**
|
|
176 |
* From CActive
|
|
177 |
* If the RunL function leaves,
|
|
178 |
* then the active scheduler calls RunError() to handle the leave.
|
|
179 |
* @param aError - The error code
|
|
180 |
*/
|
|
181 |
TInt RunError( TInt aError );
|
|
182 |
|
|
183 |
private:
|
|
184 |
|
|
185 |
/**
|
|
186 |
* Constructor
|
|
187 |
*/
|
|
188 |
CPcsContactFetch();
|
|
189 |
|
|
190 |
/**
|
|
191 |
* 2nd phase constructor
|
|
192 |
*/
|
|
193 |
void ConstructL();
|
|
194 |
|
|
195 |
/**
|
|
196 |
* Creates the substore
|
|
197 |
* @param aDataStoreURI - The store for which substore is to be created
|
|
198 |
*/
|
|
199 |
void CreateSubStoresL(TDesC& aDataStoreURI);
|
|
200 |
|
|
201 |
/**
|
|
202 |
* Reads the configured URIs from the central repository
|
|
203 |
*/
|
|
204 |
void ReadUrisFromCenrepL();
|
|
205 |
|
|
206 |
private:
|
|
207 |
|
|
208 |
/**
|
|
209 |
* Holds the observer object to communicate add/modify/delete of contacts
|
|
210 |
* Not owned.
|
|
211 |
*/
|
|
212 |
MDataStoreObserver* iObserver;
|
|
213 |
|
|
214 |
/**
|
|
215 |
* Owns an instance of active scheduler wait
|
|
216 |
*/
|
|
217 |
CActiveSchedulerWait *iWait;
|
|
218 |
|
|
219 |
/**
|
|
220 |
* Flags for store operations
|
|
221 |
*/
|
|
222 |
TBool iAtLeastOneStoreReady;
|
|
223 |
TBool iNoContactStoreAvailable;
|
|
224 |
TBool iRequestForData;
|
|
225 |
TBool iSubStoreCreated;
|
|
226 |
|
|
227 |
/**
|
|
228 |
* The contact manager for accessing the phone contacts
|
|
229 |
* Own.
|
|
230 |
*/
|
|
231 |
CVPbkContactManager* iContactManager;
|
|
232 |
|
|
233 |
/**
|
|
234 |
* Uris(data stores) read from the central repository
|
|
235 |
*/
|
|
236 |
RPointerArray<HBufC> iUriFromCenrep;
|
|
237 |
|
|
238 |
/**
|
|
239 |
* Data stores instances
|
|
240 |
*/
|
|
241 |
RPointerArray<CPcsContactStore> iAllDataStores;
|
|
242 |
};
|
|
243 |
|
|
244 |
#endif // C_PCS_CONTACT_FETCH_H
|