|
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: Phonebook proxy. |
|
15 * |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 #ifndef __CMSPHONEBOOKPROXY__ |
|
21 #define __CMSPHONEBOOKPROXY__ |
|
22 |
|
23 // INCLUDES |
|
24 #include <MVPbkContactFindObserver.h> |
|
25 #include <MVPbkContactStoreObserver.h> |
|
26 #include "cmsnotificationhandlerapi.h" |
|
27 #include <MVPbkContactStoreListObserver.h> |
|
28 #include <MPbk2StoreConfigurationObserver.h> |
|
29 #include <MVPbkSingleContactOperationObserver.h> |
|
30 #include "MCmsPhonebookOperationsObserver.h" |
|
31 #include <badesca.h> |
|
32 |
|
33 //FORWARD DECLARATIONS |
|
34 class RFs; |
|
35 class CVPbkSortOrder; |
|
36 class TResourceReader; |
|
37 class MVPbkContactLink; |
|
38 class MVPbkContactStore; |
|
39 class MVPbkStoreContact; |
|
40 class CCmsXspStoreSearch; |
|
41 class CVPbkContactManager; |
|
42 class TVPbkWordParserParam; |
|
43 class MCmsContactInterface; |
|
44 class MVPbkContactViewBase; |
|
45 class MVPbkContactLinkArray; |
|
46 class MVPbkContactStoreList; |
|
47 class CVPbkFieldTypeRefsList; |
|
48 class CPbk2StoreConfiguration; |
|
49 class MVPbkContactOperationBase; |
|
50 class CVPbkContactStoreUriArray; |
|
51 class CVPbkContactViewDefinition; |
|
52 class MVPbkContactFindFromStoresObserver; |
|
53 |
|
54 /** |
|
55 * CCmsPhonebookProxy keeps all stores opened to speed up contact |
|
56 * operations. CCmsPhonebookProxy is created and owned by CmsServer |
|
57 * instance and is shared among all client sessions. |
|
58 */ |
|
59 NONSHARABLE_CLASS( CCmsPhonebookProxy ) : public CBase, |
|
60 public MVPbkContactFindObserver, |
|
61 public MVPbkContactStoreObserver, |
|
62 public MVPbkContactStoreListObserver, |
|
63 public MPbk2StoreConfigurationObserver, |
|
64 public MVPbkSingleContactOperationObserver |
|
65 { |
|
66 public: // Constructors and destructor |
|
67 |
|
68 /** |
|
69 * Public constructor |
|
70 * |
|
71 * @param aCmsStoreOpencompleteObserver Observer to be notified about |
|
72 * store opening completion |
|
73 * @param aFileSessionHandle Opened handle to file server |
|
74 * @return Pointer to CCmsPhonebookProxy instance |
|
75 */ |
|
76 static CCmsPhonebookProxy* NewL( |
|
77 MCmsPhonebookOperationsObserver& aCmsStoreOpencompleteObserver, |
|
78 RFs& aFileSessionHandle ); |
|
79 |
|
80 /** |
|
81 * Start contact stores initialization. |
|
82 * Must be called before doing anything else. |
|
83 */ |
|
84 void InitStoresL(); |
|
85 |
|
86 /** |
|
87 * Fetch contact information |
|
88 * |
|
89 * @param aContactId Contact ID |
|
90 * @param aContactInterface Observer to be notified about operation |
|
91 * completion |
|
92 * @return Error code |
|
93 */ |
|
94 TInt FetchContactL( TInt32 aContactId, |
|
95 MCmsContactInterface* aContactInterface ); |
|
96 |
|
97 /** |
|
98 * Fetch contact information |
|
99 * |
|
100 * @param aMsisdn MSISDN of the contact |
|
101 * @param aContactInterface Observer to be notified about operation |
|
102 * completion |
|
103 * @return Error code |
|
104 */ |
|
105 TInt FetchContactL( const TDesC& aMsisdn, |
|
106 MCmsContactInterface* aContactInterface ); |
|
107 |
|
108 /** |
|
109 * Fetch contact information |
|
110 * |
|
111 * @param aPackedlink Link to the contact |
|
112 * @param aContactInterface Observer to be notified about operation |
|
113 * completion |
|
114 * @return Error code |
|
115 */ |
|
116 TInt FetchContactL( const TDesC8& aPackedlink, |
|
117 MCmsContactInterface* aContactInterface ); |
|
118 |
|
119 /** |
|
120 * Starts xSP contacts find operation. Operation result is returned via |
|
121 * MVPbkContactFindFromStoresObserver. Function caller should release |
|
122 * the operation handle |
|
123 * |
|
124 * @param aXspId Field content to be searched in the xSP contacts |
|
125 * @param aContacthandler Observer to be notife about operation result |
|
126 * @return handle to the find operation or NULL if it could not be created. |
|
127 */ |
|
128 MVPbkContactOperationBase* FindXSPContactL( const TDesC& aXspId, |
|
129 MVPbkContactFindFromStoresObserver& aContacthandler ); |
|
130 |
|
131 /** |
|
132 * @return ETrue, if there is at least one xSP store is installed |
|
133 */ |
|
134 TBool ExternalStoresIntalled() const; |
|
135 |
|
136 /** |
|
137 * Subscribe for contact operation status notifications |
|
138 * |
|
139 * @param aObserver Observer |
|
140 */ |
|
141 void AddObserverL( MCmsContactInterface* aObserver ); |
|
142 |
|
143 /** |
|
144 * Unsubscribe for contact operation status notifications |
|
145 * |
|
146 * @param aObserver Observer |
|
147 */ |
|
148 void RemoveObserver( MCmsContactInterface* aObserver ); |
|
149 |
|
150 /** |
|
151 * Maps VPbk's store event to CMS's store event |
|
152 * |
|
153 * @param aPhonebookEvent VPbk's store event |
|
154 * @return CMS's store event |
|
155 */ |
|
156 TCmsPhonebookEvent SelectEventType( |
|
157 TVPbkContactStoreEvent::TVPbkContactStoreEventType aPhonebookEvent ); |
|
158 |
|
159 /** |
|
160 * @return Contact manager, ownership is not transfered. |
|
161 */ |
|
162 CVPbkContactManager* ContactManager() const; |
|
163 |
|
164 /** |
|
165 * Cancel an ongoing asynchronous operation |
|
166 */ |
|
167 void Cancel(); |
|
168 |
|
169 /** |
|
170 * @param aExcludedStoreUri Store URI which is not used in search. |
|
171 * @return Returns number of stores used in the find operation |
|
172 */ |
|
173 TInt NumberOfStoresInFind( const TDesC& aExcludedStoreUri ); |
|
174 |
|
175 /** |
|
176 * Updates the list of xSP stores. |
|
177 */ |
|
178 void UpdateXSPStoresListL(); |
|
179 |
|
180 /** |
|
181 * Destructor |
|
182 */ |
|
183 ~CCmsPhonebookProxy(); |
|
184 |
|
185 public: |
|
186 |
|
187 /** |
|
188 * Get the store opening status |
|
189 * |
|
190 * @return ETrue : If all stores are opend and atleast one store available |
|
191 * @return EFalse: If not all stores are opened or no stores available |
|
192 */ |
|
193 TBool StoreOpenStatus(); |
|
194 |
|
195 public: //static |
|
196 |
|
197 /** |
|
198 * Implementation of word parser function that separates the field data |
|
199 * into words. |
|
200 * |
|
201 * @param aWordParserParam TVPbkWordParserCallbackParam |
|
202 * @return Parsing status code |
|
203 */ |
|
204 static TInt WordParser( TAny* aWordParserParam ); |
|
205 |
|
206 private: //From MVPbkSingleContactOperationObserver |
|
207 |
|
208 void VPbkSingleContactOperationComplete( |
|
209 MVPbkContactOperationBase& aOperation, |
|
210 MVPbkStoreContact* aContact ); |
|
211 void VPbkSingleContactOperationFailed( |
|
212 MVPbkContactOperationBase& aOperation, |
|
213 TInt aError ); |
|
214 |
|
215 private: //From MVPbkContactStoreListObserver |
|
216 |
|
217 void OpenComplete(); |
|
218 |
|
219 private: //From MVPbkContactFindObserver |
|
220 |
|
221 void FindFailed( TInt aError ); |
|
222 void FindCompleteL( MVPbkContactLinkArray* aResults ); |
|
223 |
|
224 private: //From MVPbkContactStoreObserver |
|
225 |
|
226 void StoreReady( MVPbkContactStore& aContactStore ); |
|
227 void StoreUnavailable( MVPbkContactStore& aContactStore, TInt aReason ); |
|
228 void HandleStoreEventL( |
|
229 MVPbkContactStore& aContactStore, |
|
230 TVPbkContactStoreEvent aStoreEvent ); |
|
231 |
|
232 private: //From MPbk2StoreConfigurationObserver |
|
233 |
|
234 void ConfigurationChanged(); |
|
235 void ConfigurationChangedComplete(); |
|
236 |
|
237 private: |
|
238 |
|
239 /** |
|
240 * C++ constructor |
|
241 * |
|
242 * @param aCmsStoreOpencompleteObserver Observer to be notified about |
|
243 * store opening completion |
|
244 * @param aFileSessionHandle Opened handle to file server |
|
245 * @return CCmsPhonebookProxy |
|
246 */ |
|
247 CCmsPhonebookProxy( |
|
248 MCmsPhonebookOperationsObserver& aCmsStoreOpencompleteObserver, |
|
249 RFs& aFileSessionHandle ); |
|
250 |
|
251 /** |
|
252 * Symbian OS second-phase constructor |
|
253 */ |
|
254 void ConstructL(); |
|
255 |
|
256 /** |
|
257 * Called on contact operation completion. Notifies contact object. |
|
258 */ |
|
259 void CompleteContactRequestL( TInt aError, MVPbkStoreContact* aContact ); |
|
260 |
|
261 /** |
|
262 * Creates a list of stores in current configuration |
|
263 */ |
|
264 void CreateConfigurationL(); |
|
265 |
|
266 /** |
|
267 * Finds all installed xSP stores |
|
268 * |
|
269 * @param aArray Array to keep a list of xSP stores |
|
270 */ |
|
271 void FindXSPStoresL( CDesCArrayFlat& aArray ); |
|
272 |
|
273 /** |
|
274 * Cleans data after contact operation is done. |
|
275 */ |
|
276 void ResetData(); |
|
277 |
|
278 private: |
|
279 /** |
|
280 * Finds whether the contact belongs to XSP Store or not |
|
281 * @param aContactLink - Contact which needs to be checked |
|
282 * @return - ETrue if XSP Contacts else EFalse. |
|
283 */ |
|
284 TBool IsXspContact( const MVPbkContactLink& aContactLink ) const; |
|
285 |
|
286 private: //Data |
|
287 |
|
288 /// ETrue, if at least one store was opened successfully |
|
289 TBool iAtLeastOneStoreReady; |
|
290 /// ETrue, if stores opening is done |
|
291 TBool iOpenComplete; |
|
292 /// ETrue, if there is at least one xSP store installed in the phone |
|
293 TBool iXspStoresInstalled; |
|
294 /// Default contact database, NULL if not opened. Not owned. |
|
295 MVPbkContactStore* iContactStore; |
|
296 /// Contact manager. Owned. |
|
297 CVPbkContactManager* iContactManager; |
|
298 /// CmsServerContact. Not owned. |
|
299 MCmsContactInterface* iContactInterface; |
|
300 /// List of stores in current configuration. Not owned. |
|
301 MVPbkContactStoreList* iStoreList; |
|
302 /// List of fields to make a search in xSP stores. Owned. |
|
303 CVPbkFieldTypeRefsList* iFieldTypeRefList; |
|
304 /// Store configuration. Owned. |
|
305 CPbk2StoreConfiguration* iStoreConfiguration; |
|
306 /// List of stores URIs in current configuration. Owned. |
|
307 CVPbkContactStoreUriArray* iUriList; |
|
308 /// Contact operation handle. Owned. |
|
309 MVPbkContactOperationBase* iOperation; |
|
310 /// Array of observers which are notified about |
|
311 RPointerArray<MCmsContactInterface> iObserverArray; |
|
312 /// Observer which is notified about contact operations completion. |
|
313 /// Not owned. |
|
314 MCmsPhonebookOperationsObserver& iCmsPhonebookOperationsObserver; |
|
315 /// Reference to file session handle. Not owned. |
|
316 RFs& iFileSessionHandle; |
|
317 /// Array to keep a list of installed xSP stores. Owned. |
|
318 CDesCArrayFlat ixSPStoresArray; |
|
319 }; |
|
320 |
|
321 #endif //__CMSPHONEBOOKPROXY__ |
|
322 |
|
323 |
|
324 // End of File |