63
|
1 |
/*
|
|
2 |
* Copyright (c) 2006-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: Contacts handler for client API test suite
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
//SYSTEM INCLUDES
|
|
20 |
#include <utf.h>
|
|
21 |
#include <e32std.h>
|
|
22 |
#include <badesca.h>
|
|
23 |
#include <cvpbkcontactmanager.h>
|
|
24 |
#include <cvpbkcontactstoreuriarray.h>
|
|
25 |
#include <cvpbkcontactfielditerator.h>
|
|
26 |
#include <cvpbkfieldtyperefslist.h>
|
|
27 |
#include <cvpbkcontactlinkarray.h>
|
|
28 |
#include <tvpbkcontactstoreuriptr.h>
|
|
29 |
#include <mvpbkcontactoperationbase.h>
|
|
30 |
#include <mvpbkcontactstorelist.h>
|
|
31 |
#include <mvpbkcontactstore.h>
|
|
32 |
#include <mvpbkstorecontact.h>
|
|
33 |
#include <MVPbkContactFieldData.h>
|
|
34 |
#include <mvpbkcontactfieldtextdata.h>
|
|
35 |
#include <MVPbkContactFieldDateTimeData.h>
|
|
36 |
#include <mvpbkcontactstoreproperties.h>
|
|
37 |
#include <mvpbkContactLink.h>
|
|
38 |
#include <MVPbkContactGroup.h>
|
|
39 |
#include <vpbkeng.rsg>
|
|
40 |
#include <vpbkcontactstoreuris.h>
|
|
41 |
#include <tvpbkwordParsercallbackParam.h>
|
|
42 |
#include <tvpbkcontactstoreuriptr.h>
|
|
43 |
#include <CVPbkContactIdConverter.h>
|
|
44 |
#include <barsread.h>
|
|
45 |
#include <coemain.h>
|
|
46 |
|
|
47 |
//USER INCLUDES
|
|
48 |
#include "pstestcontactshandler.h"
|
|
49 |
|
|
50 |
_LIT(KDummyPhoneNumber,"9900211");
|
|
51 |
|
|
52 |
// ---------------------------------------------------------------------------------
|
|
53 |
// 1st phase constructor
|
|
54 |
// ---------------------------------------------------------------------------------
|
|
55 |
CPcsTestContactsHandler* CPcsTestContactsHandler::NewL(TBool aSimStoreOnly)
|
|
56 |
{
|
|
57 |
CPcsTestContactsHandler* self = new ( ELeave ) CPcsTestContactsHandler();
|
|
58 |
CleanupStack::PushL( self );
|
|
59 |
self->ConstructL(aSimStoreOnly);
|
|
60 |
CleanupStack::Pop( self );
|
|
61 |
|
|
62 |
return self;
|
|
63 |
}
|
|
64 |
|
|
65 |
// ---------------------------------------------------------------------------------
|
|
66 |
// Constructor
|
|
67 |
// ---------------------------------------------------------------------------------
|
|
68 |
//
|
|
69 |
CPcsTestContactsHandler::CPcsTestContactsHandler() : CActive( CActive::EPriorityStandard ),
|
|
70 |
iAtLeastOneStoreReady(EFalse),
|
|
71 |
iStoreEventToWaitFor(KErrNotFound),
|
|
72 |
iExpectedStoreEventReceived(ETrue)
|
|
73 |
{
|
|
74 |
CActiveScheduler::Add( this );
|
|
75 |
}
|
|
76 |
|
|
77 |
// ---------------------------------------------------------------------------------
|
|
78 |
// 2nd phase constructor
|
|
79 |
// ---------------------------------------------------------------------------------
|
|
80 |
void CPcsTestContactsHandler::ConstructL(TBool aSimStoreOnly)
|
|
81 |
{
|
|
82 |
iOperationComplete = EFalse;
|
|
83 |
|
|
84 |
// initialize virtual phonebook with phonebook and sim contact uris.
|
|
85 |
CVPbkContactStoreUriArray* uriArray = CVPbkContactStoreUriArray::NewLC();
|
|
86 |
if(aSimStoreOnly)
|
|
87 |
{
|
|
88 |
uriArray->AppendL( TVPbkContactStoreUriPtr( VPbkContactStoreUris::SimGlobalAdnUri() ) );
|
|
89 |
}
|
|
90 |
else
|
|
91 |
{
|
|
92 |
uriArray->AppendL( TVPbkContactStoreUriPtr(VPbkContactStoreUris::DefaultCntDbUri()));
|
|
93 |
//The below line is not actually reqired, but kept here for code coverage
|
|
94 |
//uriArray->AppendL( TVPbkContactStoreUriPtr( VPbkContactStoreUris::SimGlobalAdnUri() ) );
|
|
95 |
}
|
|
96 |
|
|
97 |
// Create the contact manager
|
|
98 |
iContactManager = CVPbkContactManager::NewL(*uriArray);
|
|
99 |
CleanupStack::PopAndDestroy(uriArray);
|
|
100 |
|
|
101 |
// Create the active scheduler wait
|
|
102 |
iWait = new( ELeave )CActiveSchedulerWait();
|
|
103 |
|
|
104 |
// Open al the stores
|
|
105 |
iContactManager->ContactStoresL().OpenAllL( *this );
|
|
106 |
if(aSimStoreOnly)
|
|
107 |
{
|
|
108 |
iStore = iContactManager->ContactStoresL().Find( TVPbkContactStoreUriPtr( VPbkContactStoreUris::SimGlobalAdnUri() ) );
|
|
109 |
}
|
|
110 |
else
|
|
111 |
{
|
|
112 |
iStore = iContactManager->ContactStoresL().Find( TVPbkContactStoreUriPtr( VPbkContactStoreUris::DefaultCntDbUri() ) );
|
|
113 |
}
|
|
114 |
|
|
115 |
iStore->OpenL( *this );
|
|
116 |
|
|
117 |
// Wait until the stores are open
|
|
118 |
while(!iOpenComplete)
|
|
119 |
{
|
|
120 |
if( !(iWait->IsStarted()) )
|
|
121 |
iWait->Start();
|
|
122 |
}
|
|
123 |
|
|
124 |
iContactsCreatedLinks = CVPbkContactLinkArray::NewL();
|
|
125 |
iContactLinksToAddToGroup = CVPbkContactLinkArray::NewL();
|
|
126 |
}
|
|
127 |
|
|
128 |
// ---------------------------------------------------------------------------------
|
|
129 |
// Destructor
|
|
130 |
// ---------------------------------------------------------------------------------
|
|
131 |
CPcsTestContactsHandler::~CPcsTestContactsHandler()
|
|
132 |
{
|
|
133 |
delete iWait;
|
|
134 |
iWait = NULL;
|
|
135 |
|
|
136 |
if(iContactsCreatedLinks)
|
|
137 |
{
|
|
138 |
iContactsCreatedLinks->ResetAndDestroy();
|
|
139 |
delete iContactsCreatedLinks;
|
|
140 |
}
|
|
141 |
if(iContactLinksToAddToGroup)
|
|
142 |
{
|
|
143 |
iContactLinksToAddToGroup->ResetAndDestroy();
|
|
144 |
delete iContactLinksToAddToGroup;
|
|
145 |
}
|
|
146 |
//plese note you shouldn't close stores before cleaning links arrays
|
|
147 |
if ( iContactManager )
|
|
148 |
{
|
|
149 |
TRAP_IGNORE(iContactManager->ContactStoresL().CloseAll( *this ));
|
|
150 |
delete iContactManager;
|
|
151 |
iContactManager = NULL;
|
|
152 |
}
|
|
153 |
|
|
154 |
if(iOp)
|
|
155 |
{
|
|
156 |
delete iOp ;
|
|
157 |
iOp = NULL;
|
|
158 |
}
|
|
159 |
}
|
|
160 |
|
|
161 |
// ---------------------------------------------------------------------------
|
|
162 |
// From class MVPbkContactStoreListObserver.
|
|
163 |
// ---------------------------------------------------------------------------
|
|
164 |
void CPcsTestContactsHandler::OpenComplete()
|
|
165 |
{
|
|
166 |
iOpenComplete = ETrue;
|
|
167 |
if( iWait->IsStarted() )
|
|
168 |
{
|
|
169 |
iWait->AsyncStop();
|
|
170 |
}
|
|
171 |
}
|
|
172 |
|
|
173 |
// ---------------------------------------------------------------------------
|
|
174 |
// // Call back method. Called if the store is available
|
|
175 |
// ---------------------------------------------------------------------------
|
|
176 |
//
|
|
177 |
void CPcsTestContactsHandler::StoreReady(MVPbkContactStore& /*aStore*/)
|
|
178 |
{
|
|
179 |
iAtLeastOneStoreReady = ETrue;
|
|
180 |
}
|
|
181 |
|
|
182 |
// ---------------------------------------------------------------------------
|
|
183 |
// Call back method. Called if the store is not available
|
|
184 |
// ---------------------------------------------------------------------------
|
|
185 |
void CPcsTestContactsHandler::StoreUnavailable(
|
|
186 |
MVPbkContactStore& /*aContactStore*/, TInt /*aReason*/)
|
|
187 |
{
|
|
188 |
// The store is not available
|
|
189 |
// So do nothing ....
|
|
190 |
}
|
|
191 |
|
|
192 |
// ---------------------------------------------------------------------------
|
|
193 |
// Handles the events received from the contact store.
|
|
194 |
// ---------------------------------------------------------------------------
|
|
195 |
void CPcsTestContactsHandler::HandleStoreEventL(MVPbkContactStore& /*aContactStore*/,
|
|
196 |
TVPbkContactStoreEvent aStoreEvent)
|
|
197 |
{
|
|
198 |
if ( aStoreEvent.iEventType == iStoreEventToWaitFor )
|
|
199 |
{
|
|
200 |
iExpectedStoreEventReceived = ETrue;
|
|
201 |
}
|
|
202 |
|
|
203 |
switch (aStoreEvent.iEventType)
|
|
204 |
{
|
|
205 |
case TVPbkContactStoreEvent::EContactAdded:
|
|
206 |
{
|
|
207 |
// If a group is added, then we need to add this contact to the group
|
|
208 |
if(iGroupAdded)
|
|
209 |
{
|
|
210 |
MVPbkContactLink* temp = aStoreEvent.iContactLink->CloneLC();
|
|
211 |
iContactLinksToAddToGroup->AppendL(temp);
|
|
212 |
CleanupStack::Pop();
|
|
213 |
}
|
|
214 |
break;
|
|
215 |
}
|
|
216 |
|
|
217 |
case TVPbkContactStoreEvent::EContactDeleted:
|
|
218 |
case TVPbkContactStoreEvent::EContactChanged:
|
|
219 |
{
|
|
220 |
break;
|
|
221 |
}
|
|
222 |
default:
|
|
223 |
break;
|
|
224 |
}
|
|
225 |
StopSchedulerIfNothingToWaitFor();
|
|
226 |
}
|
|
227 |
|
|
228 |
// ---------------------------------------------------------------------------------
|
|
229 |
// This fucntion creates a new contact in the phonebook with the specified
|
|
230 |
// vpbkIds and a defualt Phone Number
|
|
231 |
// Callback functions: ContactOperationCompleted() and ContactOperationFailed()
|
|
232 |
// ---------------------------------------------------------------------------------
|
|
233 |
void CPcsTestContactsHandler::CreateOneContactL(cacheData& aInputCacheData)
|
|
234 |
{
|
|
235 |
//wait for operation completion
|
|
236 |
iOperationComplete = EFalse;
|
|
237 |
//wait for confirmation that contact was added
|
|
238 |
iExpectedStoreEventReceived = EFalse;
|
|
239 |
iStoreEventToWaitFor = TVPbkContactStoreEvent::EContactAdded;
|
|
240 |
|
|
241 |
fieldTypeRefList = CVPbkFieldTypeRefsList::NewL();
|
|
242 |
CleanupStack::PushL(fieldTypeRefList);
|
|
243 |
|
|
244 |
//Check if the input is correct
|
|
245 |
if( aInputCacheData.vpbkId.Count() != aInputCacheData.data.Count())
|
|
246 |
{
|
|
247 |
User::Leave(KErrGeneral);
|
|
248 |
}
|
|
249 |
|
|
250 |
// Add the vpbkIds from the data to the fieldTypeRefList
|
|
251 |
for(TInt i=0; i < aInputCacheData.vpbkId.Count();i++)
|
|
252 |
{
|
|
253 |
fieldTypeRefList->AppendL(*iContactManager->FieldTypes().Find( aInputCacheData.vpbkId[i]));
|
|
254 |
}
|
|
255 |
|
|
256 |
// Add the mobile phone also. (Basically for code coverage reasons)
|
|
257 |
fieldTypeRefList->AppendL(*iContactManager->FieldTypes().Find( R_VPBK_FIELD_TYPE_MOBILEPHONEGEN ) );
|
|
258 |
|
|
259 |
// Create the contact
|
|
260 |
iStoreContact = iStore->CreateNewContactLC();
|
|
261 |
|
|
262 |
// Add data to respective ids
|
|
263 |
for(TInt i=0; i < aInputCacheData.vpbkId.Count();i++)
|
|
264 |
{
|
|
265 |
MVPbkStoreContactField* dataField = iStoreContact->CreateFieldLC( fieldTypeRefList->FieldTypeAt( i ) );
|
|
266 |
(MVPbkContactFieldTextData::Cast(dataField->FieldData())).SetTextL( *(aInputCacheData.data[i]) );
|
|
267 |
iStoreContact->AddFieldL( dataField );
|
|
268 |
CleanupStack::Pop(); // dataField
|
|
269 |
}
|
|
270 |
|
|
271 |
// We have hardcoded the phone number, since this field is not used for search.
|
|
272 |
// This field has been added for code coverage improvment
|
|
273 |
MVPbkStoreContactField* PhoneNumberfield = iStoreContact->CreateFieldLC( fieldTypeRefList->FieldTypeAt(aInputCacheData.vpbkId.Count() ) );
|
|
274 |
(MVPbkContactFieldTextData::Cast(PhoneNumberfield->FieldData())).SetTextL( KDummyPhoneNumber);
|
|
275 |
iStoreContact->AddFieldL( PhoneNumberfield );
|
|
276 |
CleanupStack::Pop(); // PhoneNumberfield
|
|
277 |
|
|
278 |
// Commit the contact data
|
|
279 |
iStoreContact->CommitL( *this );
|
|
280 |
CleanupStack::Pop(); // iStoreContact
|
|
281 |
CleanupStack::Pop(); // fieldTypeRefList
|
|
282 |
|
|
283 |
if( !(iWait->IsStarted()) )
|
|
284 |
{
|
|
285 |
iWait->Start();
|
|
286 |
}
|
|
287 |
delete fieldTypeRefList;
|
|
288 |
fieldTypeRefList = NULL;
|
|
289 |
}
|
|
290 |
|
|
291 |
// ---------------------------------------------------------------------------------
|
|
292 |
// This fucntion deletes all the created contacts
|
|
293 |
// ---------------------------------------------------------------------------------
|
|
294 |
void CPcsTestContactsHandler::DeleteAllCreatedContactsL()
|
|
295 |
{
|
|
296 |
if(iContactsCreatedLinks->Count())
|
|
297 |
{
|
|
298 |
iOperationComplete = EFalse;
|
|
299 |
// Delete all the contacts
|
|
300 |
iOp = iContactManager->DeleteContactsL( *iContactsCreatedLinks, *this );
|
|
301 |
while(!iOperationComplete)
|
|
302 |
{
|
|
303 |
if( !(iWait->IsStarted()) )
|
|
304 |
iWait->Start();
|
|
305 |
}
|
|
306 |
}
|
|
307 |
}
|
|
308 |
|
|
309 |
// ---------------------------------------------------------------------------------
|
|
310 |
// This fucntion adds a group
|
|
311 |
// ---------------------------------------------------------------------------------
|
|
312 |
void CPcsTestContactsHandler::AddGroupL(const TDesC& aGroupName)
|
|
313 |
{
|
|
314 |
iGroupAdded = iStore->CreateNewContactGroupLC();
|
|
315 |
iGroupAdded->SetGroupLabelL( aGroupName );
|
|
316 |
iGroupAdded->CommitL(*this);
|
|
317 |
CleanupStack::Pop();
|
|
318 |
}
|
|
319 |
|
|
320 |
// ---------------------------------------------------------------------------------
|
|
321 |
// From CActive
|
|
322 |
// Handles an active object's request completion event.
|
|
323 |
// ---------------------------------------------------------------------------------
|
|
324 |
void CPcsTestContactsHandler::RunL()
|
|
325 |
{
|
|
326 |
if(!iOperationComplete)
|
|
327 |
{
|
|
328 |
TRequestStatus* status = &iStatus;
|
|
329 |
User::RequestComplete( status, KErrNone );
|
|
330 |
SetActive();
|
|
331 |
}
|
|
332 |
else
|
|
333 |
{
|
|
334 |
StopSchedulerIfNothingToWaitFor();
|
|
335 |
}
|
|
336 |
}
|
|
337 |
|
|
338 |
// ---------------------------------------------------------------------------------
|
|
339 |
// If the RunL function leaves,
|
|
340 |
// then the active scheduler calls RunError() to handle the leave.
|
|
341 |
// ---------------------------------------------------------------------------------
|
|
342 |
TInt CPcsTestContactsHandler::RunError(TInt /*aError*/)
|
|
343 |
{
|
|
344 |
return KErrNone;
|
|
345 |
}
|
|
346 |
|
|
347 |
// ---------------------------------------------------------------------------------
|
|
348 |
// From CActive
|
|
349 |
// Implements cancellation of an outstanding request.
|
|
350 |
// ---------------------------------------------------------------------------------
|
|
351 |
void CPcsTestContactsHandler::DoCancel()
|
|
352 |
{
|
|
353 |
// Not supported
|
|
354 |
}
|
|
355 |
|
|
356 |
// ---------------------------------------------------------------------------------
|
|
357 |
// Stops main active scheduler loop if stop conditions are fullfiled
|
|
358 |
// ---------------------------------------------------------------------------------
|
|
359 |
void CPcsTestContactsHandler::StopSchedulerIfNothingToWaitFor()
|
|
360 |
{
|
|
361 |
if( iOperationComplete && iExpectedStoreEventReceived )
|
|
362 |
{
|
|
363 |
CActiveScheduler::Stop();
|
|
364 |
}
|
|
365 |
}
|
|
366 |
|
|
367 |
// ---------------------------------------------------------------------------------
|
|
368 |
// Called when a contact operation has succesfully completed.
|
|
369 |
// Callback for CommitL
|
|
370 |
// ---------------------------------------------------------------------------------
|
|
371 |
void CPcsTestContactsHandler::ContactOperationCompleted(TContactOpResult /*aResult*/)
|
|
372 |
{
|
|
373 |
iOperationComplete = ETrue;
|
|
374 |
delete iStoreContact;
|
|
375 |
iStoreContact = NULL;
|
|
376 |
|
|
377 |
if( iWait->IsStarted() )
|
|
378 |
{
|
|
379 |
iWait->AsyncStop();
|
|
380 |
}
|
|
381 |
|
|
382 |
TRequestStatus* status = &iStatus;
|
|
383 |
User::RequestComplete( status, KErrNone );
|
|
384 |
SetActive();
|
|
385 |
}
|
|
386 |
|
|
387 |
// ---------------------------------------------------------------------------------
|
|
388 |
// Called when a contact operation has failed
|
|
389 |
// Callback for CommitL
|
|
390 |
// ---------------------------------------------------------------------------------
|
|
391 |
void CPcsTestContactsHandler::ContactOperationFailed
|
|
392 |
(TContactOp /*aOpCode*/, TInt /*aErrorCode*/, TBool /*aErrorNotified*/)
|
|
393 |
{
|
|
394 |
iOperationComplete = ETrue;
|
|
395 |
TRequestStatus* status = &iStatus;
|
|
396 |
User::RequestComplete( status, KErrNone );
|
|
397 |
SetActive();
|
|
398 |
}
|
|
399 |
|
|
400 |
// ---------------------------------------------------------------------------------
|
|
401 |
// Called when one step of the operation is completed.
|
|
402 |
// Callback for DeleteContactsL,
|
|
403 |
// ---------------------------------------------------------------------------------
|
|
404 |
void CPcsTestContactsHandler::StepComplete(MVPbkContactOperationBase& /*aOperation*/, TInt /*aStepSize*/ )
|
|
405 |
{
|
|
406 |
}
|
|
407 |
|
|
408 |
// ---------------------------------------------------------------------------------
|
|
409 |
// CPcsTestContactsHandler::StepComplete()
|
|
410 |
// Called when one step of the operation fails.
|
|
411 |
// Callback for DeleteContactsL,
|
|
412 |
// ---------------------------------------------------------------------------------
|
|
413 |
TBool CPcsTestContactsHandler::StepFailed(MVPbkContactOperationBase& /*aOperation*/, TInt /*aStepSize*/, TInt /*aError*/ )
|
|
414 |
{
|
|
415 |
return ETrue;
|
|
416 |
}
|
|
417 |
|
|
418 |
// ---------------------------------------------------------------------------------
|
|
419 |
// Called when operation is completed.
|
|
420 |
// This is called when all steps are executed. If EFalse is returned
|
|
421 |
// in StepFailed() call this function is NOT called.
|
|
422 |
// Callback for DeleteContactsL,
|
|
423 |
// ---------------------------------------------------------------------------------
|
|
424 |
void CPcsTestContactsHandler::OperationComplete(MVPbkContactOperationBase& aOperation )
|
|
425 |
{
|
|
426 |
iOperationComplete = ETrue;
|
|
427 |
|
|
428 |
// iDeleteComplete = ETrue;
|
|
429 |
if( iWait->IsStarted() )
|
|
430 |
{
|
|
431 |
iWait->AsyncStop();
|
|
432 |
}
|
|
433 |
|
|
434 |
iOp = &aOperation ;
|
|
435 |
if( iOp )
|
|
436 |
{
|
|
437 |
delete iOp;
|
|
438 |
iOp = NULL;
|
|
439 |
}
|
|
440 |
|
|
441 |
delete iContactLinksToDelete;
|
|
442 |
iContactLinksToDelete = NULL;
|
|
443 |
|
|
444 |
TRequestStatus* status = &iStatus;
|
|
445 |
User::RequestComplete( status, KErrNone );
|
|
446 |
SetActive();
|
|
447 |
}
|
|
448 |
|
|
449 |
// ---------------------------------------------------------------------------------
|
|
450 |
// This function deltes contacts with the id specified
|
|
451 |
// ---------------------------------------------------------------------------------
|
|
452 |
void CPcsTestContactsHandler::DeleteContactsWithIdsL(RArray<TInt>& aContactIdArray)
|
|
453 |
{
|
|
454 |
CVPbkContactIdConverter* converter = NULL;
|
|
455 |
TRAPD ( err, converter = CVPbkContactIdConverter::NewL( *iStore ) );
|
|
456 |
|
|
457 |
if ( err != KErrNotSupported )
|
|
458 |
{
|
|
459 |
iContactLinksToDelete = CVPbkContactLinkArray::NewL();
|
|
460 |
for(TInt i =0;i < aContactIdArray.Count(); i++)
|
|
461 |
{
|
|
462 |
// get the contact link
|
|
463 |
MVPbkContactLink* contactLink = NULL;
|
|
464 |
contactLink = converter->IdentifierToLinkLC(aContactIdArray[i]);
|
|
465 |
CleanupStack::Pop();
|
|
466 |
|
|
467 |
MVPbkContactLink* temp = contactLink->CloneLC();
|
|
468 |
iContactLinksToDelete->AppendL(temp);
|
|
469 |
CleanupStack::Pop();
|
|
470 |
}
|
|
471 |
|
|
472 |
// Delete the contacts
|
|
473 |
iOp = iContactManager->DeleteContactsL( *iContactLinksToDelete, *this );
|
|
474 |
while(!iOperationComplete)
|
|
475 |
{
|
|
476 |
if( !(iWait->IsStarted()) )
|
|
477 |
iWait->Start();
|
|
478 |
}
|
|
479 |
}
|
|
480 |
|
|
481 |
// Delete the converter
|
|
482 |
if(converter)
|
|
483 |
{
|
|
484 |
delete converter;
|
|
485 |
converter = NULL;
|
|
486 |
}
|
|
487 |
}
|
|
488 |
|
|
489 |
// -----------------------------------------------------------------------------
|
|
490 |
// Tests if Id returns correct vpbklink
|
|
491 |
// -----------------------------------------------------------------------------
|
|
492 |
|
|
493 |
TBool CPcsTestContactsHandler::TestVpbkLinkForIdL(CPSRequestHandler& aPsClientHandler,const CPsClientData& aSearchResult)
|
|
494 |
{
|
|
495 |
TBool ret = EFalse;
|
|
496 |
// Get the link from Ps engine
|
|
497 |
MVPbkContactLink* tmpLink1 = aPsClientHandler.ConvertToVpbkLinkLC( aSearchResult,*iContactManager );
|
|
498 |
|
|
499 |
// Get the link from the manager
|
|
500 |
CVPbkContactIdConverter* converter = NULL;
|
|
501 |
TRAPD ( err, converter = CVPbkContactIdConverter::NewL( *iStore ) );
|
|
502 |
MVPbkContactLink* tmpLink2 = NULL;
|
|
503 |
if ( err != KErrNotSupported )
|
|
504 |
{
|
|
505 |
// get the contact link
|
|
506 |
tmpLink2 = converter->IdentifierToLinkLC(aSearchResult.Id());
|
|
507 |
ret = (tmpLink1->IsSame(*tmpLink2));
|
|
508 |
CleanupStack::Pop(2);
|
|
509 |
}
|
|
510 |
else
|
|
511 |
{
|
|
512 |
CleanupStack::PopAndDestroy();
|
|
513 |
ret = EFalse;
|
|
514 |
}
|
|
515 |
|
|
516 |
// Cleanup
|
|
517 |
delete converter;
|
|
518 |
converter = NULL;
|
|
519 |
|
|
520 |
return ret;
|
|
521 |
}
|
|
522 |
|
|
523 |
// -----------------------------------------------------------------------------
|
|
524 |
// CPcsTestContactsHandler::AddCreatedContactsToGroup()
|
|
525 |
// -----------------------------------------------------------------------------
|
|
526 |
void CPcsTestContactsHandler::AddCreatedContactsToGroup()
|
|
527 |
{
|
|
528 |
if(iGroupAdded)
|
|
529 |
{
|
|
530 |
for(TInt i=0;i<iContactLinksToAddToGroup->Count();i++ )
|
|
531 |
iGroupAdded->AddContactL(iContactLinksToAddToGroup->At(i));
|
|
532 |
}
|
|
533 |
}
|
|
534 |
|
|
535 |
// End of file
|