changeset 22 | fc9cf246af83 |
parent 19 | 989d2f495d90 |
child 33 | 50974a8b132e |
19:989d2f495d90 | 22:fc9cf246af83 |
---|---|
77 |
77 |
78 |
78 |
79 TInt tCount=0; |
79 TInt tCount=0; |
80 HBufC8* contactid; |
80 HBufC8* contactid; |
81 CSingleContact* myContact=NULL; |
81 CSingleContact* myContact=NULL; |
82 TBool newFields = EFalse; |
|
83 _LIT8(KFirstNameKey,"FirstName"); |
|
84 _LIT(KValue,"Barbie"); |
|
82 |
85 |
86 void CContactCallback::HandleReturnArray(const TInt& aError,RPointerArray<HBufC8>& aArray,TInt aTransId ) |
|
87 { |
|
88 CActiveScheduler::Stop(); |
|
89 iError = aError; |
|
90 } |
|
91 |
|
92 void CContactCallback:: HandleReturnId( const TInt& aError, HBufC8* acntId, TInt aTransId ) |
|
93 { |
|
94 CActiveScheduler::Stop(); |
|
95 //HBufC8* cntId = acntId; |
|
96 iError = aError; |
|
97 if(aError == KErrNone) |
|
98 { |
|
99 delete acntId; |
|
100 acntId = NULL; |
|
101 } |
|
102 } |
|
83 void CContactCallback::HandleReturnValue( TOperationEvent aEventId, const TInt& aError, TInt aTransId ) |
103 void CContactCallback::HandleReturnValue( TOperationEvent aEventId, const TInt& aError, TInt aTransId ) |
84 { |
104 { |
85 iError= aError; |
105 iError= aError; |
86 CActiveScheduler::Stop(); |
106 CActiveScheduler::Stop(); |
87 } |
107 } |
90 void CContactCallback:: HandleReturnIter(const TInt& aError, CContactIter* aIter, TInt aTransId ) |
110 void CContactCallback:: HandleReturnIter(const TInt& aError, CContactIter* aIter, TInt aTransId ) |
91 { |
111 { |
92 |
112 |
93 |
113 |
94 CActiveScheduler::Stop(); |
114 CActiveScheduler::Stop(); |
95 |
115 iError = aError; |
96 CSingleContactField* field = NULL; |
116 CSingleContactField* field = NULL; |
97 HBufC8* buf = NULL; |
|
98 TPtrC8 buf1; |
117 TPtrC8 buf1; |
99 TPtrC buf2; |
118 TPtrC buf2; |
100 TPtrC buf3; |
119 TPtrC buf3; |
101 TInt count=0 ; |
120 TInt count=0 ; |
102 |
121 |
103 |
122 |
104 if(aError==KErrNone) |
123 if(aError==KErrNone) |
105 { |
124 { |
106 aIter->NextL(myContact,contactid); |
125 aIter->NextL(myContact,contactid); |
126 if(contactid) |
|
127 { |
|
128 delete contactid; |
|
129 contactid = NULL; |
|
130 } |
|
107 |
131 |
108 while(myContact) |
132 while(myContact) |
109 { |
133 { |
110 tCount++; |
134 tCount++; |
111 if(myContact) |
135 if(myContact) |
112 { |
136 { |
113 count++; |
137 count++; |
114 TInt len,i ; |
138 TInt len,i ; |
117 { |
141 { |
118 field = myContact->FieldAt(i); |
142 field = myContact->FieldAt(i); |
119 if(field!=NULL) |
143 if(field!=NULL) |
120 { |
144 { |
121 field->GetFieldDataL(buf1,buf2,buf3); |
145 field->GetFieldDataL(buf1,buf2,buf3); |
146 if(newFields != EFalse) |
|
147 { |
|
148 if(buf1.CompareF(KFirstNameKey) == 0) |
|
149 { |
|
150 if(buf3.CompareF(KValue) != 0) |
|
151 { |
|
152 iError = KErrGeneral; |
|
153 newFields =EFalse; |
|
154 break; |
|
155 } |
|
156 } |
|
157 newFields = EFalse; |
|
158 break; |
|
159 } |
|
122 //if(buf1.CompareF(_L8("emailgen"))==0) break; |
160 //if(buf1.CompareF(_L8("emailgen"))==0) break; |
123 } |
161 } |
124 |
162 |
125 } //for |
163 } //for |
126 |
164 |
127 } //if |
165 } //if |
128 |
166 if(myContact) |
167 { |
|
168 delete myContact; |
|
169 myContact = NULL; |
|
170 } |
|
129 aIter->NextL(myContact,contactid); |
171 aIter->NextL(myContact,contactid); |
130 |
172 |
173 if(contactid) |
|
174 { |
|
175 delete contactid; |
|
176 contactid = NULL; |
|
177 } |
|
131 |
178 |
132 } //while |
179 } //while |
133 delete aIter; |
180 |
134 } //if |
181 } //if |
135 |
182 delete aIter; |
136 |
183 } |
137 |
|
138 } |
|
139 |
184 |
140 // ----------------------------------------------------------------------------- |
185 // ----------------------------------------------------------------------------- |
141 // Ctmanualcontacts::Delete |
186 // Ctmanualcontacts::Delete |
142 // Delete here all resources allocated and opened from test methods. |
187 // Delete here all resources allocated and opened from test methods. |
143 // Called from destructor. |
188 // Called from destructor. |
170 ENTRY( "GetList_Test6", Ctmanualcontacts::GetList_Test6L ), |
215 ENTRY( "GetList_Test6", Ctmanualcontacts::GetList_Test6L ), |
171 ENTRY( "GetList_Test7", Ctmanualcontacts::GetList_Test7L ), |
216 ENTRY( "GetList_Test7", Ctmanualcontacts::GetList_Test7L ), |
172 ENTRY( "GetList_Test8", Ctmanualcontacts::GetList_Test8L ), |
217 ENTRY( "GetList_Test8", Ctmanualcontacts::GetList_Test8L ), |
173 ENTRY( "GetList_Test9", Ctmanualcontacts::GetList_Test9L ), |
218 ENTRY( "GetList_Test9", Ctmanualcontacts::GetList_Test9L ), |
174 ENTRY( "GetList_Test10", Ctmanualcontacts::GetList_Test10L ), |
219 ENTRY( "GetList_Test10", Ctmanualcontacts::GetList_Test10L ), |
175 //ENTRY( "GetList_Test11", Ctmanualcontacts::GetList_Test11L ), |
220 ENTRY( "GetList_Test11", Ctmanualcontacts::GetList_Test11L ), |
221 ENTRY( "GetList_Test12", Ctmanualcontacts::GetList_Test12L ), |
|
176 |
222 |
177 }; |
223 }; |
178 |
224 |
179 const TInt count = sizeof( KFunctions ) / |
225 const TInt count = sizeof( KFunctions ) / |
180 sizeof( TStifFunctionInfo ); |
226 sizeof( TStifFunctionInfo ); |
191 // |
237 // |
192 |
238 |
193 /* get database lists ,manual,only contacts.cdb will be listed*/ |
239 /* get database lists ,manual,only contacts.cdb will be listed*/ |
194 TInt Ctmanualcontacts::GetList_Test1L( CStifItemParser& aItem ) |
240 TInt Ctmanualcontacts::GetList_Test1L( CStifItemParser& aItem ) |
195 { |
241 { |
196 |
242 __UHEAP_MARK; |
243 icontactservice=CContactService::NewL(); |
|
244 icallback=new(ELeave) CContactCallback; |
|
197 // Print to UI |
245 // Print to UI |
198 _LIT( Ktsapicontacts, "tsapicontacts" ); |
246 _LIT( Ktsapicontacts, "tsapicontacts" ); |
199 _LIT( KExample, "In GetList_Test1L" ); |
247 _LIT( KExample, "In GetList_Test1L" ); |
200 TestModuleIf().Printf( 0, Ktsapicontacts, KExample ); |
248 TestModuleIf().Printf( 0, Ktsapicontacts, KExample ); |
201 // Print to log file |
249 // Print to log file |
211 while(buf.Compare(KNullDesC)!=0) |
259 while(buf.Compare(KNullDesC)!=0) |
212 { |
260 { |
213 iter->NextL(buf); |
261 iter->NextL(buf); |
214 } |
262 } |
215 |
263 |
264 delete iter; |
|
265 delete icallback; |
|
266 delete icontactservice; |
|
267 __UHEAP_MARKEND; |
|
216 return KErrNone ; |
268 return KErrNone ; |
217 |
269 |
218 } |
270 } |
219 |
271 |
220 |
272 |
221 /* get all contacts from the phonebook ie contacts.cdb,manual*/ |
273 /* get all contacts from the phonebook ie contacts.cdb,manual*/ |
222 TInt Ctmanualcontacts::GetList_Test2L( CStifItemParser& aItem ) |
274 TInt Ctmanualcontacts::GetList_Test2L( CStifItemParser& aItem ) |
223 { |
275 { |
224 |
276 __UHEAP_MARK; |
277 icontactservice=CContactService::NewL(); |
|
278 icallback=new(ELeave) CContactCallback; |
|
225 // Print to UI |
279 // Print to UI |
226 _LIT( Ktsapicontacts, "tsapicontacts" ); |
280 _LIT( Ktsapicontacts, "tsapicontacts" ); |
227 _LIT( KExample, "In GetList_Test1L" ); |
281 _LIT( KExample, "In GetList_Test1L" ); |
228 TestModuleIf().Printf( 0, Ktsapicontacts, KExample ); |
282 TestModuleIf().Printf( 0, Ktsapicontacts, KExample ); |
229 // Print to log file |
283 // Print to log file |
231 |
285 |
232 |
286 |
233 icontactservice->GetListL(icallback,1,EContacts); |
287 icontactservice->GetListL(icallback,1,EContacts); |
234 |
288 |
235 CActiveScheduler::Start(); |
289 CActiveScheduler::Start(); |
236 |
290 delete icallback; |
237 |
291 delete icontactservice; |
292 |
|
293 __UHEAP_MARKEND; |
|
238 return KErrNone ; |
294 return KErrNone ; |
239 |
295 |
240 |
296 |
241 } |
297 } |
242 |
298 |
254 |
310 |
255 _LIT(KCntDbUri, "cntdb://c:contacts_test_group.cdb"); |
311 _LIT(KCntDbUri, "cntdb://c:contacts_test_group.cdb"); |
256 TBuf8<15> fstname(_L8("FirstName")); |
312 TBuf8<15> fstname(_L8("FirstName")); |
257 |
313 |
258 TBufC8<25> cid ; |
314 TBufC8<25> cid ; |
259 CSearchFields *srchfield =CSearchFields :: NewL(icontactservice); |
315 __UHEAP_MARK; |
316 icontactservice=CContactService::NewL(); |
|
317 //CSearchFields *srchfield =CSearchFields :: NewL(icontactservice); |
|
260 TPtrC searchval(_L("Getlist_test")); |
318 TPtrC searchval(_L("Getlist_test")); |
261 srchfield->AppendL(fstname); |
319 // srchfield->AppendL(fstname); |
320 icallback=new(ELeave) CContactCallback; |
|
321 |
|
262 icontactservice->GetListL(icallback,1,EGroups,KNullDesC8,searchval,NULL,EAsc,KCntDbUri); |
322 icontactservice->GetListL(icallback,1,EGroups,KNullDesC8,searchval,NULL,EAsc,KCntDbUri); |
263 |
323 |
264 CActiveScheduler::Start(); |
324 CActiveScheduler::Start(); |
265 |
325 delete icallback; |
326 // delete srchfield; |
|
327 delete icontactservice; |
|
328 __UHEAP_MARKEND; |
|
266 if(myContact ==NULL) |
329 if(myContact ==NULL) |
267 return KErrNone ; |
330 { |
268 |
331 return KErrNone ; |
332 } |
|
333 //delete icallback; |
|
334 //delete icontactservice; |
|
335 //__UHEAP_MARKEND; |
|
269 return KErrGeneral; |
336 return KErrGeneral; |
270 } |
337 } |
271 |
338 |
272 /* get group list ,groups are there but no contacts in it */ |
339 /* get group list ,groups are there but no contacts in it */ |
273 TInt Ctmanualcontacts::GetList_Test4L( CStifItemParser& aItem ) |
340 TInt Ctmanualcontacts::GetList_Test4L( CStifItemParser& aItem ) |
274 { |
341 { |
275 |
342 __UHEAP_MARK; |
343 icontactservice=CContactService::NewL(); |
|
344 icallback=new(ELeave) CContactCallback; |
|
276 // Print to UI |
345 // Print to UI |
277 _LIT( Ktsapicontacts, "tsapicontacts" ); |
346 _LIT( Ktsapicontacts, "tsapicontacts" ); |
278 _LIT( KExample, "In GetList_Test1L" ); |
347 _LIT( KExample, "In GetList_Test1L" ); |
279 TestModuleIf().Printf( 0, Ktsapicontacts, KExample ); |
348 TestModuleIf().Printf( 0, Ktsapicontacts, KExample ); |
280 // Print to log file |
349 // Print to log file |
290 icontactservice->GetListL(icallback,1,EGroups); |
359 icontactservice->GetListL(icallback,1,EGroups); |
291 |
360 |
292 CActiveScheduler::Start(); |
361 CActiveScheduler::Start(); |
293 |
362 |
294 if(tCount!=0) |
363 if(tCount!=0) |
364 delete icallback; |
|
365 delete icontactservice; |
|
366 __UHEAP_MARKEND; |
|
295 return KErrNone ; |
367 return KErrNone ; |
368 delete icallback; |
|
369 delete icontactservice; |
|
370 __UHEAP_MARKEND; |
|
296 |
371 |
297 return KErrGeneral; |
372 return KErrGeneral; |
298 |
373 |
299 |
374 |
300 } |
375 } |
302 /// repeated |
377 /// repeated |
303 /* search for Lee in tmp.cdb */ |
378 /* search for Lee in tmp.cdb */ |
304 |
379 |
305 TInt Ctmanualcontacts::GetList_Test5L( CStifItemParser& aItem ) |
380 TInt Ctmanualcontacts::GetList_Test5L( CStifItemParser& aItem ) |
306 { |
381 { |
307 |
382 __UHEAP_MARK; |
383 icontactservice=CContactService::NewL(); |
|
384 icallback=new(ELeave) CContactCallback; |
|
385 |
|
308 // Print to UI |
386 // Print to UI |
309 _LIT(KCntDbUri1, "cntdb://c:tmp.cdb"); |
387 _LIT(KCntDbUri1, "cntdb://c:tmp.cdb"); |
310 _LIT( Ktsapicontacts, "tsapicontacts" ); |
388 _LIT( Ktsapicontacts, "tsapicontacts" ); |
311 _LIT( KExample, "In GetList_Test1L" ); |
389 _LIT( KExample, "In GetList_Test1L" ); |
312 TestModuleIf().Printf( 0, Ktsapicontacts, KExample ); |
390 TestModuleIf().Printf( 0, Ktsapicontacts, KExample ); |
351 icontactservice->GetListL(icallback,1,EContacts,KNullDesC8,searchval,srchfield,EAsc,KCntDbUri1); |
429 icontactservice->GetListL(icallback,1,EContacts,KNullDesC8,searchval,srchfield,EAsc,KCntDbUri1); |
352 |
430 |
353 CActiveScheduler::Start(); |
431 CActiveScheduler::Start(); |
354 |
432 |
355 if(tCount!=0) |
433 if(tCount!=0) |
356 return KErrNone ; |
434 { |
435 delete icallback; |
|
436 delete icontactservice; |
|
437 delete singleContact; |
|
438 __UHEAP_MARKEND; |
|
439 return KErrNone ; |
|
440 } |
|
357 |
441 |
442 delete icallback; |
|
443 delete icontactservice; |
|
444 delete singleContact; |
|
445 __UHEAP_MARKEND; |
|
358 |
446 |
359 return KErrGeneral ; |
447 return KErrGeneral ; |
360 } |
448 } |
361 |
449 |
362 // search for invalid search field ,ex:search for Lee as lastname in tmp.cdb |
450 // search for invalid search field ,ex:search for Lee as lastname in tmp.cdb |
363 |
451 |
364 TInt Ctmanualcontacts::GetList_Test6L( CStifItemParser& aItem ) |
452 TInt Ctmanualcontacts::GetList_Test6L( CStifItemParser& aItem ) |
365 { |
453 { |
366 |
454 __UHEAP_MARK; |
455 icontactservice=CContactService::NewL(); |
|
456 icallback=new(ELeave) CContactCallback; |
|
367 // Print to UI |
457 // Print to UI |
368 _LIT( Ktsapicontacts, "tsapicontacts" ); |
458 _LIT( Ktsapicontacts, "tsapicontacts" ); |
369 _LIT(KCntDbUri, "cntdb://c:tmp.cdb"); |
459 _LIT(KCntDbUri, "cntdb://c:tmp.cdb"); |
370 _LIT( KExample, "In GetList_Test1L" ); |
460 _LIT( KExample, "In GetList_Test1L" ); |
371 TestModuleIf().Printf( 0, Ktsapicontacts, KExample ); |
461 TestModuleIf().Printf( 0, Ktsapicontacts, KExample ); |
409 |
499 |
410 |
500 |
411 CActiveScheduler::Start(); |
501 CActiveScheduler::Start(); |
412 |
502 |
413 if(tCount ==0) |
503 if(tCount ==0) |
504 { |
|
505 delete icallback; |
|
506 delete icontactservice; |
|
507 delete singleContact; |
|
508 __UHEAP_MARKEND; |
|
414 return KErrNone ; |
509 return KErrNone ; |
415 |
510 } |
416 else |
511 |
512 delete icallback; |
|
513 delete icontactservice; |
|
514 delete singleContact; |
|
515 __UHEAP_MARKEND; |
|
417 return KErrGeneral; |
516 return KErrGeneral; |
418 |
517 |
419 } |
518 |
519 } |
|
420 |
520 |
421 /* list contacts in descending order */ |
521 /* list contacts in descending order */ |
422 TInt Ctmanualcontacts::GetList_Test7L( CStifItemParser& aItem ) |
522 TInt Ctmanualcontacts::GetList_Test7L( CStifItemParser& aItem ) |
423 { |
523 { |
524 __UHEAP_MARK; |
|
525 icontactservice=CContactService::NewL(); |
|
526 icallback=new(ELeave) CContactCallback; |
|
424 _LIT(KCntDbUri, "cntdb://c:tmp.cdb"); |
527 _LIT(KCntDbUri, "cntdb://c:tmp.cdb"); |
425 // Print to UI |
528 // Print to UI |
426 _LIT( Ktsapicontacts, "tsapicontacts" ); |
529 _LIT( Ktsapicontacts, "tsapicontacts" ); |
427 _LIT( KExample, "In GetList_Test1L" ); |
530 _LIT( KExample, "In GetList_Test1L" ); |
428 TestModuleIf().Printf( 0, Ktsapicontacts, KExample ); |
531 TestModuleIf().Printf( 0, Ktsapicontacts, KExample ); |
432 |
535 |
433 icontactservice->GetListL(icallback,1,EContacts,KNullDesC8,KNullDesC,NULL,EDesc); //,cid,KCntDbUri1,searchval,srchfield); |
536 icontactservice->GetListL(icallback,1,EContacts,KNullDesC8,KNullDesC,NULL,EDesc); //,cid,KCntDbUri1,searchval,srchfield); |
434 |
537 |
435 CActiveScheduler::Start(); |
538 CActiveScheduler::Start(); |
436 |
539 |
437 |
540 delete icallback; |
541 delete icontactservice; |
|
542 __UHEAP_MARKEND; |
|
438 return KErrNone ; |
543 return KErrNone ; |
439 |
544 |
440 } |
545 } |
441 |
546 |
442 /* testcase :list groups in descending order ; |
547 /* testcase :list groups in descending order ; |
450 _LIT( KExample, "In GetList_Test1L" ); |
555 _LIT( KExample, "In GetList_Test1L" ); |
451 TestModuleIf().Printf( 0, Ktsapicontacts, KExample ); |
556 TestModuleIf().Printf( 0, Ktsapicontacts, KExample ); |
452 // Print to log file |
557 // Print to log file |
453 iLog->Log( KExample ); |
558 iLog->Log( KExample ); |
454 |
559 |
455 |
560 __UHEAP_MARK; |
561 icontactservice=CContactService::NewL(); |
|
562 icallback=new(ELeave) CContactCallback; |
|
456 icontactservice->GetListL(icallback,1,EGroups,KNullDesC8,KNullDesC,NULL,EDesc,KCntDbUri); //,cid,KCntDbUri1,searchval,srchfield); |
563 icontactservice->GetListL(icallback,1,EGroups,KNullDesC8,KNullDesC,NULL,EDesc,KCntDbUri); //,cid,KCntDbUri1,searchval,srchfield); |
457 |
564 |
458 CActiveScheduler::Start(); |
565 CActiveScheduler::Start(); |
459 |
566 |
460 |
567 delete icallback; |
568 delete icontactservice; |
|
569 __UHEAP_MARKEND; |
|
461 return KErrNone ; |
570 return KErrNone ; |
462 |
571 |
463 } |
572 } |
464 |
573 |
465 /* list contacts ,ENULL cannot be used in sortingorder*/ |
574 /* list contacts ,ENULL cannot be used in sortingorder*/ |
466 TInt Ctmanualcontacts::GetList_Test9L( CStifItemParser& aItem ) |
575 TInt Ctmanualcontacts::GetList_Test9L( CStifItemParser& aItem ) |
467 { |
576 { |
468 |
577 __UHEAP_MARK; |
578 icontactservice=CContactService::NewL(); |
|
579 icallback=new(ELeave) CContactCallback; |
|
469 _LIT(KCntDbUri, "cntdb://c:tmp_ENul.cdb"); |
580 _LIT(KCntDbUri, "cntdb://c:tmp_ENul.cdb"); |
470 // Print to UI |
581 // Print to UI |
471 _LIT( Ktsapicontacts, "tsapicontacts" ); |
582 _LIT( Ktsapicontacts, "tsapicontacts" ); |
472 _LIT( KExample, "In GetList_Test1L" ); |
583 _LIT( KExample, "In GetList_Test1L" ); |
473 TestModuleIf().Printf( 0, Ktsapicontacts, KExample ); |
584 TestModuleIf().Printf( 0, Ktsapicontacts, KExample ); |
477 |
588 |
478 |
589 |
479 icontactservice->GetListL(icallback,1,EContacts,KNullDesC8,KNullDesC,NULL,EAsc); //,cid,KCntDbUri1,searchval,srchfield); |
590 icontactservice->GetListL(icallback,1,EContacts,KNullDesC8,KNullDesC,NULL,EAsc); //,cid,KCntDbUri1,searchval,srchfield); |
480 |
591 |
481 CActiveScheduler::Start(); |
592 CActiveScheduler::Start(); |
482 |
593 delete icallback; |
594 delete icontactservice; |
|
595 __UHEAP_MARKEND; |
|
483 |
596 |
484 return KErrNone ; |
597 return KErrNone ; |
485 |
598 |
486 } |
599 } |
487 |
600 |
494 _LIT( KExample, "In GetList_Test1L" ); |
607 _LIT( KExample, "In GetList_Test1L" ); |
495 TestModuleIf().Printf( 0, Ktsapicontacts, KExample ); |
608 TestModuleIf().Printf( 0, Ktsapicontacts, KExample ); |
496 // Print to log file |
609 // Print to log file |
497 iLog->Log( KExample ); |
610 iLog->Log( KExample ); |
498 |
611 |
499 |
612 __UHEAP_MARK; |
613 icontactservice=CContactService::NewL(); |
|
614 icallback=new(ELeave) CContactCallback; |
|
500 _LIT(KCntDbUri1, "cntdb://c:tmp.cdb"); |
615 _LIT(KCntDbUri1, "cntdb://c:tmp.cdb"); |
501 icontactservice->GetListL(icallback,1,EContacts,KNullDesC8,KNullDesC,NULL,EAsc,KCntDbUri1); //,cid,KCntDbUri1,searchval,srchfield); |
616 icontactservice->GetListL(icallback,1,EContacts,KNullDesC8,KNullDesC,NULL,EAsc,KCntDbUri1); //,cid,KCntDbUri1,searchval,srchfield); |
502 |
617 |
503 CActiveScheduler::Start(); |
618 CActiveScheduler::Start(); |
504 |
619 |
505 CContactIter* iter = CContactIter::NewL(); |
620 CContactIter* iter = CContactIter::NewL(); |
506 icontactservice->GetListL(*iter); |
621 icontactservice->GetListL(*iter); |
507 |
622 delete iter; |
623 delete icallback; |
|
624 delete icontactservice; |
|
625 __UHEAP_MARKEND; |
|
508 TPtrC buf(_L("")); |
626 TPtrC buf(_L("")); |
509 |
627 |
510 iter->NextL(buf); |
628 iter->NextL(buf); |
511 TInt count=0; |
629 TInt count=0; |
512 while(buf.Compare(KNullDesC)!=0) |
630 while(buf.Compare(KNullDesC)!=0) |
513 { count++; |
631 { count++; |
514 iter->NextL(buf); |
632 iter->NextL(buf); |
515 } |
633 } |
516 if(count==2) |
634 if(count==2) |
635 { |
|
636 |
|
517 return KErrNone ; |
637 return KErrNone ; |
518 |
638 } |
639 delete iter; |
|
640 delete icallback; |
|
641 delete icontactservice; |
|
642 //__UHEAP_MARKEND; |
|
519 return KErrGeneral; |
643 return KErrGeneral; |
520 } |
644 } |
521 |
645 |
522 |
646 /* get all contacts from the phonebook ie contacts.cdb,manual*/ |
647 TInt Ctmanualcontacts::GetList_Test11L( CStifItemParser& aItem ) |
|
648 { |
|
649 // Print to UI |
|
650 _LIT( Ktsapicontacts, "tsapicontacts" ); |
|
651 _LIT( KExample, "In GetList_Test11L" ); |
|
652 TestModuleIf().Printf( 0, Ktsapicontacts, KExample ); |
|
653 // Print to log file |
|
654 __UHEAP_MARK; |
|
655 icontactservice=CContactService::NewL(); |
|
656 icallback=new(ELeave) CContactCallback; |
|
657 |
|
658 iLog->Log( KExample ); |
|
659 // TInt count =KErrGeneral ; |
|
660 _LIT8(KFirstName,"FirstName"); |
|
661 _LIT(KFName,"Barbie"); |
|
662 _LIT8(KPrefix,"Prefix"); |
|
663 _LIT(KPfix,"Princess"); |
|
664 _LIT8(KNote,"Note"); |
|
665 _LIT(KNoteVal,"Lead role in Barbie, the island princess"); |
|
666 _LIT8(KAnniversary,"Anniversary"); |
|
667 //_LIT(KAniiVal,"08216666"); |
|
668 _LIT8(KBday,"Date"); |
|
669 _LIT8(KNickName,"SecondName"); |
|
670 _LIT(KNickNameVal,"Doll"); |
|
671 _LIT8(KPhoto,"CallerObjImg"); |
|
672 _LIT(KPhotoVal,"C:\\data\\images\\pic.jpg"); |
|
673 _LIT8(KImpp,"IMPP"); |
|
674 _LIT(KImppLabel,"IMPP"); |
|
675 |
|
676 |
|
677 //instantiate service class object |
|
678 /* create contactitem to add */ |
|
679 CSingleContact* singleContact = CSingleContact::NewL(); |
|
680 CleanupStack::PushL(singleContact); |
|
681 CSingleContactField* FName = CSingleContactField::NewL(); |
|
682 CleanupStack::PushL(FName); |
|
683 CSingleContactField* prefix = CSingleContactField::NewL(); |
|
684 CleanupStack::PushL(prefix); |
|
685 CSingleContactField* note = CSingleContactField::NewL(); |
|
686 CleanupStack::PushL(note); |
|
687 CSingleContactField* anni = CSingleContactField::NewL(); |
|
688 CleanupStack::PushL(anni); |
|
689 CSingleContactField* bday = CSingleContactField::NewL(); |
|
690 CleanupStack::PushL(bday); |
|
691 CSingleContactField* nkname = CSingleContactField::NewL(); |
|
692 CleanupStack::PushL(nkname); |
|
693 CSingleContactField* photo = CSingleContactField::NewL(); |
|
694 CleanupStack::PushL(photo); |
|
695 CSingleContactField* xspid = CSingleContactField::NewL(); |
|
696 CleanupStack::PushL(xspid); |
|
697 |
|
698 |
|
699 FName->SetFieldParamsL(KFirstName,KNullDesC,KFName); |
|
700 singleContact->AddFieldToContactL(FName); |
|
701 |
|
702 prefix->SetFieldParamsL(KPrefix,KNullDesC,KPfix); |
|
703 singleContact->AddFieldToContactL(prefix); |
|
704 |
|
705 note->SetFieldParamsL(KNote,KNullDesC,KNoteVal); |
|
706 singleContact->AddFieldToContactL(note); |
|
707 |
|
708 anni->SetFieldParamsL(KAnniversary,KNullDesC,KNullDesC); |
|
709 anni->SetDateTime(TTime(TDateTime(2007,EOctober,25,0,0,0,0))); |
|
710 //anni->SetDateTime(annival); |
|
711 singleContact->AddFieldToContactL(anni); |
|
712 |
|
713 |
|
714 bday->SetFieldParamsL(KBday,KNullDesC,KNullDesC); |
|
715 bday->SetDateTime(TTime(TDateTime(2007,EOctober,25,0,0,0,0))); |
|
716 //bday->SetDateTime(bdayval); |
|
717 singleContact->AddFieldToContactL(bday); |
|
718 |
|
719 nkname->SetFieldParamsL(KNickName,KNullDesC,KNickNameVal); |
|
720 singleContact->AddFieldToContactL(nkname); |
|
721 |
|
722 photo->SetFieldParamsL(KPhoto,KNullDesC,KPhotoVal); |
|
723 singleContact->AddFieldToContactL(photo); |
|
724 |
|
725 _LIT(KYahooId,"Yahoo:barbie@yahoo.co.in"); |
|
726 //_LIT8(); |
|
727 RPointerArray<HBufC> xspidarr; |
|
728 xspidarr.Append((_L("Yahoo:barbie@yahoo.co.in")).AllocL()); |
|
729 xspidarr.Append((_L("Google:barbie@gmail.com")).AllocL()); |
|
730 xspid->SetXspidDataL(KImpp,KImppLabel,xspidarr); |
|
731 singleContact->AddFieldToContactL(xspid); |
|
732 |
|
733 //aItem.GetNextInt(count) ; |
|
734 _LIT( KLog4, "before calling add" ); |
|
735 iLog->Log( KLog4 ); |
|
736 /* Add the contactitem */ |
|
737 HBufC8* cntId; |
|
738 TRAPD(err,cntId= icontactservice->AddL(singleContact)); |
|
739 |
|
740 TPtr8 cntIdPtrVal(cntId->Des()); |
|
741 if(err != KErrNone) |
|
742 {CleanupStack::Pop(xspid); |
|
743 CleanupStack::Pop(photo); |
|
744 CleanupStack::Pop(nkname); |
|
745 CleanupStack::Pop(bday); |
|
746 CleanupStack::Pop(anni); |
|
747 CleanupStack::Pop(note); |
|
748 CleanupStack::Pop(prefix); |
|
749 CleanupStack::Pop(FName); |
|
750 CleanupStack::Pop(singleContact); |
|
751 delete singleContact; |
|
752 delete cntId; |
|
753 delete icallback; |
|
754 delete icontactservice; |
|
755 _LIT( KLog1, "false case uheapmarkend" ); |
|
756 iLog->Log( KLog1 ); |
|
757 __UHEAP_MARKEND; |
|
758 return KErrGeneral ; |
|
759 } |
|
760 /*else |
|
761 { |
|
762 CleanupStack::Pop(xspid); |
|
763 CleanupStack::Pop(photo); |
|
764 CleanupStack::Pop(nkname); |
|
765 CleanupStack::Pop(bday); |
|
766 CleanupStack::Pop(anni); |
|
767 CleanupStack::Pop(note); |
|
768 CleanupStack::Pop(prefix); |
|
769 CleanupStack::Pop(FName); |
|
770 CleanupStack::Pop(singleContact); |
|
771 delete singleContact; |
|
772 delete cntId; |
|
773 delete icallback; |
|
774 delete icontactservice; |
|
775 _LIT( KLog1, "false case uheapmarkend" ); |
|
776 iLog->Log( KLog1 ); |
|
777 __UHEAP_MARKEND; |
|
778 return KErrNone; |
|
779 |
|
780 } |
|
781 */ |
|
782 newFields = ETrue; |
|
783 _LIT(KCntDbUri,"cntdb://c:contacts.cdb"); |
|
784 //icontactservice->GetListL(icallback,1,EContacts,KNullDesC8,KNullDesC,NULL,EAsc,KCntDbUri1); |
|
785 //icontactservice->GetListL(icallback,1,EContacts,KNullDesC8,KNullDesC,NULL,EAsc); |
|
786 icontactservice->GetListL(icallback,1,EContacts,cntIdPtrVal); //,KNullDesC,NULL,EAsc,KCntDbUri,EGetList); |
|
787 |
|
788 CActiveScheduler::Start(); |
|
789 |
|
790 if(icallback->iError == KErrNone) |
|
791 { |
|
792 CleanupStack::Pop(xspid); |
|
793 CleanupStack::Pop(photo); |
|
794 CleanupStack::Pop(nkname); |
|
795 CleanupStack::Pop(bday); |
|
796 CleanupStack::Pop(anni); |
|
797 CleanupStack::Pop(note); |
|
798 CleanupStack::Pop(prefix); |
|
799 CleanupStack::Pop(FName); |
|
800 CleanupStack::Pop(singleContact); |
|
801 delete singleContact; |
|
802 delete cntId; |
|
803 delete icallback; |
|
804 delete icontactservice; |
|
805 _LIT( KLog2, "true case uheapmarkend" ); |
|
806 iLog->Log( KLog2 ); |
|
807 __UHEAP_MARKEND; |
|
808 return KErrNone ; |
|
809 } |
|
810 CleanupStack::Pop(xspid); |
|
811 CleanupStack::Pop(photo); |
|
812 CleanupStack::Pop(nkname); |
|
813 CleanupStack::Pop(bday); |
|
814 CleanupStack::Pop(anni); |
|
815 CleanupStack::Pop(note); |
|
816 CleanupStack::Pop(prefix); |
|
817 CleanupStack::Pop(FName); |
|
818 CleanupStack::Pop(singleContact); |
|
819 delete singleContact; |
|
820 delete cntId; |
|
821 delete icallback; |
|
822 delete icontactservice; |
|
823 _LIT( KLog3, "false case uheapmarkend 2" ); |
|
824 iLog->Log( KLog3 ); |
|
825 __UHEAP_MARKEND; |
|
826 return KErrGeneral; |
|
827 |
|
828 |
|
829 } |
|
830 |
|
831 |
|
832 /* get all contacts from the phonebook ie contacts.cdb,manual*/ |
|
833 TInt Ctmanualcontacts::GetList_Test12L( CStifItemParser& aItem ) |
|
834 { |
|
835 __UHEAP_MARK; |
|
836 icontactservice=CContactService::NewL(); |
|
837 // Print to UI |
|
838 _LIT( Ktsapicontacts, "tsapicontacts" ); |
|
839 _LIT( KExample, "In GetList_Test11L" ); |
|
840 TestModuleIf().Printf( 0, Ktsapicontacts, KExample ); |
|
841 // Print to log file |
|
842 iLog->Log( KExample ); |
|
843 // TInt count =KErrGeneral ; |
|
844 _LIT8(KFirstName,"FirstName"); |
|
845 _LIT(KFName,"Kelly"); |
|
846 _LIT8(KPrefix,"Prefix"); |
|
847 _LIT(KPfix,"Princess"); |
|
848 _LIT8(KNote,"Note"); |
|
849 _LIT(KNoteVal,"Sister of Princess Barbie"); |
|
850 _LIT8(KAnniversary,"Anniversary"); |
|
851 _LIT8(KBday,"Date"); |
|
852 _LIT8(KNickName,"SecondName"); |
|
853 _LIT(KNickNameVal,"Doll"); |
|
854 _LIT8(KPhoto,"CallerObjImg"); |
|
855 _LIT(KPhotoVal,"C:\\data\\images\\pic.jpg"); |
|
856 _LIT8(KImpp,"IMPP"); |
|
857 _LIT(KImppLabel,"IMPP"); |
|
858 TPtrC8 fieldKey(KNullDesC8); |
|
859 TPtrC label(KNullDesC); |
|
860 TPtrC value(KNullDesC); |
|
861 _LIT(KValue,"Kelly"); |
|
862 //instantiate service class object |
|
863 /* create contactitem to add */ |
|
864 CSingleContact* singleContact = CSingleContact::NewL(); |
|
865 CleanupStack::PushL(singleContact); |
|
866 CSingleContactField* FName = CSingleContactField::NewL(); |
|
867 CleanupStack::PushL(FName); |
|
868 CSingleContactField* prefix = CSingleContactField::NewL(); |
|
869 CleanupStack::PushL(prefix); |
|
870 CSingleContactField* note = CSingleContactField::NewL(); |
|
871 CleanupStack::PushL(note); |
|
872 CSingleContactField* anni = CSingleContactField::NewL(); |
|
873 CleanupStack::PushL(anni); |
|
874 CSingleContactField* bday = CSingleContactField::NewL(); |
|
875 CleanupStack::PushL(bday); |
|
876 CSingleContactField* nkname = CSingleContactField::NewL(); |
|
877 CleanupStack::PushL(nkname); |
|
878 CSingleContactField* photo = CSingleContactField::NewL(); |
|
879 CleanupStack::PushL(photo); |
|
880 CSingleContactField* xspid = CSingleContactField::NewL(); |
|
881 CleanupStack::PushL(xspid); |
|
882 |
|
883 FName->SetFieldParamsL(KFirstName,KNullDesC,KFName); |
|
884 singleContact->AddFieldToContactL(FName); |
|
885 |
|
886 prefix->SetFieldParamsL(KPrefix,KNullDesC,KPfix); |
|
887 singleContact->AddFieldToContactL(prefix); |
|
888 |
|
889 note->SetFieldParamsL(KNote,KNullDesC,KNoteVal); |
|
890 singleContact->AddFieldToContactL(note); |
|
891 |
|
892 anni->SetFieldParamsL(KAnniversary,KNullDesC,KNullDesC); |
|
893 //anni->SetDateTime(annival); |
|
894 anni->SetDateTime(TTime(TDateTime(2007,EOctober,25,0,0,0,0))); |
|
895 singleContact->AddFieldToContactL(anni); |
|
896 |
|
897 |
|
898 bday->SetFieldParamsL(KBday,KNullDesC,KNullDesC); |
|
899 //bday->SetDateTime(bdayval); |
|
900 bday->SetDateTime(TTime(TDateTime(2007,EOctober,25,0,0,0,0))); |
|
901 singleContact->AddFieldToContactL(bday); |
|
902 |
|
903 nkname->SetFieldParamsL(KNickName,KNullDesC,KNickNameVal); |
|
904 singleContact->AddFieldToContactL(nkname); |
|
905 |
|
906 photo->SetFieldParamsL(KPhoto,KNullDesC,KPhotoVal); |
|
907 singleContact->AddFieldToContactL(photo); |
|
908 |
|
909 _LIT(KYahooId,"Yahoo:kelly@yahoo.co.in"); |
|
910 //_LIT8(); |
|
911 RPointerArray<HBufC> xspidarr; |
|
912 xspidarr.Append((_L("Yahoo:kelly@yahoo.co.in")).AllocL()); |
|
913 xspidarr.Append((_L("Google:kelly@gmail.com")).AllocL()); |
|
914 xspid->SetXspidDataL(KImpp,KImppLabel,xspidarr); |
|
915 |
|
916 |
|
917 singleContact->AddFieldToContactL(xspid); |
|
918 |
|
919 // aItem.GetNextInt(count) ; |
|
920 |
|
921 /* Add the contactitem */ |
|
922 HBufC8* cntId; |
|
923 TRAPD(err,cntId= icontactservice->AddL(singleContact)); |
|
924 TPtr8 cntIdPtrVal(cntId->Des()); |
|
925 |
|
926 if(err != KErrNone) |
|
927 { |
|
928 CleanupStack::Pop(xspid); |
|
929 CleanupStack::Pop(photo); |
|
930 CleanupStack::Pop(nkname); |
|
931 CleanupStack::Pop(bday); |
|
932 CleanupStack::Pop(anni); |
|
933 CleanupStack::Pop(note); |
|
934 CleanupStack::Pop(prefix); |
|
935 CleanupStack::Pop(FName); |
|
936 CleanupStack::Pop(singleContact); |
|
937 delete singleContact; |
|
938 delete cntId; |
|
939 delete icontactservice; |
|
940 __UHEAP_MARKEND; |
|
941 return KErrGeneral ; |
|
942 } |
|
943 newFields = ETrue; |
|
944 CContactIter* iterVal; |
|
945 |
|
946 TPtr8 cntIdPtr(cntId->Des()); |
|
947 TRAPD(error, iterVal = icontactservice->GetListL(EContacts,cntIdPtr)); |
|
948 |
|
949 if(error != KErrNone) |
|
950 { |
|
951 CleanupStack::Pop(xspid); |
|
952 CleanupStack::Pop(photo); |
|
953 CleanupStack::Pop(nkname); |
|
954 CleanupStack::Pop(bday); |
|
955 CleanupStack::Pop(anni); |
|
956 CleanupStack::Pop(note); |
|
957 CleanupStack::Pop(prefix); |
|
958 CleanupStack::Pop(FName); |
|
959 CleanupStack::Pop(singleContact); |
|
960 delete singleContact; |
|
961 delete cntId; |
|
962 delete iterVal; |
|
963 _LIT( KLog1, "false case uheapmarkend 1" ); |
|
964 iLog->Log( KLog1 ); |
|
965 __UHEAP_MARKEND; |
|
966 return KErrGeneral; |
|
967 } |
|
968 iterVal->NextL(myContact,contactid); |
|
969 if(contactid) |
|
970 { |
|
971 delete contactid; |
|
972 contactid = NULL; |
|
973 } |
|
974 if(myContact) |
|
975 { |
|
976 for(TInt i=0;i<myContact->FieldCount(); i++) |
|
977 { |
|
978 CSingleContactField* field = myContact->FieldAt(i); |
|
979 field->GetFieldDataL(fieldKey,label,value); |
|
980 if(value.Compare(KValue) == 0) |
|
981 { |
|
982 CleanupStack::Pop(xspid); |
|
983 CleanupStack::Pop(photo); |
|
984 CleanupStack::Pop(nkname); |
|
985 CleanupStack::Pop(bday); |
|
986 CleanupStack::Pop(anni); |
|
987 CleanupStack::Pop(note); |
|
988 CleanupStack::Pop(prefix); |
|
989 CleanupStack::Pop(FName); |
|
990 CleanupStack::Pop(singleContact); |
|
991 delete singleContact; |
|
992 delete cntId; |
|
993 delete iterVal; |
|
994 delete myContact; |
|
995 delete icontactservice; |
|
996 _LIT( KLog2, "true case uheapmarkend" ); |
|
997 iLog->Log( KLog2 ); |
|
998 __UHEAP_MARKEND; |
|
999 return KErrNone; |
|
1000 } |
|
1001 } |
|
1002 delete myContact; |
|
1003 } |
|
1004 CleanupStack::Pop(xspid); |
|
1005 CleanupStack::Pop(photo); |
|
1006 CleanupStack::Pop(nkname); |
|
1007 CleanupStack::Pop(bday); |
|
1008 CleanupStack::Pop(anni); |
|
1009 CleanupStack::Pop(note); |
|
1010 CleanupStack::Pop(prefix); |
|
1011 CleanupStack::Pop(FName); |
|
1012 CleanupStack::Pop(singleContact); |
|
1013 delete singleContact; |
|
1014 delete cntId; |
|
1015 delete iterVal; |
|
1016 delete icontactservice; |
|
1017 _LIT( KLog3, "false case uheapmarkend" ); |
|
1018 iLog->Log( KLog3 ); |
|
1019 __UHEAP_MARKEND; |
|
1020 |
|
1021 return KErrGeneral; |
|
1022 |
|
1023 |
|
1024 |
|
1025 } |
|
523 /* get group list ,groups are there in the simdatabase |
1026 /* get group list ,groups are there in the simdatabase |
524 TInt Ctmanualcontacts::GetList_Test11L( CStifItemParser& aItem ) |
1027 TInt Ctmanualcontacts::GetList_Test11L( CStifItemParser& aItem ) |
525 { |
1028 { |
526 |
1029 |
527 // Print to UI |
1030 // Print to UI |