author | Pat Downey <patd@symbian.org> |
Wed, 01 Sep 2010 12:28:47 +0100 | |
branch | RCL_3 |
changeset 45 | a9c0808a1095 |
parent 23 | 50974a8b132e |
permissions | -rw-r--r-- |
5 | 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 the License "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: Implementation of the Contacts Service APIs. |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
||
19 |
//System includes |
|
20 |
||
23
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
10
diff
changeset
|
21 |
#include <CVPbkVCardEng.h>//for the vcard engin |
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
10
diff
changeset
|
22 |
#include <CVPbkContactManager.h>// for iContactManager |
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
10
diff
changeset
|
23 |
#include <MVPbkContactStore.h>// for iContactStore |
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
10
diff
changeset
|
24 |
#include <TVPbkContactStoreUriPtr.h>//used in SetupL |
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
10
diff
changeset
|
25 |
#include <MVPbkContactStoreList.h>//used in SetupL to get contact stores |
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
10
diff
changeset
|
26 |
#include <MVPbkStoreContactField.h>//used in AddFieldToContactL |
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
10
diff
changeset
|
27 |
#include <MVPbkStoreContact.h>// used in many function to get the store contact |
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
10
diff
changeset
|
28 |
#include <MVPbkContactFieldTextData.h>//for the field text data |
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
10
diff
changeset
|
29 |
#include <TVPbkFieldTypeMapping.h>//used in CreateFieldTypeL() |
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
10
diff
changeset
|
30 |
#include <MVPbkFieldType.h>//return type of CreateFieldTypeL() |
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
10
diff
changeset
|
31 |
#include <MVPbkContactOperationBase.h>//for observer |
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
10
diff
changeset
|
32 |
#include <MVPbkContactFieldDateTimeData.h>//Used in AddDateFieldToContactL |
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
10
diff
changeset
|
33 |
#include <MVPbkContactLink.h>//for param in ContactsSaved() |
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
10
diff
changeset
|
34 |
#include <CVPbkContactStoreUriArray.h>//used in SetupL |
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
10
diff
changeset
|
35 |
#include <MVPbkStoreContact.h> // used in many function to get the store contact |
5 | 36 |
#include <MVPbkContactGroup.h> |
37 |
#include <badesca.h> |
|
23
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
10
diff
changeset
|
38 |
#include <MVPbkContactStoreProperties.h> |
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
10
diff
changeset
|
39 |
#include <TVPbkContactStoreUriPtr.h> |
5 | 40 |
#include <MVPbkContactStore.h> |
41 |
||
42 |
//User includes. |
|
43 |
#include "getliststorelistobserver.h" |
|
44 |
#include "addcontactobserver.h" |
|
45 |
#include "deletecontactobserver.h" |
|
46 |
#include "organisegroupsobserver.h" |
|
47 |
#include "contactretrieveobserver.h" |
|
48 |
#include "contactservice.h" |
|
49 |
||
50 |
class CContactIter; |
|
51 |
||
52 |
// ======== MEMBER FUNCTIONS ======== |
|
53 |
||
54 |
// --------------------------------------------------------------------------- |
|
55 |
// Static NewL() method to create an instance of the contact service core class. |
|
56 |
// --------------------------------------------------------------------------- |
|
57 |
||
58 |
EXPORT_C |
|
59 |
CContactService* CContactService::NewL() |
|
60 |
{ |
|
61 |
CContactService* self = new( ELeave ) CContactService( ); |
|
62 |
CleanupStack::PushL( self ); |
|
63 |
self->ConstructL(); |
|
64 |
CleanupStack::Pop( self ); |
|
65 |
return self; |
|
66 |
} |
|
67 |
||
68 |
||
69 |
// --------------------------------------------------------------------------- |
|
70 |
// Destructor for CContactService. |
|
71 |
// --------------------------------------------------------------------------- |
|
72 |
||
73 |
CContactService::~CContactService() |
|
74 |
{ |
|
75 |
iFs.Close(); |
|
76 |
delete iEngine; |
|
77 |
delete iContactManager; |
|
78 |
for(TInt i = 0; i < iAsyncObjArray.Count(); i++) |
|
79 |
{ |
|
80 |
((iAsyncObjArray[i]).iAsyncObj)->Cancel(); |
|
81 |
} |
|
82 |
iAsyncObjArray.Close(); |
|
83 |
} |
|
84 |
||
85 |
// --------------------------------------------------------------------------- |
|
86 |
// Constructor. |
|
87 |
// --------------------------------------------------------------------------- |
|
88 |
||
89 |
CContactService::CContactService() |
|
90 |
:iErrKey(0) |
|
91 |
{ |
|
92 |
||
93 |
} |
|
94 |
||
95 |
||
96 |
// --------------------------------------------------------------------------- |
|
97 |
// Symbian second-phase constructor |
|
98 |
// --------------------------------------------------------------------------- |
|
99 |
||
100 |
void CContactService::ConstructL() |
|
101 |
{ |
|
102 |
User::LeaveIfError( iFs.Connect() ); |
|
103 |
BaseSetupL(VPbkContactStoreUris::DefaultCntDbUri()); |
|
104 |
} |
|
105 |
||
106 |
// METHODS |
|
107 |
// --------------------------------------------------------------------------- |
|
108 |
// Method to setup basic parameters...like creating contact manager instance, |
|
109 |
// and initialising the contact store. |
|
110 |
// --------------------------------------------------------------------------- |
|
111 |
||
112 |
TInt CContactService::BaseSetupL(const TDesC& aStoreUri |
|
113 |
/*MVPbkContactStoreListObserver* aStoreObserver*/) |
|
114 |
{ |
|
115 |
//Create an instance of uriList and append all the list of URIs to the list. |
|
116 |
||
117 |
CVPbkContactStoreUriArray* uriList = |
|
118 |
CVPbkContactStoreUriArray::NewLC(); |
|
119 |
uriList->AppendL(TVPbkContactStoreUriPtr(aStoreUri)); |
|
120 |
||
121 |
//Instantiate contact manager with the |
|
122 |
//constucted uri list and file session. |
|
123 |
iContactManager = CVPbkContactManager::NewL(*uriList, |
|
124 |
&iFs); |
|
125 |
||
126 |
MVPbkContactStoreList& contactStores = iContactManager->ContactStoresL(); |
|
127 |
||
128 |
iContactStore = contactStores.Find(aStoreUri); |
|
129 |
||
130 |
CleanupStack::PopAndDestroy(uriList); |
|
131 |
||
132 |
return KErrNone; |
|
133 |
} |
|
134 |
||
135 |
||
136 |
//----------------------------------------------------------------------------------- |
|
137 |
// Open the store specific to Vcard import and export operations. |
|
138 |
//----------------------------------------------------------------------------------- |
|
139 |
||
140 |
TInt CContactService::VcardStoreOpenL(const TDesC& aStoreUri, |
|
141 |
MContactStoreListObserver* aStoreObserver) |
|
142 |
{ |
|
143 |
iContactManager->LoadContactStoreL(TVPbkContactStoreUriPtr(aStoreUri)); |
|
144 |
||
145 |
if( !iEngine ) |
|
146 |
iEngine = CVPbkVCardEng::NewL( *iContactManager ); |
|
147 |
||
148 |
aStoreObserver->SetEngine( iEngine ); |
|
149 |
||
150 |
// Open the store |
|
151 |
MVPbkContactStoreList& contactStores = iContactManager->ContactStoresL(); |
|
152 |
||
153 |
iContactStore = contactStores.Find(aStoreUri); |
|
154 |
||
155 |
if(!iContactStore) |
|
156 |
{ |
|
157 |
iContactManager->LoadContactStoreL(TVPbkContactStoreUriPtr(aStoreUri)); |
|
158 |
contactStores = iContactManager->ContactStoresL(); |
|
159 |
iContactStore = contactStores.Find(aStoreUri); |
|
160 |
} |
|
161 |
if(iContactStore) |
|
162 |
{ |
|
163 |
aStoreObserver->SetContactStore( iContactStore ); |
|
164 |
iContactStore->OpenL( *aStoreObserver ); |
|
165 |
return KErrNone; |
|
166 |
} |
|
167 |
return KErrGeneral; |
|
168 |
||
169 |
} |
|
170 |
||
171 |
||
172 |
// --------------------------------------------------------------------------- |
|
173 |
// Create data for the operation, prepare the write stream and |
|
174 |
// call the vCardEngine to execute the operation. The results are reported |
|
175 |
// through callback methods. |
|
176 |
// --------------------------------------------------------------------------- |
|
177 |
// |
|
178 |
EXPORT_C |
|
179 |
void CContactService::ExportVCardL(MContactCallback* aCallback, |
|
180 |
TInt aTransId, |
|
181 |
const TFileName& aFileName, |
|
182 |
const TDesC8& aContactId, |
|
183 |
const TDesC& aStoreUri) |
|
184 |
{ |
|
185 |
//Check for the validity of the arguments. |
|
186 |
if( !aContactId.Compare(KNullDesC8) || NULL == aCallback) |
|
187 |
{ |
|
188 |
User::Leave(KErrArgument); |
|
189 |
} |
|
190 |
TInt returncode; |
|
191 |
CExportStoreListObserver* exportObserver = |
|
192 |
CExportStoreListObserver::NewL(this, |
|
193 |
iFs, |
|
194 |
aFileName, |
|
195 |
aContactId, |
|
196 |
aCallback, |
|
197 |
aTransId); |
|
198 |
||
199 |
CleanupStack::PushL(exportObserver); |
|
200 |
exportObserver->SetContactService(this); |
|
201 |
returncode=VcardStoreOpenL(aStoreUri, |
|
202 |
exportObserver); |
|
203 |
if(returncode != KErrNone) |
|
204 |
{ |
|
205 |
User::Leave(returncode); |
|
206 |
} |
|
207 |
AddAsyncObjL(aTransId, exportObserver); |
|
208 |
||
209 |
CleanupStack::Pop(exportObserver); |
|
210 |
} |
|
211 |
||
212 |
||
213 |
// --------------------------------------------------------------------------- |
|
214 |
// Prepare the read stream and call the vCardEngine to execute the operation. |
|
215 |
// The results are reported through callback methods. |
|
216 |
// --------------------------------------------------------------------------- |
|
217 |
// |
|
218 |
EXPORT_C |
|
219 |
void CContactService:: |
|
220 |
ImportVCardToStoreL(MContactCallback* aCallback, |
|
221 |
TInt aTransId, |
|
222 |
const TFileName& aFileName, |
|
223 |
const TDesC& aStoreUri) |
|
224 |
{ |
|
225 |
//Check for the validity of the arguments. |
|
226 |
if(NULL == aCallback) |
|
227 |
{ |
|
228 |
User::Leave(KErrArgument); |
|
229 |
} |
|
230 |
||
231 |
TInt returncode; |
|
232 |
CImportStoreListObserver* importObserver = |
|
233 |
CImportStoreListObserver::NewL(iFs, |
|
234 |
aFileName, |
|
235 |
aCallback, |
|
236 |
aTransId); |
|
237 |
||
238 |
CleanupStack::PushL(importObserver); |
|
239 |
importObserver->SetContactService(this); |
|
240 |
returncode=VcardStoreOpenL(aStoreUri, |
|
241 |
importObserver); |
|
242 |
if(returncode != KErrNone) |
|
243 |
{ |
|
244 |
User::Leave(returncode); |
|
245 |
} |
|
246 |
AddAsyncObjL(aTransId, importObserver); |
|
247 |
||
248 |
CleanupStack::Pop(importObserver); |
|
249 |
||
250 |
} |
|
251 |
||
252 |
// --------------------------------------------------------------------------- |
|
253 |
// This method gets the list of contact stores from the contact manager, finds |
|
254 |
// the specified database from the list and opens the same with the appropriate |
|
255 |
// observer passed to it. |
|
256 |
// If it does not found in the list of stores then loads the same and opens it |
|
257 |
// asynchronously. |
|
258 |
// --------------------------------------------------------------------------- |
|
259 |
||
260 |
TInt CContactService:: |
|
261 |
GetContactStoreAndOpenL(const TDesC& aStoreUri, |
|
262 |
MVPbkContactStoreObserver* aStoreObserver) |
|
263 |
{ |
|
264 |
MVPbkContactStoreList& contactStores = iContactManager->ContactStoresL(); |
|
265 |
||
266 |
iContactStore = contactStores.Find(aStoreUri); |
|
267 |
||
268 |
if(!iContactStore) |
|
269 |
{ |
|
270 |
iContactManager->LoadContactStoreL(TVPbkContactStoreUriPtr(aStoreUri)); |
|
271 |
contactStores = iContactManager->ContactStoresL(); |
|
272 |
iContactStore = contactStores.Find(aStoreUri); |
|
273 |
} |
|
274 |
if(iContactStore) |
|
275 |
{ |
|
276 |
iContactStore->OpenL( *aStoreObserver ); |
|
277 |
return KErrNone; |
|
278 |
} |
|
279 |
return KErrGeneral; |
|
280 |
} |
|
281 |
||
282 |
// --------------------------------------------------------------------------- |
|
283 |
// Method which does the following... |
|
284 |
// 1. Adding a new contact to the contact store. |
|
285 |
// 2. Adding a new group to the contact store. |
|
286 |
// 3. Edit an existing contact from the contact store. |
|
287 |
// 4. Edit a group from the contact store. |
|
288 |
// --------------------------------------------------------------------------- |
|
289 |
||
290 |
EXPORT_C |
|
291 |
void CContactService::AddL( MContactCallback* aCallback, |
|
292 |
TInt aTransId, |
|
293 |
CSingleContact* aStoreContact, |
|
294 |
const TDesC8& aGroupId, |
|
295 |
const TDesC& aGroupLabel, |
|
296 |
const TDesC& aStoreUri ) |
|
297 |
{ |
|
298 |
//Check for the validity of the arguments. |
|
299 |
//if no new contact, no reference to exiting contact, |
|
300 |
// no reference to existing grp, |
|
301 |
//no label to new grp then or no callback fn parameter then, |
|
302 |
// leave the fn with the error code KErrArgument. |
|
303 |
if((aStoreContact && aGroupLabel != KNullDesC) || NULL == aCallback ) |
|
304 |
{ |
|
305 |
User::Leave(KErrArgument); |
|
306 |
} |
|
307 |
||
308 |
TInt retVal; |
|
309 |
||
310 |
// Create an instance of addContactObserver |
|
311 |
CAddContactObserver* addContactObserver = |
|
312 |
CAddContactObserver::NewL(this, |
|
313 |
iContactStore, |
|
314 |
aStoreContact, |
|
315 |
aGroupId, |
|
316 |
aGroupLabel, |
|
317 |
aTransId, |
|
318 |
aCallback); |
|
319 |
||
320 |
CleanupStack::PushL(addContactObserver); |
|
321 |
||
322 |
retVal = GetContactStoreAndOpenL(aStoreUri, |
|
323 |
addContactObserver); |
|
324 |
if(retVal != KErrNone) |
|
325 |
{ |
|
326 |
User::Leave(retVal); |
|
327 |
} |
|
328 |
AddAsyncObjL(aTransId, addContactObserver); |
|
329 |
CleanupStack::Pop(addContactObserver); |
|
330 |
||
331 |
} |
|
332 |
||
333 |
||
334 |
// --------------------------------------------------------------------------- |
|
335 |
// Method for deleting a contact or list of contacts from the contact store. |
|
336 |
// --------------------------------------------------------------------------- |
|
337 |
||
338 |
EXPORT_C |
|
339 |
void CContactService::DeleteL( MContactCallback* aCallback, |
|
340 |
TInt aTransId, |
|
341 |
RPointerArray<TDesC8>& aContactIdArray, |
|
342 |
const TDesC& aStoreUri ) |
|
343 |
{ |
|
344 |
//Check for the validity of the arguments. |
|
345 |
if( !aCallback || (aContactIdArray.Count()==0)) |
|
346 |
{ |
|
347 |
User::Leave(KErrArgument); |
|
348 |
} |
|
349 |
TInt retVal; |
|
350 |
||
351 |
//Intantiate delete contact observer for deleting contacts from the contact store. |
|
352 |
CDeleteContactObserver* deleteContactsObserver = |
|
353 |
CDeleteContactObserver::NewL(this, |
|
354 |
iContactStore, |
|
355 |
aContactIdArray, |
|
356 |
aTransId, |
|
357 |
aCallback ); |
|
358 |
||
359 |
CleanupStack::PushL(deleteContactsObserver); |
|
360 |
||
361 |
retVal = GetContactStoreAndOpenL(aStoreUri, |
|
362 |
deleteContactsObserver); |
|
363 |
if(retVal != KErrNone) |
|
364 |
{ |
|
365 |
User::Leave(retVal); |
|
366 |
} |
|
367 |
AddAsyncObjL(aTransId, deleteContactsObserver); |
|
368 |
||
369 |
CleanupStack::Pop(deleteContactsObserver); |
|
370 |
||
371 |
} |
|
372 |
||
373 |
||
374 |
// --------------------------------------------------------------------------- |
|
375 |
// Method does the following... |
|
376 |
// 1. Associates one or more contacts to the specified group. |
|
377 |
// 2. Disassociates one or more contacts from specified group. |
|
378 |
// --------------------------------------------------------------------------- |
|
379 |
||
380 |
EXPORT_C |
|
381 |
void CContactService::OrganiseGroupsL(MContactCallback* aCallback, |
|
382 |
TInt aTransId, |
|
383 |
const TDesC8& aGroupId, |
|
384 |
RPointerArray<TDesC8>& aContactIdArray, |
|
385 |
TBool aAssociateFlag, |
|
386 |
const TDesC& aStoreUri) |
|
387 |
{ |
|
388 |
//Check for the validity of the arguments. |
|
389 |
if(!aCallback) |
|
390 |
{ |
|
391 |
User::Leave(KErrArgument); |
|
392 |
} |
|
393 |
||
394 |
||
395 |
TInt retVal; |
|
396 |
//Create an instance of organise groups observer. |
|
397 |
COrganiseGroupsObserver* organiseGroupsObserver = |
|
398 |
COrganiseGroupsObserver::NewL(this, |
|
399 |
aGroupId, |
|
400 |
aContactIdArray, |
|
401 |
aAssociateFlag, |
|
402 |
aTransId, |
|
403 |
aCallback, |
|
404 |
iContactStore); |
|
405 |
||
406 |
CleanupStack::PushL(organiseGroupsObserver); |
|
407 |
||
408 |
retVal = GetContactStoreAndOpenL(aStoreUri, |
|
409 |
organiseGroupsObserver); |
|
410 |
if(retVal != KErrNone) |
|
411 |
{ |
|
412 |
User::Leave(retVal); |
|
413 |
} |
|
414 |
AddAsyncObjL(aTransId, organiseGroupsObserver); |
|
415 |
||
416 |
CleanupStack::Pop(organiseGroupsObserver); //organiseGroupsObserver |
|
417 |
} |
|
418 |
||
419 |
//--------------------------------------------------- |
|
420 |
//Based on the kind of request for GetListL fetches a list of either contacts, groups or databases. |
|
421 |
//In case of fetching contacts/groups it calls GetContactStoreAndOpenL() for setting up the database before fetching. |
|
422 |
//In case of fetching of list of databases it calls GetContactsDatabases() |
|
423 |
//In both cases the result is to be iterable. |
|
424 |
//It can also be used in retrieving a single contact, in which case iterator is initialized directly. |
|
425 |
//--------------------------------------------------- |
|
426 |
EXPORT_C |
|
427 |
void CContactService::GetListL( MContactCallback* aCallback, |
|
428 |
TInt aTransId, |
|
429 |
Ttype type, |
|
430 |
const TDesC8& aContactId, |
|
431 |
const TDesC& aSearchVal, |
|
432 |
CSearchFields* aSearchFields, |
|
433 |
TOrder aSortOrder, |
|
10
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
434 |
const TDesC& aStoreUri, TCmdType val) |
5 | 435 |
{ |
436 |
TInt retVal = KErrGeneral; |
|
437 |
CContactIter* iter; |
|
438 |
CGetListStoreListObserver* getListOpenObserver; |
|
439 |
if(!(aCallback)) |
|
440 |
{ |
|
441 |
User::Leave(KErrArgument); |
|
442 |
} |
|
443 |
||
444 |
||
445 |
switch(type) |
|
446 |
{ |
|
447 |
case EContacts: |
|
448 |
case EGroups: |
|
449 |
if(&aContactId && aContactId.Compare(KNullDesC8)) |
|
450 |
{ |
|
451 |
// Create Iterator |
|
452 |
iter = CContactIter::NewL(); |
|
453 |
CleanupStack::PushL(iter); |
|
454 |
||
455 |
//Extract the contactlink from the contactid |
|
456 |
||
457 |
MVPbkContactLinkArray* linkArray = iContactManager->CreateLinksLC(aContactId); |
|
458 |
//Open Store using GetContactStoreAndOpenL() |
|
459 |
//and Create instantiate storelist observer |
|
460 |
getListOpenObserver = |
|
461 |
CGetListStoreListObserver::NewL((linkArray->At(0). |
|
462 |
ContactStore(). |
|
463 |
StoreProperties(). |
|
464 |
Uri(). |
|
465 |
UriDes()), |
|
466 |
aContactId, |
|
467 |
aSearchVal, |
|
468 |
aSearchFields, |
|
469 |
aSortOrder, |
|
470 |
aCallback, |
|
471 |
this, |
|
472 |
iter, |
|
473 |
type, |
|
474 |
aTransId, |
|
10
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
475 |
iContactStore,val) ; |
5 | 476 |
|
477 |
CleanupStack::PushL(getListOpenObserver); |
|
478 |
||
479 |
//Opens the database and goes to observer's StoreReady() function. |
|
480 |
retVal = GetContactStoreAndOpenL( aStoreUri, getListOpenObserver ); |
|
481 |
if(retVal != KErrNone) |
|
482 |
{ |
|
483 |
User::Leave(retVal); |
|
484 |
} |
|
485 |
AddAsyncObjL(aTransId, getListOpenObserver); |
|
486 |
||
487 |
||
488 |
CleanupStack::Pop(getListOpenObserver); |
|
489 |
CleanupStack::PopAndDestroy();//CreateLinksLC() |
|
490 |
CleanupStack::Pop(iter); |
|
491 |
break; |
|
492 |
||
493 |
} |
|
494 |
||
495 |
// Create Iterator |
|
496 |
iter = CContactIter::NewL(); |
|
497 |
CleanupStack::PushL(iter); |
|
498 |
||
499 |
||
500 |
//Open Store using GetContactStoreAndOpenL() and Create |
|
501 |
//instantiate storelist observer |
|
502 |
getListOpenObserver = |
|
503 |
CGetListStoreListObserver::NewL(aStoreUri, |
|
504 |
aContactId, |
|
505 |
aSearchVal, |
|
506 |
aSearchFields, |
|
507 |
aSortOrder, |
|
508 |
aCallback, |
|
509 |
this, |
|
510 |
iter, |
|
511 |
type, |
|
512 |
aTransId, |
|
10
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
513 |
iContactStore,val) ; |
5 | 514 |
CleanupStack::PushL(getListOpenObserver); |
515 |
||
516 |
//Opens the database and goes to observer's StoreReady() function. |
|
517 |
retVal = GetContactStoreAndOpenL(aStoreUri, |
|
518 |
getListOpenObserver); |
|
519 |
if(retVal != KErrNone) |
|
520 |
{ |
|
521 |
User::Leave(retVal); |
|
522 |
} |
|
523 |
AddAsyncObjL(aTransId, getListOpenObserver); |
|
524 |
||
525 |
||
526 |
CleanupStack::Pop(getListOpenObserver); |
|
527 |
CleanupStack::Pop(iter); |
|
528 |
break; |
|
529 |
default: |
|
530 |
User::Leave(KErrArgument); |
|
531 |
} |
|
532 |
} |
|
533 |
||
534 |
//--------------------------------------------------- |
|
535 |
//Gets the list of databases from the member varible iContactManager |
|
536 |
//and reads the data and sets the iterator with the result. |
|
537 |
//--------------------------------------------------- |
|
538 |
EXPORT_C void CContactService::GetListL( CContactIter& aIter ) |
|
539 |
{ |
|
540 |
HBufC* ptr = NULL; |
|
541 |
||
542 |
//Get the list of stores present |
|
543 |
TInt count=(iContactManager->ContactStoresL()).Count(); |
|
544 |
||
545 |
RPointerArray<HBufC> array(count); |
|
546 |
CleanupClosePushL(array); |
|
547 |
for(int i=0; i<count; i++) |
|
548 |
{ |
|
549 |
ptr = |
|
550 |
iContactManager->ContactStoresL().At(i).StoreProperties().Uri().UriDes().AllocL(); |
|
551 |
CleanupStack::PushL(ptr); |
|
552 |
array.AppendL(ptr); |
|
553 |
CleanupStack::Pop(ptr); |
|
554 |
} |
|
555 |
//Set the iterator to point to this array |
|
556 |
aIter.SetDbNamePtr(array, count); |
|
557 |
CleanupStack::Pop(&array); |
|
558 |
} |
|
559 |
||
560 |
||
561 |
const MVPbkFieldTypeList& CContactService::GetFieldTypes() |
|
562 |
{ |
|
563 |
return iContactManager->FieldTypes(); |
|
564 |
} |
|
565 |
||
566 |
||
567 |
CVPbkContactManager& CContactService::GetContactManager() |
|
568 |
{ |
|
569 |
return *iContactManager; |
|
570 |
} |
|
571 |
||
572 |
||
573 |
// --------------------------------------------------------------------------- |
|
574 |
// Adds asynchronous request object |
|
575 |
// --------------------------------------------------------------------------- |
|
576 |
// |
|
577 |
void CContactService::AddAsyncObjL(const TInt32 aTransactionId, |
|
578 |
MCancelAsync* aAsyncObj) |
|
579 |
{ |
|
580 |
TAsyncRequestInfo asyncRequestInfo; |
|
581 |
asyncRequestInfo.iTransactionId = aTransactionId; |
|
582 |
asyncRequestInfo.iAsyncObj = aAsyncObj; |
|
583 |
iAsyncObjArray.AppendL( asyncRequestInfo ); |
|
584 |
} |
|
585 |
||
586 |
// --------------------------------------------------------------------------- |
|
587 |
// Cancels asynchronous request |
|
588 |
// --------------------------------------------------------------------------- |
|
589 |
// |
|
590 |
EXPORT_C TInt CContactService::Cancel( const TInt32 aTransactionId ) |
|
591 |
{ |
|
592 |
TInt pos = iAsyncObjArray.Count() - 1; |
|
593 |
TAsyncRequestInfo obj; |
|
594 |
TInt retVal = KErrNotFound; |
|
595 |
||
596 |
for ( ; pos >= 0; pos-- ) |
|
597 |
{ |
|
598 |
obj = iAsyncObjArray[pos]; |
|
599 |
if( obj.iTransactionId == aTransactionId ) |
|
600 |
{ |
|
601 |
obj.iAsyncObj->Cancel(); |
|
602 |
iAsyncObjArray.Remove(pos); |
|
603 |
iAsyncObjArray.Compress(); |
|
604 |
retVal = KErrNone; |
|
605 |
} |
|
606 |
} |
|
607 |
return retVal; |
|
608 |
} |
|
609 |
||
610 |
// --------------------------------------------------------------------------- |
|
611 |
// Gets the unsupported field key ID |
|
612 |
// --------------------------------------------------------------------------- |
|
613 |
// |
|
614 |
EXPORT_C TInt CContactService :: GetErrKey() |
|
615 |
{ |
|
616 |
return iErrKey; |
|
617 |
} |
|
618 |
// --------------------------------------------------------------------------- |
|
619 |
// Notifies Messaging service about the completeion of the request |
|
620 |
// --------------------------------------------------------------------------- |
|
621 |
// |
|
622 |
void CContactService::RequestComplete( const TInt32 aTransactionId ) |
|
623 |
{ |
|
624 |
TInt pos = iAsyncObjArray.Count() - 1; |
|
625 |
TAsyncRequestInfo obj; |
|
626 |
for ( ; pos >= 0; pos-- ) |
|
627 |
{ |
|
628 |
obj = iAsyncObjArray[pos]; |
|
629 |
if( obj.iTransactionId == aTransactionId ) |
|
630 |
{ |
|
631 |
iAsyncObjArray.Remove(pos); |
|
632 |
iAsyncObjArray.Compress(); |
|
633 |
return; |
|
634 |
} |
|
635 |
} |
|
636 |
} |
|
637 |
||
638 |
||
639 |
//end of file |