author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Tue, 24 Nov 2009 08:56:33 +0200 | |
changeset 33 | 50974a8b132e |
parent 22 | fc9cf246af83 |
child 59 | 1aa6688bfd6b |
permissions | -rw-r--r-- |
19 | 1 |
/* |
2 |
* Copyright (c) 2002 - 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: ?Description |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
||
19 |
||
20 |
||
21 |
// INCLUDE FILES |
|
22 |
#include <e32svr.h> |
|
23 |
#include <StifParser.h> |
|
33
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
24 |
#include <StifTestInterface.h> |
19 | 25 |
#include <VPbkEng.rsg> |
26 |
||
27 |
#include <MVPbkContactFieldTextData.h> |
|
28 |
#include <MVPbkContactStoreList.h> |
|
29 |
#include <MVPbkContactOperationBase.h> |
|
30 |
#include <MVPbkContactLink.h> |
|
31 |
#include <CVPbkContactLinkArray.h> |
|
32 |
#include <MVPbkContactGroup.h> |
|
33 |
#include <utf.h> |
|
34 |
#include <CVPbkPhoneNumberMatchStrategy.h> |
|
35 |
#include <CVPbkContactStoreUriArray.h> |
|
36 |
#include <TVPbkContactStoreUriPtr.h> |
|
37 |
#include "tcontacts_async.h" |
|
38 |
#include "singlecontact.h" |
|
39 |
||
40 |
// CONSTANTS |
|
41 |
_LIT(KError,"Error code is"); |
|
42 |
_LIT(KSuccess,"Successful"); |
|
43 |
_LIT(KNewLine,"\n"); |
|
44 |
_LIT(KServiceOpen,"Service handle created"); |
|
45 |
_LIT(KServiceClose,"Service handle deleted"); |
|
46 |
_LIT(KPhoneNumber,"9886431364"); |
|
47 |
_LIT(KGroup1,"Test1"); |
|
48 |
TInt KInvalidKey = -1; |
|
49 |
// ============================ MEMBER FUNCTIONS =============================== |
|
50 |
||
51 |
// ----------------------------------------------------------------------------- |
|
52 |
// CContactsUT::Delete |
|
53 |
// Delete here all resources allocated and opened from test methods. |
|
54 |
// Called from destructor. |
|
55 |
// ----------------------------------------------------------------------------- |
|
56 |
// |
|
57 |
void CContactsUT::Delete() |
|
58 |
{ |
|
59 |
||
60 |
} |
|
61 |
||
62 |
// ----------------------------------------------------------------------------- |
|
63 |
// CContactsUT::RunMethodL |
|
64 |
// Run specified method. Contains also table of test mothods and their names. |
|
65 |
// ----------------------------------------------------------------------------- |
|
66 |
// |
|
67 |
TInt CContactsUT::RunMethodL( |
|
68 |
CStifItemParser& aItem ) |
|
69 |
{ |
|
70 |
||
71 |
static TStifFunctionInfo const KFunctions[] = |
|
72 |
{ |
|
73 |
ENTRY( "Add_contact_sapi", CContactsUT::AddContactSAPIL ), |
|
74 |
ENTRY( "Delete_contact_sapi", CContactsUT::DeleteContactSAPIL ), |
|
75 |
ENTRY( "Modify_contact_sapi", CContactsUT::ModifyContactSAPIL ), |
|
76 |
ENTRY( "Getlist_delete_contact", CContactsUT::GetListDeleteContactL ), |
|
77 |
ENTRY( "Add_getlist_contact", CContactsUT::AddContactGetListL ), |
|
78 |
ENTRY( "Get_group", CContactsUT::GetGroupsL ), |
|
79 |
ENTRY( "Get_contact", CContactsUT::GetContactsL ), |
|
80 |
ENTRY( "Get_database", CContactsUT::GetDatabaseL ), |
|
81 |
ENTRY( "Add_contact", CContactsUT::AddL ), |
|
82 |
ENTRY( "Add_group", CContactsUT::AddGroupL ), |
|
83 |
ENTRY( "Modify_contact", CContactsUT::ModifyL ), |
|
84 |
ENTRY( "Modify_group", CContactsUT::ModifyGroupL ), |
|
85 |
ENTRY( "Delete_contact", CContactsUT::DeleteContactL ), |
|
86 |
ENTRY( "Delete_group", CContactsUT::DeleteGroupL ), |
|
87 |
ENTRY( "Organise_add", CContactsUT::OrganiseAddL ), |
|
88 |
ENTRY( "Organise_delete", CContactsUT::OrganiseDeleteL ), |
|
89 |
ENTRY( "Import", CContactsUT::ImportL ), |
|
90 |
ENTRY( "Export", CContactsUT::ExportL ), |
|
91 |
ENTRY( "Get_SearchContact", CContactsUT::GetSearchContactL ), |
|
92 |
ENTRY( "Get_ContactAsc", CContactsUT::GetContactsAscOrderL ), |
|
93 |
ENTRY( "Get_ContactDsc", CContactsUT::GetContactsDscOrderL ), |
|
94 |
ENTRY( "Get_ContactbyId", CContactsUT::GetListConactIdL ), |
|
95 |
ENTRY( "AddInvalidField", CContactsUT::AddInvalidFieldL ), |
|
96 |
ENTRY( "AddMultiplePhoneNumbersContact", CContactsUT::AddMultiplePhoneNumbersContactL ), |
|
97 |
ENTRY( "DeleteSingleContact", CContactsUT::DeleteSingleContactL ), |
|
98 |
ENTRY( "GetListCancelTest", CContactsUT::GetListCancelL ), |
|
99 |
ENTRY( "GetListSrchCancelTest", CContactsUT::GetListSrchCancelL ), |
|
100 |
ENTRY( "ExportCancelTest", CContactsUT::ExportCancelL ), |
|
101 |
ENTRY( "AddCancelTest", CContactsUT::AddCancelL ), |
|
102 |
ENTRY( "ImportCancelTest", CContactsUT::ImportCancelL ), |
|
103 |
ENTRY( "DeleteCancelTest", CContactsUT::DeleteCancelL ), |
|
104 |
ENTRY( "OrganiseCancelTest", CContactsUT::OrganiseCancelL), |
|
105 |
}; |
|
106 |
||
107 |
const TInt count = sizeof( KFunctions ) / |
|
108 |
sizeof( TStifFunctionInfo ); |
|
109 |
||
110 |
return RunInternalL( KFunctions, count, aItem ); |
|
111 |
||
112 |
} |
|
22
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
113 |
void CContactsUT::HandleReturnId( const TInt& aError, HBufC8* acntId, TInt aTransId ) |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
114 |
{ |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
115 |
CActiveScheduler::Stop(); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
116 |
} |
19 | 117 |
|
22
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
118 |
void CContactsUT::HandleReturnArray(const TInt& aError, RPointerArray<HBufC8>& aArray, TInt aTransId ) |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
119 |
{ |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
120 |
CActiveScheduler::Stop(); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
121 |
} |
19 | 122 |
void CContactsUT::HandleReturnValue(TOperationEvent /*aEvent*/, const TInt& aError, TInt /*aTransId*/ ) |
123 |
{ |
|
124 |
CActiveScheduler::Stop(); |
|
125 |
_LIT(KFunc,"In Handle Return Value\n"); |
|
126 |
iLog->Log(KFunc); |
|
127 |
if(aError == KErrArgument) |
|
128 |
iErr = KErrNone; |
|
129 |
else |
|
130 |
iErr = aError; |
|
131 |
TBuf<5> buf; |
|
132 |
buf.Num(aError); |
|
133 |
iLog->Log(KError); |
|
134 |
iLog->Log(buf); |
|
135 |
iLog->Log(KNewLine); |
|
136 |
} |
|
137 |
||
138 |
void CContactsUT::HandleReturnIter(const TInt& aError, CContactIter* aIter, TInt /*aTransId*/ ) |
|
139 |
{ |
|
140 |
CActiveScheduler::Stop(); |
|
141 |
_LIT(KFunc,"In Handle Return Iter\n"); |
|
142 |
iLog->Log(KFunc); |
|
143 |
iErr = aError; |
|
144 |
TBuf<5> buf; |
|
145 |
buf.Num(aError); |
|
146 |
iLog->Log(KError); |
|
147 |
iLog->Log(buf); |
|
148 |
iLog->Log(KNewLine); |
|
149 |
||
150 |
if(EGetContactDelete == iOperation ) |
|
151 |
{ |
|
152 |
iOperation = ENone; |
|
153 |
CSingleContact* singleContact = NULL; |
|
154 |
HBufC8* buf = NULL; |
|
155 |
TInt count = 0; |
|
156 |
while(ETrue) |
|
157 |
{ |
|
158 |
aIter->NextL(singleContact,buf); |
|
159 |
if(!singleContact) |
|
160 |
{ |
|
161 |
break; |
|
162 |
} |
|
163 |
iBuffer = buf; |
|
164 |
// delete buf; |
|
165 |
delete singleContact; |
|
166 |
break; |
|
167 |
} |
|
168 |
} |
|
169 |
if(iOperation == EContact) |
|
170 |
{ |
|
171 |
iOperation = ENone; |
|
172 |
iErr = KErrGeneral; |
|
173 |
CSingleContact* singleContact = NULL; |
|
174 |
HBufC8* buf = NULL; |
|
175 |
||
176 |
_LIT(KPhone,"Birbal"); |
|
177 |
_LIT8(KField,"FirstName"); |
|
178 |
||
179 |
while(ETrue) |
|
180 |
{ |
|
181 |
__UHEAP_MARK; |
|
182 |
aIter->NextL(singleContact,buf); |
|
183 |
if(!singleContact) |
|
184 |
{ |
|
185 |
break; |
|
186 |
} |
|
187 |
CleanupStack::PushL(singleContact); |
|
188 |
//CleanupStack::PushL(buf); |
|
189 |
if(!buf->Compare(*iBuffer)) |
|
190 |
{ |
|
191 |
TInt count(singleContact->FieldCount()); |
|
192 |
CSingleContactField* field = NULL; |
|
193 |
while(count) |
|
194 |
{ |
|
195 |
TPtrC8 fieldKey; |
|
196 |
TPtrC label; |
|
197 |
TPtrC value; |
|
198 |
field = singleContact->FieldAt(--count); |
|
199 |
field->GetFieldDataL(fieldKey,label,value); |
|
200 |
if(!fieldKey.Compare(KField)) |
|
201 |
{ |
|
202 |
field->SetFieldParamsL(KField,KNullDesC,KPhone); |
|
203 |
iLog->Log(_L("Phone Contact Field modified \n")); |
|
204 |
__UHEAP_MARK; |
|
205 |
iServiceHandle->AddL(this,0,singleContact); |
|
206 |
iLog->Log(_L("AddL called\n")); |
|
207 |
iLog->Log(_L("Start Active Scheduler\n")); |
|
208 |
CActiveScheduler::Start(); |
|
209 |
__UHEAP_MARKEND; |
|
210 |
break; |
|
211 |
} |
|
212 |
} |
|
213 |
} |
|
214 |
||
215 |
//CleanupStack::PopAndDestroy(buf); |
|
216 |
delete buf; |
|
217 |
CleanupStack::PopAndDestroy(singleContact); |
|
218 |
__UHEAP_MARKEND; |
|
219 |
} |
|
220 |
} |
|
221 |
if(EGetContact == iOperation ) |
|
222 |
{ |
|
223 |
iOperation = ENone; |
|
224 |
//iErr = KErrGeneral; |
|
225 |
_LIT8(KFirstName,"FirstName"); |
|
226 |
_LIT(KName,"Kats"); |
|
227 |
CSingleContact* singleContact = NULL; |
|
228 |
HBufC8* buf = NULL; |
|
229 |
TInt count = 0; |
|
230 |
while(ETrue) |
|
231 |
{ |
|
232 |
aIter->NextL(singleContact,buf); |
|
233 |
if(!singleContact) |
|
234 |
{ |
|
235 |
break; |
|
236 |
} |
|
237 |
++count; |
|
238 |
TInt count(singleContact->FieldCount()); |
|
239 |
while(count) |
|
240 |
{ |
|
241 |
CSingleContactField* field = singleContact->FieldAt(--count); |
|
242 |
TPtrC8 fieldKey; |
|
243 |
TPtrC label; |
|
244 |
TPtrC value; |
|
245 |
field->GetFieldDataL(fieldKey,label,value); |
|
246 |
if (fieldKey == KFirstName && value == KName) |
|
247 |
{ |
|
248 |
iErr = KErrNone; |
|
249 |
} |
|
250 |
// delete field; |
|
251 |
} |
|
252 |
delete buf; |
|
253 |
delete singleContact; |
|
254 |
} |
|
255 |
delete buf; |
|
256 |
} |
|
257 |
if(EContactVerify == iOperation ) |
|
258 |
{ |
|
259 |
iOperation = ENone; |
|
260 |
iErr = KErrGeneral; |
|
261 |
_LIT8(KFirstName,"FirstName"); |
|
262 |
_LIT(KName,"Tenali"); |
|
263 |
CSingleContact* singleContact = NULL; |
|
264 |
HBufC8* buf = NULL; |
|
265 |
aIter->NextL(singleContact,buf); |
|
266 |
if(buf->Compare(*iBuf)==0) |
|
267 |
{ |
|
268 |
iErr = KErrNone; |
|
269 |
} |
|
270 |
} |
|
271 |
if(EContactId == iOperation ) |
|
272 |
{ |
|
273 |
iOperation = ENone; |
|
274 |
//iErr = KErrGeneral; |
|
275 |
_LIT8(KFirstName,"FirstName"); |
|
276 |
_LIT(KName,"Tenali"); |
|
277 |
CSingleContact* singleContact = NULL; |
|
278 |
HBufC8* buf = NULL; |
|
279 |
TInt count = 0; |
|
280 |
||
281 |
aIter->NextL(singleContact,buf); |
|
282 |
iOperation = EContactVerify; |
|
283 |
iBuf = buf; |
|
284 |
iServiceHandle->GetListL(this,0,EContacts,*buf); |
|
285 |
CActiveScheduler::Start(); |
|
286 |
delete singleContact; |
|
287 |
} |
|
288 |
if(ESearchContact == iOperation ) |
|
289 |
{ |
|
290 |
iOperation = ENone; |
|
291 |
iErr = KErrGeneral; |
|
292 |
_LIT8(KFirstName,"FirstName"); |
|
293 |
_LIT(KName,"Tenali"); |
|
294 |
CSingleContact* singleContact = NULL; |
|
295 |
HBufC8* buf = NULL; |
|
296 |
TInt count = 0; |
|
297 |
while(ETrue) |
|
298 |
{ |
|
299 |
aIter->NextL(singleContact,buf); |
|
300 |
if(!singleContact) |
|
301 |
{ |
|
302 |
break; |
|
303 |
} |
|
304 |
++count; |
|
305 |
TInt count(singleContact->FieldCount()); |
|
306 |
while(count) |
|
307 |
{ |
|
308 |
CSingleContactField* field = singleContact->FieldAt(--count); |
|
309 |
TPtrC8 fieldKey; |
|
310 |
TPtrC label; |
|
311 |
TPtrC value; |
|
312 |
field->GetFieldDataL(fieldKey,label,value); |
|
313 |
if (fieldKey == KFirstName && value == KName) |
|
314 |
{ |
|
315 |
iErr = KErrNone; |
|
316 |
} |
|
317 |
else if (fieldKey == KFirstName) |
|
318 |
{ |
|
319 |
break; |
|
320 |
} |
|
321 |
} |
|
322 |
delete singleContact; |
|
323 |
} |
|
324 |
} |
|
325 |
if(EAscContact == iOperation ) |
|
326 |
{ |
|
327 |
iOperation = ENone; |
|
328 |
iErr = KErrGeneral; |
|
329 |
_LIT8(KFirstName,"FirstName"); |
|
330 |
_LIT(KNameT,"Tenali"); |
|
331 |
_LIT(KNameB,"Birbal"); |
|
332 |
TInt count1 = 0; |
|
333 |
TInt tCount = 0; |
|
334 |
TInt bCount = 0; |
|
335 |
CSingleContact* singleContact = NULL; |
|
336 |
HBufC8* buf = NULL; |
|
337 |
TInt count = 0; |
|
338 |
||
339 |
while(ETrue) |
|
340 |
{ |
|
341 |
aIter->NextL(singleContact,buf); |
|
342 |
if(!singleContact) |
|
343 |
{ |
|
344 |
break; |
|
345 |
} |
|
346 |
++count; |
|
347 |
TInt count(singleContact->FieldCount()); |
|
348 |
while(count) |
|
349 |
{ |
|
350 |
CSingleContactField* field = singleContact->FieldAt(--count); |
|
351 |
TPtrC8 fieldKey; |
|
352 |
TPtrC label; |
|
353 |
TPtrC value; |
|
354 |
field->GetFieldDataL(fieldKey,label,value); |
|
355 |
if (fieldKey == KFirstName && value == KNameT) |
|
356 |
{ |
|
357 |
++count1; |
|
358 |
tCount = count1; |
|
359 |
} |
|
360 |
if (fieldKey == KFirstName && value == KNameB) |
|
361 |
{ |
|
362 |
++count1; |
|
363 |
bCount = count1; |
|
364 |
} |
|
365 |
||
366 |
} |
|
367 |
delete singleContact; |
|
368 |
} |
|
369 |
||
370 |
if(bCount>0 && tCount>0 && bCount<tCount) |
|
371 |
{ |
|
372 |
iErr = KErrNone; |
|
373 |
} |
|
374 |
} |
|
375 |
||
376 |
if(EDscContact == iOperation ) |
|
377 |
{ |
|
378 |
iOperation = ENone; |
|
379 |
iErr = KErrGeneral; |
|
380 |
_LIT8(KFirstName,"FirstName"); |
|
381 |
_LIT(KNameT,"Tenali"); |
|
382 |
_LIT(KNameB,"Birbal"); |
|
383 |
TInt count1 = 0; |
|
384 |
TInt tCount = 0; |
|
385 |
TInt bCount = 0; |
|
386 |
CSingleContact* singleContact = NULL; |
|
387 |
HBufC8* buf = NULL; |
|
388 |
TInt count = 0; |
|
389 |
while(ETrue) |
|
390 |
{ |
|
391 |
aIter->NextL(singleContact,buf); |
|
392 |
if(!singleContact) |
|
393 |
{ |
|
394 |
break; |
|
395 |
} |
|
396 |
++count; |
|
397 |
TInt count(singleContact->FieldCount()); |
|
398 |
while(count) |
|
399 |
{ |
|
400 |
CSingleContactField* field = singleContact->FieldAt(--count); |
|
401 |
TPtrC8 fieldKey; |
|
402 |
TPtrC label; |
|
403 |
TPtrC value; |
|
404 |
field->GetFieldDataL(fieldKey,label,value); |
|
405 |
if (fieldKey == KFirstName && value == KNameT) |
|
406 |
{ |
|
407 |
++count1; |
|
408 |
tCount = count1; |
|
409 |
} |
|
410 |
if (fieldKey == KFirstName && value == KNameB) |
|
411 |
{ |
|
412 |
++count1; |
|
413 |
bCount = count1; |
|
414 |
} |
|
415 |
} |
|
416 |
delete singleContact; |
|
417 |
} |
|
418 |
if(bCount>tCount) |
|
419 |
{ |
|
420 |
iErr = KErrNone; |
|
421 |
} |
|
422 |
} |
|
423 |
if(EGetGroup == iOperation ) |
|
424 |
{ |
|
425 |
iOperation = ENone; |
|
426 |
iErr = KErrGeneral; |
|
427 |
CSingleContact* singleContact = NULL; |
|
428 |
HBufC8* buf = NULL; |
|
429 |
TInt count = 0; |
|
430 |
while(ETrue) |
|
431 |
{ |
|
432 |
aIter->NextL(singleContact,buf); |
|
433 |
iBuffer = buf; |
|
434 |
if(!singleContact) |
|
435 |
{ |
|
436 |
break; |
|
437 |
} |
|
438 |
++count; |
|
439 |
TInt fields(singleContact->FieldCount()); |
|
440 |
while(fields) |
|
441 |
{ |
|
442 |
CSingleContactField* field = singleContact->FieldAt(--fields); |
|
443 |
TPtrC groupId; |
|
444 |
RPointerArray<TDesC8> array; |
|
445 |
field->GetFieldDataL(groupId,array); |
|
446 |
||
447 |
||
448 |
if(groupId.Compare(KGroup1)==0) |
|
449 |
{ |
|
450 |
iErr = KErrNone; |
|
451 |
break; |
|
452 |
} |
|
453 |
||
454 |
} |
|
455 |
||
456 |
} |
|
457 |
} |
|
458 |
delete aIter; |
|
459 |
} |
|
460 |
||
461 |
void CContactsUT::HandleRetrieveContact( MVPbkStoreContact* /*aStoreContact*/, TInt /*aTransId*/ ) |
|
462 |
{ |
|
463 |
CActiveScheduler::Stop(); |
|
464 |
_LIT(KFunc,"In Handle Retrieve Contact\n"); |
|
465 |
iLog->Log(KFunc); |
|
466 |
} |
|
467 |
||
468 |
void CContactsUT::ContactOperationCompleted(TContactOpResult aResult) |
|
469 |
{ |
|
470 |
CActiveScheduler::Stop(); |
|
471 |
_LIT(KFunc,"In ContactOperationCompleted \n"); |
|
472 |
iLog->Log(KFunc); |
|
473 |
iErr = KErrNone; |
|
474 |
TBuf<5> buf; |
|
475 |
buf.Num(aResult.iOpCode); |
|
476 |
iLog->Log(KSuccess); |
|
477 |
iLog->Log(buf); |
|
478 |
iLog->Log(KNewLine); |
|
479 |
switch(iOperation) |
|
480 |
{/* |
|
481 |
case EContact: delete iStoreContact; |
|
482 |
iStoreContact = NULL; |
|
483 |
break;*/ |
|
484 |
case EGroup: delete iGroup; |
|
485 |
iGroup = NULL; |
|
486 |
break; |
|
487 |
} |
|
488 |
iOperation = ENone; |
|
489 |
} |
|
490 |
void CContactsUT::ContactOperationFailed |
|
491 |
(TContactOp /*aOpCode*/, TInt aErrorCode, TBool /*aErrorNotified*/) |
|
492 |
{ |
|
493 |
CActiveScheduler::Stop(); |
|
494 |
_LIT(KFunc,"In ContactOperationFailed \n"); |
|
495 |
iLog->Log(KFunc); |
|
496 |
iErr = aErrorCode; |
|
497 |
TBuf<5> buf; |
|
498 |
buf.Num(aErrorCode); |
|
499 |
iLog->Log(KError); |
|
500 |
iLog->Log(buf); |
|
501 |
iLog->Log(KNewLine); |
|
502 |
switch(iOperation) |
|
503 |
{ |
|
504 |
case EContact:/* delete iStoreContact; |
|
505 |
iStoreContact = NULL; |
|
506 |
break;*/ |
|
507 |
case EGroup: delete iGroup; |
|
508 |
iGroup = NULL; |
|
509 |
break; |
|
510 |
} |
|
511 |
iOperation = ENone; |
|
512 |
} |
|
513 |
||
514 |
void CContactsUT::FindCompleteL( MVPbkContactLinkArray* aResults ) |
|
515 |
{ |
|
516 |
CActiveScheduler::Stop(); |
|
517 |
_LIT(KFunc,"In FindCompleteL \n"); |
|
518 |
iLog->Log(KFunc); |
|
519 |
iErr = KErrNone; |
|
520 |
TInt count = aResults->Count(); |
|
521 |
iFindResults = aResults; |
|
522 |
iLog->Log(KSuccess); |
|
523 |
} |
|
524 |
void CContactsUT::FindFailed( TInt aError ) |
|
525 |
{ |
|
526 |
CActiveScheduler::Stop(); |
|
527 |
_LIT(KFunc,"In FindFailed \n"); |
|
528 |
iLog->Log(KFunc); |
|
529 |
iErr = aError; |
|
530 |
TBuf<5> buf; |
|
531 |
buf.Num(aError); |
|
532 |
iLog->Log(KError); |
|
533 |
iLog->Log(buf); |
|
534 |
iLog->Log(KNewLine); |
|
535 |
} |
|
536 |
||
537 |
void CContactsUT::VPbkSingleContactOperationComplete( |
|
538 |
MVPbkContactOperationBase& aOperation, |
|
539 |
MVPbkStoreContact* aContact ) |
|
540 |
{ |
|
541 |
CActiveScheduler::Stop(); |
|
542 |
_LIT(KFunc,"In VPbkSingleContactOperationComplete \n"); |
|
543 |
iLog->Log(KFunc); |
|
544 |
iErr = KErrNone; |
|
545 |
||
546 |
if(iOperation == EVCard) |
|
547 |
{ |
|
548 |
iDestStream.CommitL(); |
|
549 |
delete iOp; |
|
550 |
iOp = NULL; |
|
551 |
iDestStream.Close(); |
|
552 |
delete iResult; |
|
553 |
iResult = NULL; |
|
554 |
} |
|
555 |
else if(iOperation == EVCardEx) |
|
556 |
{ |
|
557 |
delete iOp; |
|
558 |
iOp = NULL; |
|
559 |
} |
|
560 |
else |
|
561 |
{ |
|
562 |
delete iStoreContact; |
|
563 |
iStoreContact = NULL; |
|
564 |
iStoreContact = aContact; |
|
565 |
if( iOp == &aOperation ) |
|
566 |
{ |
|
567 |
delete iOp; |
|
568 |
iOp = NULL; |
|
569 |
} |
|
570 |
} |
|
571 |
iOperation = ENone; |
|
572 |
iLog->Log(KSuccess); |
|
573 |
} |
|
574 |
||
575 |
||
576 |
void CContactsUT::VPbkSingleContactOperationFailed( |
|
577 |
MVPbkContactOperationBase& aOperation, |
|
578 |
TInt aError ) |
|
579 |
{ |
|
580 |
CActiveScheduler::Stop(); |
|
581 |
_LIT(KFunc,"In VPbkSingleContactOperationFailed \n"); |
|
582 |
iLog->Log(KFunc); |
|
583 |
iErr = aError; |
|
584 |
; |
|
585 |
if(iOperation == EVCard) |
|
586 |
{ |
|
587 |
iDestStream.CommitL(); |
|
588 |
delete iOp; |
|
589 |
iOp = NULL; |
|
590 |
iDestStream.Close(); |
|
591 |
delete iBuffer; |
|
592 |
iBuffer = NULL; |
|
593 |
delete iResult; |
|
594 |
iResult = NULL; |
|
595 |
} |
|
596 |
else if(iOperation == EVCardEx) |
|
597 |
{ |
|
598 |
delete iOp; |
|
599 |
iOp = NULL; |
|
600 |
} |
|
601 |
else |
|
602 |
{ |
|
603 |
delete iStoreContact; |
|
604 |
iStoreContact = NULL; |
|
605 |
if( iOp == &aOperation ) |
|
606 |
{ |
|
607 |
delete iOp; |
|
608 |
iOp = NULL; |
|
609 |
} |
|
610 |
} |
|
611 |
TBuf<5> buf; |
|
612 |
buf.Num(aError); |
|
613 |
iLog->Log(KError); |
|
614 |
iLog->Log(buf); |
|
615 |
iLog->Log(KNewLine); |
|
616 |
||
617 |
iOperation = ENone; |
|
618 |
} |
|
619 |
||
620 |
void CContactsUT::StepComplete( |
|
621 |
MVPbkContactOperationBase& /*aOperation*/, |
|
622 |
TInt /*aStepSize*/ ) |
|
623 |
{ |
|
624 |
_LIT(KFunc,"In StepComplete \n"); |
|
625 |
iLog->Log(KFunc); |
|
626 |
iLog->Log(KSuccess); |
|
627 |
iLog->Log(KNewLine); |
|
628 |
} |
|
629 |
||
630 |
TBool CContactsUT::StepFailed( |
|
631 |
MVPbkContactOperationBase& /*aOperation*/, |
|
632 |
TInt /*aStepSize*/, TInt /*aError*/ ) |
|
633 |
{ |
|
634 |
_LIT(KFunc,"In StepFailed \n"); |
|
635 |
iLog->Log(KFunc); |
|
636 |
return EFalse; |
|
637 |
} |
|
638 |
||
639 |
void CContactsUT::OperationComplete( |
|
640 |
MVPbkContactOperationBase& /*aOperation*/ ) |
|
641 |
{ |
|
642 |
CActiveScheduler::Stop(); |
|
643 |
_LIT(KFunc,"In OperationComplete \n"); |
|
644 |
iLog->Log(KFunc); |
|
645 |
iErr = KErrNone; |
|
646 |
iLog->Log(KSuccess); |
|
647 |
iLog->Log(KNewLine); |
|
648 |
} |
|
649 |
||
650 |
||
651 |
//Delete all contacts |
|
652 |
void CContactsUT::DeleteAllL() |
|
653 |
{ |
|
654 |
// Print to UI |
|
655 |
_LIT( KContactsTest, "ContactsUT" ); |
|
656 |
_LIT( KExample, "In DeleteAllL" ); |
|
657 |
TestModuleIf().Printf( 0, KContactsTest, KExample ); |
|
658 |
// Print to log file |
|
659 |
iLog->Log( KExample ); |
|
660 |
||
661 |
iErr = KErrNone; |
|
662 |
||
663 |
__UHEAP_MARK; |
|
664 |
iOp = iContactManager->MatchPhoneNumberL( |
|
665 |
KPhoneNumber, KPhoneNumber().Length(), *this ); |
|
666 |
CActiveScheduler::Start(); |
|
667 |
delete iOp; |
|
668 |
iOp = NULL; |
|
669 |
||
670 |
TInt count(iFindResults->Count()); |
|
671 |
iContactToDelete = CVPbkContactLinkArray::NewLC(); |
|
672 |
while(count) |
|
673 |
{ |
|
674 |
MVPbkContactLink* link = iFindResults->At(--count).CloneLC(); |
|
675 |
iContactToDelete->AppendL(link); |
|
676 |
CleanupStack::Pop(); |
|
677 |
} |
|
678 |
delete iFindResults; |
|
679 |
iFindResults = NULL; |
|
680 |
||
681 |
iOp = iContactManager->DeleteContactsL( *iContactToDelete, *this ); |
|
682 |
CActiveScheduler::Start(); |
|
683 |
delete iOp; |
|
684 |
iOp = NULL; |
|
685 |
CleanupStack::PopAndDestroy(iContactToDelete); |
|
686 |
iContactToDelete = NULL; |
|
687 |
||
688 |
||
689 |
__UHEAP_MARKEND; |
|
690 |
} |
|
691 |
||
692 |
//Add 1 contact |
|
693 |
void CContactsUT::AddOneContactL(TDesC& aName) |
|
694 |
{ |
|
695 |
// Print to UI |
|
696 |
_LIT( KContactsTest, "ContactsUT" ); |
|
697 |
_LIT( KExample, "In AddOneContactL" ); |
|
698 |
TestModuleIf().Printf( 0, KContactsTest, KExample ); |
|
699 |
// Print to log file |
|
700 |
iLog->Log( KExample ); |
|
701 |
||
702 |
iErr = KErrNone; |
|
703 |
||
704 |
__UHEAP_MARK; |
|
705 |
CVPbkFieldTypeRefsList* fieldTypeRefList = CVPbkFieldTypeRefsList::NewL(); |
|
706 |
CleanupStack::PushL(fieldTypeRefList); |
|
707 |
||
708 |
fieldTypeRefList->AppendL( |
|
709 |
*iContactManager->FieldTypes().Find( R_VPBK_FIELD_TYPE_FIRSTNAME ) ); |
|
710 |
fieldTypeRefList->AppendL( |
|
711 |
*iContactManager->FieldTypes().Find( R_VPBK_FIELD_TYPE_MOBILEPHONEGEN ) ); |
|
712 |
||
713 |
// Create first contact |
|
714 |
iStoreContact = iStore->CreateNewContactLC(); |
|
715 |
||
716 |
// Create contact field for contact |
|
717 |
MVPbkStoreContactField* field = iStoreContact->CreateFieldLC( fieldTypeRefList->FieldTypeAt( 0 ) ); |
|
718 |
// Set contact field data |
|
719 |
(MVPbkContactFieldTextData::Cast(field->FieldData())).SetTextL( aName ); |
|
720 |
// Add the contact field to contact |
|
721 |
iStoreContact->AddFieldL( field ); |
|
722 |
CleanupStack::Pop(); // field |
|
723 |
||
724 |
// Create contact field for contact |
|
725 |
field = iStoreContact->CreateFieldLC( fieldTypeRefList->FieldTypeAt( 1 ) ); |
|
726 |
// Set contact field data |
|
727 |
(MVPbkContactFieldTextData::Cast(field->FieldData())).SetTextL( KPhoneNumber ); |
|
728 |
// Add the contact field to contact |
|
729 |
iStoreContact->AddFieldL( field ); |
|
730 |
CleanupStack::Pop(); // field |
|
731 |
||
732 |
// Commit the new created contact to contact store |
|
733 |
iStoreContact->CommitL( *this ); |
|
734 |
CActiveScheduler::Start(); |
|
735 |
CleanupStack::PopAndDestroy(); // iStoreContact |
|
736 |
iStoreContact = NULL; |
|
737 |
CleanupStack::PopAndDestroy(fieldTypeRefList); |
|
738 |
__UHEAP_MARKEND; |
|
739 |
} |
|
740 |
||
741 |
//Check for contact |
|
742 |
void CContactsUT::CheckContactsL(TInt& aCount,RPointerArray<TDesC8>& aIdArray) |
|
743 |
{ |
|
744 |
// Print to UI |
|
745 |
_LIT( KContactsTest, "ContactsUT" ); |
|
746 |
_LIT( KExample, "In CheckContactsL" ); |
|
747 |
TestModuleIf().Printf( 0, KContactsTest, KExample ); |
|
748 |
// Print to log file |
|
749 |
iLog->Log( KExample ); |
|
750 |
||
751 |
iErr = KErrNone; |
|
752 |
||
753 |
//__UHEAP_MARK; |
|
754 |
iOp = iContactManager->MatchPhoneNumberL( |
|
755 |
KPhoneNumber, KPhoneNumber().Length(), *this ); |
|
756 |
CActiveScheduler::Start(); |
|
757 |
delete iOp; |
|
758 |
iOp = NULL; |
|
759 |
||
760 |
aCount = iFindResults->Count(); |
|
761 |
TInt count(aCount); |
|
762 |
while(count) |
|
763 |
{ |
|
764 |
aIdArray.AppendL((const_cast<MVPbkContactLink&>(iFindResults->At(--count))).PackLC()); |
|
765 |
CleanupStack::Pop(); |
|
766 |
} |
|
767 |
delete iFindResults; |
|
768 |
iFindResults = NULL; |
|
769 |
// __UHEAP_MARKENDC(aCount); |
|
770 |
} |
|
771 |
||
772 |
// ----------------------------------------------------------------------------- |
|
773 |
// CContactsUT::?member_function |
|
774 |
// ?implementation_description |
|
775 |
// (other items were commented in a header). |
|
776 |
// ----------------------------------------------------------------------------- |
|
777 |
// |
|
778 |
TInt CContactsUT::AddContactSAPIL( CStifItemParser& aItem ) |
|
779 |
{ |
|
780 |
// Print to UI |
|
781 |
_LIT( KContactsTest, "ContactsUT" ); |
|
782 |
_LIT( KExample, "In AddContactSAPIL" ); |
|
783 |
TestModuleIf().Printf( 0, KContactsTest, KExample ); |
|
784 |
// Print to log file |
|
785 |
iLog->Log( KExample ); |
|
786 |
||
787 |
TInt i = 0; |
|
788 |
TPtrC string; |
|
789 |
_LIT( KParam, "Param[%i]: %S" ); |
|
790 |
while ( aItem.GetNextString ( string ) == KErrNone ) |
|
791 |
{ |
|
792 |
TestModuleIf().Printf( i, KContactsTest, |
|
793 |
KParam, i, &string ); |
|
794 |
i++; |
|
795 |
} |
|
796 |
||
797 |
iErr = KErrNone; |
|
798 |
||
799 |
DeleteAllL(); |
|
800 |
||
801 |
/**Add contact using SAPI Core class*/ |
|
802 |
||
803 |
_LIT8(KFirstName,"FirstName"); |
|
804 |
_LIT(KName,"Sikandar"); |
|
805 |
_LIT8(KNumber,"MobilePhoneGen"); |
|
806 |
||
807 |
__UHEAP_MARK; |
|
808 |
//instantiate service class |
|
809 |
CContactService* serviceHandle = CContactService::NewL(); |
|
810 |
CleanupStack::PushL(serviceHandle); |
|
811 |
iLog->Log( KServiceOpen ); |
|
812 |
||
813 |
CSingleContact* singleContact = CSingleContact::NewL(); |
|
814 |
CleanupStack::PushL(singleContact); |
|
815 |
iLog->Log(_L("single Contact created\n")); |
|
816 |
||
817 |
CSingleContactField* nameContactField = CSingleContactField::NewL(); |
|
818 |
CleanupStack::PushL(nameContactField); |
|
819 |
iLog->Log(_L("Name Contact Field created \n")); |
|
820 |
||
821 |
CSingleContactField* phoneContactField = CSingleContactField::NewL(); |
|
822 |
CleanupStack::PushL(phoneContactField); |
|
823 |
iLog->Log(_L("Phone Contact Field created \n")); |
|
824 |
||
825 |
nameContactField->SetFieldParamsL(KFirstName,KNullDesC,KName); |
|
826 |
singleContact->AddFieldToContactL(nameContactField); |
|
827 |
iLog->Log(_L("Name Contact Field added \n")); |
|
828 |
||
829 |
phoneContactField->SetFieldParamsL(KNumber,KNullDesC,KPhoneNumber); |
|
830 |
singleContact->AddFieldToContactL(phoneContactField); |
|
831 |
iLog->Log(_L("Phone Contact Field added \n")); |
|
832 |
||
833 |
serviceHandle->AddL(this,0,singleContact); |
|
834 |
iLog->Log(_L("AddL called\n")); |
|
835 |
iLog->Log(_L("Start Active Scheduler\n")); |
|
836 |
CActiveScheduler::Start(); |
|
837 |
||
838 |
CleanupStack::Pop(phoneContactField);//singleContactField |
|
839 |
CleanupStack::Pop(nameContactField);//singleContactField |
|
840 |
CleanupStack::PopAndDestroy(singleContact);//singleContact |
|
841 |
CleanupStack::PopAndDestroy(serviceHandle);//serviceHandle |
|
842 |
iLog->Log( KServiceClose ); |
|
843 |
__UHEAP_MARKEND; |
|
844 |
/**end */ |
|
845 |
||
846 |
TInt count; |
|
847 |
RPointerArray<TDesC8> idArray; |
|
848 |
CheckContactsL(count,idArray); |
|
849 |
if(count != 1) |
|
850 |
{ |
|
851 |
iErr = KErrGeneral; |
|
852 |
} |
|
853 |
idArray.ResetAndDestroy(); |
|
854 |
||
855 |
DeleteAllL(); |
|
856 |
return iErr; |
|
857 |
} |
|
858 |
||
859 |
// ----------------------------------------------------------------------------- |
|
860 |
// CContactsUT::?member_function |
|
861 |
// ?implementation_description |
|
862 |
// (other items were commented in a header). |
|
863 |
// ----------------------------------------------------------------------------- |
|
864 |
// |
|
865 |
TInt CContactsUT::DeleteContactSAPIL( CStifItemParser& aItem ) |
|
866 |
{ |
|
867 |
// Print to UI |
|
868 |
_LIT( KContactsTest, "ContactsUT" ); |
|
869 |
_LIT( KExample, "In DeleteContactSAPIL" ); |
|
870 |
TestModuleIf().Printf( 0, KContactsTest, KExample ); |
|
871 |
// Print to log file |
|
872 |
iLog->Log( KExample ); |
|
873 |
||
874 |
TInt i = 0; |
|
875 |
TPtrC string; |
|
876 |
_LIT( KParam, "Param[%i]: %S" ); |
|
877 |
while ( aItem.GetNextString ( string ) == KErrNone ) |
|
878 |
{ |
|
879 |
TestModuleIf().Printf( i, KContactsTest, |
|
880 |
KParam, i, &string ); |
|
881 |
i++; |
|
882 |
} |
|
883 |
||
884 |
iErr = KErrNone; |
|
885 |
||
886 |
DeleteAllL(); |
|
887 |
_LIT(KName,"SpiderMan"); |
|
888 |
TPtrC name(KName); |
|
889 |
AddOneContactL(name); |
|
890 |
||
891 |
TInt count(0); |
|
892 |
RPointerArray<TDesC8> idArray; |
|
893 |
CleanupClosePushL(idArray); |
|
894 |
CheckContactsL(count,idArray); |
|
895 |
if(count != 1) |
|
896 |
{ |
|
897 |
return KErrGeneral; |
|
898 |
} |
|
899 |
||
900 |
/**Delete using SAPI core class*/ |
|
901 |
||
902 |
__UHEAP_MARK; |
|
903 |
CContactService* serviceHandle = CContactService::NewL(); |
|
904 |
CleanupStack::PushL(serviceHandle); |
|
905 |
iLog->Log( KServiceOpen ); |
|
906 |
||
907 |
serviceHandle->DeleteL(this,0,idArray); |
|
908 |
iLog->Log(_L("DeleteL called\n")); |
|
909 |
iLog->Log(_L("Start Active Scheduler\n")); |
|
910 |
CActiveScheduler::Start(); |
|
911 |
||
912 |
CleanupStack::PopAndDestroy(serviceHandle);//serviceHandle |
|
913 |
iLog->Log( KServiceClose ); |
|
914 |
__UHEAP_MARKEND; |
|
915 |
/**end*/ |
|
916 |
CleanupStack::Pop(&idArray); |
|
917 |
idArray.ResetAndDestroy(); |
|
918 |
||
919 |
RPointerArray<TDesC8> idArray1; |
|
920 |
CleanupClosePushL(idArray1); |
|
921 |
CheckContactsL(count,idArray1); |
|
922 |
if(count) |
|
923 |
{ |
|
924 |
iErr = KErrGeneral; |
|
925 |
} |
|
926 |
CleanupStack::Pop(&idArray1); |
|
927 |
idArray.ResetAndDestroy(); |
|
928 |
return iErr; |
|
929 |
||
930 |
} |
|
931 |
||
932 |
// ----------------------------------------------------------------------------- |
|
933 |
// CContactsUT::?member_function |
|
934 |
// ?implementation_description |
|
935 |
// (other items were commented in a header). |
|
936 |
// ----------------------------------------------------------------------------- |
|
937 |
// |
|
938 |
TInt CContactsUT::ModifyContactSAPIL( CStifItemParser& aItem ) |
|
939 |
{ |
|
940 |
// Print to UI |
|
941 |
_LIT( KContactsTest, "ContactsUT" ); |
|
942 |
_LIT( KExample, "In ModifyContactSAPIL" ); |
|
943 |
TestModuleIf().Printf( 0, KContactsTest, KExample ); |
|
944 |
// Print to log file |
|
945 |
iLog->Log( KExample ); |
|
946 |
||
947 |
TInt i = 0; |
|
948 |
TPtrC string; |
|
949 |
_LIT( KParam, "Param[%i]: %S" ); |
|
950 |
while ( aItem.GetNextString ( string ) == KErrNone ) |
|
951 |
{ |
|
952 |
TestModuleIf().Printf( i, KContactsTest, |
|
953 |
KParam, i, &string ); |
|
954 |
i++; |
|
955 |
} |
|
956 |
||
957 |
iErr = KErrNone; |
|
958 |
||
959 |
DeleteAllL(); |
|
960 |
_LIT(KName,"SuperMan"); |
|
961 |
TPtrC name(KName); |
|
962 |
AddOneContactL(name); |
|
963 |
||
964 |
TInt count(0); |
|
965 |
RPointerArray<TDesC8> idArray; |
|
966 |
CleanupClosePushL(idArray); |
|
967 |
CheckContactsL(count,idArray); |
|
968 |
if(count != 1) |
|
969 |
{ |
|
970 |
return KErrGeneral; |
|
971 |
} |
|
972 |
||
973 |
/**Get using SAPI core class*/ |
|
974 |
__UHEAP_MARK; |
|
975 |
CContactService* serviceHandle = CContactService::NewL(); |
|
976 |
CleanupStack::PushL(serviceHandle); |
|
977 |
iLog->Log( KServiceOpen ); |
|
978 |
||
979 |
serviceHandle->GetListL(this,0,EContacts,*idArray[0]); |
|
980 |
iLog->Log(_L("GetListL called\n")); |
|
981 |
iLog->Log(_L("Start Active Scheduler\n")); |
|
982 |
CActiveScheduler::Start(); |
|
983 |
||
984 |
if(!iSingleContact) |
|
985 |
{ |
|
986 |
return KErrGeneral; |
|
987 |
} |
|
988 |
||
989 |
_LIT(KName1,"SpiderMan"); |
|
990 |
_LIT8(KFirstName,"FirstName"); |
|
991 |
CSingleContactField* field = NULL; |
|
992 |
TInt fieldCount(iSingleContact->FieldCount()); |
|
993 |
while(fieldCount) |
|
994 |
{ |
|
995 |
TPtrC8 fieldKey; |
|
996 |
TPtrC label; |
|
997 |
TPtrC value; |
|
998 |
field = iSingleContact->FieldAt(--fieldCount); |
|
999 |
field->GetFieldDataL(fieldKey,label,value); |
|
1000 |
if(!fieldKey.Compare(KFirstName) && !value.Compare(KName)) |
|
1001 |
{ |
|
1002 |
field->SetFieldParamsL(KFirstName,KNullDesC,KName1); |
|
1003 |
iLog->Log(_L("Phone Contact Field modified \n")); |
|
1004 |
break; |
|
1005 |
} |
|
1006 |
} |
|
1007 |
||
1008 |
__UHEAP_MARK; |
|
1009 |
serviceHandle->AddL(this,0,iSingleContact); |
|
1010 |
iLog->Log(_L("AddL called\n")); |
|
1011 |
iLog->Log(_L("Start Active Scheduler\n")); |
|
1012 |
CActiveScheduler::Start(); |
|
1013 |
__UHEAP_MARKEND; |
|
1014 |
||
1015 |
delete iSingleContact; |
|
1016 |
iSingleContact = NULL; |
|
1017 |
||
1018 |
CleanupStack::PopAndDestroy(serviceHandle);//serviceHandle |
|
1019 |
iLog->Log( KServiceClose ); |
|
1020 |
__UHEAP_MARKEND; |
|
1021 |
/**end*/ |
|
1022 |
||
1023 |
||
1024 |
CleanupStack::Pop(&idArray); |
|
1025 |
idArray.ResetAndDestroy(); |
|
1026 |
||
1027 |
RPointerArray<TDesC8> idArray1; |
|
1028 |
CleanupClosePushL(idArray1); |
|
1029 |
CheckContactsL(count,idArray1); |
|
1030 |
if(count != 1) |
|
1031 |
{ |
|
1032 |
iErr = KErrGeneral; |
|
1033 |
} |
|
1034 |
CleanupStack::Pop(); |
|
1035 |
idArray1.ResetAndDestroy(); |
|
1036 |
//to implement ..checking name |
|
1037 |
return iErr; |
|
1038 |
||
1039 |
} |
|
1040 |
||
1041 |
// ----------------------------------------------------------------------------- |
|
1042 |
// CContactsUT::?member_function |
|
1043 |
// ?implementation_description |
|
1044 |
// (other items were commented in a header). |
|
1045 |
// ----------------------------------------------------------------------------- |
|
1046 |
// |
|
1047 |
TInt CContactsUT::ImportContactSAPIL( CStifItemParser& aItem ) |
|
1048 |
{ |
|
1049 |
// Print to UI |
|
1050 |
_LIT( KContactsTest, "ContactsUT" ); |
|
1051 |
_LIT( KExample, "In ImportContactSAPIL" ); |
|
1052 |
TestModuleIf().Printf( 0, KContactsTest, KExample ); |
|
1053 |
// Print to log file |
|
1054 |
iLog->Log( KExample ); |
|
1055 |
||
1056 |
TInt i = 0; |
|
1057 |
TPtrC string; |
|
1058 |
_LIT( KParam, "Param[%i]: %S" ); |
|
1059 |
while ( aItem.GetNextString ( string ) == KErrNone ) |
|
1060 |
{ |
|
1061 |
TestModuleIf().Printf( i, KContactsTest, |
|
1062 |
KParam, i, &string ); |
|
1063 |
i++; |
|
1064 |
} |
|
1065 |
||
1066 |
iErr = KErrNone; |
|
1067 |
_LIT(KFileName,"c:\\vcardim.vcf"); |
|
1068 |
||
1069 |
/* DeleteAllL(); |
|
1070 |
||
1071 |
_LIT(KName,"SuperMan"); |
|
1072 |
TPtrC name(KName); |
|
1073 |
AddOneContactL(name); |
|
1074 |
||
1075 |
TInt count(0); |
|
1076 |
RPointerArray<TDesC8> idArray; |
|
1077 |
CleanupClosePushL(idArray); |
|
1078 |
CheckContactsL(count,idArray); |
|
1079 |
if(count != 1) |
|
1080 |
{ |
|
1081 |
return KErrGeneral; |
|
1082 |
} |
|
1083 |
||
1084 |
//__UHEAP_MARK; |
|
1085 |
MVPbkContactLinkArray* linkArray = iContactManager->CreateLinksLC(*idArray[0]); |
|
1086 |
iVCardEngine = CVPbkVCardEng::NewL( *iContactManager ); |
|
1087 |
// Create the buffer to store the contact |
|
1088 |
iBuffer = HBufC8::NewL( 1024 ); |
|
1089 |
TPtr8 bufferPtr( iBuffer->Des() ); |
|
1090 |
iDestStream.Open( bufferPtr ); |
|
1091 |
//export the contact from MVPbkContactLink |
|
1092 |
// __UHEAP_MARK; |
|
1093 |
iOp = iVCardEngine->ExportVCardL( iDestStream, linkArray->At(0), *this ); |
|
1094 |
CActiveScheduler::Start(); |
|
1095 |
||
1096 |
// __UHEAP_MARKEND; |
|
1097 |
if( !iErr ) |
|
1098 |
{ |
|
1099 |
iDestStream.CommitL(); |
|
1100 |
} |
|
1101 |
||
1102 |
iDestStream.Close(); |
|
1103 |
if(iBuffer) |
|
1104 |
{ |
|
1105 |
RFile file; |
|
1106 |
CleanupClosePushL(file); |
|
1107 |
file.Replace(iRfs,KFileName,EFileWrite); |
|
1108 |
file.Write(0,*iBuffer); |
|
1109 |
CleanupStack::PopAndDestroy(&file); |
|
1110 |
} |
|
1111 |
delete iBuffer; |
|
1112 |
iBuffer = NULL; |
|
1113 |
delete iVCardEngine; |
|
1114 |
iVCardEngine = NULL; |
|
1115 |
CleanupStack::PopAndDestroy();//linkArray |
|
1116 |
//__UHEAP_MARKEND; |
|
1117 |
||
1118 |
CleanupStack::Pop(&idArray); |
|
1119 |
idArray.ResetAndDestroy(); |
|
1120 |
DeleteAllL(); |
|
1121 |
*/ |
|
1122 |
DeleteAllL(); |
|
1123 |
__UHEAP_MARK; |
|
1124 |
CContactService* serviceHandle = CContactService::NewL(); |
|
1125 |
CleanupStack::PushL(serviceHandle); |
|
1126 |
iLog->Log( KServiceOpen ); |
|
1127 |
||
1128 |
TFileName importFile(KFileName); |
|
1129 |
||
1130 |
serviceHandle->ImportVCardToStoreL(this,0,importFile); |
|
1131 |
iLog->Log(_L("ImportVCardToStoreL called\n")); |
|
1132 |
iLog->Log(_L("Start Active Scheduler\n")); |
|
1133 |
CActiveScheduler::Start(); |
|
1134 |
||
1135 |
CleanupStack::PopAndDestroy(serviceHandle);//serviceHandle |
|
1136 |
iLog->Log( KServiceClose ); |
|
1137 |
__UHEAP_MARKEND; |
|
1138 |
||
1139 |
TInt count = 0; |
|
1140 |
RPointerArray<TDesC8> idArray; |
|
1141 |
CleanupClosePushL(idArray); |
|
1142 |
CheckContactsL(count,idArray); |
|
1143 |
if(count != 1) |
|
1144 |
{ |
|
1145 |
return KErrGeneral; |
|
1146 |
} |
|
1147 |
CleanupStack::Pop(&idArray); |
|
1148 |
idArray.ResetAndDestroy(); |
|
1149 |
return iErr; |
|
1150 |
} |
|
1151 |
||
1152 |
// ----------------------------------------------------------------------------- |
|
1153 |
// CContactsUT::?member_function |
|
1154 |
// ?implementation_description |
|
1155 |
// (other items were commented in a header). |
|
1156 |
// ----------------------------------------------------------------------------- |
|
1157 |
// |
|
1158 |
TInt CContactsUT::ExportContactSAPIL( CStifItemParser& aItem ) |
|
1159 |
{ |
|
1160 |
// Print to UI |
|
1161 |
_LIT( KContactsTest, "ContactsUT" ); |
|
1162 |
_LIT( KExample, "In ExportContactSAPIL" ); |
|
1163 |
TestModuleIf().Printf( 0, KContactsTest, KExample ); |
|
1164 |
// Print to log file |
|
1165 |
iLog->Log( KExample ); |
|
1166 |
||
1167 |
TInt i = 0; |
|
1168 |
TPtrC string; |
|
1169 |
_LIT( KParam, "Param[%i]: %S" ); |
|
1170 |
while ( aItem.GetNextString ( string ) == KErrNone ) |
|
1171 |
{ |
|
1172 |
TestModuleIf().Printf( i, KContactsTest, |
|
1173 |
KParam, i, &string ); |
|
1174 |
i++; |
|
1175 |
} |
|
1176 |
||
1177 |
iErr = KErrNone; |
|
1178 |
_LIT(KFileName,"c:\\vcardim.vcf"); |
|
1179 |
_LIT(KFileName1,"c:\\vcardim1.vcf"); |
|
1180 |
||
1181 |
DeleteAllL(); |
|
1182 |
||
1183 |
_LIT(KName,"SuperMan"); |
|
1184 |
TPtrC name(KName); |
|
1185 |
AddOneContactL(name); |
|
1186 |
||
1187 |
_LIT(KName1,"SpiderMan"); |
|
1188 |
TPtrC name1(KName1); |
|
1189 |
AddOneContactL(name1); |
|
1190 |
||
1191 |
TInt count(0); |
|
1192 |
RPointerArray<TDesC8> idArray; |
|
1193 |
CleanupClosePushL(idArray); |
|
1194 |
CheckContactsL(count,idArray); |
|
1195 |
TInt ret = iRfs.Delete(KFileName); |
|
1196 |
// ret = iRfs.Delete(KFileName1); |
|
1197 |
/* if(count != 1) |
|
1198 |
{ |
|
1199 |
return KErrGeneral; |
|
1200 |
}*/ |
|
1201 |
||
1202 |
/* __UHEAP_MARK; |
|
1203 |
RFile writeStream; |
|
1204 |
CleanupClosePushL(writeStream); |
|
1205 |
User::LeaveIfError(writeStream.Create(iRfs,KFileName,EFileWrite)); |
|
1206 |
while(count) |
|
1207 |
{ |
|
1208 |
writeStream.Write(*idArray[--count]); |
|
1209 |
} |
|
1210 |
CleanupStack::PopAndDestroy(&writeStream); |
|
1211 |
__UHEAP_MARKEND; |
|
1212 |
*/ |
|
1213 |
//iBuffer = HBufC8::NewL( 1024 ); |
|
1214 |
//TPtr8 bfrPtr(iBuffer->Des()); |
|
1215 |
// __UHEAP_MARK; |
|
1216 |
//RFileReadStream readStream; |
|
1217 |
// CleanupClosePushL(readStream); |
|
1218 |
// User::LeaveIfError(readStream.Open(iRfs,KFileName,EFileRead)); |
|
1219 |
||
1220 |
//TInt cells = User::CountAllocCells(); |
|
1221 |
__UHEAP_MARK; |
|
1222 |
RFileWriteStream destStream; |
|
1223 |
CleanupClosePushL(destStream); |
|
1224 |
User::LeaveIfError(destStream.Create(iRfs,KFileName,EFileWrite)); |
|
1225 |
iVCardEngine = CVPbkVCardEng::NewL( *iContactManager ); |
|
1226 |
while(count) |
|
1227 |
{ |
|
1228 |
MVPbkContactLinkArray* linkArray = iContactManager->CreateLinksLC(*idArray[--count]); |
|
1229 |
const MVPbkContactLink& link = linkArray->At(0); |
|
1230 |
iOp = iVCardEngine->ExportVCardL( destStream, link, *this ); |
|
1231 |
CActiveScheduler::Start(); |
|
1232 |
destStream.CommitL(); |
|
1233 |
CleanupStack::PopAndDestroy(); |
|
1234 |
} |
|
1235 |
delete iVCardEngine; |
|
1236 |
iVCardEngine = NULL; |
|
1237 |
CleanupStack::PopAndDestroy(&destStream); |
|
1238 |
__UHEAP_MARKEND; |
|
1239 |
CleanupStack::Pop(&idArray); |
|
1240 |
idArray.ResetAndDestroy(); |
|
1241 |
||
1242 |
/* |
|
1243 |
//CleanupStack::PushL(linkArray); |
|
1244 |
cells = User::CountAllocCells(); |
|
1245 |
iVCardEngine = CVPbkVCardEng::NewL( *iContactManager ); |
|
1246 |
||
1247 |
cells = User::CountAllocCells(); |
|
1248 |
RDesWriteStream destStream; |
|
1249 |
CleanupClosePushL(destStream); |
|
1250 |
//User::LeaveIfError(destStream.Create(iRfs,KFileName1,EFileWrite)); |
|
1251 |
destStream.Open(bfrPtr); |
|
1252 |
TInt links = linkArray->Count(); |
|
1253 |
while(links) |
|
1254 |
{ |
|
1255 |
const MVPbkContactLink& link = linkArray->At(--links); |
|
1256 |
iOp = iVCardEngine->ExportVCardL( destStream, link, *this ); |
|
1257 |
CActiveScheduler::Start(); |
|
1258 |
} |
|
1259 |
destStream.CommitL(); |
|
1260 |
CleanupStack::PopAndDestroy(&destStream); |
|
1261 |
||
1262 |
cells = User::CountAllocCells(); |
|
1263 |
delete iVCardEngine; |
|
1264 |
iVCardEngine = NULL; |
|
1265 |
cells = User::CountAllocCells(); |
|
1266 |
||
1267 |
CleanupStack::PopAndDestroy(); |
|
1268 |
cells = User::CountAllocCells(); |
|
1269 |
CleanupStack::PopAndDestroy(&readStream); |
|
1270 |
||
1271 |
// __UHEAP_MARKEND; |
|
1272 |
if(iBuffer) |
|
1273 |
{ |
|
1274 |
RFile file; |
|
1275 |
CleanupClosePushL(file); |
|
1276 |
file.Replace(iRfs,KFileName,EFileWrite); |
|
1277 |
file.Write(0,*iBuffer); |
|
1278 |
CleanupStack::PopAndDestroy(&file); |
|
1279 |
} |
|
1280 |
delete iBuffer; |
|
1281 |
iBuffer = NULL; |
|
1282 |
CleanupStack::Pop(&idArray); |
|
1283 |
idArray.ResetAndDestroy(); |
|
1284 |
/* |
|
1285 |
// Create the buffer to store the contact |
|
1286 |
iBuffer = HBufC8::NewL( 1024 ); |
|
1287 |
TPtr8 bufferPtr( iBuffer->Des() ); |
|
1288 |
iDestStream.Open( bufferPtr ); |
|
1289 |
//export the contact from MVPbkContactLink |
|
1290 |
// __UHEAP_MARK; |
|
1291 |
||
1292 |
CActiveScheduler::Start(); |
|
1293 |
||
1294 |
// __UHEAP_MARKEND; |
|
1295 |
if( !iErr ) |
|
1296 |
{ |
|
1297 |
iDestStream.CommitL(); |
|
1298 |
} |
|
1299 |
||
1300 |
iDestStream.Close(); |
|
1301 |
if(iBuffer) |
|
1302 |
{ |
|
1303 |
RFile file; |
|
1304 |
CleanupClosePushL(file); |
|
1305 |
file.Replace(iRfs,KFileName,EFileWrite); |
|
1306 |
file.Write(0,*iBuffer); |
|
1307 |
CleanupStack::PopAndDestroy(&file); |
|
1308 |
} |
|
1309 |
delete iBuffer; |
|
1310 |
iBuffer = NULL; |
|
1311 |
delete iVCardEngine; |
|
1312 |
iVCardEngine = NULL; |
|
1313 |
CleanupStack::PopAndDestroy();//linkArray |
|
1314 |
//__UHEAP_MARKEND; |
|
1315 |
||
1316 |
CleanupStack::Pop(&idArray); |
|
1317 |
idArray.ResetAndDestroy(); |
|
1318 |
DeleteAllL(); |
|
1319 |
*/ |
|
1320 |
/* __UHEAP_MARK; |
|
1321 |
CContactService* serviceHandle = CContactService::NewL(); |
|
1322 |
CleanupStack::PushL(serviceHandle); |
|
1323 |
iLog->Log( KServiceOpen ); |
|
1324 |
||
1325 |
TFileName exportFile(KFileName); |
|
1326 |
||
1327 |
serviceHandle->ExportVCardL(this,0,exportFile,idArray); |
|
1328 |
iLog->Log(_L("ExportVCardL called\n")); |
|
1329 |
iLog->Log(_L("Start Active Scheduler\n")); |
|
1330 |
CActiveScheduler::Start(); |
|
1331 |
||
1332 |
CleanupStack::PopAndDestroy(serviceHandle);//serviceHandle |
|
1333 |
iLog->Log( KServiceClose ); |
|
1334 |
__UHEAP_MARKEND; |
|
1335 |
*//* |
|
1336 |
TInt count = 0; |
|
1337 |
RPointerArray<TDesC8> idArray; |
|
1338 |
CleanupClosePushL(idArray); |
|
1339 |
CheckContactsL(count,idArray); |
|
1340 |
if(count != 1) |
|
1341 |
{ |
|
1342 |
return KErrGeneral; |
|
1343 |
}*/ |
|
1344 |
/* CleanupStack::Pop(&idArray); |
|
1345 |
idArray.ResetAndDestroy();*/ |
|
1346 |
return iErr; |
|
1347 |
} |
|
1348 |
// ----------------------------------------------------------------------------- |
|
1349 |
// CContactsUT::?member_function |
|
1350 |
// ?implementation_description |
|
1351 |
// (other items were commented in a header). |
|
1352 |
// ----------------------------------------------------------------------------- |
|
1353 |
// |
|
1354 |
TInt CContactsUT::GetListDeleteContactL( CStifItemParser& aItem ) |
|
1355 |
{ |
|
1356 |
// Print to UI |
|
1357 |
_LIT( KContactsTest, "ContactsUT" ); |
|
1358 |
_LIT( KExample, "In Add" ); |
|
1359 |
TestModuleIf().Printf( 0, KContactsTest, KExample ); |
|
1360 |
// Print to log file |
|
1361 |
iLog->Log( KExample ); |
|
1362 |
||
1363 |
TInt i = 0; |
|
1364 |
TPtrC string; |
|
1365 |
_LIT( KParam, "Param[%i]: %S" ); |
|
1366 |
while ( aItem.GetNextString ( string ) == KErrNone ) |
|
1367 |
{ |
|
1368 |
TestModuleIf().Printf( i, KContactsTest, |
|
1369 |
KParam, i, &string ); |
|
1370 |
i++; |
|
1371 |
} |
|
1372 |
||
1373 |
iErr = KErrNone; |
|
1374 |
||
1375 |
||
1376 |
/**Getlist using SAPI core class*/ |
|
1377 |
||
1378 |
//__UHEAP_MARK; |
|
1379 |
CContactService* serviceHandle = CContactService::NewL(); |
|
1380 |
CleanupStack::PushL(serviceHandle); |
|
1381 |
iLog->Log( KServiceOpen ); |
|
1382 |
||
1383 |
iOperation = EGetContactDelete; |
|
1384 |
serviceHandle->GetListL(this,0,EContacts); |
|
1385 |
iLog->Log(_L("GetListL called\n")); |
|
1386 |
iLog->Log(_L("Start Active Scheduler\n")); |
|
1387 |
CActiveScheduler::Start(); |
|
1388 |
||
1389 |
//iOperation = EGetContact; |
|
1390 |
//iServiceHandle->GetListL(this,0,EContacts,*iBuffer); |
|
1391 |
//CActiveScheduler::Start(); |
|
1392 |
/**Delete using SAPI core class*/ |
|
1393 |
||
1394 |
// __UHEAP_MARK; |
|
1395 |
RPointerArray<TDesC8> idArray; |
|
1396 |
CleanupClosePushL(idArray); |
|
1397 |
idArray.AppendL(iBuffer); |
|
1398 |
||
1399 |
||
1400 |
serviceHandle->DeleteL(this,0,idArray); |
|
1401 |
iLog->Log(_L("DeleteL called\n")); |
|
1402 |
iLog->Log(_L("Start Active Scheduler\n")); |
|
1403 |
CActiveScheduler::Start(); |
|
1404 |
||
1405 |
||
1406 |
CleanupStack::PopAndDestroy(&idArray);//singleContactField |
|
1407 |
||
1408 |
CleanupStack::PopAndDestroy(serviceHandle);//serviceHandle |
|
1409 |
iLog->Log( KServiceClose ); |
|
1410 |
// __UHEAP_MARKEND; |
|
1411 |
||
1412 |
||
1413 |
||
1414 |
return iErr; |
|
1415 |
} |
|
1416 |
// ----------------------------------------------------------------------------- |
|
1417 |
// CContactsUT::?member_function |
|
1418 |
// ?implementation_description |
|
1419 |
// (other items were commented in a header). |
|
1420 |
// ----------------------------------------------------------------------------- |
|
1421 |
// |
|
1422 |
TInt CContactsUT::AddContactGetListL( CStifItemParser& aItem ) |
|
1423 |
{ |
|
1424 |
// Print to UI |
|
1425 |
_LIT( KContactsTest, "ContactsUT" ); |
|
1426 |
_LIT( KExample, "In Add" ); |
|
1427 |
TestModuleIf().Printf( 0, KContactsTest, KExample ); |
|
1428 |
// Print to log file |
|
1429 |
iLog->Log( KExample ); |
|
1430 |
||
1431 |
TInt i = 0; |
|
1432 |
TPtrC string; |
|
1433 |
_LIT( KParam, "Param[%i]: %S" ); |
|
1434 |
while ( aItem.GetNextString ( string ) == KErrNone ) |
|
1435 |
{ |
|
1436 |
TestModuleIf().Printf( i, KContactsTest, |
|
1437 |
KParam, i, &string ); |
|
1438 |
i++; |
|
1439 |
} |
|
1440 |
||
1441 |
iErr = KErrNone; |
|
1442 |
||
1443 |
/**Add contact using SAPI Core class*/ |
|
1444 |
||
1445 |
_LIT8(KFirstName,"FirstName"); |
|
1446 |
_LIT(KName,"Kats"); |
|
1447 |
_LIT8(KNumber,"MobilePhoneHome"); |
|
1448 |
_LIT(KPhone,"98789"); |
|
1449 |
||
1450 |
// __UHEAP_MARK; |
|
1451 |
//instantiate service class |
|
1452 |
CContactService* serviceHandle = CContactService::NewL(); |
|
1453 |
CleanupStack::PushL(serviceHandle); |
|
1454 |
iLog->Log( KServiceOpen ); |
|
1455 |
||
1456 |
CSingleContact* singleContact = CSingleContact::NewL(); |
|
1457 |
CleanupStack::PushL(singleContact); |
|
1458 |
iLog->Log(_L("single Contact created\n")); |
|
1459 |
||
1460 |
CSingleContactField* nameContactField = CSingleContactField::NewL(); |
|
1461 |
CleanupStack::PushL(nameContactField); |
|
1462 |
iLog->Log(_L("Name Contact Field created \n")); |
|
1463 |
||
1464 |
CSingleContactField* phoneContactField = CSingleContactField::NewL(); |
|
1465 |
CleanupStack::PushL(phoneContactField); |
|
1466 |
iLog->Log(_L("Phone Contact Field created \n")); |
|
1467 |
||
1468 |
nameContactField->SetFieldParamsL(KFirstName,KNullDesC,KName); |
|
1469 |
singleContact->AddFieldToContactL(nameContactField); |
|
1470 |
iLog->Log(_L("Name Contact Field added \n")); |
|
1471 |
||
1472 |
phoneContactField->SetFieldParamsL(KNumber,KNullDesC,KPhone); |
|
1473 |
singleContact->AddFieldToContactL(phoneContactField); |
|
1474 |
iLog->Log(_L("Phone Contact Field added \n")); |
|
1475 |
||
1476 |
serviceHandle->AddL(this,0,singleContact,KNullDesC8,KNullDesC); |
|
1477 |
iLog->Log(_L("AddL called\n")); |
|
1478 |
iLog->Log(_L("Start Active Scheduler\n")); |
|
1479 |
CActiveScheduler::Start(); |
|
1480 |
||
1481 |
CleanupStack::Pop(phoneContactField);//singleContactField |
|
1482 |
CleanupStack::Pop(nameContactField);//singleContactField |
|
1483 |
CleanupStack::PopAndDestroy(singleContact);//singleContact |
|
1484 |
// CleanupStack::PopAndDestroy(serviceHandle);//serviceHandle |
|
1485 |
// iLog->Log( KServiceClose ); |
|
1486 |
// __UHEAP_MARKENDC(1); |
|
1487 |
/**end */ |
|
1488 |
||
1489 |
if(iErr) |
|
1490 |
{ |
|
1491 |
return iErr; |
|
1492 |
} |
|
1493 |
||
1494 |
/**Getlist using SAPI core class*/ |
|
1495 |
||
1496 |
//__UHEAP_MARK; |
|
1497 |
//serviceHandle = CContactService::NewL(); |
|
1498 |
// CleanupStack::PushL(serviceHandle); |
|
1499 |
iLog->Log( KServiceOpen ); |
|
1500 |
||
1501 |
iOperation = EGetContact; |
|
1502 |
serviceHandle->GetListL(this,0,EContacts); |
|
1503 |
iLog->Log(_L("GetListL called\n")); |
|
1504 |
iLog->Log(_L("Start Active Scheduler\n")); |
|
1505 |
CActiveScheduler::Start(); |
|
1506 |
||
1507 |
//iOperation = EGetContact; |
|
1508 |
//iServiceHandle->GetListL(this,0,EContacts,*iBuffer); |
|
1509 |
//CActiveScheduler::Start(); |
|
1510 |
||
1511 |
CleanupStack::PopAndDestroy(serviceHandle);//serviceHandle |
|
1512 |
iLog->Log( KServiceClose ); |
|
1513 |
// __UHEAP_MARKEND; |
|
1514 |
||
1515 |
if(iErr) |
|
1516 |
{ |
|
1517 |
return iErr; |
|
1518 |
} |
|
1519 |
/**Delete using virtual Phonebook */ |
|
1520 |
||
1521 |
||
1522 |
// Create find operation |
|
1523 |
iOp = iContactManager->MatchPhoneNumberL( |
|
1524 |
KPhone, KPhone().Length(), *this ); |
|
1525 |
CActiveScheduler::Start(); |
|
1526 |
||
1527 |
iErr = KErrGeneral; |
|
1528 |
TInt count(iFindResults->Count()); |
|
1529 |
while(count) |
|
1530 |
{ |
|
1531 |
iContactToDelete = CVPbkContactLinkArray::NewL(); |
|
1532 |
iContactToDelete->AppendL(&(const_cast<MVPbkContactLink&>(iFindResults->At(--count)))); |
|
1533 |
iOp = iContactManager->DeleteContactsL( *iContactToDelete, *this ); |
|
1534 |
CActiveScheduler::Start(); |
|
1535 |
} |
|
1536 |
/**end */ |
|
1537 |
||
1538 |
||
1539 |
return iErr; |
|
1540 |
} |
|
1541 |
// ----------------------------------------------------------------------------- |
|
1542 |
// CContactsUT::?member_function |
|
1543 |
// ?implementation_description |
|
1544 |
// (other items were commented in a header). |
|
1545 |
// ----------------------------------------------------------------------------- |
|
1546 |
// |
|
1547 |
TInt CContactsUT::GetGroupsL( CStifItemParser& aItem ) |
|
1548 |
{ |
|
1549 |
||
1550 |
// Print to UI |
|
1551 |
_LIT( KContactsTest, "ContactsUT" ); |
|
1552 |
_LIT( KExample, "In Add" ); |
|
1553 |
TestModuleIf().Printf( 0, KContactsTest, KExample ); |
|
1554 |
// Print to log file |
|
1555 |
iLog->Log( KExample ); |
|
1556 |
||
1557 |
TInt i = 0; |
|
1558 |
TPtrC string; |
|
1559 |
_LIT( KParam, "Param[%i]: %S" ); |
|
1560 |
while ( aItem.GetNextString ( string ) == KErrNone ) |
|
1561 |
{ |
|
1562 |
TestModuleIf().Printf( i, KContactsTest, |
|
1563 |
KParam, i, &string ); |
|
1564 |
i++; |
|
1565 |
} |
|
1566 |
||
1567 |
iErr = KErrNone; |
|
1568 |
||
1569 |
/**Add 1 group using virtual phonebook */ |
|
1570 |
||
1571 |
||
1572 |
||
1573 |
iGroup = iStore->CreateNewContactGroupLC(); |
|
1574 |
iGroup->SetGroupLabelL(KGroup1); |
|
1575 |
iOperation = EGroup; |
|
1576 |
iGroup->CommitL(*this); |
|
1577 |
||
1578 |
CActiveScheduler::Start(); |
|
1579 |
CleanupStack::Pop(); |
|
1580 |
||
1581 |
||
1582 |
// __UHEAP_MARK; |
|
1583 |
iServiceHandle = CContactService::NewL(); |
|
1584 |
iLog->Log( KServiceOpen ); |
|
1585 |
||
1586 |
iOperation = EGetGroup; |
|
1587 |
iServiceHandle->GetListL(this,0,EGroups); |
|
1588 |
iLog->Log(_L("GetListL called\n")); |
|
1589 |
iLog->Log(_L("Start Active Scheduler\n")); |
|
1590 |
CActiveScheduler::Start(); |
|
1591 |
iOperation = EGetContactDelete; |
|
1592 |
iServiceHandle->GetListL(this, 0, EGroups, *iBuffer); |
|
1593 |
CActiveScheduler::Start(); |
|
1594 |
||
1595 |
delete iServiceHandle;//serviceHandle |
|
1596 |
iServiceHandle = NULL; |
|
1597 |
iLog->Log( KServiceClose ); |
|
1598 |
// __UHEAP_MARKEND; |
|
1599 |
||
1600 |
||
1601 |
||
1602 |
||
1603 |
return iErr; |
|
1604 |
||
1605 |
} |
|
1606 |
||
1607 |
TInt CContactsUT::GetDatabaseL( CStifItemParser& aItem ) |
|
1608 |
{ |
|
1609 |
||
1610 |
// Print to UI |
|
1611 |
_LIT( KContactsTest, "ContactsUT" ); |
|
1612 |
_LIT( KExample, "In Add" ); |
|
1613 |
TestModuleIf().Printf( 0, KContactsTest, KExample ); |
|
1614 |
// Print to log file |
|
1615 |
iLog->Log( KExample ); |
|
1616 |
||
1617 |
TInt i = 0; |
|
1618 |
TPtrC string; |
|
1619 |
_LIT( KParam, "Param[%i]: %S" ); |
|
1620 |
while ( aItem.GetNextString ( string ) == KErrNone ) |
|
1621 |
{ |
|
1622 |
TestModuleIf().Printf( i, KContactsTest, |
|
1623 |
KParam, i, &string ); |
|
1624 |
i++; |
|
1625 |
} |
|
1626 |
||
1627 |
iErr = KErrNone; |
|
1628 |
||
1629 |
||
1630 |
||
1631 |
// __UHEAP_MARK; |
|
1632 |
iServiceHandle = CContactService::NewL(); |
|
1633 |
iLog->Log( KServiceOpen ); |
|
1634 |
||
1635 |
iOperation = EGetDatabase; |
|
1636 |
||
1637 |
CContactIter* iter = CContactIter::NewL(); |
|
1638 |
iServiceHandle->GetListL(*iter); |
|
1639 |
iLog->Log(_L("GetListL called\n")); |
|
1640 |
TPtrC DbName; |
|
1641 |
iter->NextL(DbName); |
|
1642 |
||
1643 |
while(!DbName.Compare(KNullDesC)) |
|
1644 |
{ |
|
1645 |
iter->NextL(DbName); |
|
1646 |
} |
|
1647 |
||
1648 |
delete iServiceHandle;//serviceHandle |
|
1649 |
iServiceHandle = NULL; |
|
1650 |
iLog->Log( KServiceClose ); |
|
1651 |
// __UHEAP_MARKEND; |
|
1652 |
||
1653 |
||
1654 |
||
1655 |
||
1656 |
return iErr; |
|
1657 |
||
1658 |
} |
|
1659 |
||
1660 |
// ----------------------------------------------------------------------------- |
|
1661 |
// CContactsUT::?member_function |
|
1662 |
// ?implementation_description |
|
1663 |
// (other items were commented in a header). |
|
1664 |
// ----------------------------------------------------------------------------- |
|
1665 |
// |
|
1666 |
TInt CContactsUT::GetContactsL( CStifItemParser& aItem ) |
|
1667 |
{ |
|
1668 |
||
1669 |
// Print to UI |
|
1670 |
_LIT( KContactsTest, "ContactsUT" ); |
|
1671 |
_LIT( KExample, "In Add" ); |
|
1672 |
TestModuleIf().Printf( 0, KContactsTest, KExample ); |
|
1673 |
// Print to log file |
|
1674 |
iLog->Log( KExample ); |
|
1675 |
||
1676 |
TInt i = 0; |
|
1677 |
TPtrC string; |
|
1678 |
_LIT( KParam, "Param[%i]: %S" ); |
|
1679 |
while ( aItem.GetNextString ( string ) == KErrNone ) |
|
1680 |
{ |
|
1681 |
TestModuleIf().Printf( i, KContactsTest, |
|
1682 |
KParam, i, &string ); |
|
1683 |
i++; |
|
1684 |
} |
|
1685 |
||
1686 |
iErr = KErrNone; |
|
1687 |
||
1688 |
/**Delete using virtual Phonebook */ |
|
1689 |
||
1690 |
_LIT(KPhone,"13579"); |
|
1691 |
// Create find operation |
|
1692 |
iOp = iContactManager->MatchPhoneNumberL( |
|
1693 |
KPhone, KPhone().Length(), *this ); |
|
1694 |
CActiveScheduler::Start(); |
|
1695 |
||
1696 |
iErr = KErrGeneral; |
|
1697 |
TInt count1(iFindResults->Count()); |
|
1698 |
while(count1) |
|
1699 |
{ |
|
1700 |
iContactToDelete = CVPbkContactLinkArray::NewL(); |
|
1701 |
iContactToDelete->AppendL(&(const_cast<MVPbkContactLink&>(iFindResults->At(--count1)))); |
|
1702 |
iOp = iContactManager->DeleteContactsL( *iContactToDelete, *this ); |
|
1703 |
CActiveScheduler::Start(); |
|
1704 |
} |
|
1705 |
/**end */ |
|
1706 |
||
1707 |
/**Add 2 contacts using virtual phonebook*/ |
|
1708 |
||
1709 |
CVPbkFieldTypeRefsList* fieldTypeRefList = CVPbkFieldTypeRefsList::NewL(); |
|
1710 |
CleanupStack::PushL(fieldTypeRefList); |
|
1711 |
||
1712 |
fieldTypeRefList->AppendL( |
|
1713 |
*iContactManager->FieldTypes().Find( R_VPBK_FIELD_TYPE_FIRSTNAME ) ); |
|
1714 |
fieldTypeRefList->AppendL( |
|
1715 |
*iContactManager->FieldTypes().Find( R_VPBK_FIELD_TYPE_MOBILEPHONEGEN ) ); |
|
1716 |
||
1717 |
// Create first contact |
|
1718 |
iStoreContact = iStore->CreateNewContactLC(); |
|
1719 |
||
1720 |
// Create contact field for contact |
|
1721 |
MVPbkStoreContactField* field = iStoreContact->CreateFieldLC( fieldTypeRefList->FieldTypeAt( 0 ) ); |
|
1722 |
// Set contact field data |
|
1723 |
_LIT(KFirstName,"Tenali"); |
|
1724 |
(MVPbkContactFieldTextData::Cast(field->FieldData())).SetTextL( KFirstName ); |
|
1725 |
// Add the contact field to contact |
|
1726 |
iStoreContact->AddFieldL( field ); |
|
1727 |
CleanupStack::Pop(); // field |
|
1728 |
||
1729 |
// Create contact field for contact |
|
1730 |
field = iStoreContact->CreateFieldLC( fieldTypeRefList->FieldTypeAt( 1 ) ); |
|
1731 |
// Set contact field data |
|
1732 |
_LIT(KFirstNumber,"13579"); |
|
1733 |
(MVPbkContactFieldTextData::Cast(field->FieldData())).SetTextL( KFirstNumber ); |
|
1734 |
// Add the contact field to contact |
|
1735 |
iStoreContact->AddFieldL( field ); |
|
1736 |
CleanupStack::Pop(); // field |
|
1737 |
||
1738 |
// Commit the new created contact to contact store |
|
1739 |
iStoreContact->CommitL( *this ); |
|
1740 |
CActiveScheduler::Start(); |
|
1741 |
CleanupStack::Pop(); // iStoreContact |
|
1742 |
||
1743 |
||
1744 |
// Create second contact |
|
1745 |
iStoreContact = iStore->CreateNewContactLC(); |
|
1746 |
||
1747 |
// Create contact field for contact |
|
1748 |
field = iStoreContact->CreateFieldLC( fieldTypeRefList->FieldTypeAt( 0 ) ); |
|
1749 |
// Set contact field data |
|
1750 |
_LIT(KSecondName,"Birbal"); |
|
1751 |
(MVPbkContactFieldTextData::Cast(field->FieldData())).SetTextL( KSecondName ); |
|
1752 |
// Add the contact field to contact |
|
1753 |
iStoreContact->AddFieldL( field ); |
|
1754 |
CleanupStack::Pop(); // field |
|
1755 |
||
1756 |
// Create contact field for contact |
|
1757 |
field = iStoreContact->CreateFieldLC( fieldTypeRefList->FieldTypeAt( 1 ) ); |
|
1758 |
// Set contact field data |
|
1759 |
_LIT(KSecondNumber,"13579"); |
|
1760 |
(MVPbkContactFieldTextData::Cast(field->FieldData())).SetTextL( KSecondNumber ); |
|
1761 |
// Add the contact field to contact |
|
1762 |
iStoreContact->AddFieldL( field ); |
|
1763 |
CleanupStack::Pop(); // field |
|
1764 |
||
1765 |
// Commit the new created contact to contact store |
|
1766 |
iStoreContact->CommitL( *this ); |
|
1767 |
CActiveScheduler::Start(); |
|
1768 |
CleanupStack::Pop(); // iStoreContact |
|
1769 |
||
1770 |
CleanupStack::PopAndDestroy(fieldTypeRefList); |
|
1771 |
/**end*/ |
|
1772 |
__UHEAP_MARK; |
|
1773 |
iServiceHandle = CContactService::NewL(); |
|
1774 |
iLog->Log( KServiceOpen ); |
|
1775 |
||
1776 |
iOperation = EGetContact; |
|
1777 |
iServiceHandle->GetListL(this,0,EContacts); |
|
1778 |
iLog->Log(_L("GetListL called\n")); |
|
1779 |
iLog->Log(_L("Start Active Scheduler\n")); |
|
1780 |
CActiveScheduler::Start(); |
|
1781 |
||
1782 |
delete iServiceHandle;//serviceHandle |
|
1783 |
iServiceHandle = NULL; |
|
1784 |
iLog->Log( KServiceClose ); |
|
1785 |
__UHEAP_MARKEND; |
|
1786 |
return iErr; |
|
1787 |
||
1788 |
} |
|
1789 |
||
1790 |
||
1791 |
TInt CContactsUT::GetContactsAscOrderL( CStifItemParser& aItem ) |
|
1792 |
{ |
|
1793 |
||
1794 |
// Print to UI |
|
1795 |
_LIT( KContactsTest, "ContactsUT" ); |
|
1796 |
_LIT( KExample, "In Add" ); |
|
1797 |
TestModuleIf().Printf( 0, KContactsTest, KExample ); |
|
1798 |
// Print to log file |
|
1799 |
iLog->Log( KExample ); |
|
1800 |
||
1801 |
TInt i = 0; |
|
1802 |
TPtrC string; |
|
1803 |
_LIT( KParam, "Param[%i]: %S" ); |
|
1804 |
while ( aItem.GetNextString ( string ) == KErrNone ) |
|
1805 |
{ |
|
1806 |
TestModuleIf().Printf( i, KContactsTest, |
|
1807 |
KParam, i, &string ); |
|
1808 |
i++; |
|
1809 |
} |
|
1810 |
||
1811 |
iErr = KErrNone; |
|
1812 |
||
1813 |
||
1814 |
_LIT(KPhone,"13579"); |
|
1815 |
// Create find operation |
|
1816 |
iOp = iContactManager->MatchPhoneNumberL( |
|
1817 |
KPhone, KPhone().Length(), *this ); |
|
1818 |
CActiveScheduler::Start(); |
|
1819 |
||
1820 |
iErr = KErrGeneral; |
|
1821 |
TInt count1(iFindResults->Count()); |
|
1822 |
while(count1) |
|
1823 |
{ |
|
1824 |
iContactToDelete = CVPbkContactLinkArray::NewL(); |
|
1825 |
iContactToDelete->AppendL(&(const_cast<MVPbkContactLink&>(iFindResults->At(--count1)))); |
|
1826 |
iOp = iContactManager->DeleteContactsL( *iContactToDelete, *this ); |
|
1827 |
CActiveScheduler::Start(); |
|
1828 |
} |
|
1829 |
/*end */ |
|
1830 |
||
1831 |
/**Add 2 contact using virtual phonebook*/ |
|
1832 |
||
1833 |
CVPbkFieldTypeRefsList* fieldTypeRefList = CVPbkFieldTypeRefsList::NewL(); |
|
1834 |
CleanupStack::PushL(fieldTypeRefList); |
|
1835 |
||
1836 |
fieldTypeRefList->AppendL( |
|
1837 |
*iContactManager->FieldTypes().Find( R_VPBK_FIELD_TYPE_FIRSTNAME ) ); |
|
1838 |
fieldTypeRefList->AppendL( |
|
1839 |
*iContactManager->FieldTypes().Find( R_VPBK_FIELD_TYPE_MOBILEPHONEGEN ) ); |
|
1840 |
||
1841 |
// Create first contact |
|
1842 |
iStoreContact = iStore->CreateNewContactLC(); |
|
1843 |
||
1844 |
// Create contact field for contact |
|
1845 |
MVPbkStoreContactField* field = iStoreContact->CreateFieldLC( fieldTypeRefList->FieldTypeAt( 0 ) ); |
|
1846 |
// Set contact field data |
|
1847 |
_LIT(KFirstName,"Tenali"); |
|
1848 |
(MVPbkContactFieldTextData::Cast(field->FieldData())).SetTextL( KFirstName ); |
|
1849 |
// Add the contact field to contact |
|
1850 |
iStoreContact->AddFieldL( field ); |
|
1851 |
CleanupStack::Pop(); // field |
|
1852 |
||
1853 |
// Create contact field for contact |
|
1854 |
field = iStoreContact->CreateFieldLC( fieldTypeRefList->FieldTypeAt( 1 ) ); |
|
1855 |
// Set contact field data |
|
1856 |
_LIT(KFirstNumber,"13579"); |
|
1857 |
(MVPbkContactFieldTextData::Cast(field->FieldData())).SetTextL( KFirstNumber ); |
|
1858 |
// Add the contact field to contact |
|
1859 |
iStoreContact->AddFieldL( field ); |
|
1860 |
CleanupStack::Pop(); // field |
|
1861 |
||
1862 |
// Commit the new created contact to contact store |
|
1863 |
iStoreContact->CommitL( *this ); |
|
1864 |
CActiveScheduler::Start(); |
|
1865 |
CleanupStack::Pop(); // iStoreContact |
|
1866 |
||
1867 |
||
1868 |
// Create second contact |
|
1869 |
iStoreContact = iStore->CreateNewContactLC(); |
|
1870 |
||
1871 |
// Create contact field for contact |
|
1872 |
field = iStoreContact->CreateFieldLC( fieldTypeRefList->FieldTypeAt( 0 ) ); |
|
1873 |
// Set contact field data |
|
1874 |
_LIT(KSecondName,"Birbal"); |
|
1875 |
(MVPbkContactFieldTextData::Cast(field->FieldData())).SetTextL( KSecondName ); |
|
1876 |
// Add the contact field to contact |
|
1877 |
iStoreContact->AddFieldL( field ); |
|
1878 |
CleanupStack::Pop(); // field |
|
1879 |
||
1880 |
// Create contact field for contact |
|
1881 |
field = iStoreContact->CreateFieldLC( fieldTypeRefList->FieldTypeAt( 1 ) ); |
|
1882 |
// Set contact field data |
|
1883 |
_LIT(KSecondNumber,"13579"); |
|
1884 |
(MVPbkContactFieldTextData::Cast(field->FieldData())).SetTextL( KSecondNumber ); |
|
1885 |
// Add the contact field to contact |
|
1886 |
iStoreContact->AddFieldL( field ); |
|
1887 |
CleanupStack::Pop(); // field |
|
1888 |
||
1889 |
// Commit the new created contact to contact store |
|
1890 |
iStoreContact->CommitL( *this ); |
|
1891 |
CActiveScheduler::Start(); |
|
1892 |
CleanupStack::Pop(); // iStoreContact |
|
1893 |
||
1894 |
CleanupStack::PopAndDestroy(fieldTypeRefList); |
|
1895 |
/**end*/ |
|
1896 |
||
1897 |
||
1898 |
||
1899 |
||
1900 |
||
1901 |
/**GetList using SAPI Core class */ |
|
1902 |
// __UHEAP_MARK; |
|
1903 |
iServiceHandle = CContactService::NewL(); |
|
1904 |
iLog->Log( KServiceOpen ); |
|
1905 |
||
1906 |
iOperation = EAscContact; |
|
1907 |
iServiceHandle->GetListL(this,0,EContacts,KNullDesC8,_L(""),NULL,EAsc); |
|
1908 |
iLog->Log(_L("GetListL called\n")); |
|
1909 |
iLog->Log(_L("Start Active Scheduler\n")); |
|
1910 |
CActiveScheduler::Start(); |
|
1911 |
||
1912 |
delete iServiceHandle;//serviceHandle |
|
1913 |
iServiceHandle = NULL; |
|
1914 |
iLog->Log( KServiceClose ); |
|
1915 |
||
1916 |
||
1917 |
return iErr; |
|
1918 |
||
1919 |
} |
|
1920 |
||
1921 |
||
1922 |
||
1923 |
TInt CContactsUT::GetContactsDscOrderL( CStifItemParser& aItem ) |
|
1924 |
{ |
|
1925 |
||
1926 |
// Print to UI |
|
1927 |
_LIT( KContactsTest, "ContactsUT" ); |
|
1928 |
_LIT( KExample, "In Add" ); |
|
1929 |
TestModuleIf().Printf( 0, KContactsTest, KExample ); |
|
1930 |
// Print to log file |
|
1931 |
iLog->Log( KExample ); |
|
1932 |
||
1933 |
TInt i = 0; |
|
1934 |
TPtrC string; |
|
1935 |
_LIT( KParam, "Param[%i]: %S" ); |
|
1936 |
while ( aItem.GetNextString ( string ) == KErrNone ) |
|
1937 |
{ |
|
1938 |
TestModuleIf().Printf( i, KContactsTest, |
|
1939 |
KParam, i, &string ); |
|
1940 |
i++; |
|
1941 |
} |
|
1942 |
||
1943 |
iErr = KErrNone; |
|
1944 |
||
1945 |
/**Delete using virtual Phonebook */ |
|
1946 |
||
1947 |
_LIT(KPhone,"13579"); |
|
1948 |
// Create find operation |
|
1949 |
iOp = iContactManager->MatchPhoneNumberL( |
|
1950 |
KPhone, KPhone().Length(), *this ); |
|
1951 |
CActiveScheduler::Start(); |
|
1952 |
||
1953 |
iErr = KErrGeneral; |
|
1954 |
TInt count1(iFindResults->Count()); |
|
1955 |
while(count1) |
|
1956 |
{ |
|
1957 |
iContactToDelete = CVPbkContactLinkArray::NewL(); |
|
1958 |
iContactToDelete->AppendL(&(const_cast<MVPbkContactLink&>(iFindResults->At(--count1)))); |
|
1959 |
iOp = iContactManager->DeleteContactsL( *iContactToDelete, *this ); |
|
1960 |
CActiveScheduler::Start(); |
|
1961 |
} |
|
1962 |
/**end */ |
|
1963 |
||
1964 |
/**Add 2 contact using virtual phonebook*/ |
|
1965 |
||
1966 |
CVPbkFieldTypeRefsList* fieldTypeRefList = CVPbkFieldTypeRefsList::NewL(); |
|
1967 |
CleanupStack::PushL(fieldTypeRefList); |
|
1968 |
||
1969 |
fieldTypeRefList->AppendL( |
|
1970 |
*iContactManager->FieldTypes().Find( R_VPBK_FIELD_TYPE_FIRSTNAME ) ); |
|
1971 |
fieldTypeRefList->AppendL( |
|
1972 |
*iContactManager->FieldTypes().Find( R_VPBK_FIELD_TYPE_MOBILEPHONEGEN ) ); |
|
1973 |
||
1974 |
// Create first contact |
|
1975 |
iStoreContact = iStore->CreateNewContactLC(); |
|
1976 |
||
1977 |
// Create contact field for contact |
|
1978 |
MVPbkStoreContactField* field = iStoreContact->CreateFieldLC( fieldTypeRefList->FieldTypeAt( 0 ) ); |
|
1979 |
// Set contact field data |
|
1980 |
_LIT(KFirstName,"Tenali"); |
|
1981 |
(MVPbkContactFieldTextData::Cast(field->FieldData())).SetTextL( KFirstName ); |
|
1982 |
// Add the contact field to contact |
|
1983 |
iStoreContact->AddFieldL( field ); |
|
1984 |
CleanupStack::Pop(); // field |
|
1985 |
||
1986 |
// Create contact field for contact |
|
1987 |
field = iStoreContact->CreateFieldLC( fieldTypeRefList->FieldTypeAt( 1 ) ); |
|
1988 |
// Set contact field data |
|
1989 |
_LIT(KFirstNumber,"13579"); |
|
1990 |
(MVPbkContactFieldTextData::Cast(field->FieldData())).SetTextL( KFirstNumber ); |
|
1991 |
// Add the contact field to contact |
|
1992 |
iStoreContact->AddFieldL( field ); |
|
1993 |
CleanupStack::Pop(); // field |
|
1994 |
||
1995 |
// Commit the new created contact to contact store |
|
1996 |
iStoreContact->CommitL( *this ); |
|
1997 |
CActiveScheduler::Start(); |
|
1998 |
CleanupStack::Pop(); // iStoreContact |
|
1999 |
||
2000 |
||
2001 |
// Create second contact |
|
2002 |
iStoreContact = iStore->CreateNewContactLC(); |
|
2003 |
||
2004 |
// Create contact field for contact |
|
2005 |
field = iStoreContact->CreateFieldLC( fieldTypeRefList->FieldTypeAt( 0 ) ); |
|
2006 |
// Set contact field data |
|
2007 |
_LIT(KSecondName,"Birbal"); |
|
2008 |
(MVPbkContactFieldTextData::Cast(field->FieldData())).SetTextL( KSecondName ); |
|
2009 |
// Add the contact field to contact |
|
2010 |
iStoreContact->AddFieldL( field ); |
|
2011 |
CleanupStack::Pop(); // field |
|
2012 |
||
2013 |
// Create contact field for contact |
|
2014 |
field = iStoreContact->CreateFieldLC( fieldTypeRefList->FieldTypeAt( 1 ) ); |
|
2015 |
// Set contact field data |
|
2016 |
_LIT(KSecondNumber,"13579"); |
|
2017 |
(MVPbkContactFieldTextData::Cast(field->FieldData())).SetTextL( KSecondNumber ); |
|
2018 |
// Add the contact field to contact |
|
2019 |
iStoreContact->AddFieldL( field ); |
|
2020 |
CleanupStack::Pop(); // field |
|
2021 |
||
2022 |
// Commit the new created contact to contact store |
|
2023 |
iStoreContact->CommitL( *this ); |
|
2024 |
CActiveScheduler::Start(); |
|
2025 |
CleanupStack::Pop(); // iStoreContact |
|
2026 |
||
2027 |
CleanupStack::PopAndDestroy(fieldTypeRefList); |
|
2028 |
/**end*/ |
|
2029 |
||
2030 |
||
2031 |
||
2032 |
||
2033 |
||
2034 |
/**GetList using SAPI Core class */ |
|
2035 |
// __UHEAP_MARK; |
|
2036 |
iServiceHandle = CContactService::NewL(); |
|
2037 |
iLog->Log( KServiceOpen ); |
|
2038 |
||
2039 |
iOperation = EDscContact; |
|
2040 |
iServiceHandle->GetListL(this,0,EContacts,KNullDesC8,_L(""),NULL,EDesc); |
|
2041 |
iLog->Log(_L("GetListL called\n")); |
|
2042 |
iLog->Log(_L("Start Active Scheduler\n")); |
|
2043 |
CActiveScheduler::Start(); |
|
2044 |
||
2045 |
||
2046 |
||
2047 |
delete iServiceHandle;//serviceHandle |
|
2048 |
iServiceHandle = NULL; |
|
2049 |
iLog->Log( KServiceClose ); |
|
2050 |
||
2051 |
||
2052 |
return iErr; |
|
2053 |
||
2054 |
} |
|
2055 |
||
2056 |
TInt CContactsUT::GetSearchContactL( CStifItemParser& aItem ) |
|
2057 |
{ |
|
2058 |
||
2059 |
// Print to UI |
|
2060 |
_LIT( KContactsTest, "ContactsUT" ); |
|
2061 |
_LIT( KExample, "In Add" ); |
|
2062 |
TestModuleIf().Printf( 0, KContactsTest, KExample ); |
|
2063 |
// Print to log file |
|
2064 |
iLog->Log( KExample ); |
|
2065 |
||
2066 |
TInt i = 0; |
|
2067 |
TPtrC string; |
|
2068 |
_LIT( KParam, "Param[%i]: %S" ); |
|
2069 |
while ( aItem.GetNextString ( string ) == KErrNone ) |
|
2070 |
{ |
|
2071 |
TestModuleIf().Printf( i, KContactsTest, |
|
2072 |
KParam, i, &string ); |
|
2073 |
i++; |
|
2074 |
} |
|
2075 |
||
2076 |
iErr = KErrNone; |
|
2077 |
||
2078 |
||
2079 |
/**Delete using virtual Phonebook */ |
|
2080 |
||
2081 |
_LIT(KPhone,"13579"); |
|
2082 |
// Create find operation |
|
2083 |
iOp = iContactManager->MatchPhoneNumberL( |
|
2084 |
KPhone, KPhone().Length(), *this ); |
|
2085 |
CActiveScheduler::Start(); |
|
2086 |
||
2087 |
iErr = KErrGeneral; |
|
2088 |
TInt count1(iFindResults->Count()); |
|
2089 |
while(count1) |
|
2090 |
{ |
|
2091 |
iContactToDelete = CVPbkContactLinkArray::NewL(); |
|
2092 |
iContactToDelete->AppendL(&(const_cast<MVPbkContactLink&>(iFindResults->At(--count1)))); |
|
2093 |
iOp = iContactManager->DeleteContactsL( *iContactToDelete, *this ); |
|
2094 |
CActiveScheduler::Start(); |
|
2095 |
} |
|
2096 |
/**end */ |
|
2097 |
||
2098 |
/**Add 2 contact using virtual phonebook*/ |
|
2099 |
||
2100 |
CVPbkFieldTypeRefsList* fieldTypeRefList = CVPbkFieldTypeRefsList::NewL(); |
|
2101 |
CleanupStack::PushL(fieldTypeRefList); |
|
2102 |
||
2103 |
fieldTypeRefList->AppendL( |
|
2104 |
*iContactManager->FieldTypes().Find( R_VPBK_FIELD_TYPE_FIRSTNAME ) ); |
|
2105 |
fieldTypeRefList->AppendL( |
|
2106 |
*iContactManager->FieldTypes().Find( R_VPBK_FIELD_TYPE_MOBILEPHONEGEN ) ); |
|
2107 |
||
2108 |
// Create first contact |
|
2109 |
iStoreContact = iStore->CreateNewContactLC(); |
|
2110 |
||
2111 |
// Create contact field for contact |
|
2112 |
MVPbkStoreContactField* field = iStoreContact->CreateFieldLC( fieldTypeRefList->FieldTypeAt( 0 ) ); |
|
2113 |
// Set contact field data |
|
2114 |
_LIT(KFirstName,"Tenali"); |
|
2115 |
(MVPbkContactFieldTextData::Cast(field->FieldData())).SetTextL( KFirstName ); |
|
2116 |
// Add the contact field to contact |
|
2117 |
iStoreContact->AddFieldL( field ); |
|
2118 |
CleanupStack::Pop(); // field |
|
2119 |
||
2120 |
// Create contact field for contact |
|
2121 |
field = iStoreContact->CreateFieldLC( fieldTypeRefList->FieldTypeAt( 1 ) ); |
|
2122 |
// Set contact field data |
|
2123 |
_LIT(KFirstNumber,"13579"); |
|
2124 |
(MVPbkContactFieldTextData::Cast(field->FieldData())).SetTextL( KFirstNumber ); |
|
2125 |
// Add the contact field to contact |
|
2126 |
iStoreContact->AddFieldL( field ); |
|
2127 |
CleanupStack::Pop(); // field |
|
2128 |
||
2129 |
// Commit the new created contact to contact store |
|
2130 |
iStoreContact->CommitL( *this ); |
|
2131 |
CActiveScheduler::Start(); |
|
2132 |
CleanupStack::Pop(); // iStoreContact |
|
2133 |
||
2134 |
||
2135 |
// Create second contact |
|
2136 |
iStoreContact = iStore->CreateNewContactLC(); |
|
2137 |
||
2138 |
// Create contact field for contact |
|
2139 |
field = iStoreContact->CreateFieldLC( fieldTypeRefList->FieldTypeAt( 0 ) ); |
|
2140 |
// Set contact field data |
|
2141 |
_LIT(KSecondName,"Birbal"); |
|
2142 |
(MVPbkContactFieldTextData::Cast(field->FieldData())).SetTextL( KSecondName ); |
|
2143 |
// Add the contact field to contact |
|
2144 |
iStoreContact->AddFieldL( field ); |
|
2145 |
CleanupStack::Pop(); // field |
|
2146 |
||
2147 |
// Create contact field for contact |
|
2148 |
field = iStoreContact->CreateFieldLC( fieldTypeRefList->FieldTypeAt( 1 ) ); |
|
2149 |
// Set contact field data |
|
2150 |
_LIT(KSecondNumber,"13579"); |
|
2151 |
(MVPbkContactFieldTextData::Cast(field->FieldData())).SetTextL( KSecondNumber ); |
|
2152 |
// Add the contact field to contact |
|
2153 |
iStoreContact->AddFieldL( field ); |
|
2154 |
CleanupStack::Pop(); // field |
|
2155 |
||
2156 |
// Commit the new created contact to contact store |
|
2157 |
iStoreContact->CommitL( *this ); |
|
2158 |
CActiveScheduler::Start(); |
|
2159 |
CleanupStack::Pop(); // iStoreContact |
|
2160 |
||
2161 |
CleanupStack::PopAndDestroy(fieldTypeRefList); |
|
2162 |
/**end*/ |
|
2163 |
||
2164 |
||
2165 |
||
2166 |
||
2167 |
||
2168 |
/**GetList using SAPI Core class */ |
|
2169 |
// __UHEAP_MARK; |
|
2170 |
iServiceHandle = CContactService::NewL(); |
|
2171 |
iLog->Log( KServiceOpen ); |
|
2172 |
||
2173 |
iOperation = ESearchContact; |
|
2174 |
iServiceHandle->GetListL(this,0,EContacts,KNullDesC8,_L(""),NULL,EAsc); |
|
2175 |
iLog->Log(_L("GetListL called\n")); |
|
2176 |
iLog->Log(_L("Start Active Scheduler\n")); |
|
2177 |
CActiveScheduler::Start(); |
|
2178 |
||
2179 |
||
2180 |
delete iServiceHandle;//serviceHandle |
|
2181 |
iServiceHandle = NULL; |
|
2182 |
iLog->Log( KServiceClose ); |
|
2183 |
||
2184 |
||
2185 |
return iErr; |
|
2186 |
||
2187 |
} |
|
2188 |
TInt CContactsUT::GetListConactIdL( CStifItemParser& aItem ) |
|
2189 |
{ |
|
2190 |
// Print to UI |
|
2191 |
_LIT( KContactsTest, "ContactsUT" ); |
|
2192 |
_LIT( KExample, "In Add" ); |
|
2193 |
TestModuleIf().Printf( 0, KContactsTest, KExample ); |
|
2194 |
// Print to log file |
|
2195 |
iLog->Log( KExample ); |
|
2196 |
||
2197 |
TInt i = 0; |
|
2198 |
TPtrC string; |
|
2199 |
_LIT( KParam, "Param[%i]: %S" ); |
|
2200 |
while ( aItem.GetNextString ( string ) == KErrNone ) |
|
2201 |
{ |
|
2202 |
TestModuleIf().Printf( i, KContactsTest, |
|
2203 |
KParam, i, &string ); |
|
2204 |
i++; |
|
2205 |
} |
|
2206 |
||
2207 |
iErr = KErrNone; |
|
2208 |
||
2209 |
||
2210 |
/**Delete using virtual Phonebook */ |
|
2211 |
||
2212 |
_LIT(KPhone,"13579"); |
|
2213 |
// Create find operation |
|
2214 |
iOp = iContactManager->MatchPhoneNumberL( |
|
2215 |
KPhone, KPhone().Length(), *this ); |
|
2216 |
CActiveScheduler::Start(); |
|
2217 |
||
2218 |
iErr = KErrGeneral; |
|
2219 |
TInt count1(iFindResults->Count()); |
|
2220 |
while(count1) |
|
2221 |
{ |
|
2222 |
iContactToDelete = CVPbkContactLinkArray::NewL(); |
|
2223 |
iContactToDelete->AppendL(&(const_cast<MVPbkContactLink&>(iFindResults->At(--count1)))); |
|
2224 |
iOp = iContactManager->DeleteContactsL( *iContactToDelete, *this ); |
|
2225 |
CActiveScheduler::Start(); |
|
2226 |
} |
|
2227 |
/**end */ |
|
2228 |
||
2229 |
/**Add 2 contact using virtual phonebook*/ |
|
2230 |
||
2231 |
CVPbkFieldTypeRefsList* fieldTypeRefList = CVPbkFieldTypeRefsList::NewL(); |
|
2232 |
CleanupStack::PushL(fieldTypeRefList); |
|
2233 |
||
2234 |
fieldTypeRefList->AppendL( |
|
2235 |
*iContactManager->FieldTypes().Find( R_VPBK_FIELD_TYPE_FIRSTNAME ) ); |
|
2236 |
fieldTypeRefList->AppendL( |
|
2237 |
*iContactManager->FieldTypes().Find( R_VPBK_FIELD_TYPE_MOBILEPHONEGEN ) ); |
|
2238 |
||
2239 |
// Create first contact |
|
2240 |
iStoreContact = iStore->CreateNewContactLC(); |
|
2241 |
||
2242 |
// Create contact field for contact |
|
2243 |
MVPbkStoreContactField* field = iStoreContact->CreateFieldLC( fieldTypeRefList->FieldTypeAt( 0 ) ); |
|
2244 |
// Set contact field data |
|
2245 |
_LIT(KFirstName,"Tenali"); |
|
2246 |
(MVPbkContactFieldTextData::Cast(field->FieldData())).SetTextL( KFirstName ); |
|
2247 |
// Add the contact field to contact |
|
2248 |
iStoreContact->AddFieldL( field ); |
|
2249 |
CleanupStack::Pop(); // field |
|
2250 |
||
2251 |
// Create contact field for contact |
|
2252 |
field = iStoreContact->CreateFieldLC( fieldTypeRefList->FieldTypeAt( 1 ) ); |
|
2253 |
// Set contact field data |
|
2254 |
_LIT(KFirstNumber,"13579"); |
|
2255 |
(MVPbkContactFieldTextData::Cast(field->FieldData())).SetTextL( KFirstNumber ); |
|
2256 |
// Add the contact field to contact |
|
2257 |
iStoreContact->AddFieldL( field ); |
|
2258 |
CleanupStack::Pop(); // field |
|
2259 |
||
2260 |
// Commit the new created contact to contact store |
|
2261 |
iStoreContact->CommitL( *this ); |
|
2262 |
CActiveScheduler::Start(); |
|
2263 |
CleanupStack::Pop(); // iStoreContact |
|
2264 |
||
2265 |
||
2266 |
// Create second contact |
|
2267 |
iStoreContact = iStore->CreateNewContactLC(); |
|
2268 |
||
2269 |
// Create contact field for contact |
|
2270 |
field = iStoreContact->CreateFieldLC( fieldTypeRefList->FieldTypeAt( 0 ) ); |
|
2271 |
// Set contact field data |
|
2272 |
_LIT(KSecondName,"Birbal"); |
|
2273 |
(MVPbkContactFieldTextData::Cast(field->FieldData())).SetTextL( KSecondName ); |
|
2274 |
// Add the contact field to contact |
|
2275 |
iStoreContact->AddFieldL( field ); |
|
2276 |
CleanupStack::Pop(); // field |
|
2277 |
||
2278 |
// Create contact field for contact |
|
2279 |
field = iStoreContact->CreateFieldLC( fieldTypeRefList->FieldTypeAt( 1 ) ); |
|
2280 |
// Set contact field data |
|
2281 |
_LIT(KSecondNumber,"13579"); |
|
2282 |
(MVPbkContactFieldTextData::Cast(field->FieldData())).SetTextL( KSecondNumber ); |
|
2283 |
// Add the contact field to contact |
|
2284 |
iStoreContact->AddFieldL( field ); |
|
2285 |
CleanupStack::Pop(); // field |
|
2286 |
||
2287 |
// Commit the new created contact to contact store |
|
2288 |
iStoreContact->CommitL( *this ); |
|
2289 |
CActiveScheduler::Start(); |
|
2290 |
CleanupStack::Pop(); // iStoreContact |
|
2291 |
||
2292 |
CleanupStack::PopAndDestroy(fieldTypeRefList); |
|
2293 |
/**end*/ |
|
2294 |
||
2295 |
||
2296 |
||
2297 |
||
2298 |
||
2299 |
/**GetList using SAPI Core class */ |
|
2300 |
// __UHEAP_MARK; |
|
2301 |
iServiceHandle = CContactService::NewL(); |
|
2302 |
iLog->Log( KServiceOpen ); |
|
2303 |
||
2304 |
iOperation = EContactId; |
|
2305 |
iServiceHandle->GetListL(this,0,EContacts); |
|
2306 |
iLog->Log(_L("GetListL called\n")); |
|
2307 |
iLog->Log(_L("Start Active Scheduler\n")); |
|
2308 |
CActiveScheduler::Start(); |
|
2309 |
||
2310 |
||
2311 |
delete iServiceHandle;//serviceHandle |
|
2312 |
iServiceHandle = NULL; |
|
2313 |
iLog->Log( KServiceClose ); |
|
2314 |
||
2315 |
||
2316 |
return iErr; |
|
2317 |
||
2318 |
} |
|
2319 |
||
2320 |
// ----------------------------------------------------------------------------- |
|
2321 |
// CContactsUT::?member_function |
|
2322 |
// ?implementation_description |
|
2323 |
// (other items were commented in a header). |
|
2324 |
// ----------------------------------------------------------------------------- |
|
2325 |
// |
|
2326 |
TInt CContactsUT::AddL( CStifItemParser& aItem ) |
|
2327 |
{ |
|
2328 |
||
2329 |
// Print to UI |
|
2330 |
_LIT( KContactsTest, "ContactsUT" ); |
|
2331 |
_LIT( KExample, "In Add" ); |
|
2332 |
TestModuleIf().Printf( 0, KContactsTest, KExample ); |
|
2333 |
// Print to log file |
|
2334 |
iLog->Log( KExample ); |
|
2335 |
||
2336 |
TInt i = 0; |
|
2337 |
TPtrC string; |
|
2338 |
_LIT( KParam, "Param[%i]: %S" ); |
|
2339 |
while ( aItem.GetNextString ( string ) == KErrNone ) |
|
2340 |
{ |
|
2341 |
TestModuleIf().Printf( i, KContactsTest, |
|
2342 |
KParam, i, &string ); |
|
2343 |
i++; |
|
2344 |
} |
|
2345 |
||
2346 |
iErr = KErrNone; |
|
2347 |
||
2348 |
/**Add contact using SAPI Core class*/ |
|
2349 |
||
2350 |
_LIT8(KFirstName,"FirstName"); |
|
2351 |
_LIT(KName,"Sikandar"); |
|
2352 |
_LIT8(KNumber,"MobilePhoneHome"); |
|
2353 |
_LIT(KPhone,"123456"); |
|
2354 |
||
2355 |
// __UHEAP_MARK; |
|
2356 |
//instantiate service class |
|
2357 |
CContactService* serviceHandle = CContactService::NewL(); |
|
2358 |
CleanupStack::PushL(serviceHandle); |
|
2359 |
iLog->Log( KServiceOpen ); |
|
2360 |
||
2361 |
CSingleContact* singleContact = CSingleContact::NewL(); |
|
2362 |
CleanupStack::PushL(singleContact); |
|
2363 |
iLog->Log(_L("single Contact created\n")); |
|
2364 |
||
2365 |
CSingleContactField* nameContactField = CSingleContactField::NewL(); |
|
2366 |
CleanupStack::PushL(nameContactField); |
|
2367 |
iLog->Log(_L("Name Contact Field created \n")); |
|
2368 |
||
2369 |
CSingleContactField* phoneContactField = CSingleContactField::NewL(); |
|
2370 |
CleanupStack::PushL(phoneContactField); |
|
2371 |
iLog->Log(_L("Phone Contact Field created \n")); |
|
2372 |
||
2373 |
nameContactField->SetFieldParamsL(KFirstName,KNullDesC,KName); |
|
2374 |
singleContact->AddFieldToContactL(nameContactField); |
|
2375 |
iLog->Log(_L("Name Contact Field added \n")); |
|
2376 |
||
2377 |
phoneContactField->SetFieldParamsL(KNumber,KNullDesC,KPhone); |
|
2378 |
singleContact->AddFieldToContactL(phoneContactField); |
|
2379 |
iLog->Log(_L("Phone Contact Field added \n")); |
|
2380 |
||
2381 |
serviceHandle->AddL(this,0,singleContact,KNullDesC8,KNullDesC); |
|
2382 |
iLog->Log(_L("AddL called\n")); |
|
2383 |
iLog->Log(_L("Start Active Scheduler\n")); |
|
2384 |
CActiveScheduler::Start(); |
|
2385 |
||
2386 |
CleanupStack::Pop(phoneContactField);//singleContactField |
|
2387 |
CleanupStack::Pop(nameContactField);//singleContactField |
|
2388 |
CleanupStack::PopAndDestroy(singleContact);//singleContact |
|
2389 |
CleanupStack::PopAndDestroy(serviceHandle);//serviceHandle |
|
2390 |
iLog->Log( KServiceClose ); |
|
2391 |
// __UHEAP_MARKEND; |
|
2392 |
/**end */ |
|
2393 |
||
2394 |
if(iErr) |
|
2395 |
{ |
|
2396 |
return iErr; |
|
2397 |
} |
|
2398 |
||
2399 |
/**Delete using virtual Phonebook */ |
|
2400 |
/* |
|
2401 |
||
2402 |
// Create find operation |
|
2403 |
iOp = iContactManager->MatchPhoneNumberL( |
|
2404 |
KPhone, KPhone().Length(), *this ); |
|
2405 |
CActiveScheduler::Start(); |
|
2406 |
||
2407 |
iErr = KErrGeneral; |
|
2408 |
TInt count(iFindResults->Count()); |
|
2409 |
while(count) |
|
2410 |
{ |
|
2411 |
iContactToDelete = CVPbkContactLinkArray::NewL(); |
|
2412 |
iContactToDelete->AppendL(&(const_cast<MVPbkContactLink&>(iFindResults->At(--count)))); |
|
2413 |
iOp = iContactManager->DeleteContactsL( *iContactToDelete, *this ); |
|
2414 |
CActiveScheduler::Start(); |
|
2415 |
} |
|
2416 |
/**end */ |
|
2417 |
||
2418 |
||
2419 |
return iErr; |
|
2420 |
||
2421 |
} |
|
2422 |
||
2423 |
||
2424 |
// ----------------------------------------------------------------------------- |
|
2425 |
// CContactsUT::?member_function |
|
2426 |
// ?implementation_description |
|
2427 |
// (other items were commented in a header). |
|
2428 |
// ----------------------------------------------------------------------------- |
|
2429 |
// |
|
2430 |
TInt CContactsUT::AddInvalidFieldL( CStifItemParser& aItem ) |
|
2431 |
{ |
|
2432 |
||
2433 |
// Print to UI |
|
2434 |
_LIT( KContactsTest, "ContactsUT" ); |
|
2435 |
_LIT( KExample, "In Add" ); |
|
2436 |
TestModuleIf().Printf( 0, KContactsTest, KExample ); |
|
2437 |
// Print to log file |
|
2438 |
iLog->Log( KExample ); |
|
2439 |
||
2440 |
TInt i = 0; |
|
2441 |
TPtrC string; |
|
2442 |
_LIT( KParam, "Param[%i]: %S" ); |
|
2443 |
while ( aItem.GetNextString ( string ) == KErrNone ) |
|
2444 |
{ |
|
2445 |
TestModuleIf().Printf( i, KContactsTest, |
|
2446 |
KParam, i, &string ); |
|
2447 |
i++; |
|
2448 |
} |
|
2449 |
||
2450 |
iErr = KErrNone; |
|
2451 |
||
2452 |
/**Add contact using SAPI Core class*/ |
|
2453 |
||
2454 |
_LIT8(KFirstName,"FistName"); //invalid field |
|
2455 |
_LIT(KName,"Sikandar"); |
|
2456 |
_LIT8(KNumber,"MobilePhoneHome"); |
|
2457 |
_LIT(KPhone,"123456"); |
|
2458 |
||
2459 |
// __UHEAP_MARK; |
|
2460 |
//instantiate service class |
|
2461 |
CContactService* serviceHandle = CContactService::NewL(); |
|
2462 |
CleanupStack::PushL(serviceHandle); |
|
2463 |
iLog->Log( KServiceOpen ); |
|
2464 |
||
2465 |
CSingleContact* singleContact = CSingleContact::NewL(); |
|
2466 |
CleanupStack::PushL(singleContact); |
|
2467 |
iLog->Log(_L("single Contact created\n")); |
|
2468 |
||
2469 |
CSingleContactField* nameContactField = CSingleContactField::NewL(); |
|
2470 |
CleanupStack::PushL(nameContactField); |
|
2471 |
iLog->Log(_L("Name Contact Field created \n")); |
|
2472 |
||
2473 |
CSingleContactField* phoneContactField = CSingleContactField::NewL(); |
|
2474 |
CleanupStack::PushL(phoneContactField); |
|
2475 |
iLog->Log(_L("Phone Contact Field created \n")); |
|
2476 |
||
2477 |
nameContactField->SetFieldParamsL(KFirstName,KNullDesC,KName); |
|
2478 |
singleContact->AddFieldToContactL(nameContactField); |
|
2479 |
iLog->Log(_L("Name Contact Field added \n")); |
|
2480 |
||
2481 |
phoneContactField->SetFieldParamsL(KNumber,KNullDesC,KPhone); |
|
2482 |
singleContact->AddFieldToContactL(phoneContactField); |
|
2483 |
iLog->Log(_L("Phone Contact Field added \n")); |
|
2484 |
||
2485 |
serviceHandle->AddL(this,0,singleContact,KNullDesC8,KNullDesC); |
|
2486 |
iLog->Log(_L("AddL called\n")); |
|
2487 |
iLog->Log(_L("Start Active Scheduler\n")); |
|
2488 |
CActiveScheduler::Start(); |
|
2489 |
||
2490 |
CleanupStack::Pop(phoneContactField);//singleContactField |
|
2491 |
CleanupStack::Pop(nameContactField);//singleContactField |
|
2492 |
CleanupStack::PopAndDestroy(singleContact);//singleContact |
|
2493 |
CleanupStack::PopAndDestroy(serviceHandle);//serviceHandle |
|
2494 |
iLog->Log( KServiceClose ); |
|
2495 |
// __UHEAP_MARKEND; |
|
2496 |
/**end */ |
|
2497 |
||
2498 |
if( KInvalidKey == iErr ) |
|
2499 |
{ |
|
2500 |
return KErrNone; |
|
2501 |
} |
|
2502 |
||
2503 |
||
2504 |
return iErr; |
|
2505 |
||
2506 |
} |
|
2507 |
||
2508 |
||
2509 |
||
2510 |
// ----------------------------------------------------------------------------- |
|
2511 |
// CContactsUT::?member_function |
|
2512 |
// ?implementation_description |
|
2513 |
// (other items were commented in a header). |
|
2514 |
// ----------------------------------------------------------------------------- |
|
2515 |
// |
|
2516 |
TInt CContactsUT::AddMultiplePhoneNumbersContactL( CStifItemParser& aItem ) |
|
2517 |
{ |
|
2518 |
||
2519 |
// Print to UI |
|
2520 |
_LIT( KContactsTest, "ContactsUT" ); |
|
2521 |
_LIT( KExample, "In Add" ); |
|
2522 |
TestModuleIf().Printf( 0, KContactsTest, KExample ); |
|
2523 |
// Print to log file |
|
2524 |
iLog->Log( KExample ); |
|
2525 |
||
2526 |
TInt i = 0; |
|
2527 |
TPtrC string; |
|
2528 |
_LIT( KParam, "Param[%i]: %S" ); |
|
2529 |
while ( aItem.GetNextString ( string ) == KErrNone ) |
|
2530 |
{ |
|
2531 |
TestModuleIf().Printf( i, KContactsTest, |
|
2532 |
KParam, i, &string ); |
|
2533 |
i++; |
|
2534 |
} |
|
2535 |
||
2536 |
iErr = KErrNone; |
|
2537 |
||
2538 |
/**Add contact using SAPI Core class*/ |
|
2539 |
||
2540 |
_LIT8(KFirstName,"FirstName"); |
|
2541 |
_LIT(KName,"Sikandar"); |
|
2542 |
_LIT8(KNumber,"MobilePhoneHome"); |
|
2543 |
_LIT(KPhone,"123456"); |
|
2544 |
_LIT8(KNumber2,"MobilePhoneWork"); |
|
2545 |
_LIT(KPhone2,"654321"); |
|
2546 |
||
2547 |
// __UHEAP_MARK; |
|
2548 |
//instantiate service class |
|
2549 |
CContactService* serviceHandle = CContactService::NewL(); |
|
2550 |
CleanupStack::PushL(serviceHandle); |
|
2551 |
iLog->Log( KServiceOpen ); |
|
2552 |
||
2553 |
CSingleContact* singleContact = CSingleContact::NewL(); |
|
2554 |
CleanupStack::PushL(singleContact); |
|
2555 |
iLog->Log(_L("single Contact created\n")); |
|
2556 |
||
2557 |
CSingleContactField* nameContactField = CSingleContactField::NewL(); |
|
2558 |
CleanupStack::PushL(nameContactField); |
|
2559 |
iLog->Log(_L("Name Contact Field created \n")); |
|
2560 |
||
2561 |
CSingleContactField* phoneContactField = CSingleContactField::NewL(); |
|
2562 |
CleanupStack::PushL(phoneContactField); |
|
2563 |
iLog->Log(_L("Phone Contact Field created \n")); |
|
2564 |
||
2565 |
CSingleContactField* workPhoneContactField = CSingleContactField::NewL(); |
|
2566 |
CleanupStack::PushL(workPhoneContactField); |
|
2567 |
iLog->Log(_L("Work Phone Contact Field created \n")); |
|
2568 |
||
2569 |
nameContactField->SetFieldParamsL(KFirstName,KNullDesC,KName); |
|
2570 |
singleContact->AddFieldToContactL(nameContactField); |
|
2571 |
iLog->Log(_L("Name Contact Field added \n")); |
|
2572 |
||
2573 |
phoneContactField->SetFieldParamsL(KNumber,KNullDesC,KPhone); |
|
2574 |
singleContact->AddFieldToContactL(phoneContactField); |
|
2575 |
iLog->Log(_L("Phone Contact Field added \n")); |
|
2576 |
||
2577 |
workPhoneContactField->SetFieldParamsL(KNumber2,KNullDesC,KPhone2); |
|
2578 |
singleContact->AddFieldToContactL(workPhoneContactField); |
|
2579 |
iLog->Log(_L("Phone Contact Field added \n")); |
|
2580 |
||
2581 |
serviceHandle->AddL(this,0,singleContact,KNullDesC8,KNullDesC); |
|
2582 |
iLog->Log(_L("AddL called\n")); |
|
2583 |
iLog->Log(_L("Start Active Scheduler\n")); |
|
2584 |
CActiveScheduler::Start(); |
|
2585 |
||
2586 |
CleanupStack::Pop(workPhoneContactField);//singleContactField |
|
2587 |
CleanupStack::Pop(phoneContactField);//singleContactField |
|
2588 |
CleanupStack::Pop(nameContactField);//singleContactField |
|
2589 |
CleanupStack::PopAndDestroy(singleContact);//singleContact |
|
2590 |
CleanupStack::PopAndDestroy(serviceHandle);//serviceHandle |
|
2591 |
iLog->Log( KServiceClose ); |
|
2592 |
// __UHEAP_MARKEND; |
|
2593 |
/**end */ |
|
2594 |
||
2595 |
if(iErr) |
|
2596 |
{ |
|
2597 |
return iErr; |
|
2598 |
} |
|
2599 |
||
2600 |
/**Delete using virtual Phonebook */ |
|
2601 |
/* |
|
2602 |
||
2603 |
// Create find operation |
|
2604 |
iOp = iContactManager->MatchPhoneNumberL( |
|
2605 |
KPhone, KPhone().Length(), *this ); |
|
2606 |
CActiveScheduler::Start(); |
|
2607 |
||
2608 |
iErr = KErrGeneral; |
|
2609 |
TInt count(iFindResults->Count()); |
|
2610 |
while(count) |
|
2611 |
{ |
|
2612 |
iContactToDelete = CVPbkContactLinkArray::NewL(); |
|
2613 |
iContactToDelete->AppendL(&(const_cast<MVPbkContactLink&>(iFindResults->At(--count)))); |
|
2614 |
iOp = iContactManager->DeleteContactsL( *iContactToDelete, *this ); |
|
2615 |
CActiveScheduler::Start(); |
|
2616 |
} |
|
2617 |
/**end */ |
|
2618 |
||
2619 |
||
2620 |
return iErr; |
|
2621 |
||
2622 |
} |
|
2623 |
||
2624 |
||
2625 |
||
2626 |
||
2627 |
// ----------------------------------------------------------------------------- |
|
2628 |
// CContactsUT::AddGroupL |
|
2629 |
// Example test method function. |
|
2630 |
// (other items were commented in a header). |
|
2631 |
// ----------------------------------------------------------------------------- |
|
2632 |
// |
|
2633 |
TInt CContactsUT::AddGroupL( CStifItemParser& aItem ) |
|
2634 |
{ |
|
2635 |
||
2636 |
// Print to UI |
|
2637 |
_LIT( KContactsTest, "ContactsTest" ); |
|
2638 |
_LIT( KExample, "In AddGroup" ); |
|
2639 |
TestModuleIf().Printf( 0, KContactsTest, KExample ); |
|
2640 |
// Print to log file |
|
2641 |
iLog->Log( KExample ); |
|
2642 |
||
2643 |
TInt i = 0; |
|
2644 |
TPtrC string; |
|
2645 |
_LIT( KParam, "Param[%i]: %S" ); |
|
2646 |
while ( aItem.GetNextString ( string ) == KErrNone ) |
|
2647 |
{ |
|
2648 |
TestModuleIf().Printf( i, KContactsTest, |
|
2649 |
KParam, i, &string ); |
|
2650 |
i++; |
|
2651 |
} |
|
2652 |
||
2653 |
iErr = KErrNone; |
|
2654 |
||
2655 |
/**Add group using SAPI core class */ |
|
2656 |
__UHEAP_MARK; |
|
2657 |
_LIT(KGroup,"Test"); |
|
2658 |
//instantiate service class |
|
2659 |
CContactService* serviceHandle = CContactService::NewL(); |
|
2660 |
CleanupStack::PushL(serviceHandle); |
|
2661 |
iLog->Log( KServiceOpen ); |
|
2662 |
||
2663 |
serviceHandle->AddL(this,0,NULL,KNullDesC8,KGroup); |
|
2664 |
iLog->Log(_L("AddL called\n")); |
|
2665 |
iLog->Log(_L("Start Active Scheduler\n")); |
|
2666 |
CActiveScheduler::Start(); |
|
2667 |
||
2668 |
CleanupStack::PopAndDestroy(serviceHandle);//serviceHandle |
|
2669 |
iLog->Log( KServiceClose ); |
|
2670 |
/**end */ |
|
2671 |
__UHEAP_MARKEND; |
|
2672 |
if(iErr) |
|
2673 |
{ |
|
2674 |
return iErr; |
|
2675 |
} |
|
2676 |
||
2677 |
/** Check for the added group using virtual phonebook classes */ |
|
2678 |
iFindResults = iStore->ContactGroupsLC(); |
|
2679 |
TInt count(iFindResults->Count()); |
|
2680 |
while(count) |
|
2681 |
{ |
|
2682 |
iResult = &(const_cast<MVPbkContactLink&>(iFindResults->At(--count))); |
|
2683 |
iOp = iContactManager->RetrieveContactL(*iResult,*this); |
|
2684 |
CActiveScheduler::Start(); |
|
2685 |
||
2686 |
if(iErr) |
|
2687 |
{ |
|
2688 |
break; |
|
2689 |
} |
|
2690 |
iErr = KErrGeneral; |
|
2691 |
iGroup = iStoreContact->Group(); |
|
2692 |
if(!iGroup->GroupLabel().Compare(KGroup)) |
|
2693 |
{ |
|
2694 |
iErr = KErrNone; |
|
2695 |
iContactToDelete = CVPbkContactLinkArray::NewL(); |
|
2696 |
iContactToDelete->AppendL(iResult); |
|
2697 |
iOp = iContactManager->DeleteContactsL( *iContactToDelete, *this ); |
|
2698 |
CActiveScheduler::Start(); |
|
2699 |
break; |
|
2700 |
} |
|
2701 |
} |
|
2702 |
CleanupStack::Pop(); |
|
2703 |
iFindResults = NULL; |
|
2704 |
/**end */ |
|
2705 |
||
2706 |
return iErr; |
|
2707 |
||
2708 |
} |
|
2709 |
||
2710 |
||
2711 |
// ----------------------------------------------------------------------------- |
|
2712 |
// CContactsUT::DeleteL |
|
2713 |
// Example test method function. |
|
2714 |
// (other items were commented in a header). |
|
2715 |
// ----------------------------------------------------------------------------- |
|
2716 |
// |
|
2717 |
TInt CContactsUT::DeleteContactL( CStifItemParser& aItem ) |
|
2718 |
{ |
|
2719 |
||
2720 |
// Print to UI |
|
2721 |
_LIT( KContactsTest, "ContactsTest" ); |
|
2722 |
_LIT( KExample, "In Delete" ); |
|
2723 |
TestModuleIf().Printf( 0, KContactsTest, KExample ); |
|
2724 |
// Print to log file |
|
2725 |
iLog->Log( KExample ); |
|
2726 |
||
2727 |
TInt i = 0; |
|
2728 |
TPtrC string; |
|
2729 |
_LIT( KParam, "Param[%i]: %S" ); |
|
2730 |
while ( aItem.GetNextString ( string ) == KErrNone ) |
|
2731 |
{ |
|
2732 |
TestModuleIf().Printf( i, KContactsTest, |
|
2733 |
KParam, i, &string ); |
|
2734 |
i++; |
|
2735 |
} |
|
2736 |
||
2737 |
iErr = KErrNone; |
|
2738 |
||
2739 |
/**Add 2 contacts using virtual phonebook*/ |
|
2740 |
||
2741 |
CVPbkFieldTypeRefsList* fieldTypeRefList = CVPbkFieldTypeRefsList::NewL(); |
|
2742 |
CleanupStack::PushL(fieldTypeRefList); |
|
2743 |
||
2744 |
fieldTypeRefList->AppendL( |
|
2745 |
*iContactManager->FieldTypes().Find( R_VPBK_FIELD_TYPE_FIRSTNAME ) ); |
|
2746 |
fieldTypeRefList->AppendL( |
|
2747 |
*iContactManager->FieldTypes().Find( R_VPBK_FIELD_TYPE_MOBILEPHONEGEN ) ); |
|
2748 |
||
2749 |
// Create first contact |
|
2750 |
iStoreContact = iStore->CreateNewContactLC(); |
|
2751 |
||
2752 |
// Create contact field for contact |
|
2753 |
MVPbkStoreContactField* field = iStoreContact->CreateFieldLC( fieldTypeRefList->FieldTypeAt( 0 ) ); |
|
2754 |
// Set contact field data |
|
2755 |
_LIT(KFirstName,"Tenali"); |
|
2756 |
(MVPbkContactFieldTextData::Cast(field->FieldData())).SetTextL( KFirstName ); |
|
2757 |
// Add the contact field to contact |
|
2758 |
iStoreContact->AddFieldL( field ); |
|
2759 |
CleanupStack::Pop(); // field |
|
2760 |
||
2761 |
// Create contact field for contact |
|
2762 |
field = iStoreContact->CreateFieldLC( fieldTypeRefList->FieldTypeAt( 1 ) ); |
|
2763 |
// Set contact field data |
|
2764 |
_LIT(KFirstNumber,"13579"); |
|
2765 |
(MVPbkContactFieldTextData::Cast(field->FieldData())).SetTextL( KFirstNumber ); |
|
2766 |
// Add the contact field to contact |
|
2767 |
iStoreContact->AddFieldL( field ); |
|
2768 |
CleanupStack::Pop(); // field |
|
2769 |
||
2770 |
// Commit the new created contact to contact store |
|
2771 |
iStoreContact->CommitL( *this ); |
|
2772 |
CActiveScheduler::Start(); |
|
2773 |
CleanupStack::Pop(); // iStoreContact |
|
2774 |
||
2775 |
||
2776 |
// Create second contact |
|
2777 |
iStoreContact = iStore->CreateNewContactLC(); |
|
2778 |
||
2779 |
// Create contact field for contact |
|
2780 |
field = iStoreContact->CreateFieldLC( fieldTypeRefList->FieldTypeAt( 0 ) ); |
|
2781 |
// Set contact field data |
|
2782 |
_LIT(KSecondName,"Birbal"); |
|
2783 |
(MVPbkContactFieldTextData::Cast(field->FieldData())).SetTextL( KSecondName ); |
|
2784 |
// Add the contact field to contact |
|
2785 |
iStoreContact->AddFieldL( field ); |
|
2786 |
CleanupStack::Pop(); // field |
|
2787 |
||
2788 |
// Create contact field for contact |
|
2789 |
field = iStoreContact->CreateFieldLC( fieldTypeRefList->FieldTypeAt( 1 ) ); |
|
2790 |
// Set contact field data |
|
2791 |
_LIT(KSecondNumber,"13579"); |
|
2792 |
(MVPbkContactFieldTextData::Cast(field->FieldData())).SetTextL( KSecondNumber ); |
|
2793 |
// Add the contact field to contact |
|
2794 |
iStoreContact->AddFieldL( field ); |
|
2795 |
CleanupStack::Pop(); // field |
|
2796 |
||
2797 |
// Commit the new created contact to contact store |
|
2798 |
iStoreContact->CommitL( *this ); |
|
2799 |
CActiveScheduler::Start(); |
|
2800 |
CleanupStack::Pop(); // iStoreContact |
|
2801 |
||
2802 |
CleanupStack::PopAndDestroy(fieldTypeRefList); |
|
2803 |
/**end*/ |
|
2804 |
||
2805 |
/** Search for the added contacts*/ |
|
2806 |
||
2807 |
// Phone number to be searched for |
|
2808 |
_LIT( KMatchNo, "13579" ); |
|
2809 |
// Create find operation |
|
2810 |
iOp = iContactManager->MatchPhoneNumberL( |
|
2811 |
KMatchNo, KMatchNo().Length(), *this ); |
|
2812 |
||
2813 |
CActiveScheduler::Start(); |
|
2814 |
TInt count(iFindResults->Count()); |
|
2815 |
/**end*/ |
|
2816 |
||
2817 |
/**Delete using SAPI core class*/ |
|
2818 |
||
2819 |
if(count>1) |
|
2820 |
{ |
|
2821 |
__UHEAP_MARK; |
|
2822 |
RPointerArray<TDesC8> idArray; |
|
2823 |
CleanupClosePushL(idArray); |
|
2824 |
TInt num(count); |
|
2825 |
while(count) |
|
2826 |
{ |
|
2827 |
HBufC8* contactId = (const_cast<MVPbkContactLink&>(iFindResults->At(--count))).PackLC(); |
|
2828 |
idArray.AppendL(contactId); |
|
2829 |
} |
|
2830 |
||
2831 |
CContactService* serviceHandle = CContactService::NewL(); |
|
2832 |
CleanupStack::PushL(serviceHandle); |
|
2833 |
iLog->Log( KServiceOpen ); |
|
2834 |
||
2835 |
serviceHandle->DeleteL(this,0,idArray); |
|
2836 |
iLog->Log(_L("DeleteL called\n")); |
|
2837 |
iLog->Log(_L("Start Active Scheduler\n")); |
|
2838 |
CActiveScheduler::Start(); |
|
2839 |
||
2840 |
CleanupStack::PopAndDestroy(serviceHandle);//serviceHandle |
|
2841 |
||
2842 |
CleanupStack::PopAndDestroy(num);//destroy all contactIds |
|
2843 |
CleanupStack::PopAndDestroy(&idArray);//singleContactField |
|
2844 |
||
2845 |
iLog->Log( KServiceClose ); |
|
2846 |
__UHEAP_MARKEND; |
|
2847 |
||
2848 |
} |
|
2849 |
/**end*/ |
|
2850 |
||
2851 |
return iErr; |
|
2852 |
||
2853 |
} |
|
2854 |
||
2855 |
||
2856 |
// ----------------------------------------------------------------------------- |
|
2857 |
// CContactsUT::DeleteInvalidContactL |
|
2858 |
// Example test method function. |
|
2859 |
// (other items were commented in a header). |
|
2860 |
// ----------------------------------------------------------------------------- |
|
2861 |
// |
|
2862 |
TInt CContactsUT::DeleteSingleContactL( CStifItemParser& aItem ) |
|
2863 |
{ |
|
2864 |
||
2865 |
// Print to UI |
|
2866 |
_LIT( KContactsTest, "ContactsTest" ); |
|
2867 |
_LIT( KExample, "In Delete" ); |
|
2868 |
TestModuleIf().Printf( 0, KContactsTest, KExample ); |
|
2869 |
// Print to log file |
|
2870 |
iLog->Log( KExample ); |
|
2871 |
||
2872 |
TInt i = 0; |
|
2873 |
TPtrC string; |
|
2874 |
_LIT( KParam, "Param[%i]: %S" ); |
|
2875 |
while ( aItem.GetNextString ( string ) == KErrNone ) |
|
2876 |
{ |
|
2877 |
TestModuleIf().Printf( i, KContactsTest, |
|
2878 |
KParam, i, &string ); |
|
2879 |
i++; |
|
2880 |
} |
|
2881 |
||
2882 |
iErr = KErrNone; |
|
2883 |
||
2884 |
/**Add 2 contacts using virtual phonebook*/ |
|
2885 |
||
2886 |
CVPbkFieldTypeRefsList* fieldTypeRefList = CVPbkFieldTypeRefsList::NewL(); |
|
2887 |
CleanupStack::PushL(fieldTypeRefList); |
|
2888 |
||
2889 |
fieldTypeRefList->AppendL( |
|
2890 |
*iContactManager->FieldTypes().Find( R_VPBK_FIELD_TYPE_FIRSTNAME ) ); |
|
2891 |
fieldTypeRefList->AppendL( |
|
2892 |
*iContactManager->FieldTypes().Find( R_VPBK_FIELD_TYPE_MOBILEPHONEGEN ) ); |
|
2893 |
||
2894 |
// Create first contact |
|
2895 |
iStoreContact = iStore->CreateNewContactLC(); |
|
2896 |
||
2897 |
// Create contact field for contact |
|
2898 |
MVPbkStoreContactField* field = iStoreContact->CreateFieldLC( fieldTypeRefList->FieldTypeAt( 0 ) ); |
|
2899 |
// Set contact field data |
|
2900 |
_LIT(KFirstName,"Tenali"); |
|
2901 |
(MVPbkContactFieldTextData::Cast(field->FieldData())).SetTextL( KFirstName ); |
|
2902 |
// Add the contact field to contact |
|
2903 |
iStoreContact->AddFieldL( field ); |
|
2904 |
CleanupStack::Pop(); // field |
|
2905 |
||
2906 |
// Create contact field for contact |
|
2907 |
field = iStoreContact->CreateFieldLC( fieldTypeRefList->FieldTypeAt( 1 ) ); |
|
2908 |
// Set contact field data |
|
2909 |
_LIT(KFirstNumber,"13579"); |
|
2910 |
(MVPbkContactFieldTextData::Cast(field->FieldData())).SetTextL( KFirstNumber ); |
|
2911 |
// Add the contact field to contact |
|
2912 |
iStoreContact->AddFieldL( field ); |
|
2913 |
CleanupStack::Pop(); // field |
|
2914 |
||
2915 |
// Commit the new created contact to contact store |
|
2916 |
iStoreContact->CommitL( *this ); |
|
2917 |
CActiveScheduler::Start(); |
|
2918 |
CleanupStack::Pop(); // iStoreContact |
|
2919 |
||
2920 |
||
2921 |
// Create second contact |
|
2922 |
iStoreContact = iStore->CreateNewContactLC(); |
|
2923 |
||
2924 |
// Create contact field for contact |
|
2925 |
field = iStoreContact->CreateFieldLC( fieldTypeRefList->FieldTypeAt( 0 ) ); |
|
2926 |
// Set contact field data |
|
2927 |
_LIT(KSecondName,"Birbal"); |
|
2928 |
(MVPbkContactFieldTextData::Cast(field->FieldData())).SetTextL( KSecondName ); |
|
2929 |
// Add the contact field to contact |
|
2930 |
iStoreContact->AddFieldL( field ); |
|
2931 |
CleanupStack::Pop(); // field |
|
2932 |
||
2933 |
// Create contact field for contact |
|
2934 |
field = iStoreContact->CreateFieldLC( fieldTypeRefList->FieldTypeAt( 1 ) ); |
|
2935 |
// Set contact field data |
|
2936 |
_LIT(KSecondNumber,"13579"); |
|
2937 |
(MVPbkContactFieldTextData::Cast(field->FieldData())).SetTextL( KSecondNumber ); |
|
2938 |
// Add the contact field to contact |
|
2939 |
iStoreContact->AddFieldL( field ); |
|
2940 |
CleanupStack::Pop(); // field |
|
2941 |
||
2942 |
// Commit the new created contact to contact store |
|
2943 |
iStoreContact->CommitL( *this ); |
|
2944 |
CActiveScheduler::Start(); |
|
2945 |
CleanupStack::Pop(); // iStoreContact |
|
2946 |
||
2947 |
CleanupStack::PopAndDestroy(fieldTypeRefList); |
|
2948 |
/**end*/ |
|
2949 |
||
2950 |
/** Search for the added contacts*/ |
|
2951 |
||
2952 |
// Phone number to be searched for |
|
2953 |
_LIT( KMatchNo, "13579" ); |
|
2954 |
// Create find operation |
|
2955 |
iOp = iContactManager->MatchPhoneNumberL( |
|
2956 |
KMatchNo, KMatchNo().Length(), *this ); |
|
2957 |
||
2958 |
CActiveScheduler::Start(); |
|
2959 |
TInt count(iFindResults->Count()); |
|
2960 |
/**end*/ |
|
2961 |
||
2962 |
/**Delete using SAPI core class*/ |
|
2963 |
||
2964 |
if(count>1) |
|
2965 |
{ |
|
2966 |
__UHEAP_MARK; |
|
2967 |
RPointerArray<TDesC8> idArray; |
|
2968 |
CleanupClosePushL(idArray); |
|
2969 |
TInt num(1); |
|
2970 |
if(count) |
|
2971 |
{ |
|
2972 |
HBufC8* contactId = (const_cast<MVPbkContactLink&>(iFindResults->At(--count))).PackLC(); |
|
2973 |
idArray.AppendL(contactId); |
|
2974 |
} |
|
2975 |
||
2976 |
CContactService* serviceHandle = CContactService::NewL(); |
|
2977 |
CleanupStack::PushL(serviceHandle); |
|
2978 |
iLog->Log( KServiceOpen ); |
|
2979 |
||
2980 |
serviceHandle->DeleteL(this,0,idArray); |
|
2981 |
iLog->Log(_L("DeleteL called\n")); |
|
2982 |
iLog->Log(_L("Start Active Scheduler\n")); |
|
2983 |
CActiveScheduler::Start(); |
|
2984 |
||
2985 |
CleanupStack::PopAndDestroy(serviceHandle);//serviceHandle |
|
2986 |
||
2987 |
CleanupStack::PopAndDestroy(num);//destroy all contactIds |
|
2988 |
CleanupStack::PopAndDestroy(&idArray);//singleContactField |
|
2989 |
||
2990 |
iLog->Log( KServiceClose ); |
|
2991 |
__UHEAP_MARKEND; |
|
2992 |
||
2993 |
} |
|
2994 |
/**end*/ |
|
2995 |
||
2996 |
return iErr; |
|
2997 |
||
2998 |
} |
|
2999 |
||
3000 |
// ----------------------------------------------------------------------------- |
|
3001 |
// CContactsUT::DeleteListL |
|
3002 |
// Example test method function. |
|
3003 |
// (other items were commented in a header). |
|
3004 |
// ----------------------------------------------------------------------------- |
|
3005 |
// |
|
3006 |
TInt CContactsUT::DeleteGroupL( CStifItemParser& aItem ) |
|
3007 |
{ |
|
3008 |
||
3009 |
// Print to UI |
|
3010 |
_LIT( KContactsTest, "ContactsTest" ); |
|
3011 |
_LIT( KExample, "In DeleteList" ); |
|
3012 |
TestModuleIf().Printf( 0, KContactsTest, KExample ); |
|
3013 |
// Print to log file |
|
3014 |
iLog->Log( KExample ); |
|
3015 |
||
3016 |
TInt i = 0; |
|
3017 |
TPtrC string; |
|
3018 |
_LIT( KParam, "Param[%i]: %S" ); |
|
3019 |
while ( aItem.GetNextString ( string ) == KErrNone ) |
|
3020 |
{ |
|
3021 |
TestModuleIf().Printf( i, KContactsTest, |
|
3022 |
KParam, i, &string ); |
|
3023 |
i++; |
|
3024 |
} |
|
3025 |
iErr = KErrNone; |
|
3026 |
||
3027 |
/**Add 2 groups using virtual phonebook */ |
|
3028 |
||
3029 |
_LIT(KGroup1,"Test1"); |
|
3030 |
_LIT(KGroup2,"Test2"); |
|
3031 |
iGroup = iStore->CreateNewContactGroupLC(); |
|
3032 |
iGroup->SetGroupLabelL(KGroup1); |
|
3033 |
iOperation = EGroup; |
|
3034 |
iGroup->CommitL(*this); |
|
3035 |
||
3036 |
CActiveScheduler::Start(); |
|
3037 |
CleanupStack::Pop(); |
|
3038 |
||
3039 |
iGroup = iStore->CreateNewContactGroupLC(); |
|
3040 |
iGroup->SetGroupLabelL(KGroup2); |
|
3041 |
iOperation = EGroup; |
|
3042 |
iGroup->CommitL(*this); |
|
3043 |
||
3044 |
CActiveScheduler::Start(); |
|
3045 |
CleanupStack::Pop(); |
|
3046 |
/**end */ |
|
3047 |
||
3048 |
if(iErr) |
|
3049 |
{ |
|
3050 |
return iErr; |
|
3051 |
} |
|
3052 |
||
3053 |
/**Delete the groups using SAPI core class */ |
|
3054 |
||
3055 |
/** Check for the added group using virtual phonebook classes */ |
|
3056 |
||
3057 |
iFindResults = iStore->ContactGroupsLC(); |
|
3058 |
TInt count(iFindResults->Count()); |
|
3059 |
if(count>1) |
|
3060 |
{ |
|
3061 |
HBufC8* groupId; |
|
3062 |
RPointerArray<TDesC8> idArray; |
|
3063 |
CleanupClosePushL(idArray); |
|
3064 |
while(count) |
|
3065 |
{ |
|
3066 |
iResult = &(const_cast<MVPbkContactLink&>(iFindResults->At(--count))); |
|
3067 |
iOp = iContactManager->RetrieveContactL(*iResult,*this); |
|
3068 |
CActiveScheduler::Start(); |
|
3069 |
||
3070 |
iGroup = iStoreContact->Group(); |
|
3071 |
if(!iGroup->GroupLabel().Compare(KGroup1) || !iGroup->GroupLabel().Compare(KGroup2)) |
|
3072 |
{ |
|
3073 |
groupId = iResult->PackLC(); |
|
3074 |
idArray.AppendL(groupId); |
|
3075 |
} |
|
3076 |
} |
|
3077 |
TInt num(idArray.Count()); |
|
3078 |
if( num < 2) |
|
3079 |
{ |
|
3080 |
return KErrGeneral; |
|
3081 |
} |
|
3082 |
__UHEAP_MARK; |
|
3083 |
CContactService* serviceHandle = CContactService::NewL(); |
|
3084 |
CleanupStack::PushL(serviceHandle); |
|
3085 |
iLog->Log( KServiceOpen ); |
|
3086 |
||
3087 |
serviceHandle->DeleteL(this,0,idArray); |
|
3088 |
iLog->Log(_L("DeleteL called\n")); |
|
3089 |
iLog->Log(_L("Start Active Scheduler\n")); |
|
3090 |
CActiveScheduler::Start(); |
|
3091 |
||
3092 |
CleanupStack::PopAndDestroy(serviceHandle);//serviceHandle |
|
3093 |
__UHEAP_MARKEND; |
|
3094 |
CleanupStack::PopAndDestroy(num);//destroy all contactIds |
|
3095 |
CleanupStack::PopAndDestroy(&idArray);//singleContactField |
|
3096 |
||
3097 |
iLog->Log( KServiceClose ); |
|
3098 |
} |
|
3099 |
CleanupStack::Pop(); |
|
3100 |
iFindResults = NULL; |
|
3101 |
/**end */ |
|
3102 |
||
3103 |
return iErr; |
|
3104 |
||
3105 |
} |
|
3106 |
||
3107 |
// ----------------------------------------------------------------------------- |
|
3108 |
// CContactsUT::ModifyL |
|
3109 |
// Example test method function. |
|
3110 |
// (other items were commented in a header). |
|
3111 |
// ----------------------------------------------------------------------------- |
|
3112 |
// |
|
3113 |
TInt CContactsUT::ModifyL( CStifItemParser& aItem ) |
|
3114 |
{ |
|
3115 |
||
3116 |
||
3117 |
// Print to UI |
|
3118 |
_LIT( KContactsTest, "ContactsTest" ); |
|
3119 |
_LIT( KExample, "In Modify" ); |
|
3120 |
TestModuleIf().Printf( 0, KContactsTest, KExample ); |
|
3121 |
// Print to log file |
|
3122 |
iLog->Log( KExample ); |
|
3123 |
||
3124 |
TInt i = 0; |
|
3125 |
TPtrC string; |
|
3126 |
_LIT( KParam, "Param[%i]: %S" ); |
|
3127 |
while ( aItem.GetNextString ( string ) == KErrNone ) |
|
3128 |
{ |
|
3129 |
TestModuleIf().Printf( i, KContactsTest, |
|
3130 |
KParam, i, &string ); |
|
3131 |
i++; |
|
3132 |
} |
|
3133 |
iErr = KErrNone; |
|
3134 |
||
3135 |
DeleteAllL(); |
|
3136 |
_LIT(KFirstName,"Tenali"); |
|
3137 |
TPtrC ptr(KFirstName); |
|
3138 |
AddOneContactL(ptr); |
|
3139 |
||
3140 |
/** Retrieve contact ids and modify using SAPI core class */ |
|
3141 |
||
3142 |
// Create find operation |
|
3143 |
iOp = iContactManager->MatchPhoneNumberL( |
|
3144 |
KPhoneNumber, KPhoneNumber().Length(), *this ); |
|
3145 |
||
3146 |
CActiveScheduler::Start(); |
|
3147 |
||
3148 |
TInt count(iFindResults->Count()); |
|
3149 |
/**end*/ |
|
3150 |
||
3151 |
/**Modify using SAPI core class*/ |
|
3152 |
||
3153 |
if(count) |
|
3154 |
{ |
|
3155 |
while(count) |
|
3156 |
{ |
|
3157 |
//__UHEAP_MARK; |
|
3158 |
iBuffer = (const_cast<MVPbkContactLink&>(iFindResults->At(--count))).PackLC(); |
|
3159 |
CleanupStack::Pop();//iBuffer |
|
3160 |
iServiceHandle = CContactService::NewL(); |
|
3161 |
iLog->Log( KServiceOpen ); |
|
3162 |
||
3163 |
iOperation = EContact; |
|
3164 |
iServiceHandle->GetListL(this,0,EContacts,*iBuffer); |
|
3165 |
iLog->Log(_L("GetListL called\n")); |
|
3166 |
iLog->Log(_L("Start Active Scheduler\n")); |
|
3167 |
CActiveScheduler::Start(); |
|
3168 |
||
3169 |
delete iServiceHandle;//serviceHandle |
|
3170 |
iServiceHandle = NULL; |
|
3171 |
iLog->Log( KServiceClose ); |
|
3172 |
//__UHEAP_MARKEND; |
|
3173 |
} |
|
3174 |
||
3175 |
} |
|
3176 |
||
3177 |
/** ends */ |
|
3178 |
||
3179 |
return iErr; |
|
3180 |
||
3181 |
} |
|
3182 |
||
3183 |
// ----------------------------------------------------------------------------- |
|
3184 |
// CContactsUT::ModifyGroupL |
|
3185 |
// Example test method function. |
|
3186 |
// (other items were commented in a header). |
|
3187 |
// ----------------------------------------------------------------------------- |
|
3188 |
// |
|
3189 |
TInt CContactsUT::ModifyGroupL( CStifItemParser& aItem ) |
|
3190 |
{ |
|
3191 |
||
3192 |
// Print to UI |
|
3193 |
_LIT( KContactsTest, "ContactsTest" ); |
|
3194 |
_LIT( KExample, "In ModifyGroup" ); |
|
3195 |
TestModuleIf().Printf( 0, KContactsTest, KExample ); |
|
3196 |
// Print to log file |
|
3197 |
iLog->Log( KExample ); |
|
3198 |
||
3199 |
TInt i = 0; |
|
3200 |
TPtrC string; |
|
3201 |
_LIT( KParam, "Param[%i]: %S" ); |
|
3202 |
while ( aItem.GetNextString ( string ) == KErrNone ) |
|
3203 |
{ |
|
3204 |
TestModuleIf().Printf( i, KContactsTest, |
|
3205 |
KParam, i, &string ); |
|
3206 |
i++; |
|
3207 |
} |
|
3208 |
iErr = KErrNone; |
|
3209 |
/**Add 1 group using virtual phonebook */ |
|
3210 |
||
3211 |
_LIT(KGroup1,"Modify1"); |
|
3212 |
_LIT(KGroup2,"Modify2"); |
|
3213 |
iGroup = iStore->CreateNewContactGroupLC(); |
|
3214 |
iGroup->SetGroupLabelL(KGroup1); |
|
3215 |
iOperation = EGroup; |
|
3216 |
iGroup->CommitL(*this); |
|
3217 |
||
3218 |
CActiveScheduler::Start(); |
|
3219 |
CleanupStack::Pop(); |
|
3220 |
/**end */ |
|
3221 |
||
3222 |
/** Check for the added group using virtual phonebook classes */ |
|
3223 |
iFindResults = iStore->ContactGroupsLC(); |
|
3224 |
TInt count(iFindResults->Count()); |
|
3225 |
while(count) |
|
3226 |
{ |
|
3227 |
iResult = &(const_cast<MVPbkContactLink&>(iFindResults->At(--count))); |
|
3228 |
iOp = iContactManager->RetrieveContactL(*iResult,*this); |
|
3229 |
CActiveScheduler::Start(); |
|
3230 |
||
3231 |
if(iErr) |
|
3232 |
{ |
|
3233 |
break; |
|
3234 |
} |
|
3235 |
iErr = KErrGeneral; |
|
3236 |
iGroup = iStoreContact->Group(); |
|
3237 |
if(!iGroup->GroupLabel().Compare(KGroup1)) |
|
3238 |
{ |
|
3239 |
__UHEAP_MARK; |
|
3240 |
CContactService* serviceHandle = CContactService::NewL(); |
|
3241 |
CleanupStack::PushL(serviceHandle); |
|
3242 |
iLog->Log( KServiceOpen ); |
|
3243 |
||
3244 |
serviceHandle->AddL(this,0,NULL,KNullDesC8,KGroup2); |
|
3245 |
iLog->Log(_L("ModifyGroupL called\n")); |
|
3246 |
iLog->Log(_L("Start Active Scheduler\n")); |
|
3247 |
CActiveScheduler::Start(); |
|
3248 |
||
3249 |
CleanupStack::PopAndDestroy(serviceHandle);//serviceHandle |
|
3250 |
iLog->Log( KServiceClose ); |
|
3251 |
__UHEAP_MARKEND; |
|
3252 |
} |
|
3253 |
} |
|
3254 |
CleanupStack::Pop(); |
|
3255 |
iFindResults = NULL; |
|
3256 |
/**end */ |
|
3257 |
||
3258 |
/** Check for the added group using virtual phonebook classes */ |
|
3259 |
iFindResults = iStore->ContactGroupsLC(); |
|
3260 |
count = iFindResults->Count(); |
|
3261 |
while(count) |
|
3262 |
{ |
|
3263 |
iResult = &(const_cast<MVPbkContactLink&>(iFindResults->At(--count))); |
|
3264 |
iOp = iContactManager->RetrieveContactL(*iResult,*this); |
|
3265 |
CActiveScheduler::Start(); |
|
3266 |
||
3267 |
if(iErr) |
|
3268 |
{ |
|
3269 |
break; |
|
3270 |
} |
|
3271 |
iErr = KErrGeneral; |
|
3272 |
iGroup = iStoreContact->Group(); |
|
3273 |
if(!iGroup->GroupLabel().Compare(KGroup2)) |
|
3274 |
{ |
|
3275 |
iErr = KErrNone; |
|
3276 |
iContactToDelete = CVPbkContactLinkArray::NewL(); |
|
3277 |
iContactToDelete->AppendL(iResult); |
|
3278 |
iOp = iContactManager->DeleteContactsL( *iContactToDelete, *this ); |
|
3279 |
CActiveScheduler::Start(); |
|
3280 |
break; |
|
3281 |
} |
|
3282 |
} |
|
3283 |
CleanupStack::Pop(); |
|
3284 |
iFindResults = NULL; |
|
3285 |
||
3286 |
/**end */ |
|
3287 |
return iErr; |
|
3288 |
||
3289 |
} |
|
3290 |
||
3291 |
// ----------------------------------------------------------------------------- |
|
3292 |
// CContactsUT::OrganiseAddL |
|
3293 |
// Example test method function. |
|
3294 |
// (other items were commented in a header). |
|
3295 |
// ----------------------------------------------------------------------------- |
|
3296 |
// |
|
3297 |
TInt CContactsUT::OrganiseAddL( CStifItemParser& aItem ) |
|
3298 |
{ |
|
3299 |
||
3300 |
// Print to UI |
|
3301 |
_LIT( KContactsTest, "ContactsTest" ); |
|
3302 |
_LIT( KExample, "In OrganiseAdd" ); |
|
3303 |
TestModuleIf().Printf( 0, KContactsTest, KExample ); |
|
3304 |
// Print to log file |
|
3305 |
iLog->Log( KExample ); |
|
3306 |
||
3307 |
TInt i = 0; |
|
3308 |
TPtrC string; |
|
3309 |
_LIT( KParam, "Param[%i]: %S" ); |
|
3310 |
while ( aItem.GetNextString ( string ) == KErrNone ) |
|
3311 |
{ |
|
3312 |
TestModuleIf().Printf( i, KContactsTest, |
|
3313 |
KParam, i, &string ); |
|
3314 |
i++; |
|
3315 |
} |
|
3316 |
||
3317 |
iErr = KErrNone; |
|
3318 |
||
3319 |
/** Add 1 group */ |
|
3320 |
||
3321 |
_LIT(KGroup,"OrganiseTest1"); |
|
3322 |
iGroup = iStore->CreateNewContactGroupLC(); |
|
3323 |
iGroup->SetGroupLabelL(KGroup); |
|
3324 |
iOperation = EGroup; |
|
3325 |
iGroup->CommitL(*this); |
|
3326 |
||
3327 |
CActiveScheduler::Start(); |
|
3328 |
CleanupStack::Pop(); |
|
3329 |
/** ends */ |
|
3330 |
||
3331 |
||
3332 |
if(iErr) |
|
3333 |
{ |
|
3334 |
return iErr; |
|
3335 |
} |
|
3336 |
||
3337 |
/** Retrieve the group id */ |
|
3338 |
HBufC8* groupId = NULL; |
|
3339 |
iFindResults = iStore->ContactGroupsLC(); |
|
3340 |
TInt count(iFindResults->Count()); |
|
3341 |
iErr = KErrGeneral; |
|
3342 |
while(count) |
|
3343 |
{ |
|
3344 |
iResult = &(const_cast<MVPbkContactLink&>(iFindResults->At(--count))); |
|
3345 |
iOp = iContactManager->RetrieveContactL(*iResult,*this); |
|
3346 |
CActiveScheduler::Start(); |
|
3347 |
||
3348 |
iGroup = iStoreContact->Group(); |
|
3349 |
if(!iGroup->GroupLabel().Compare(KGroup)) |
|
3350 |
{ |
|
3351 |
groupId =iResult->PackLC(); |
|
3352 |
CleanupStack::Pop();//groupId |
|
3353 |
break; |
|
3354 |
} |
|
3355 |
} |
|
3356 |
CleanupStack::Pop();//iFindResults |
|
3357 |
CleanupStack::PushL(groupId); |
|
3358 |
iFindResults = NULL; |
|
3359 |
/** ends */ |
|
3360 |
||
3361 |
||
3362 |
/** Add 2 contacts */ |
|
3363 |
||
3364 |
DeleteAllL(); |
|
3365 |
_LIT(KFirstName,"Tenali"); |
|
3366 |
_LIT(KSecondName,"Birbal"); |
|
3367 |
||
3368 |
TPtrC ptr1(KFirstName); |
|
3369 |
TPtrC ptr2(KSecondName); |
|
3370 |
||
3371 |
AddOneContactL(ptr1); |
|
3372 |
AddOneContactL(ptr2); |
|
3373 |
||
3374 |
||
3375 |
||
3376 |
/** Retrieve the 2 contacts */ |
|
3377 |
||
3378 |
// Phone number to be searched for |
|
3379 |
// Create find operation |
|
3380 |
iOp = iContactManager->MatchPhoneNumberL( |
|
3381 |
KPhoneNumber, KPhoneNumber().Length(), *this ); |
|
3382 |
||
3383 |
CActiveScheduler::Start(); |
|
3384 |
count = iFindResults->Count(); |
|
3385 |
/**end*/ |
|
3386 |
||
3387 |
/**Organise using SAPI core class*/ |
|
3388 |
if(count>1 && groupId) |
|
3389 |
{ |
|
3390 |
RPointerArray<TDesC8> idArray; |
|
3391 |
CleanupClosePushL(idArray); |
|
3392 |
TInt num(count); |
|
3393 |
while(count) |
|
3394 |
{ |
|
3395 |
HBufC8* contactId = (const_cast<MVPbkContactLink&>(iFindResults->At(--count))).PackLC(); |
|
3396 |
idArray.AppendL(contactId); |
|
3397 |
} |
|
3398 |
__UHEAP_MARK; |
|
3399 |
CContactService* serviceHandle = CContactService::NewL(); |
|
3400 |
CleanupStack::PushL(serviceHandle); |
|
3401 |
iLog->Log( KServiceOpen ); |
|
3402 |
||
3403 |
serviceHandle->OrganiseGroupsL(this,0,*groupId,idArray,ETrue); |
|
3404 |
iLog->Log(_L("OrganiseGroupsL called\n")); |
|
3405 |
iLog->Log(_L("Start Active Scheduler\n")); |
|
3406 |
CActiveScheduler::Start(); |
|
3407 |
||
3408 |
||
3409 |
CleanupStack::PopAndDestroy(serviceHandle);//serviceHandle |
|
3410 |
__UHEAP_MARKEND; |
|
3411 |
CleanupStack::PopAndDestroy(num);//destroy all contactIds |
|
3412 |
CleanupStack::PopAndDestroy(&idArray);//singleContactField |
|
3413 |
||
3414 |
iLog->Log( KServiceClose ); |
|
3415 |
} |
|
3416 |
/** ends */ |
|
3417 |
||
3418 |
||
3419 |
/** Check for the group and delete*/ |
|
3420 |
iFindResults = iStore->ContactGroupsLC(); |
|
3421 |
count = iFindResults->Count(); |
|
3422 |
iErr = KErrGeneral; |
|
3423 |
while(count) |
|
3424 |
{ |
|
3425 |
iResult = &(const_cast<MVPbkContactLink&>(iFindResults->At(--count))); |
|
3426 |
if(!(iResult->PackLC())->Compare(*groupId)) |
|
3427 |
{ |
|
3428 |
iOp = iContactManager->RetrieveContactL(*iResult,*this); |
|
3429 |
CActiveScheduler::Start(); |
|
3430 |
||
3431 |
iGroup = iStoreContact->Group(); |
|
3432 |
MVPbkContactLinkArray* linkArray = iGroup->ItemsContainedLC(); |
|
3433 |
if(linkArray->Count() == 2 ) |
|
3434 |
{ |
|
3435 |
iErr = KErrNone; |
|
3436 |
} |
|
3437 |
CleanupStack::Pop();//linkArray |
|
3438 |
||
3439 |
iContactToDelete = CVPbkContactLinkArray::NewL(); |
|
3440 |
iContactToDelete->AppendL(iResult); |
|
3441 |
iOp = iContactManager->DeleteContactsL( *iContactToDelete, *this ); |
|
3442 |
CActiveScheduler::Start(); |
|
3443 |
} |
|
3444 |
CleanupStack::PopAndDestroy(); |
|
3445 |
} |
|
3446 |
CleanupStack::Pop(); |
|
3447 |
iFindResults = NULL; |
|
3448 |
/**end */ |
|
3449 |
CleanupStack::PopAndDestroy(groupId); |
|
3450 |
||
3451 |
return iErr; |
|
3452 |
} |
|
3453 |
||
3454 |
||
3455 |
// ----------------------------------------------------------------------------- |
|
3456 |
// CContactsUT::OrganiseDeleteL |
|
3457 |
// Example test method function. |
|
3458 |
// (other items were commented in a header). |
|
3459 |
// ----------------------------------------------------------------------------- |
|
3460 |
// |
|
3461 |
TInt CContactsUT::OrganiseDeleteL( CStifItemParser& aItem ) |
|
3462 |
{ |
|
3463 |
||
3464 |
// Print to UI |
|
3465 |
_LIT( KContactsTest, "ContactsTest" ); |
|
3466 |
_LIT( KExample, "In OrganiseDelete" ); |
|
3467 |
TestModuleIf().Printf( 0, KContactsTest, KExample ); |
|
3468 |
// Print to log file |
|
3469 |
iLog->Log( KExample ); |
|
3470 |
||
3471 |
TInt i = 0; |
|
3472 |
TPtrC string; |
|
3473 |
_LIT( KParam, "Param[%i]: %S" ); |
|
3474 |
while ( aItem.GetNextString ( string ) == KErrNone ) |
|
3475 |
{ |
|
3476 |
TestModuleIf().Printf( i, KContactsTest, |
|
3477 |
KParam, i, &string ); |
|
3478 |
i++; |
|
3479 |
} |
|
3480 |
iErr = KErrNone; |
|
3481 |
||
3482 |
/** Add 1 group */ |
|
3483 |
||
3484 |
_LIT(KGroup,"OrganiseTest1"); |
|
3485 |
iGroup = iStore->CreateNewContactGroupLC(); |
|
3486 |
iGroup->SetGroupLabelL(KGroup); |
|
3487 |
iOperation = EGroup; |
|
3488 |
iGroup->CommitL(*this); |
|
3489 |
||
3490 |
CActiveScheduler::Start(); |
|
3491 |
CleanupStack::Pop(); |
|
3492 |
/** ends */ |
|
3493 |
||
3494 |
||
3495 |
if(iErr) |
|
3496 |
{ |
|
3497 |
return iErr; |
|
3498 |
} |
|
3499 |
||
3500 |
||
3501 |
/** Add 2 contacts */ |
|
3502 |
||
3503 |
CVPbkFieldTypeRefsList* fieldTypeRefList = CVPbkFieldTypeRefsList::NewL(); |
|
3504 |
CleanupStack::PushL(fieldTypeRefList); |
|
3505 |
||
3506 |
fieldTypeRefList->AppendL( |
|
3507 |
*iContactManager->FieldTypes().Find( R_VPBK_FIELD_TYPE_FIRSTNAME ) ); |
|
3508 |
fieldTypeRefList->AppendL( |
|
3509 |
*iContactManager->FieldTypes().Find( R_VPBK_FIELD_TYPE_MOBILEPHONEGEN ) ); |
|
3510 |
||
3511 |
// Create first contact |
|
3512 |
iStoreContact = iStore->CreateNewContactLC(); |
|
3513 |
||
3514 |
// Create contact field for contact |
|
3515 |
MVPbkStoreContactField* field = iStoreContact->CreateFieldLC( fieldTypeRefList->FieldTypeAt( 0 ) ); |
|
3516 |
// Set contact field data |
|
3517 |
_LIT(KFirstName,"Tenali"); |
|
3518 |
(MVPbkContactFieldTextData::Cast(field->FieldData())).SetTextL( KFirstName ); |
|
3519 |
// Add the contact field to contact |
|
3520 |
iStoreContact->AddFieldL( field ); |
|
3521 |
CleanupStack::Pop(); // field |
|
3522 |
||
3523 |
// Create contact field for contact |
|
3524 |
field = iStoreContact->CreateFieldLC( fieldTypeRefList->FieldTypeAt( 1 ) ); |
|
3525 |
// Set contact field data |
|
3526 |
_LIT(KFirstNumber,"97531"); |
|
3527 |
(MVPbkContactFieldTextData::Cast(field->FieldData())).SetTextL( KFirstNumber ); |
|
3528 |
// Add the contact field to contact |
|
3529 |
iStoreContact->AddFieldL( field ); |
|
3530 |
CleanupStack::Pop(); // field |
|
3531 |
||
3532 |
// Commit the new created contact to contact store |
|
3533 |
iStoreContact->CommitL( *this ); |
|
3534 |
CActiveScheduler::Start(); |
|
3535 |
CleanupStack::Pop(); // iStoreContact |
|
3536 |
||
3537 |
||
3538 |
// Create second contact |
|
3539 |
iStoreContact = iStore->CreateNewContactLC(); |
|
3540 |
||
3541 |
// Create contact field for contact |
|
3542 |
field = iStoreContact->CreateFieldLC( fieldTypeRefList->FieldTypeAt( 0 ) ); |
|
3543 |
// Set contact field data |
|
3544 |
_LIT(KSecondName,"Birbal"); |
|
3545 |
(MVPbkContactFieldTextData::Cast(field->FieldData())).SetTextL( KSecondName ); |
|
3546 |
// Add the contact field to contact |
|
3547 |
iStoreContact->AddFieldL( field ); |
|
3548 |
CleanupStack::Pop(); // field |
|
3549 |
||
3550 |
// Create contact field for contact |
|
3551 |
field = iStoreContact->CreateFieldLC( fieldTypeRefList->FieldTypeAt( 1 ) ); |
|
3552 |
// Set contact field data |
|
3553 |
_LIT(KSecondNumber,"97531"); |
|
3554 |
(MVPbkContactFieldTextData::Cast(field->FieldData())).SetTextL( KSecondNumber ); |
|
3555 |
// Add the contact field to contact |
|
3556 |
iStoreContact->AddFieldL( field ); |
|
3557 |
CleanupStack::Pop(); // field |
|
3558 |
||
3559 |
// Commit the new created contact to contact store |
|
3560 |
iStoreContact->CommitL( *this ); |
|
3561 |
CActiveScheduler::Start(); |
|
3562 |
CleanupStack::Pop(); // iStoreContact |
|
3563 |
||
3564 |
CleanupStack::PopAndDestroy(fieldTypeRefList); |
|
3565 |
/** end */ |
|
3566 |
||
3567 |
||
3568 |
if(iErr) |
|
3569 |
{ |
|
3570 |
return iErr; |
|
3571 |
} |
|
3572 |
||
3573 |
/** Retrieve the 2 contacts */ |
|
3574 |
RPointerArray<TDesC8> idArray; |
|
3575 |
CleanupClosePushL(idArray); |
|
3576 |
// Phone number to be searched for |
|
3577 |
_LIT( KMatchNo, "97531" ); |
|
3578 |
// Create find operation |
|
3579 |
iOp = iContactManager->MatchPhoneNumberL( |
|
3580 |
KMatchNo, KMatchNo().Length(), *this ); |
|
3581 |
||
3582 |
CActiveScheduler::Start(); |
|
3583 |
TInt count = iFindResults->Count(); |
|
3584 |
TInt num(count); |
|
3585 |
iContactToDelete = CVPbkContactLinkArray::NewL(); |
|
3586 |
while(count) |
|
3587 |
{ |
|
3588 |
iResult = &(const_cast<MVPbkContactLink&>(iFindResults->At(--count))); |
|
3589 |
iContactToDelete->AppendL(iResult); |
|
3590 |
idArray.AppendL(iResult->PackLC()); |
|
3591 |
} |
|
3592 |
/** ends */ |
|
3593 |
||
3594 |
/** Retrieve the group id */ |
|
3595 |
HBufC8* groupId = NULL; |
|
3596 |
iFindResults = iStore->ContactGroupsLC(); |
|
3597 |
count = iFindResults->Count(); |
|
3598 |
iErr = KErrGeneral; |
|
3599 |
while(count) |
|
3600 |
{ |
|
3601 |
iResult = &(const_cast<MVPbkContactLink&>(iFindResults->At(--count))); |
|
3602 |
iOp = iContactManager->RetrieveContactL(*iResult,*this); |
|
3603 |
CActiveScheduler::Start(); |
|
3604 |
||
3605 |
iGroup = iStoreContact->Group(); |
|
3606 |
if(!iGroup->GroupLabel().Compare(KGroup)) |
|
3607 |
{ |
|
3608 |
groupId =iResult->PackLC(); |
|
3609 |
TInt count(iContactToDelete->Count()); |
|
3610 |
while(count) |
|
3611 |
{ |
|
3612 |
iGroup->AddContactL(iContactToDelete->At(--count)); |
|
3613 |
} |
|
3614 |
CleanupStack::Pop(); |
|
3615 |
break; |
|
3616 |
} |
|
3617 |
} |
|
3618 |
CleanupStack::Pop(); |
|
3619 |
CleanupStack::PushL(groupId); |
|
3620 |
iFindResults = NULL; |
|
3621 |
delete iContactToDelete; |
|
3622 |
iContactToDelete = NULL; |
|
3623 |
/** ends */ |
|
3624 |
||
3625 |
/**Organise using SAPI core class*/ |
|
3626 |
if(groupId) |
|
3627 |
{ |
|
3628 |
__UHEAP_MARK; |
|
3629 |
CContactService* serviceHandle = CContactService::NewL(); |
|
3630 |
CleanupStack::PushL(serviceHandle); |
|
3631 |
iLog->Log( KServiceOpen ); |
|
3632 |
||
3633 |
serviceHandle->OrganiseGroupsL(this,0,*groupId,idArray,EFalse); |
|
3634 |
iLog->Log(_L("OrganiseGroupsL called\n")); |
|
3635 |
iLog->Log(_L("Start Active Scheduler\n")); |
|
3636 |
CActiveScheduler::Start(); |
|
3637 |
||
3638 |
||
3639 |
CleanupStack::PopAndDestroy(serviceHandle);//serviceHandle |
|
3640 |
||
3641 |
iLog->Log( KServiceClose ); |
|
3642 |
__UHEAP_MARKEND; |
|
3643 |
} |
|
3644 |
/** ends */ |
|
3645 |
||
3646 |
||
3647 |
/** Check for the group */ |
|
3648 |
iFindResults = iStore->ContactGroupsLC(); |
|
3649 |
count = iFindResults->Count(); |
|
3650 |
iErr = KErrGeneral; |
|
3651 |
while(count) |
|
3652 |
{ |
|
3653 |
iResult = &(const_cast<MVPbkContactLink&>(iFindResults->At(--count))); |
|
3654 |
if(!(iResult->PackLC())->Compare(*groupId)) |
|
3655 |
{ |
|
3656 |
iContactToDelete = CVPbkContactLinkArray::NewL(); |
|
3657 |
iContactToDelete->AppendL(iResult); |
|
3658 |
iOp = iContactManager->DeleteContactsL( *iContactToDelete, *this ); |
|
3659 |
CActiveScheduler::Start(); |
|
3660 |
} |
|
3661 |
CleanupStack::PopAndDestroy(); |
|
3662 |
} |
|
3663 |
CleanupStack::Pop(); //iFindResults |
|
3664 |
iFindResults = NULL; |
|
3665 |
/**end */ |
|
3666 |
CleanupStack::PopAndDestroy(groupId); |
|
3667 |
CleanupStack::PopAndDestroy(num);//destroy all contactIds |
|
3668 |
CleanupStack::PopAndDestroy(&idArray);//singleContactField |
|
3669 |
||
3670 |
return iErr; |
|
3671 |
} |
|
3672 |
||
3673 |
// ----------------------------------------------------------------------------- |
|
3674 |
// CContactsUT::OrganiseDeleteL |
|
3675 |
// Example test method function. |
|
3676 |
// (other items were commented in a header). |
|
3677 |
// ----------------------------------------------------------------------------- |
|
3678 |
// |
|
3679 |
TInt CContactsUT::ImportL( CStifItemParser& aItem ) |
|
3680 |
{ |
|
3681 |
||
3682 |
// Print to UI |
|
3683 |
_LIT( KContactsTest, "ContactsTest" ); |
|
3684 |
_LIT( KExample, "In Import" ); |
|
3685 |
TestModuleIf().Printf( 0, KContactsTest, KExample ); |
|
3686 |
// Print to log file |
|
3687 |
iLog->Log( KExample ); |
|
3688 |
||
3689 |
TInt i = 0; |
|
3690 |
TPtrC string; |
|
3691 |
_LIT( KParam, "Param[%i]: %S" ); |
|
3692 |
while ( aItem.GetNextString ( string ) == KErrNone ) |
|
3693 |
{ |
|
3694 |
TestModuleIf().Printf( i, KContactsTest, |
|
3695 |
KParam, i, &string ); |
|
3696 |
i++; |
|
3697 |
} |
|
3698 |
iErr = KErrNone; |
|
3699 |
_LIT(KFileName,"c:\\vcardex.vcf"); |
|
3700 |
||
3701 |
/** Add 1 contact */ |
|
3702 |
CVPbkFieldTypeRefsList* fieldTypeRefList = CVPbkFieldTypeRefsList::NewL(); |
|
3703 |
CleanupStack::PushL(fieldTypeRefList); |
|
3704 |
||
3705 |
fieldTypeRefList->AppendL( |
|
3706 |
*iContactManager->FieldTypes().Find( R_VPBK_FIELD_TYPE_FIRSTNAME ) ); |
|
3707 |
fieldTypeRefList->AppendL( |
|
3708 |
*iContactManager->FieldTypes().Find( R_VPBK_FIELD_TYPE_MOBILEPHONEGEN ) ); |
|
3709 |
||
3710 |
// Create first contact |
|
3711 |
iStoreContact = iStore->CreateNewContactLC(); |
|
3712 |
||
3713 |
// Create contact field for contact |
|
3714 |
MVPbkStoreContactField* field = iStoreContact->CreateFieldLC( fieldTypeRefList->FieldTypeAt( 0 ) ); |
|
3715 |
// Set contact field data |
|
3716 |
_LIT(KFirstName,"Tenali"); |
|
3717 |
(MVPbkContactFieldTextData::Cast(field->FieldData())).SetTextL( KFirstName ); |
|
3718 |
// Add the contact field to contact |
|
3719 |
iStoreContact->AddFieldL( field ); |
|
3720 |
CleanupStack::Pop(); // field |
|
3721 |
||
3722 |
// Create contact field for contact |
|
3723 |
field = iStoreContact->CreateFieldLC( fieldTypeRefList->FieldTypeAt( 1 ) ); |
|
3724 |
// Set contact field data |
|
3725 |
_LIT(KFirstNumber,"45678"); |
|
3726 |
(MVPbkContactFieldTextData::Cast(field->FieldData())).SetTextL( KFirstNumber ); |
|
3727 |
// Add the contact field to contact |
|
3728 |
iStoreContact->AddFieldL( field ); |
|
3729 |
CleanupStack::Pop(); // field |
|
3730 |
||
3731 |
// Commit the new created contact to contact store |
|
3732 |
iStoreContact->CommitL( *this ); |
|
3733 |
CActiveScheduler::Start(); |
|
3734 |
CleanupStack::Pop(); // iStoreContact |
|
3735 |
||
3736 |
CleanupStack::PopAndDestroy(fieldTypeRefList); |
|
3737 |
/** end */ |
|
3738 |
||
3739 |
/** Retrieve the contact */ |
|
3740 |
||
3741 |
// Phone number to be searched for |
|
3742 |
_LIT( KMatchNo, "45678" ); |
|
3743 |
// Create find operation |
|
3744 |
iOp = iContactManager->MatchPhoneNumberL( |
|
3745 |
KMatchNo, KMatchNo().Length(), *this ); |
|
3746 |
||
3747 |
CActiveScheduler::Start(); |
|
3748 |
TInt count = iFindResults->Count(); |
|
3749 |
while(count) |
|
3750 |
{ |
|
3751 |
iResult = &(const_cast<MVPbkContactLink&>(iFindResults->At(--count))); |
|
3752 |
iVCardEngine = CVPbkVCardEng::NewL( *iContactManager ); |
|
3753 |
||
3754 |
// Create the buffer to store the contact |
|
3755 |
iBuffer = HBufC8::NewL( 1024 ); |
|
3756 |
TPtr8 bufferPtr( iBuffer->Des() ); |
|
3757 |
iDestStream.Open( bufferPtr ); |
|
3758 |
||
3759 |
iOperation = EVCard; |
|
3760 |
||
3761 |
//export the contact from MVPbkContactLink |
|
3762 |
iOp = iVCardEngine->ExportVCardL( iDestStream, *iResult, *this ); |
|
3763 |
CActiveScheduler::Start(); |
|
3764 |
||
3765 |
delete iVCardEngine; |
|
3766 |
iVCardEngine = NULL; |
|
3767 |
||
3768 |
if(iBuffer) |
|
3769 |
{ |
|
3770 |
RFile file; |
|
3771 |
CleanupClosePushL(file); |
|
3772 |
file.Replace(iRfs,KFileName,EFileWrite); |
|
3773 |
file.Write(0,*iBuffer); |
|
3774 |
CleanupStack::PopAndDestroy(&file); |
|
3775 |
delete iBuffer; |
|
3776 |
iBuffer = NULL; |
|
3777 |
} |
|
3778 |
||
3779 |
iContactToDelete = CVPbkContactLinkArray::NewL(); |
|
3780 |
iContactToDelete->AppendL(iResult); |
|
3781 |
iOp = iContactManager->DeleteContactsL( *iContactToDelete, *this ); |
|
3782 |
CActiveScheduler::Start(); |
|
3783 |
} |
|
3784 |
iFindResults = NULL; |
|
3785 |
__UHEAP_MARK; |
|
3786 |
//using sapi |
|
3787 |
CContactService* serviceHandle = CContactService::NewL(); |
|
3788 |
CleanupStack::PushL(serviceHandle); |
|
3789 |
iLog->Log( KServiceOpen ); |
|
3790 |
||
3791 |
TFileName file(KFileName); |
|
3792 |
||
3793 |
serviceHandle->ImportVCardToStoreL(this,0,file); |
|
3794 |
iLog->Log(_L("ImportVCardToStoreL called\n")); |
|
3795 |
iLog->Log(_L("Start Active Scheduler\n")); |
|
3796 |
CActiveScheduler::Start(); |
|
3797 |
||
3798 |
CleanupStack::PopAndDestroy(serviceHandle);//serviceHandle |
|
3799 |
iLog->Log( KServiceClose ); |
|
3800 |
__UHEAP_MARKEND; |
|
3801 |
/**Delete using virtual Phonebook */ |
|
3802 |
||
3803 |
||
3804 |
// Create find operation |
|
3805 |
iOp = iContactManager->MatchPhoneNumberL( |
|
3806 |
KMatchNo, KMatchNo().Length(), *this ); |
|
3807 |
CActiveScheduler::Start(); |
|
3808 |
iErr = KErrGeneral; |
|
3809 |
count = iFindResults->Count(); |
|
3810 |
while(count) |
|
3811 |
{ |
|
3812 |
iContactToDelete = CVPbkContactLinkArray::NewL(); |
|
3813 |
iContactToDelete->AppendL(&(const_cast<MVPbkContactLink&>(iFindResults->At(--count)))); |
|
3814 |
iOp = iContactManager->DeleteContactsL( *iContactToDelete, *this ); |
|
3815 |
CActiveScheduler::Start(); |
|
3816 |
} |
|
3817 |
/**end */ |
|
3818 |
||
3819 |
return iErr; |
|
3820 |
} |
|
3821 |
// ----------------------------------------------------------------------------- |
|
3822 |
// CContactsUT::OrganiseDeleteL |
|
3823 |
// Example test method function. |
|
3824 |
// (other items were commented in a header). |
|
3825 |
// ----------------------------------------------------------------------------- |
|
3826 |
// |
|
3827 |
TInt CContactsUT::ExportL( CStifItemParser& aItem ) |
|
3828 |
{ |
|
3829 |
||
3830 |
// Print to UI |
|
3831 |
_LIT( KContactsTest, "ContactsTest" ); |
|
3832 |
_LIT( KExample, "In Import" ); |
|
3833 |
TestModuleIf().Printf( 0, KContactsTest, KExample ); |
|
3834 |
// Print to log file |
|
3835 |
iLog->Log( KExample ); |
|
3836 |
||
3837 |
TInt i = 0; |
|
3838 |
TPtrC string; |
|
3839 |
_LIT( KParam, "Param[%i]: %S" ); |
|
3840 |
while ( aItem.GetNextString ( string ) == KErrNone ) |
|
3841 |
{ |
|
3842 |
TestModuleIf().Printf( i, KContactsTest, |
|
3843 |
KParam, i, &string ); |
|
3844 |
i++; |
|
3845 |
} |
|
3846 |
iErr = KErrNone; |
|
3847 |
_LIT(KFileName,"c:\\vcardim.vcf"); |
|
3848 |
RFs fs; |
|
3849 |
CleanupClosePushL(fs); |
|
3850 |
User::LeaveIfError(fs.Connect()); |
|
3851 |
RFile file; |
|
3852 |
if(!file.Open(fs,KFileName,EFileRead)) |
|
3853 |
{ |
|
3854 |
file.Close(); |
|
3855 |
fs.Delete(KFileName); |
|
3856 |
} |
|
3857 |
CleanupStack::PopAndDestroy(&fs); |
|
3858 |
||
3859 |
DeleteAllL(); |
|
3860 |
_LIT(KFirstName,"Akbar"); |
|
3861 |
TPtrC ptr(KFirstName); |
|
3862 |
AddOneContactL(ptr); |
|
3863 |
||
3864 |
/** Retrieve the contact */ |
|
3865 |
||
3866 |
// Phone number to be searched for |
|
3867 |
// Create find operation |
|
3868 |
iOp = iContactManager->MatchPhoneNumberL( |
|
3869 |
KPhoneNumber, KPhoneNumber().Length(), *this ); |
|
3870 |
||
3871 |
CActiveScheduler::Start(); |
|
3872 |
TInt count = iFindResults->Count(); |
|
3873 |
while(count) |
|
3874 |
{ |
|
3875 |
iResult = &(const_cast<MVPbkContactLink&>(iFindResults->At(--count))); |
|
3876 |
iBuffer = iResult->PackLC(); |
|
3877 |
CleanupStack::Pop(); |
|
3878 |
||
3879 |
// __UHEAP_MARK; |
|
3880 |
//using sapi |
|
3881 |
CContactService* serviceHandle = CContactService::NewL(); |
|
3882 |
CleanupStack::PushL(serviceHandle); |
|
3883 |
iLog->Log( KServiceOpen ); |
|
3884 |
||
3885 |
TFileName file(KFileName); |
|
3886 |
serviceHandle->ExportVCardL(this,0,file,*iBuffer); |
|
3887 |
iLog->Log(_L("ExportVCardL called\n")); |
|
3888 |
iLog->Log(_L("Start Active Scheduler\n")); |
|
3889 |
CActiveScheduler::Start(); |
|
3890 |
||
3891 |
CleanupStack::PopAndDestroy(serviceHandle);//serviceHandle |
|
3892 |
iLog->Log( KServiceClose ); |
|
3893 |
// __UHEAP_MARKEND; |
|
3894 |
||
3895 |
iContactToDelete = CVPbkContactLinkArray::NewL(); |
|
3896 |
iContactToDelete->AppendL(iResult); |
|
3897 |
iOp = iContactManager->DeleteContactsL( *iContactToDelete, *this ); |
|
3898 |
CActiveScheduler::Start(); |
|
3899 |
||
3900 |
delete iBuffer; |
|
3901 |
iBuffer = NULL; |
|
3902 |
||
3903 |
RPointerArray< MVPbkStoreContact > importedContacts; |
|
3904 |
CleanupClosePushL(importedContacts); |
|
3905 |
||
3906 |
iVCardEngine = CVPbkVCardEng::NewL( *iContactManager ); |
|
3907 |
||
3908 |
// Open the RFileReadStream that holds the vCard content |
|
3909 |
iErr = iSource.Open( iRfs, KFileName, EFileRead ); |
|
3910 |
||
3911 |
// Import the contact from RFileReadStream asynchronously |
|
3912 |
// The operation status is reported via MVPbkSingleContactOperationObserver. |
|
3913 |
iOp = iVCardEngine->ImportVCardL( importedContacts, *iStore, iSource, *this ); |
|
3914 |
CActiveScheduler::Start(); |
|
3915 |
||
3916 |
if(!importedContacts.Count()) |
|
3917 |
{ |
|
3918 |
return KErrGeneral; |
|
3919 |
||
3920 |
} |
|
3921 |
||
3922 |
// Close iImportedContacts |
|
3923 |
// |
|
3924 |
importedContacts.ResetAndDestroy(); |
|
3925 |
CleanupStack::PopAndDestroy(&importedContacts); |
|
3926 |
} |
|
3927 |
iFindResults = NULL; |
|
3928 |
||
3929 |
||
3930 |
return iErr; |
|
3931 |
} |
|
3932 |
||
3933 |
||
3934 |
TInt CContactsUT::GetListCancelL( CStifItemParser& /*aItem*/) |
|
3935 |
{ |
|
3936 |
||
3937 |
int ret=0; |
|
3938 |
ret = getlist_cancel(0, NULL); |
|
3939 |
||
3940 |
if(ret==0) |
|
3941 |
return KErrNone; |
|
3942 |
else |
|
3943 |
return KErrGeneral; |
|
3944 |
} |
|
3945 |
||
3946 |
||
3947 |
TInt CContactsUT::GetListSrchCancelL( CStifItemParser& /*aItem*/) |
|
3948 |
{ |
|
3949 |
||
3950 |
int ret=0; |
|
3951 |
ret = getlistsrh_cancel(0, NULL); |
|
3952 |
||
3953 |
if(ret==0) |
|
3954 |
return KErrNone; |
|
3955 |
else |
|
3956 |
return KErrGeneral; |
|
3957 |
} |
|
3958 |
||
3959 |
||
3960 |
||
3961 |
TInt CContactsUT::ExportCancelL( CStifItemParser& /*aItem*/) |
|
3962 |
{ |
|
3963 |
||
3964 |
int ret=0; |
|
3965 |
ret = export_cancel(0, NULL); |
|
3966 |
||
3967 |
if(ret==0) |
|
3968 |
return KErrNone; |
|
3969 |
else |
|
3970 |
return KErrGeneral; |
|
3971 |
||
3972 |
||
3973 |
} |
|
3974 |
||
3975 |
TInt CContactsUT::AddCancelL( CStifItemParser& /*aItem*/ ) |
|
3976 |
{ |
|
3977 |
int ret=0; |
|
3978 |
ret = add_cancel(0, NULL); |
|
3979 |
||
3980 |
if(ret==0) |
|
3981 |
return KErrNone; |
|
3982 |
else |
|
3983 |
return KErrGeneral; |
|
3984 |
} |
|
3985 |
||
3986 |
TInt CContactsUT::ImportCancelL( CStifItemParser& /*aItem*/) |
|
3987 |
{ |
|
3988 |
||
3989 |
int ret=0; |
|
3990 |
ret = import_cancel(0, NULL); |
|
3991 |
||
3992 |
if(ret==0) |
|
3993 |
return KErrNone; |
|
3994 |
else |
|
3995 |
return KErrGeneral; |
|
3996 |
||
3997 |
||
3998 |
} |
|
3999 |
||
4000 |
TInt CContactsUT::DeleteCancelL( CStifItemParser& /*aItem*/) |
|
4001 |
{ |
|
4002 |
||
4003 |
int ret=0; |
|
4004 |
ret = delete_cancel(0, NULL); |
|
4005 |
||
4006 |
if(ret==0) |
|
4007 |
return KErrNone; |
|
4008 |
else |
|
4009 |
return KErrGeneral; |
|
4010 |
||
4011 |
} |
|
4012 |
TInt CContactsUT::OrganiseCancelL( CStifItemParser& /*aItem*/) |
|
4013 |
{ |
|
4014 |
||
4015 |
int ret=0; |
|
4016 |
ret = organise_cancel(0, NULL); |
|
4017 |
||
4018 |
if(ret==0) |
|
4019 |
return KErrNone; |
|
4020 |
else |
|
4021 |
return KErrGeneral; |
|
4022 |
||
4023 |
} |
|
4024 |
//End of file |