1 /* |
|
2 * Copyright (c) 2004-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: |
|
15 : |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 |
|
21 #ifndef SCVPBKCONTACTSTORELIST_H |
|
22 #define SCVPBKCONTACTSTORELIST_H |
|
23 |
|
24 // INCLUDES |
|
25 #include <e32base.h> |
|
26 #include <MVPbkContactStoreList.h> |
|
27 #include <MVPbkContactStore.h> |
|
28 #include <MVPbkObjectHierarchy.h> |
|
29 #include <MVPbkContactOperationFactory.h> |
|
30 |
|
31 // FORWARD DECLARATIONS |
|
32 |
|
33 |
|
34 |
|
35 class CVPbkContactStoreStub : public CBase, public MVPbkContactStore |
|
36 { |
|
37 public: // Destructor |
|
38 |
|
39 /** |
|
40 * Clients don't destroy the stores directly because they don't |
|
41 * own them. The ownerships are managed by CVPbkContactManager. |
|
42 */ |
|
43 ~CVPbkContactStoreStub() { }; |
|
44 |
|
45 CVPbkContactStoreStub() { }; |
|
46 |
|
47 public: // New functions |
|
48 /** |
|
49 * Returns fixed properties of this contact store. |
|
50 * |
|
51 * Fixed properties do not change when the store is open. |
|
52 * The store must be opened before retrieving the properties. |
|
53 * |
|
54 * @return Store properties. |
|
55 */ |
|
56 const MVPbkContactStoreProperties& StoreProperties() const ; |
|
57 |
|
58 /** |
|
59 * Opens this contact store asynchronously. |
|
60 * |
|
61 * Calls back the observer when the opening completes. Notice |
|
62 * that the same store instance can be opened by several observers. |
|
63 * |
|
64 * @param aObserver An observer for the store. |
|
65 * @exception KErrInUse If another asynchronous operation |
|
66 * is already in progress. |
|
67 */ |
|
68 void OpenL( |
|
69 MVPbkContactStoreObserver& aObserver ) ; |
|
70 |
|
71 /** |
|
72 * Replaces an existing store and opens it asynchronously. |
|
73 * |
|
74 * E.g. If the database is a file then this replaces the database if |
|
75 * it's not locked by other clients. If the store |
|
76 * implementation can not implment replacing then this behaves |
|
77 * like OpenL. |
|
78 * |
|
79 * If the store does not exist, it is created if possible. |
|
80 * Calls back the observer when the opening completes. |
|
81 * |
|
82 * @param aObserver An observer for the store. |
|
83 */ |
|
84 void ReplaceL( |
|
85 MVPbkContactStoreObserver& aObserver ) ; |
|
86 |
|
87 /** |
|
88 * Closes this contact store from a single observer. |
|
89 * |
|
90 * This can be always called safely even if OpenL or ReplaceL |
|
91 * hasn't been called. |
|
92 * If the client calls OpenL it must also call this after usage, |
|
93 * The observer will no longer receive events from this store. |
|
94 * If there are other observers for the store then the store |
|
95 * will remain open for them. |
|
96 * |
|
97 * @param aObserver An observer that was given in OpenL or ReplaceL. |
|
98 */ |
|
99 void Close( |
|
100 MVPbkContactStoreObserver& aObserver ) ; |
|
101 |
|
102 /** |
|
103 * Creates a new contact associated to this store. |
|
104 * |
|
105 * The contact can be edited and then it must be committed by |
|
106 * calling MVPbkStoreContact::CommitL for actually saving |
|
107 * it to the store. |
|
108 * |
|
109 * @return A new contact associated to this store. Caller takes |
|
110 * ownership of the returned contact. |
|
111 * @see MVPbkStoreContact |
|
112 * @see MVPbkStoreContact::CommitL |
|
113 */ |
|
114 MVPbkStoreContact* CreateNewContactLC() ; |
|
115 |
|
116 /** |
|
117 * Creates a new contact group associated to this store. |
|
118 * |
|
119 * MVPbkContactStoreProperties::SupportsContactGroups must be |
|
120 * true if this is used. |
|
121 * The contact group might be saved to the store immeadiately |
|
122 * depending on the store implementation. |
|
123 * It is left open for editing. Use CommitL to commit |
|
124 * the creation of the group and its content. |
|
125 * |
|
126 * @return A new contact group associated to this store. Caller takes |
|
127 * the ownership of the returned contact group. |
|
128 * @exception KErrNotSupported if the store doesn't support groups. |
|
129 * Client should check store properties before |
|
130 * calling this. |
|
131 * @see MVPbkContactStoreProperties |
|
132 * @see MVPbkContactGroup |
|
133 * @see MVPbkStoreContact |
|
134 * @see MVPbkStoreContact::CommitL |
|
135 */ |
|
136 MVPbkContactGroup* CreateNewContactGroupLC() ; |
|
137 |
|
138 /** |
|
139 * Creates a new contact view from the store asynchronously. |
|
140 * |
|
141 * Client gets the ownership of the view. The content of |
|
142 * the view depends on the CVPbkContactViewDefinition. The |
|
143 * client must wait the observer event before using the view. |
|
144 * |
|
145 * @param aViewDefinition Defines the properties of the new view. |
|
146 * @param aObserver An observer for the view events. |
|
147 * @param aSortOrder Field types that are used in the view contact |
|
148 * in the same order as in this list. Notice that |
|
149 * stores may not support all possible field types |
|
150 * in a view contact. The implementation |
|
151 * of the view contact must have as many fields as |
|
152 * the sort order. If the store doesn't support the |
|
153 * field type in a view contact then it sets empty |
|
154 * data to the field. |
|
155 * @return A new contact view object. Caller takes ownership of the |
|
156 * returned contact. |
|
157 * @see MVPbkContactView |
|
158 * @see CVPbkContactViewDefinition |
|
159 */ |
|
160 MVPbkContactView* CreateViewLC( |
|
161 const CVPbkContactViewDefinition& aViewDefinition, |
|
162 MVPbkContactViewObserver& aObserver, |
|
163 const MVPbkFieldTypeList& aSortOrder ) ; |
|
164 |
|
165 /** |
|
166 * Returns contact groups contained in this store. |
|
167 * |
|
168 * MVPbkContactStoreProperties::SupportsContactGroups must be |
|
169 * true if this is used. Implementation should return an empty |
|
170 * link array and not NULL. |
|
171 * |
|
172 * @return Contact group identifiers contained in this store. |
|
173 */ |
|
174 MVPbkContactLinkArray* ContactGroupsLC() const ; |
|
175 |
|
176 /** |
|
177 * Returns a contact store information. Information can vary |
|
178 * runtime. |
|
179 * |
|
180 * @return Contact store information. |
|
181 */ |
|
182 const MVPbkContactStoreInfo& StoreInfo() const ; |
|
183 |
|
184 /** |
|
185 * This is part of Virtual Phonebook internal framefork and not |
|
186 * usable for clients. Clients use CVPbkContactManager |
|
187 * for creating links from a stream. |
|
188 * |
|
189 * Creates a link array from a stream. Stream contains the internals |
|
190 * of the contact link. Internals are the contact store implementation |
|
191 * specific part of the package format. |
|
192 * |
|
193 * NOTE: this must work wheter the OpenL has been called or not. This |
|
194 * means that a link can not contain any data that would need |
|
195 * an open store before internalizing. |
|
196 * |
|
197 * @param aStream A stream containing the link internals. |
|
198 * @return A new contact link. |
|
199 * @internal |
|
200 */ |
|
201 MVPbkContactLink* CreateLinkFromInternalsLC( |
|
202 RReadStream& aStream ) const ; |
|
203 |
|
204 /** |
|
205 * Returns own contact link asynchronously. |
|
206 * |
|
207 * @params aObserver Operation observer |
|
208 * @return operation handle |
|
209 * @Asynchronous |
|
210 */ |
|
211 MVPbkContactOperationBase* OwnContactLinkL( |
|
212 MVPbkSingleContactLinkOperationObserver& aObserver) const ; |
|
213 |
|
214 |
|
215 /** |
|
216 * Returns the parent object of this object. For the root of the |
|
217 * hierarchy returns self. |
|
218 * @return The parent object. |
|
219 */ |
|
220 MVPbkObjectHierarchy& ParentObject() const ; |
|
221 |
|
222 |
|
223 /** |
|
224 * Creates an operation for contact retrieval. |
|
225 * |
|
226 * @param aLink A link to the contact |
|
227 * @param aObserver An observer for the operation. |
|
228 * @return A handle to the operation or NULL if the factory |
|
229 * doesn't have reference to the store of the link. |
|
230 */ |
|
231 MVPbkContactOperation* CreateContactRetrieverL( |
|
232 const MVPbkContactLink& aLink, |
|
233 MVPbkSingleContactOperationObserver& aObserver) ; |
|
234 |
|
235 /** |
|
236 * Creates an operation for deleting multiple contacts. |
|
237 * |
|
238 * @param aContactLinks An array of contact links that specify |
|
239 * the contacts. |
|
240 * @param aObserver An observer for the operation. |
|
241 * @return A handle to the operation or NULL |
|
242 */ |
|
243 MVPbkContactOperation* CreateDeleteContactsOperationL( |
|
244 const MVPbkContactLinkArray& aContactLinks, |
|
245 MVPbkBatchOperationObserver& aObserver ) ; |
|
246 |
|
247 /** |
|
248 * Creates an operation for committing multiple contacts. |
|
249 * |
|
250 * @param aContacts An array of contact links that specify |
|
251 * the contacts |
|
252 * @param aObserver An observer for the operation. |
|
253 * @return A handle to the operation or NULL |
|
254 */ |
|
255 MVPbkContactOperation* CreateCommitContactsOperationL( |
|
256 const TArray<MVPbkStoreContact*>& aContacts, |
|
257 MVPbkBatchOperationObserver& aObserver) ; |
|
258 |
|
259 /** |
|
260 * Creates an operation for asynchronous phone number matching. |
|
261 * |
|
262 * @param aPhoneNumber A phone number to search for. |
|
263 * @param aMaxMatchDigits Maximum number of digits to match from |
|
264 * the end of the number. |
|
265 * @param aObserver Observer for the find process. |
|
266 * @return A handle to the operation or NULL |
|
267 */ |
|
268 MVPbkContactOperation* CreateMatchPhoneNumberOperationL( |
|
269 const TDesC& aPhoneNumber, |
|
270 TInt aMaxMatchDigits, |
|
271 MVPbkContactFindObserver& aObserver) ; |
|
272 |
|
273 /** |
|
274 * Creates an operation for asynchronous contact finding. |
|
275 * |
|
276 * @param aSearchString String to search for. |
|
277 * @param aFieldTypes List of field types that the search will include. |
|
278 * @param aObserver Observer for the find process. |
|
279 * @return A handle to the operation or NULL |
|
280 */ |
|
281 MVPbkContactOperation* CreateFindOperationL( |
|
282 const TDesC& aSearchString, |
|
283 const MVPbkFieldTypeList& aFieldTypes, |
|
284 MVPbkContactFindObserver& aObserver) ; |
|
285 |
|
286 /** |
|
287 * Creates an operation for asynchronous contact finding. |
|
288 * Finds a string containing text that is stored in one or more fields. |
|
289 * Client can give multiple find words. All the words must match to separated |
|
290 * data. E.g if there are two find words: "Jo" and "Jo" then field data |
|
291 * "John Johnson" matches but "John Doe" doesn't if the word parser uses |
|
292 * white space as a word separator. |
|
293 * |
|
294 * NOTE: The accuracy of the results depends on the ability of the store |
|
295 * implementation to implement the find. The performance can vary |
|
296 * too depending on the store. |
|
297 * |
|
298 * @param aSearchStrings Words that are compared to field data. |
|
299 * @param aFieldTypes Types of the fields that are used. |
|
300 * @param aObserver An observer for asynchronous operation. |
|
301 * @param aWordParserCallBack a client implementation of word parser |
|
302 * function that separates the field data |
|
303 * into words. Parameter to function is |
|
304 * TVPbkWordParserParam. |
|
305 * @return A handle to the operation or NULL |
|
306 */ |
|
307 MVPbkContactOperation* CreateFindOperationL( |
|
308 const MDesC16Array& aSearchStrings, |
|
309 const MVPbkFieldTypeList& aFieldTypes, |
|
310 MVPbkContactFindFromStoresObserver& aObserver, |
|
311 const TCallBack& aWordParserCallBack ) ; |
|
312 |
|
313 /** |
|
314 * Creates an operation for compressing the store. |
|
315 * |
|
316 * @param aObserver An observer for the compress operation. |
|
317 * @return A handle to the operation or NULL |
|
318 */ |
|
319 MVPbkContactOperation* CreateCompressStoresOperationL( |
|
320 MVPbkBatchOperationObserver& aObserver) ; |
|
321 |
|
322 }; |
|
323 |
|
324 |
|
325 |
|
326 // CLASS DECLARATIONS |
|
327 /** |
|
328 * An interface for a list of contact stores. |
|
329 * |
|
330 * The interface provides an access to multiple stores. It's possible to open |
|
331 * and close all stores in single call using this interface. When client calls |
|
332 * OpenAllL it must also calls CloseAll after usage. |
|
333 * |
|
334 * @see CVPbkContactManager::ContactStoresL |
|
335 */ |
|
336 class CVPbkContactStoreListStub : public CBase, public MVPbkContactStoreList |
|
337 { |
|
338 public: // interface |
|
339 ~CVPbkContactStoreListStub() { }; |
|
340 |
|
341 CVPbkContactStoreListStub() { }; |
|
342 |
|
343 /** |
|
344 * Returns the number of stores in the list. |
|
345 * |
|
346 * @return The number of stores in the list. |
|
347 */ |
|
348 TInt Count() const ; |
|
349 |
|
350 /** |
|
351 * Returns the store in given index in the list. |
|
352 * |
|
353 * @param aIndex the index of the store in the list |
|
354 * @precond aIndex >= && aIndex < Count() |
|
355 * VPbkError::Panic(VPbkError::EInvalidStoreIndex) |
|
356 * is raised if the precondition does not hold. |
|
357 * @return The store in the specified index. |
|
358 */ |
|
359 MVPbkContactStore& At(TInt aIndex) const ; |
|
360 |
|
361 /** |
|
362 * Finds the contact store corresponding to the aUri. |
|
363 * |
|
364 * @param aUri the store URI to search for. |
|
365 * @return The contact store corresponding to the aUri or NULL. |
|
366 */ |
|
367 MVPbkContactStore* Find( |
|
368 const TVPbkContactStoreUriPtr& aUri) const ; |
|
369 |
|
370 /** |
|
371 * Opens all stores in the list asynchronously. |
|
372 * |
|
373 * A client can not use stores before it has successfully opened |
|
374 * them. CloseAll must be always called by the same observer that has |
|
375 * opened stores. |
|
376 * |
|
377 * NOTE: There can be only one observer for one store list at a time. |
|
378 * |
|
379 * @param aObserver An observer for the stores. |
|
380 * @exception KErrInUse If one observer is currently opening this list. |
|
381 */ |
|
382 void OpenAllL(MVPbkContactStoreListObserver& aObserver) ; |
|
383 |
|
384 /** |
|
385 * Closes all stores in the list. |
|
386 * |
|
387 * This is safe to call in all circumstances. Implementations |
|
388 * can not trust that OpenAllL has been called before. |
|
389 * |
|
390 * @param aObserver An observer for the close process. |
|
391 */ |
|
392 void CloseAll(MVPbkContactStoreListObserver& aObserver) ; |
|
393 |
|
394 |
|
395 |
|
396 }; |
|
397 |
|
398 #endif // SCVPBKCONTACTSTORELIST_H |
|
399 |
|
400 //End of file |
|