changeset 22 | fc9cf246af83 |
parent 19 | 989d2f495d90 |
child 33 | 50974a8b132e |
19:989d2f495d90 | 22:fc9cf246af83 |
---|---|
70 |
70 |
71 // ?comment |
71 // ?comment |
72 ?code |
72 ?code |
73 } |
73 } |
74 */ |
74 */ |
75 |
75 TInt cmdNum = 0; |
76 TInt Iterator_cnt=0; |
76 TInt Iterator_cnt=0; |
77 |
77 |
78 //HBufC8 *contactid ; |
78 //HBufC8 *contactid ; |
79 HBufC8* contactid=NULL; |
79 HBufC8* contactid=NULL; |
80 CSingleContact* myContact=NULL; |
80 CSingleContact* myContact=NULL; |
81 |
81 void CContactCallback::HandleReturnArray( const TInt& aError, RPointerArray<HBufC8>& aArray, TInt aTransId ) |
82 { |
|
83 CActiveScheduler::Stop(); |
|
84 iError= aError ; |
|
85 } |
|
82 |
86 |
83 |
87 |
84 void CContactCallback::HandleReturnValue( TOperationEvent aEventId, const TInt& aError, TInt aTransId ) |
88 void CContactCallback::HandleReturnValue( TOperationEvent aEventId, const TInt& aError, TInt aTransId ) |
85 { |
89 { |
86 |
90 |
93 void CContactCallback:: HandleReturnIter( const TInt& aError, CContactIter* aIter, TInt aTransId ) |
97 void CContactCallback:: HandleReturnIter( const TInt& aError, CContactIter* aIter, TInt aTransId ) |
94 { |
98 { |
95 |
99 |
96 |
100 |
97 CActiveScheduler::Stop(); |
101 CActiveScheduler::Stop(); |
98 CSingleContactField* field = NULL; |
102 |
99 HBufC8* buf = NULL; |
103 if(cmdNum == 10) |
100 TBuf8<100> buf1; |
104 { |
101 TBuf<100> buf2; |
105 aIter->NextL(myContact,contactid); |
102 TBuf<100> buf3; |
106 delete aIter; |
103 TInt count=0 ; |
107 if(contactid) |
104 |
108 { |
105 |
109 delete contactid; |
110 } |
|
111 return; |
|
112 } |
|
106 if(aError==KErrNone) |
113 if(aError==KErrNone) |
107 { |
114 { |
108 aIter->NextL(myContact,contactid); |
115 aIter->NextL(myContact,contactid); |
116 if(contactid) |
|
117 { |
|
118 delete contactid; |
|
119 } |
|
120 if(myContact) |
|
121 { |
|
122 delete myContact; |
|
123 } |
|
109 } |
124 } |
110 delete aIter; |
125 delete aIter; |
111 return; |
126 return; |
112 } |
127 } |
113 |
128 |
129 |
|
130 void CContactCallback:: HandleReturnId( const TInt& aError, HBufC8* acntId, TInt aTransId ) |
|
131 { |
|
132 |
|
133 /*RFs fs; |
|
134 RFile file; |
|
135 User::LeaveIfError(fs.Connect()); |
|
136 CleanupClosePushL(fs); |
|
137 TInt errfile =file.Replace(fs,_L("C:\\iter.txt"), EFileWrite | EFileStreamText); |
|
138 file.Write(_L8("\n Starting logs")); |
|
139 file.Flush(); */ |
|
140 CActiveScheduler::Stop(); |
|
141 //HBufC8* cntId = acntId; |
|
142 iError = aError; |
|
143 if(acntId == NULL) |
|
144 { |
|
145 /*file.Write(_L8("\n cntid is nul")); |
|
146 file.Flush(); */ |
|
147 iError = KErrGeneral; |
|
148 return; |
|
149 } |
|
150 if(cmdNum == 14) |
|
151 { |
|
152 CContactService* cntservice=CContactService::NewL(); |
|
153 _LIT8(KField,"FirstName"); |
|
154 _LIT(KLabel,"FirstName"); |
|
155 _LIT(KValue,"Barbie"); |
|
156 TPtrC8 fieldKey(KNullDesC8); |
|
157 TPtrC label(KNullDesC); |
|
158 TPtrC value(KNullDesC); |
|
159 //CContactCallback* callbk=new(ELeave) CContactCallback; |
|
160 TPtr8 cntIdPtrVal(acntId->Des()); |
|
161 CContactIter* iterVal; |
|
162 TRAPD(err, iterVal = cntservice->GetListL(EContacts,cntIdPtrVal)); |
|
163 if(err != KErrNone) |
|
164 { |
|
165 /*file.Write(_L8("\n err code of getlist is non zero")); |
|
166 file.Flush(); */ |
|
167 iError = KErrGeneral; |
|
168 return; |
|
169 } |
|
170 iterVal->NextL(myContact,contactid); |
|
171 if(myContact) |
|
172 { |
|
173 for(TInt i=0;i<myContact->FieldCount(); i++) |
|
174 { |
|
175 CSingleContactField* field = myContact->FieldAt(i); |
|
176 field->GetFieldDataL(fieldKey,label,value); |
|
177 if(value.Compare(KValue) == 0) |
|
178 { |
|
179 iError = KErrNone; |
|
180 break; |
|
181 } |
|
182 } |
|
183 } |
|
184 else |
|
185 { |
|
186 /*file.Write(_L8("\n no contact is got")); |
|
187 file.Flush(); */ |
|
188 iError = KErrGeneral; |
|
189 } |
|
190 delete cntservice; |
|
191 delete iterVal; |
|
192 if(myContact) |
|
193 { |
|
194 delete myContact; |
|
195 } |
|
196 if(contactid) |
|
197 { |
|
198 delete contactid; |
|
199 } |
|
200 } |
|
201 /*file.Write(_L8("\n return")); |
|
202 file.Flush(); |
|
203 |
|
204 file.Close();*/ |
|
205 delete acntId; |
|
206 } |
|
114 // ============================ MEMBER FUNCTIONS =============================== |
207 // ============================ MEMBER FUNCTIONS =============================== |
115 |
208 |
116 // ----------------------------------------------------------------------------- |
209 // ----------------------------------------------------------------------------- |
117 // Ctdeleteadd::Delete |
210 // Ctdeleteadd::Delete |
118 // Delete here all resources allocated and opened from test methods. |
211 // Delete here all resources allocated and opened from test methods. |
149 //ENTRY( "Add_Test9", Ctdeleteadd::Add_Test9L ), |
242 //ENTRY( "Add_Test9", Ctdeleteadd::Add_Test9L ), |
150 ENTRY( "Add_Test10", Ctdeleteadd::Add_Test10L ), |
243 ENTRY( "Add_Test10", Ctdeleteadd::Add_Test10L ), |
151 ENTRY( "Add_Test11", Ctdeleteadd::Add_Test11L ), |
244 ENTRY( "Add_Test11", Ctdeleteadd::Add_Test11L ), |
152 ENTRY( "Add_Test12", Ctdeleteadd::Add_Test12L ), |
245 ENTRY( "Add_Test12", Ctdeleteadd::Add_Test12L ), |
153 ENTRY( "Add_Test13", Ctdeleteadd::Add_Test13L ), |
246 ENTRY( "Add_Test13", Ctdeleteadd::Add_Test13L ), |
247 ENTRY( "Add_Test14", Ctdeleteadd::Add_Test14L ), |
|
248 ENTRY( "Add_Test15", Ctdeleteadd::Add_Test15L ), |
|
249 ENTRY( "Add_Test16", Ctdeleteadd::Add_Test16L ), |
|
250 ENTRY( "Add_Test17", Ctdeleteadd::Add_Test17L ), |
|
251 |
|
154 |
252 |
155 }; |
253 }; |
156 |
254 |
157 const TInt count = sizeof( KFunctions ) / |
255 const TInt count = sizeof( KFunctions ) / |
158 sizeof( TStifFunctionInfo ); |
256 sizeof( TStifFunctionInfo ); |
165 |
263 |
166 /* Adding single contact to default database*/ |
264 /* Adding single contact to default database*/ |
167 TInt Ctdeleteadd::Add_Test1L( CStifItemParser& aItem ) |
265 TInt Ctdeleteadd::Add_Test1L( CStifItemParser& aItem ) |
168 { |
266 { |
169 |
267 |
170 |
268 __UHEAP_MARK; |
269 icontactservice=CContactService::NewL(); |
|
270 icallback=new(ELeave) CContactCallback; |
|
171 TInt count =KErrGeneral ; |
271 TInt count =KErrGeneral ; |
172 _LIT8(KFirstName,"FirstName"); |
272 _LIT8(KFirstName,"FirstName"); |
173 _LIT(KName,"Aaaa"); |
273 _LIT(KName,"Aaaa"); |
174 //instantiate service class object |
274 //instantiate service class object |
175 |
275 |
176 /* create contactitem to add */ |
276 /* create contactitem to add */ |
177 CSingleContact* singleContact = CSingleContact::NewL(); |
277 CSingleContact* singleContact = CSingleContact::NewL(); |
278 CleanupStack::PushL(singleContact); |
|
178 CSingleContactField* singleContactField = CSingleContactField::NewL(); |
279 CSingleContactField* singleContactField = CSingleContactField::NewL(); |
280 CleanupStack::PushL(singleContactField); |
|
179 |
281 |
180 |
282 |
181 singleContactField->SetFieldParamsL(KFirstName,KNullDesC,KName); |
283 singleContactField->SetFieldParamsL(KFirstName,KNullDesC,KName); |
182 singleContact->AddFieldToContactL(singleContactField); |
284 singleContact->AddFieldToContactL(singleContactField); |
183 |
285 |
188 icontactservice->AddL(icallback,0,singleContact); |
290 icontactservice->AddL(icallback,0,singleContact); |
189 CActiveScheduler::Start(); |
291 CActiveScheduler::Start(); |
190 |
292 |
191 /* check whether add api returns the expected error code */ |
293 /* check whether add api returns the expected error code */ |
192 if(count == icallback->iError ) |
294 if(count == icallback->iError ) |
295 { |
|
296 CleanupStack::Pop(singleContactField); |
|
297 CleanupStack::Pop(singleContact); |
|
298 delete singleContact; |
|
299 delete icallback; |
|
300 delete icontactservice; |
|
301 __UHEAP_MARKEND; |
|
193 return KErrNone ; |
302 return KErrNone ; |
194 |
303 } |
304 CleanupStack::Pop(singleContactField); |
|
305 CleanupStack::Pop(singleContact); |
|
306 delete singleContact; |
|
307 delete icallback; |
|
308 delete icontactservice; |
|
309 __UHEAP_MARKEND; |
|
195 return KErrGeneral ; |
310 return KErrGeneral ; |
196 |
|
197 |
|
198 } |
311 } |
199 |
312 |
200 /* Adding contact with invalid fieldname */ |
313 /* Adding contact with invalid fieldname */ |
201 TInt Ctdeleteadd::Add_Test2L( CStifItemParser& aItem ) |
314 TInt Ctdeleteadd::Add_Test2L( CStifItemParser& aItem ) |
202 { |
315 { |
203 |
316 |
204 |
317 __UHEAP_MARK; |
318 icontactservice=CContactService::NewL(); |
|
319 icallback=new(ELeave) CContactCallback; |
|
205 TInt count =KErrGeneral ; |
320 TInt count =KErrGeneral ; |
206 _LIT8(KFirstName,"FrstName"); |
321 _LIT8(KFirstName,"FrstName"); |
207 _LIT(KName,"Aaaa"); |
322 _LIT(KName,"Aaaa"); |
208 //instantiate service class object |
323 //instantiate service class object |
209 |
324 |
210 /* create contactitem with invalid fieldname "FrstName */ |
325 /* create contactitem with invalid fieldname "FrstName */ |
211 CSingleContact* singleContact = CSingleContact::NewL(); |
326 CSingleContact* singleContact = CSingleContact::NewL(); |
327 CleanupStack::PushL(singleContact); |
|
212 CSingleContactField* singleContactField = CSingleContactField::NewL(); |
328 CSingleContactField* singleContactField = CSingleContactField::NewL(); |
329 CleanupStack::PushL(singleContactField); |
|
213 |
330 |
214 |
331 |
215 singleContactField->SetFieldParamsL(KFirstName,KNullDesC,KName); |
332 singleContactField->SetFieldParamsL(KFirstName,KNullDesC,KName); |
216 singleContact->AddFieldToContactL(singleContactField); |
333 singleContact->AddFieldToContactL(singleContactField); |
217 |
334 |
221 TRAPD(err, icontactservice->AddL(icallback,0,singleContact)) |
338 TRAPD(err, icontactservice->AddL(icallback,0,singleContact)) |
222 CActiveScheduler::Start(); |
339 CActiveScheduler::Start(); |
223 |
340 |
224 /* check whether Add api returns the expected error code */ |
341 /* check whether Add api returns the expected error code */ |
225 if(-1 == icallback->iError ) |
342 if(-1 == icallback->iError ) |
343 { |
|
344 CleanupStack::Pop(singleContactField); |
|
345 CleanupStack::Pop(singleContact); |
|
346 delete singleContact; |
|
347 delete icallback; |
|
348 delete icontactservice; |
|
349 __UHEAP_MARKEND; |
|
226 return KErrNone ; |
350 return KErrNone ; |
227 |
351 } |
352 CleanupStack::Pop(singleContactField); |
|
353 CleanupStack::Pop(singleContact); |
|
354 delete singleContact; |
|
355 delete icallback; |
|
356 delete icontactservice; |
|
357 __UHEAP_MARKEND; |
|
228 return KErrGeneral ; |
358 return KErrGeneral ; |
229 |
359 |
230 } |
360 } |
231 |
361 |
232 /* adding contact with more fields */ |
362 /* adding contact with more fields */ |
233 TInt Ctdeleteadd::Add_Test3L( CStifItemParser& aItem ) |
363 TInt Ctdeleteadd::Add_Test3L( CStifItemParser& aItem ) |
234 { |
364 { |
235 |
365 |
236 |
366 icallback=new(ELeave) CContactCallback; |
367 CSingleContact* singleContact = CSingleContact::NewL(); |
|
237 TInt count =KErrGeneral ; |
368 TInt count =KErrGeneral ; |
238 _LIT8(KFirstName,"FirstName"); |
369 _LIT8(KFirstName,"FirstName"); |
239 _LIT(KFName,"XYZ"); |
370 _LIT(KFName,"XYZ"); |
240 _LIT8(KLastName,"LastName"); |
371 _LIT8(KLastName,"LastName"); |
241 _LIT(KLName,"123"); |
372 _LIT(KLName,"123"); |
258 _LIT8(KRing,"Ringtone"); |
389 _LIT8(KRing,"Ringtone"); |
259 _LIT(KName,"C:\\data\\sounds\\digital\\around.mp3"); |
390 _LIT(KName,"C:\\data\\sounds\\digital\\around.mp3"); |
260 //instantiate service class object |
391 //instantiate service class object |
261 /* create contactitem to add */ |
392 /* create contactitem to add */ |
262 CSingleContactField* FName = CSingleContactField::NewL(); |
393 CSingleContactField* FName = CSingleContactField::NewL(); |
394 //CleanupStack::PushL(FName); |
|
263 CSingleContactField* LName = CSingleContactField::NewL(); |
395 CSingleContactField* LName = CSingleContactField::NewL(); |
396 //CleanupStack::PushL(LName); |
|
264 CSingleContactField* Pfix = CSingleContactField::NewL(); |
397 CSingleContactField* Pfix = CSingleContactField::NewL(); |
398 //CleanupStack::PushL(Pfix); |
|
265 CSingleContactField* Sfix = CSingleContactField::NewL(); |
399 CSingleContactField* Sfix = CSingleContactField::NewL(); |
400 //CleanupStack::PushL(Sfix); |
|
266 CSingleContactField* Landno = CSingleContactField::NewL(); |
401 CSingleContactField* Landno = CSingleContactField::NewL(); |
402 //CleanupStack::PushL(Landno); |
|
267 CSingleContactField* Mobno = CSingleContactField::NewL(); |
403 CSingleContactField* Mobno = CSingleContactField::NewL(); |
404 //CleanupStack::PushL(Mobno); |
|
268 CSingleContactField* Faxno = CSingleContactField::NewL(); |
405 CSingleContactField* Faxno = CSingleContactField::NewL(); |
406 //CleanupStack::PushL(Faxno); |
|
269 CSingleContactField* Note = CSingleContactField::NewL(); |
407 CSingleContactField* Note = CSingleContactField::NewL(); |
408 //CleanupStack::PushL(Note); |
|
270 CSingleContactField* Job = CSingleContactField::NewL(); |
409 CSingleContactField* Job = CSingleContactField::NewL(); |
410 //CleanupStack::PushL(Job); |
|
271 CSingleContactField* Mail = CSingleContactField::NewL(); |
411 CSingleContactField* Mail = CSingleContactField::NewL(); |
412 //CleanupStack::PushL(Mail); |
|
272 CSingleContactField* Ring = CSingleContactField::NewL(); |
413 CSingleContactField* Ring = CSingleContactField::NewL(); |
273 |
414 //CleanupStack::PushL(Ring); |
274 CSingleContact* singleContact = CSingleContact::NewL(); |
415 |
275 |
|
276 |
416 |
277 FName->SetFieldParamsL(KFirstName,KNullDesC,KFName); |
417 FName->SetFieldParamsL(KFirstName,KNullDesC,KFName); |
278 singleContact->AddFieldToContactL(FName); |
418 singleContact->AddFieldToContactL(FName); |
279 |
419 |
280 LName->SetFieldParamsL(KLastName,KNullDesC,KLName); |
420 LName->SetFieldParamsL(KLastName,KNullDesC,KLName); |
307 Ring->SetFieldParamsL(KRing,KNullDesC,KName); |
447 Ring->SetFieldParamsL(KRing,KNullDesC,KName); |
308 singleContact->AddFieldToContactL(Ring); |
448 singleContact->AddFieldToContactL(Ring); |
309 |
449 |
310 |
450 |
311 aItem.GetNextInt(count) ; |
451 aItem.GetNextInt(count) ; |
312 |
452 __UHEAP_MARK; |
453 icontactservice=CContactService::NewL(); |
|
454 CSingleContact* singleContact1 = CSingleContact::NewL(); |
|
455 CleanupStack::PushL(singleContact1); |
|
456 CSingleContactField* FName1 = CSingleContactField::NewL(); |
|
457 CleanupStack::PushL(FName1); |
|
458 FName1->SetFieldParamsL(KFirstName,KNullDesC,KFName); |
|
459 singleContact1->AddFieldToContactL(FName1); |
|
313 /* Add the contactitem */ |
460 /* Add the contactitem */ |
314 icontactservice->AddL(icallback,0,singleContact); |
461 icontactservice->AddL(icallback,0,singleContact); |
315 CActiveScheduler::Start(); |
462 CActiveScheduler::Start(); |
316 |
463 CleanupStack::Pop(FName1); |
464 CleanupStack::Pop(singleContact1); |
|
465 delete singleContact1; |
|
466 delete icontactservice; |
|
467 |
|
317 TPtrC String; |
468 TPtrC String; |
318 |
469 |
319 // TPtrC db1(_L("cntdb://c:testcontacts2.cdb")); |
470 // TPtrC db1(_L("cntdb://c:testcontacts2.cdb")); |
320 |
471 |
321 /* get the filename for export */ |
472 /* get the filename for export */ |
322 if(aItem.GetNextString(String) != KErrNone ) |
473 if(aItem.GetNextString(String) != KErrNone ) |
323 { |
474 { |
324 _LIT(Kerr ,"Failed to read input file name") ; |
475 _LIT(Kerr ,"Failed to read input file name") ; |
325 iLog->Log(Kerr) ; |
476 iLog->Log(Kerr) ; |
477 |
|
478 //CleanupStack::Pop(11); |
|
479 //CleanupStack::Pop(singleContact); |
|
480 //delete singleContact; |
|
481 //delete singleContact; |
|
482 /*delete FName; |
|
483 delete LName; |
|
484 delete Pfix; |
|
485 delete Sfix; |
|
486 delete Landno; |
|
487 delete Mobno; |
|
488 delete Faxno; |
|
489 delete Note; |
|
490 delete Job; |
|
491 delete Mail; |
|
492 delete singleContact; |
|
493 delete icallback; |
|
494 delete icontactservice; |
|
495 __UHEAP_MARKEND;*/ |
|
326 return KErrGeneral ; |
496 return KErrGeneral ; |
327 } |
497 } |
328 |
498 |
329 TBuf<256> string1; |
499 /* TBuf<256> string1; |
330 string1.Copy(String); |
500 string1.Copy(String); |
331 |
501 |
332 icontactservice->GetListL(icallback,1,EContacts,KNullDesC8) ; |
502 icontactservice->GetListL(icallback,1,EContacts,KNullDesC8) ; |
333 CActiveScheduler::Start(); |
503 CActiveScheduler::Start(); |
334 |
504 |
335 |
505 |
336 icontactservice->ExportVCardL(icallback,2,string1,*contactid); |
506 icontactservice->ExportVCardL(icallback,2,string1,*contactid); |
337 CActiveScheduler::Start(); |
507 CActiveScheduler::Start(); |
338 |
508 |
339 |
509 */ |
340 |
510 |
341 /* check whether add api returns the expected error code */ |
511 /* check whether add api returns the expected error code */ |
342 if(count == icallback->iError ) |
512 if(count == icallback->iError ) |
513 { |
|
514 delete icallback; |
|
515 __UHEAP_MARKEND; |
|
343 return KErrNone ; |
516 return KErrNone ; |
344 |
517 } |
345 return KErrGeneral ; |
518 delete icallback; |
519 __UHEAP_MARKEND; |
|
520 return KErrGeneral ; |
|
346 |
521 |
347 |
522 |
348 } |
523 } |
349 |
524 |
350 |
525 |
351 /* Adding a group */ |
526 /* Adding a group */ |
352 TInt Ctdeleteadd::Add_Test4L( CStifItemParser& aItem ) |
527 TInt Ctdeleteadd::Add_Test4L( CStifItemParser& aItem ) |
353 { |
528 { |
354 |
529 __UHEAP_MARK; |
530 icontactservice=CContactService::NewL(); |
|
531 icallback=new(ELeave) CContactCallback; |
|
355 // Print to UI |
532 // Print to UI |
356 _LIT( Ktsapicontacts, "tsapicontacts" ); |
533 _LIT( Ktsapicontacts, "tsapicontacts" ); |
357 _LIT( KExample, "In GetList_Test1L" ); |
534 _LIT( KExample, "In GetList_Test1L" ); |
358 TestModuleIf().Printf( 0, Ktsapicontacts, KExample ); |
535 TestModuleIf().Printf( 0, Ktsapicontacts, KExample ); |
359 // Print to log file |
536 // Print to log file |
371 icontactservice->AddL(icallback,0,NULL,KNullDesC8,KGroup); |
548 icontactservice->AddL(icallback,0,NULL,KNullDesC8,KGroup); |
372 CActiveScheduler::Start(); |
549 CActiveScheduler::Start(); |
373 |
550 |
374 /* check whether add api returns the expected error code */ |
551 /* check whether add api returns the expected error code */ |
375 if(count == icallback->iError ) |
552 if(count == icallback->iError ) |
553 { |
|
554 delete icallback; |
|
555 delete icontactservice; |
|
556 __UHEAP_MARKEND; |
|
376 return KErrNone ; |
557 return KErrNone ; |
377 |
558 } |
559 delete icallback; |
|
560 delete icontactservice; |
|
561 __UHEAP_MARKEND; |
|
378 return KErrGeneral ; |
562 return KErrGeneral ; |
379 |
563 |
380 } |
564 } |
381 |
565 |
382 |
566 |
383 |
567 |
384 |
568 |
385 /* Adding the same group name twice */ |
569 /* Adding the same group name twice */ |
386 TInt Ctdeleteadd::Add_Test5L( CStifItemParser& aItem ) |
570 TInt Ctdeleteadd::Add_Test5L( CStifItemParser& aItem ) |
387 { |
571 { |
388 |
572 __UHEAP_MARK; |
573 icontactservice=CContactService::NewL(); |
|
574 icallback=new(ELeave) CContactCallback; |
|
389 // Print to UI |
575 // Print to UI |
390 _LIT( Ktsapicontacts, "tsapicontacts" ); |
576 _LIT( Ktsapicontacts, "tsapicontacts" ); |
391 _LIT( KExample, "In GetList_Test1L" ); |
577 _LIT( KExample, "In GetList_Test1L" ); |
392 TestModuleIf().Printf( 0, Ktsapicontacts, KExample ); |
578 TestModuleIf().Printf( 0, Ktsapicontacts, KExample ); |
393 // Print to log file |
579 // Print to log file |
409 icontactservice->AddL(icallback,0,NULL,KNullDesC8,KGroup); |
595 icontactservice->AddL(icallback,0,NULL,KNullDesC8,KGroup); |
410 CActiveScheduler::Start(); |
596 CActiveScheduler::Start(); |
411 |
597 |
412 /* check whether add api returns the expected error code */ |
598 /* check whether add api returns the expected error code */ |
413 if(count == icallback->iError ) |
599 if(count == icallback->iError ) |
414 return KErrNone ; |
600 { |
415 |
601 delete icallback; |
602 delete icontactservice; |
|
603 __UHEAP_MARKEND; |
|
604 return KErrNone ; |
|
605 } |
|
606 delete icallback; |
|
607 delete icontactservice; |
|
608 __UHEAP_MARKEND; |
|
416 return KErrGeneral ; |
609 return KErrGeneral ; |
417 |
610 |
418 } |
611 } |
419 |
612 |
420 /* Adding same contact twice to default database*/ |
613 /* Adding same contact twice to default database*/ |
421 TInt Ctdeleteadd::Add_Test6L( CStifItemParser& aItem ) |
614 TInt Ctdeleteadd::Add_Test6L( CStifItemParser& aItem ) |
422 { |
615 { |
423 |
616 |
424 |
617 __UHEAP_MARK; |
618 icontactservice=CContactService::NewL(); |
|
619 icallback=new(ELeave) CContactCallback; |
|
425 TInt count =KErrGeneral ; |
620 TInt count =KErrGeneral ; |
426 _LIT8(KFirstName,"FirstName"); |
621 _LIT8(KFirstName,"FirstName"); |
427 _LIT(KName,"Aaaa"); |
622 _LIT(KName,"Aaaa"); |
428 //instantiate service class object |
623 //instantiate service class object |
429 |
624 |
430 /* create contactitem to add */ |
625 /* create contactitem to add */ |
431 CSingleContact* singleContact = CSingleContact::NewL(); |
626 CSingleContact* singleContact = CSingleContact::NewL(); |
627 CleanupStack::PushL(singleContact); |
|
432 CSingleContactField* singleContactField = CSingleContactField::NewL(); |
628 CSingleContactField* singleContactField = CSingleContactField::NewL(); |
629 CleanupStack::PushL(singleContactField); |
|
433 |
630 |
434 |
631 |
435 singleContactField->SetFieldParamsL(KFirstName,KNullDesC,KName); |
632 singleContactField->SetFieldParamsL(KFirstName,KNullDesC,KName); |
436 singleContact->AddFieldToContactL(singleContactField); |
633 singleContact->AddFieldToContactL(singleContactField); |
437 |
634 |
445 icontactservice->AddL(icallback,0,singleContact); |
642 icontactservice->AddL(icallback,0,singleContact); |
446 CActiveScheduler::Start(); |
643 CActiveScheduler::Start(); |
447 |
644 |
448 /* check whether add api returns the expected error code */ |
645 /* check whether add api returns the expected error code */ |
449 if(count == icallback->iError ) |
646 if(count == icallback->iError ) |
647 { |
|
648 CleanupStack::Pop(singleContactField); |
|
649 CleanupStack::Pop(singleContact); |
|
650 delete singleContact; |
|
651 delete icallback; |
|
652 delete icontactservice; |
|
653 __UHEAP_MARKEND; |
|
450 return KErrNone ; |
654 return KErrNone ; |
451 |
655 } |
656 CleanupStack::Pop(singleContactField); |
|
657 CleanupStack::Pop(singleContact); |
|
658 delete singleContact; |
|
659 delete icallback; |
|
660 delete icontactservice; |
|
661 __UHEAP_MARKEND; |
|
452 return KErrGeneral ; |
662 return KErrGeneral ; |
453 |
663 |
454 |
664 |
455 } |
665 } |
456 |
666 |
457 // same contact twice to different database |
667 // same contact twice to different database |
458 TInt Ctdeleteadd::Add_Test7L( CStifItemParser& aItem ) |
668 TInt Ctdeleteadd::Add_Test7L( CStifItemParser& aItem ) |
459 { |
669 { |
460 |
670 __UHEAP_MARK; |
671 icontactservice=CContactService::NewL(); |
|
672 icallback=new(ELeave) CContactCallback; |
|
461 _LIT(KCntDbUri, "cntdb://c:contacts.cdb"); |
673 _LIT(KCntDbUri, "cntdb://c:contacts.cdb"); |
462 TInt count =KErrGeneral ; |
674 TInt count =KErrGeneral ; |
463 _LIT8(KFirstName,"FirstName"); |
675 _LIT8(KFirstName,"FirstName"); |
464 _LIT(KName,"Aaaa"); |
676 _LIT(KName,"Aaaa"); |
465 //instantiate service class object |
677 //instantiate service class object |
466 |
678 |
467 /* create contactitem to add */ |
679 /* create contactitem to add */ |
468 CSingleContact* singleContact = CSingleContact::NewL(); |
680 CSingleContact* singleContact = CSingleContact::NewL(); |
681 CleanupStack::PushL(singleContact); |
|
469 CSingleContactField* singleContactField = CSingleContactField::NewL(); |
682 CSingleContactField* singleContactField = CSingleContactField::NewL(); |
683 CleanupStack::PushL(singleContactField); |
|
470 |
684 |
471 |
685 |
472 singleContactField->SetFieldParamsL(KFirstName,KNullDesC,KName); |
686 singleContactField->SetFieldParamsL(KFirstName,KNullDesC,KName); |
473 singleContact->AddFieldToContactL(singleContactField); |
687 singleContact->AddFieldToContactL(singleContactField); |
474 |
688 |
482 icontactservice->AddL(icallback,0,singleContact,KNullDesC8,KNullDesC,KCntDbUri); |
696 icontactservice->AddL(icallback,0,singleContact,KNullDesC8,KNullDesC,KCntDbUri); |
483 CActiveScheduler::Start(); |
697 CActiveScheduler::Start(); |
484 |
698 |
485 /* check whether add api returns the expected error code */ |
699 /* check whether add api returns the expected error code */ |
486 if(count == icallback->iError ) |
700 if(count == icallback->iError ) |
701 { |
|
702 CleanupStack::Pop(singleContactField); |
|
703 CleanupStack::Pop(singleContact); |
|
704 delete singleContact; |
|
705 delete icallback; |
|
706 delete icontactservice; |
|
707 __UHEAP_MARKEND; |
|
487 return KErrNone ; |
708 return KErrNone ; |
488 |
709 } |
710 |
|
711 CleanupStack::Pop(singleContactField); |
|
712 CleanupStack::Pop(singleContact); |
|
713 delete singleContact; |
|
714 delete icallback; |
|
715 delete icontactservice; |
|
716 __UHEAP_MARKEND; |
|
489 return KErrGeneral ; |
717 return KErrGeneral ; |
490 |
718 |
491 |
719 |
492 } |
720 } |
493 |
721 |
494 /* Adding single contact to default database with the same key and different label*/ |
722 /* Adding single contact to default database with the same key and different label*/ |
495 |
723 |
496 TInt Ctdeleteadd::Add_Test8L( CStifItemParser& aItem ) |
724 TInt Ctdeleteadd::Add_Test8L( CStifItemParser& aItem ) |
497 { |
725 { |
498 |
726 __UHEAP_MARK; |
499 |
727 icontactservice=CContactService::NewL(); |
728 icallback=new(ELeave) CContactCallback; |
|
500 TInt count =KErrGeneral ; |
729 TInt count =KErrGeneral ; |
501 |
730 |
502 _LIT8(KLandline,"LandPhoneHome"); |
731 _LIT8(KLandline,"LandPhoneHome"); |
503 _LIT8(Anni,"Anniversary"); |
732 _LIT8(Anni,"Anniversary"); |
504 _LIT(KLandno1,"08216666"); |
733 _LIT(KLandno1,"08216666"); |
508 _LIT(Land2,"no.2"); |
737 _LIT(Land2,"no.2"); |
509 //instantiate service class object |
738 //instantiate service class object |
510 |
739 |
511 /* create contactitem to add */ |
740 /* create contactitem to add */ |
512 CSingleContact* singleContact = CSingleContact::NewL(); |
741 CSingleContact* singleContact = CSingleContact::NewL(); |
742 CleanupStack::PushL(singleContact); |
|
513 CSingleContactField* singleContactField1 = CSingleContactField::NewL(); |
743 CSingleContactField* singleContactField1 = CSingleContactField::NewL(); |
744 CleanupStack::PushL(singleContactField1); |
|
514 CSingleContactField* singleContactField2 = CSingleContactField::NewL(); |
745 CSingleContactField* singleContactField2 = CSingleContactField::NewL(); |
746 CleanupStack::PushL(singleContactField2); |
|
515 |
747 |
516 singleContactField1->SetFieldParamsL(KLandline,Land1,KLandno1); |
748 singleContactField1->SetFieldParamsL(KLandline,Land1,KLandno1); |
517 singleContactField2->SetFieldParamsL(KLandline,Land2,KLandno2); |
749 singleContactField2->SetFieldParamsL(KLandline,Land2,KLandno2); |
518 singleContact->AddFieldToContactL(singleContactField1); |
750 singleContact->AddFieldToContactL(singleContactField1); |
519 singleContact->AddFieldToContactL(singleContactField2); |
751 singleContact->AddFieldToContactL(singleContactField2); |
520 |
752 |
521 CSingleContactField* singleContactField3 = CSingleContactField::NewL(); |
753 CSingleContactField* singleContactField3 = CSingleContactField::NewL(); |
754 CleanupStack::PushL(singleContactField3); |
|
522 CSingleContactField* singleContactField4 = CSingleContactField::NewL(); |
755 CSingleContactField* singleContactField4 = CSingleContactField::NewL(); |
756 CleanupStack::PushL(singleContactField4); |
|
523 |
757 |
524 singleContactField3->SetFieldParamsL(KLandline,Land1,KLandno1); |
758 singleContactField3->SetFieldParamsL(KLandline,Land1,KLandno1); |
525 singleContactField4->SetFieldParamsL(KLandline,Land2,KLandno2); |
759 singleContactField4->SetFieldParamsL(KLandline,Land2,KLandno2); |
526 singleContact->AddFieldToContactL(singleContactField1); |
760 singleContact->AddFieldToContactL(singleContactField3); |
527 singleContact->AddFieldToContactL(singleContactField2); |
761 singleContact->AddFieldToContactL(singleContactField4); |
528 aItem.GetNextInt(count) ; |
762 aItem.GetNextInt(count) ; |
529 |
763 |
530 /* Add the contactitem */ |
764 /* Add the contactitem */ |
531 icontactservice->AddL(icallback,0,singleContact); |
765 icontactservice->AddL(icallback,0,singleContact); |
532 CActiveScheduler::Start(); |
766 CActiveScheduler::Start(); |
533 |
767 |
534 /* check whether add api returns the expected error code */ |
768 /* check whether add api returns the expected error code */ |
535 if(count == icallback->iError ) |
769 if(count == icallback->iError ) |
770 { |
|
771 |
|
772 CleanupStack::Pop(4); |
|
773 CleanupStack::Pop(singleContact); |
|
774 delete singleContact; |
|
775 delete icallback; |
|
776 delete icontactservice; |
|
777 __UHEAP_MARKEND; |
|
536 return KErrNone ; |
778 return KErrNone ; |
537 |
779 } |
780 |
|
781 CleanupStack::Pop(4); |
|
782 CleanupStack::Pop(singleContact); |
|
783 delete singleContact; |
|
784 delete icallback; |
|
785 delete icontactservice; |
|
786 __UHEAP_MARKEND; |
|
538 return KErrGeneral ; |
787 return KErrGeneral ; |
539 |
788 |
540 |
789 |
541 } |
790 } |
542 |
791 |
576 |
825 |
577 |
826 |
578 /* Adding single contact to default database using contactid*/ |
827 /* Adding single contact to default database using contactid*/ |
579 TInt Ctdeleteadd::Add_Test10L( CStifItemParser& aItem ) |
828 TInt Ctdeleteadd::Add_Test10L( CStifItemParser& aItem ) |
580 { |
829 { |
581 |
830 __UHEAP_MARK; |
831 cmdNum =10; |
|
832 icontactservice=CContactService::NewL(); |
|
833 icallback=new(ELeave) CContactCallback; |
|
582 _LIT(KCntDbUri, "cntdb://c:contacts.cdb"); |
834 _LIT(KCntDbUri, "cntdb://c:contacts.cdb"); |
583 _LIT(KCntDbUri1, "cntdb://c:singlecontacts.cdb"); |
835 _LIT(KCntDbUri1, "cntdb://c:singlecontacts.cdb"); |
584 TInt count =KErrGeneral ; |
836 TInt count =KErrGeneral ; |
585 _LIT8(KFirstName,"FirstName"); |
837 _LIT8(KFirstName,"FirstName"); |
586 _LIT(KName,"Aaaa"); |
838 _LIT(KName,"Aaaa"); |
587 //instantiate service class object |
839 //instantiate service class object |
588 |
840 |
589 /* create contactitem to add */ |
841 /* create contactitem to add */ |
590 CSingleContact* singleContact = CSingleContact::NewL(); |
842 CSingleContact* singleContact = CSingleContact::NewL(); |
843 CleanupStack::PushL(singleContact); |
|
591 CSingleContactField* singleContactField = CSingleContactField::NewL(); |
844 CSingleContactField* singleContactField = CSingleContactField::NewL(); |
845 CleanupStack::PushL(singleContactField); |
|
592 |
846 |
593 |
847 |
594 singleContactField->SetFieldParamsL(KFirstName,KNullDesC,KName); |
848 singleContactField->SetFieldParamsL(KFirstName,KNullDesC,KName); |
595 singleContact->AddFieldToContactL(singleContactField); |
849 singleContact->AddFieldToContactL(singleContactField); |
596 |
850 |
603 |
857 |
604 TPtrC searchval(_L("Aaaa")); |
858 TPtrC searchval(_L("Aaaa")); |
605 |
859 |
606 TBuf8<15> fstname(_L8("FirstName")); |
860 TBuf8<15> fstname(_L8("FirstName")); |
607 CSearchFields *srchfield =CSearchFields :: NewL(icontactservice); |
861 CSearchFields *srchfield =CSearchFields :: NewL(icontactservice); |
608 |
862 //CleanupStack::PushL(srchfield); |
609 |
863 |
610 srchfield->AppendL(fstname); |
864 srchfield->AppendL(fstname); |
611 iLog->Log(_L("Calling GetList")); |
865 iLog->Log(_L("Calling GetList")); |
612 icontactservice->GetListL(icallback,0,EContacts,KNullDesC8,searchval,srchfield,EAsc,KCntDbUri); |
866 icontactservice->GetListL(icallback,0,EContacts,KNullDesC8,searchval,srchfield,EAsc,KCntDbUri); |
613 CActiveScheduler::Start(); |
867 CActiveScheduler::Start(); |
630 |
884 |
631 TRAP(err1,icontactservice->AddL(icallback,0,myContact,KNullDesC8,KNullDesC,KCntDbUri1)); |
885 TRAP(err1,icontactservice->AddL(icallback,0,myContact,KNullDesC8,KNullDesC,KCntDbUri1)); |
632 if(err1!=0 ) |
886 if(err1!=0 ) |
633 { |
887 { |
634 iLog->Log(_L("Error returned while calling add")); |
888 iLog->Log(_L("Error returned while calling add")); |
889 //CleanupStack::Pop(srchfield); |
|
890 CleanupStack::Pop(singleContactField); |
|
891 CleanupStack::Pop(singleContact); |
|
892 delete singleContact; |
|
893 delete icallback; |
|
894 delete icontactservice; |
|
895 delete myContact; |
|
896 //delete srchfield; |
|
897 __UHEAP_MARKEND; |
|
635 return KErrNone ; |
898 return KErrNone ; |
636 } |
899 } |
637 |
900 |
638 iLog->Log(_L("Starting Schudular")); |
901 iLog->Log(_L("Starting Scheuduler")); |
639 CActiveScheduler::Start(); |
902 CActiveScheduler::Start(); |
640 iLog->Log(_L("Error %d\n"),icallback->iError); |
903 iLog->Log(_L("Error %d\n"),icallback->iError); |
641 iLog->Log(_L("Add successful")); |
904 iLog->Log(_L("Add successful")); |
642 |
905 |
643 |
906 |
644 if(count == icallback->iError ) |
907 if(count == icallback->iError ) |
908 { |
|
909 //CleanupStack::Pop(srchfield); |
|
910 CleanupStack::Pop(singleContactField); |
|
911 CleanupStack::Pop(singleContact); |
|
912 delete singleContact; |
|
913 delete icallback; |
|
914 delete icontactservice; |
|
915 delete myContact; |
|
916 //delete srchfield; |
|
917 __UHEAP_MARKEND; |
|
645 return KErrNone ; |
918 return KErrNone ; |
646 |
919 } |
920 //CleanupStack::Pop(srchfield); |
|
921 CleanupStack::Pop(singleContactField); |
|
922 CleanupStack::Pop(singleContact); |
|
923 delete singleContact; |
|
924 delete icallback; |
|
925 delete icontactservice; |
|
926 delete myContact; |
|
927 //delete srchfield; |
|
928 __UHEAP_MARKEND; |
|
647 return KErrGeneral ; |
929 return KErrGeneral ; |
648 |
930 |
649 |
931 |
650 } |
932 } |
651 |
933 |
652 /* Adding a group and contact together*/ |
934 /* Adding a group and contact together*/ |
653 TInt Ctdeleteadd::Add_Test11L( CStifItemParser& aItem ) |
935 TInt Ctdeleteadd::Add_Test11L( CStifItemParser& aItem ) |
654 { |
936 { |
655 |
937 __UHEAP_MARK; |
938 icontactservice=CContactService::NewL(); |
|
939 icallback=new(ELeave) CContactCallback; |
|
656 // Print to UI |
940 // Print to UI |
657 _LIT( Ktsapicontacts, "tsapicontacts" ); |
941 _LIT( Ktsapicontacts, "tsapicontacts" ); |
658 _LIT( KExample, "In GetList_Test1L" ); |
942 _LIT( KExample, "In GetList_Test1L" ); |
659 TestModuleIf().Printf( 0, Ktsapicontacts, KExample ); |
943 TestModuleIf().Printf( 0, Ktsapicontacts, KExample ); |
660 // Print to log file |
944 // Print to log file |
670 _LIT(KName,"Aaaa"); |
954 _LIT(KName,"Aaaa"); |
671 //instantiate service class object |
955 //instantiate service class object |
672 |
956 |
673 /* create contactitem to add */ |
957 /* create contactitem to add */ |
674 CSingleContact* singleContact = CSingleContact::NewL(); |
958 CSingleContact* singleContact = CSingleContact::NewL(); |
959 CleanupStack::PushL(singleContact); |
|
675 CSingleContactField* singleContactField = CSingleContactField::NewL(); |
960 CSingleContactField* singleContactField = CSingleContactField::NewL(); |
961 CleanupStack::PushL(singleContactField); |
|
676 |
962 |
677 |
963 |
678 singleContactField->SetFieldParamsL(KFirstName,KNullDesC,KName); |
964 singleContactField->SetFieldParamsL(KFirstName,KNullDesC,KName); |
679 singleContact->AddFieldToContactL(singleContactField); |
965 singleContact->AddFieldToContactL(singleContactField); |
680 |
966 |
682 |
968 |
683 /*Add group1 to phonebook */ |
969 /*Add group1 to phonebook */ |
684 TInt err1; |
970 TInt err1; |
685 TRAPD(err,icontactservice->AddL(icallback,0,singleContact,KNullDesC8,KGroup)); |
971 TRAPD(err,icontactservice->AddL(icallback,0,singleContact,KNullDesC8,KGroup)); |
686 if(err || err1) |
972 if(err || err1) |
973 { |
|
974 CleanupStack::Pop(singleContactField); |
|
975 CleanupStack::Pop(singleContact); |
|
976 delete singleContact; |
|
977 delete icallback; |
|
978 delete icontactservice; |
|
979 __UHEAP_MARKEND; |
|
687 return KErrNone; |
980 return KErrNone; |
981 } |
|
688 CActiveScheduler::Start(); |
982 CActiveScheduler::Start(); |
689 |
983 |
690 /* check whether add api returns the expected error code */ |
984 /* check whether add api returns the expected error code */ |
691 if(count == icallback->iError ) |
985 if(count == icallback->iError ) |
692 return KErrNone ; |
986 { |
693 |
987 CleanupStack::Pop(singleContactField); |
988 CleanupStack::Pop(singleContact); |
|
989 delete singleContact; |
|
990 delete icallback; |
|
991 delete icontactservice; |
|
992 __UHEAP_MARKEND; |
|
993 return KErrNone ; |
|
994 } |
|
995 CleanupStack::Pop(singleContactField); |
|
996 CleanupStack::Pop(singleContact); |
|
997 delete singleContact; |
|
998 delete icallback; |
|
999 delete icontactservice; |
|
1000 __UHEAP_MARKEND; |
|
694 return KErrGeneral ; |
1001 return KErrGeneral ; |
695 |
1002 |
696 } |
1003 } |
697 |
1004 |
698 |
1005 |
699 /* Adding single contact to virtual database with the same key and different label*/ |
1006 /* Adding single contact to virtual database with the same key and different label*/ |
700 |
1007 |
701 TInt Ctdeleteadd::Add_Test12L( CStifItemParser& aItem ) |
1008 TInt Ctdeleteadd::Add_Test12L( CStifItemParser& aItem ) |
702 { |
1009 { |
703 |
1010 __UHEAP_MARK; |
704 |
1011 icontactservice=CContactService::NewL(); |
1012 icallback=new(ELeave) CContactCallback; |
|
705 TInt count =KErrGeneral ; |
1013 TInt count =KErrGeneral ; |
706 _LIT(KCntDbUri, "cntdb://c:contacts.cdb"); |
1014 _LIT(KCntDbUri, "cntdb://c:contacts.cdb"); |
707 _LIT8(KLandline,"LandPhoneHome"); |
1015 _LIT8(KLandline,"LandPhoneHome"); |
708 _LIT8(Anni,"Anniversary"); |
1016 _LIT8(Anni,"Anniversary"); |
709 _LIT(KLandno1,"08216666"); |
1017 _LIT(KLandno1,"08216666"); |
713 _LIT(Land2,"no.2"); |
1021 _LIT(Land2,"no.2"); |
714 //instantiate service class object |
1022 //instantiate service class object |
715 |
1023 |
716 /* create contactitem to add */ |
1024 /* create contactitem to add */ |
717 CSingleContact* singleContact = CSingleContact::NewL(); |
1025 CSingleContact* singleContact = CSingleContact::NewL(); |
1026 CleanupStack::PushL(singleContact); |
|
718 CSingleContactField* singleContactField1 = CSingleContactField::NewL(); |
1027 CSingleContactField* singleContactField1 = CSingleContactField::NewL(); |
1028 CleanupStack::PushL(singleContactField1); |
|
719 CSingleContactField* singleContactField2 = CSingleContactField::NewL(); |
1029 CSingleContactField* singleContactField2 = CSingleContactField::NewL(); |
1030 CleanupStack::PushL(singleContactField2); |
|
720 |
1031 |
721 singleContactField1->SetFieldParamsL(KLandline,Land1,KLandno1); |
1032 singleContactField1->SetFieldParamsL(KLandline,Land1,KLandno1); |
722 singleContactField2->SetFieldParamsL(KLandline,Land2,KLandno2); |
1033 singleContactField2->SetFieldParamsL(KLandline,Land2,KLandno2); |
723 singleContact->AddFieldToContactL(singleContactField1); |
1034 singleContact->AddFieldToContactL(singleContactField1); |
724 singleContact->AddFieldToContactL(singleContactField2); |
1035 singleContact->AddFieldToContactL(singleContactField2); |
725 |
1036 |
726 CSingleContactField* singleContactField3 = CSingleContactField::NewL(); |
1037 CSingleContactField* singleContactField3 = CSingleContactField::NewL(); |
1038 CleanupStack::PushL(singleContactField3); |
|
727 CSingleContactField* singleContactField4 = CSingleContactField::NewL(); |
1039 CSingleContactField* singleContactField4 = CSingleContactField::NewL(); |
1040 CleanupStack::PushL(singleContactField4); |
|
728 |
1041 |
729 singleContactField3->SetFieldParamsL(KLandline,Land1,KLandno1); |
1042 singleContactField3->SetFieldParamsL(KLandline,Land1,KLandno1); |
730 singleContactField4->SetFieldParamsL(KLandline,Land2,KLandno2); |
1043 singleContactField4->SetFieldParamsL(KLandline,Land2,KLandno2); |
731 singleContact->AddFieldToContactL(singleContactField1); |
1044 singleContact->AddFieldToContactL(singleContactField3); |
732 singleContact->AddFieldToContactL(singleContactField2); |
1045 singleContact->AddFieldToContactL(singleContactField4); |
733 aItem.GetNextInt(count) ; |
1046 aItem.GetNextInt(count) ; |
734 |
1047 |
735 /* Add the contactitem */ |
1048 /* Add the contactitem */ |
736 icontactservice->AddL(icallback,0,singleContact,KNullDesC8,KNullDesC,KCntDbUri); |
1049 icontactservice->AddL(icallback,0,singleContact,KNullDesC8,KNullDesC,KCntDbUri); |
737 CActiveScheduler::Start(); |
1050 CActiveScheduler::Start(); |
738 |
1051 |
739 /* check whether add api returns the expected error code */ |
1052 /* check whether add api returns the expected error code */ |
740 if(count == icallback->iError ) |
1053 if(count == icallback->iError ) |
1054 { |
|
1055 CleanupStack::Pop(singleContactField4); |
|
1056 CleanupStack::Pop(singleContactField3); |
|
1057 CleanupStack::Pop(singleContactField2); |
|
1058 CleanupStack::Pop(singleContactField1); |
|
1059 CleanupStack::Pop(singleContact); |
|
1060 delete singleContact; |
|
1061 delete icallback; |
|
1062 delete icontactservice; |
|
1063 __UHEAP_MARKEND; |
|
741 return KErrNone ; |
1064 return KErrNone ; |
742 |
1065 } |
1066 CleanupStack::Pop(singleContactField4); |
|
1067 CleanupStack::Pop(singleContactField3); |
|
1068 CleanupStack::Pop(singleContactField2); |
|
1069 CleanupStack::Pop(singleContactField1); |
|
1070 CleanupStack::Pop(singleContact); |
|
1071 delete singleContact; |
|
1072 delete icallback; |
|
1073 delete icontactservice; |
|
1074 __UHEAP_MARKEND; |
|
743 return KErrGeneral ; |
1075 return KErrGeneral ; |
744 |
1076 |
745 |
1077 |
746 } |
1078 } |
747 |
1079 |
749 /* Adding single contact to virtual database with the same key and same label*/ |
1081 /* Adding single contact to virtual database with the same key and same label*/ |
750 |
1082 |
751 TInt Ctdeleteadd::Add_Test13L( CStifItemParser& aItem ) |
1083 TInt Ctdeleteadd::Add_Test13L( CStifItemParser& aItem ) |
752 { |
1084 { |
753 |
1085 |
754 |
1086 __UHEAP_MARK; |
1087 icontactservice=CContactService::NewL(); |
|
1088 icallback=new(ELeave) CContactCallback; |
|
755 TInt count =KErrGeneral ; |
1089 TInt count =KErrGeneral ; |
756 _LIT(KCntDbUri, "cntdb://c:contacts.cdb"); |
1090 _LIT(KCntDbUri, "cntdb://c:contacts.cdb"); |
757 _LIT8(KLandline,"LandPhoneHome"); |
1091 _LIT8(KLandline,"LandPhoneHome"); |
758 _LIT8(Anni,"Anniversary"); |
1092 _LIT8(Anni,"Anniversary"); |
759 _LIT(KLandno1,"abc"); |
1093 _LIT(KLandno1,"abc"); |
763 _LIT(Land2,"no.2"); |
1097 _LIT(Land2,"no.2"); |
764 //instantiate service class object |
1098 //instantiate service class object |
765 |
1099 |
766 /* create contactitem to add */ |
1100 /* create contactitem to add */ |
767 CSingleContact* singleContact = CSingleContact::NewL(); |
1101 CSingleContact* singleContact = CSingleContact::NewL(); |
1102 CleanupStack::PushL(singleContact); |
|
768 CSingleContactField* singleContactField1 = CSingleContactField::NewL(); |
1103 CSingleContactField* singleContactField1 = CSingleContactField::NewL(); |
1104 CleanupStack::PushL(singleContactField1); |
|
769 CSingleContactField* singleContactField2 = CSingleContactField::NewL(); |
1105 CSingleContactField* singleContactField2 = CSingleContactField::NewL(); |
1106 CleanupStack::PushL(singleContactField2); |
|
770 |
1107 |
771 singleContactField1->SetFieldParamsL(KLandline,Land1,KLandno1); |
1108 singleContactField1->SetFieldParamsL(KLandline,Land1,KLandno1); |
772 singleContactField2->SetFieldParamsL(KLandline,Land1,KLandno2); |
1109 singleContactField2->SetFieldParamsL(KLandline,Land1,KLandno2); |
773 singleContact->AddFieldToContactL(singleContactField1); |
1110 singleContact->AddFieldToContactL(singleContactField1); |
774 singleContact->AddFieldToContactL(singleContactField2); |
1111 singleContact->AddFieldToContactL(singleContactField2); |
775 |
1112 |
776 CSingleContactField* singleContactField3 = CSingleContactField::NewL(); |
1113 CSingleContactField* singleContactField3 = CSingleContactField::NewL(); |
1114 CleanupStack::PushL(singleContactField3); |
|
777 CSingleContactField* singleContactField4 = CSingleContactField::NewL(); |
1115 CSingleContactField* singleContactField4 = CSingleContactField::NewL(); |
1116 CleanupStack::PushL(singleContactField4); |
|
778 |
1117 |
779 singleContactField3->SetFieldParamsL(KLandline,Land1,KLandno1); |
1118 singleContactField3->SetFieldParamsL(KLandline,Land1,KLandno1); |
780 singleContactField4->SetFieldParamsL(KLandline,Land1,KLandno2); |
1119 singleContactField4->SetFieldParamsL(KLandline,Land1,KLandno2); |
781 singleContact->AddFieldToContactL(singleContactField3); |
1120 singleContact->AddFieldToContactL(singleContactField3); |
782 singleContact->AddFieldToContactL(singleContactField4); |
1121 singleContact->AddFieldToContactL(singleContactField4); |
786 icontactservice->AddL(icallback,0,singleContact,KNullDesC8,KNullDesC,KCntDbUri); |
1125 icontactservice->AddL(icallback,0,singleContact,KNullDesC8,KNullDesC,KCntDbUri); |
787 CActiveScheduler::Start(); |
1126 CActiveScheduler::Start(); |
788 |
1127 |
789 /* check whether add api returns the expected error code */ |
1128 /* check whether add api returns the expected error code */ |
790 if(count == icallback->iError ) |
1129 if(count == icallback->iError ) |
1130 { |
|
1131 CleanupStack::Pop(singleContactField4); |
|
1132 CleanupStack::Pop(singleContactField3); |
|
1133 CleanupStack::Pop(singleContactField2); |
|
1134 CleanupStack::Pop(singleContactField1); |
|
1135 CleanupStack::Pop(singleContact); |
|
1136 delete singleContact; |
|
1137 delete icallback; |
|
1138 delete icontactservice; |
|
1139 __UHEAP_MARKEND; |
|
791 return KErrNone ; |
1140 return KErrNone ; |
792 |
1141 } |
1142 CleanupStack::Pop(singleContactField4); |
|
1143 CleanupStack::Pop(singleContactField3); |
|
1144 CleanupStack::Pop(singleContactField2); |
|
1145 CleanupStack::Pop(singleContactField1); |
|
1146 CleanupStack::Pop(singleContact); |
|
1147 delete singleContact; |
|
1148 delete icallback; |
|
1149 delete icontactservice; |
|
1150 __UHEAP_MARKEND; |
|
793 return KErrGeneral ; |
1151 return KErrGeneral ; |
794 |
1152 |
795 |
1153 |
796 } |
1154 } |
797 |
1155 |
798 |
1156 TInt Ctdeleteadd::Add_Test14L(CStifItemParser& aItem ) |
799 |
1157 { |
1158 |
|
1159 __UHEAP_MARK; |
|
1160 icontactservice=CContactService::NewL(); |
|
1161 icallback=new(ELeave) CContactCallback; |
|
1162 TInt count =KErrGeneral ; |
|
1163 _LIT8(KFirstName,"FirstName"); |
|
1164 _LIT(KName,"Aaaa"); |
|
1165 //instantiate service class object |
|
1166 _LIT8(KPrefix,"Prefix"); |
|
1167 _LIT(KPfix,"Princess"); |
|
1168 _LIT8(KNote,"Note"); |
|
1169 _LIT(KNoteVal,"Lead role in Barbie, the island princess"); |
|
1170 _LIT8(KAnniversary,"Anniversary"); |
|
1171 _LIT8(KBday,"Date"); |
|
1172 _LIT8(KNickName,"SecondName"); |
|
1173 _LIT(KNickNameVal,"Doll"); |
|
1174 _LIT8(KPhoto,"CallerObjImg"); |
|
1175 _LIT(KPhotoVal,"C:\\data\\images\\pic.jpg"); |
|
1176 _LIT8(KImpp,"IMPP"); |
|
1177 _LIT(KImppLabel,"IMPP"); |
|
1178 |
|
1179 /* create contactitem to add */ |
|
1180 CSingleContact* singleContact = CSingleContact::NewL(); |
|
1181 CleanupStack::PushL(singleContact); |
|
1182 CSingleContactField* singleContactField = CSingleContactField::NewL(); |
|
1183 CleanupStack::PushL(singleContactField); |
|
1184 CSingleContactField* prefix = CSingleContactField::NewL(); |
|
1185 CleanupStack::PushL(prefix); |
|
1186 CSingleContactField* note = CSingleContactField::NewL(); |
|
1187 CleanupStack::PushL(note); |
|
1188 CSingleContactField* anni = CSingleContactField::NewL(); |
|
1189 CleanupStack::PushL(anni); |
|
1190 CSingleContactField* bday = CSingleContactField::NewL(); |
|
1191 CleanupStack::PushL(bday); |
|
1192 CSingleContactField* nkname = CSingleContactField::NewL(); |
|
1193 CleanupStack::PushL(nkname); |
|
1194 CSingleContactField* photo = CSingleContactField::NewL(); |
|
1195 CleanupStack::PushL(photo); |
|
1196 CSingleContactField* xspid = CSingleContactField::NewL(); |
|
1197 CleanupStack::PushL(xspid); |
|
1198 |
|
1199 singleContactField->SetFieldParamsL(KFirstName,KNullDesC,KName); |
|
1200 singleContact->AddFieldToContactL(singleContactField); |
|
1201 prefix->SetFieldParamsL(KPrefix,KNullDesC,KPfix); |
|
1202 singleContact->AddFieldToContactL(prefix); |
|
1203 |
|
1204 note->SetFieldParamsL(KNote,KNullDesC,KNoteVal); |
|
1205 singleContact->AddFieldToContactL(note); |
|
1206 |
|
1207 |
|
1208 anni->SetFieldParamsL(KAnniversary,KNullDesC,KNullDesC); |
|
1209 anni->SetDateTime(TTime(TDateTime(2007,EOctober,25,0,0,0,0))); |
|
1210 singleContact->AddFieldToContactL(anni); |
|
1211 |
|
1212 |
|
1213 bday->SetFieldParamsL(KBday,KNullDesC,KNullDesC); |
|
1214 bday->SetDateTime(TTime(TDateTime(2007,EOctober,25,0,0,0,0))); |
|
1215 singleContact->AddFieldToContactL(bday); |
|
1216 |
|
1217 nkname->SetFieldParamsL(KNickName,KNullDesC,KNickNameVal); |
|
1218 singleContact->AddFieldToContactL(nkname); |
|
1219 |
|
1220 photo->SetFieldParamsL(KPhoto,KNullDesC,KPhotoVal); |
|
1221 singleContact->AddFieldToContactL(photo); |
|
1222 |
|
1223 RPointerArray<HBufC> xspidarr; |
|
1224 xspidarr.Append((_L("Yahoo:barbie@yahoo.co.in")).AllocL()); |
|
1225 xspidarr.Append((_L("Google:barbie@gmail.com")).AllocL()); |
|
1226 xspid->SetXspidDataL(KImpp,KImppLabel,xspidarr); |
|
1227 singleContact->AddFieldToContactL(xspid); |
|
1228 |
|
1229 //aItem.GetNextInt(count); |
|
1230 |
|
1231 /* Add the contactitem */ |
|
1232 icontactservice->AddL(icallback,0,singleContact); |
|
1233 CActiveScheduler::Start(); |
|
1234 |
|
1235 /* check whether add api returns the expected error code */ |
|
1236 if(KErrNone == icallback->iError ) |
|
1237 { |
|
1238 CleanupStack::Pop(xspid); |
|
1239 CleanupStack::Pop(photo); |
|
1240 CleanupStack::Pop(nkname); |
|
1241 CleanupStack::Pop(bday); |
|
1242 CleanupStack::Pop(anni); |
|
1243 CleanupStack::Pop(note); |
|
1244 CleanupStack::Pop(prefix); |
|
1245 CleanupStack::Pop(singleContactField); |
|
1246 CleanupStack::Pop(singleContact); |
|
1247 delete singleContact; |
|
1248 delete icallback; |
|
1249 delete icontactservice; |
|
1250 __UHEAP_MARKEND; |
|
1251 return KErrNone ; |
|
1252 } |
|
1253 CleanupStack::Pop(xspid); |
|
1254 CleanupStack::Pop(photo); |
|
1255 CleanupStack::Pop(nkname); |
|
1256 CleanupStack::Pop(bday); |
|
1257 CleanupStack::Pop(anni); |
|
1258 CleanupStack::Pop(note); |
|
1259 CleanupStack::Pop(prefix); |
|
1260 CleanupStack::Pop(singleContactField); |
|
1261 CleanupStack::Pop(singleContact); |
|
1262 delete singleContact; |
|
1263 delete icallback; |
|
1264 delete icontactservice; |
|
1265 __UHEAP_MARKEND; |
|
1266 return KErrGeneral ; |
|
1267 |
|
1268 } |
|
1269 |
|
1270 TInt Ctdeleteadd::Add_Test15L(CStifItemParser& aItem ) |
|
1271 { |
|
1272 __UHEAP_MARK; |
|
1273 |
|
1274 cmdNum = 15; |
|
1275 TInt count =KErrGeneral ; |
|
1276 _LIT8(KFirstName,"FirstName"); |
|
1277 _LIT(KFName,"Barbie"); |
|
1278 _LIT8(KPrefix,"Prefix"); |
|
1279 _LIT(KPfix,"Princess"); |
|
1280 _LIT8(KNote,"Note"); |
|
1281 _LIT(KNoteVal,"Lead role in Barbie, the island princess"); |
|
1282 _LIT8(KAnniversary,"Anniversary"); |
|
1283 // _LIT(KAnniVal,"20090521:023443:000000"); |
|
1284 //TTime annival; |
|
1285 //annival.Set(KAnniVal); |
|
1286 //_LIT(KAniiVal,"08216666"); |
|
1287 _LIT8(KBday,"Date"); |
|
1288 // _LIT(KBDayVal,"20099420:023443:000000"); |
|
1289 // TTime bdayval; |
|
1290 // bdayval.Set(KBDayVal); |
|
1291 _LIT8(KNickName,"SecondName"); |
|
1292 _LIT(KNickNameVal,"Doll"); |
|
1293 _LIT8(KPhoto,"CallerObjImg"); |
|
1294 _LIT(KPhotoVal,"C:\\data\\images\\pic.jpg"); |
|
1295 _LIT8(KImpp,"IMPP"); |
|
1296 _LIT(KImppLabel,"IMPP"); |
|
1297 |
|
1298 |
|
1299 //instantiate service class object |
|
1300 /* create contactitem to add */ |
|
1301 |
|
1302 CSingleContact* singleContact = CSingleContact::NewL(); |
|
1303 //CleanupStack::PushL(singleContact); |
|
1304 CSingleContactField* FName = CSingleContactField::NewL(); |
|
1305 //CleanupStack::PushL(FName); |
|
1306 CSingleContactField* prefix = CSingleContactField::NewL(); |
|
1307 //CleanupStack::PushL(prefix); |
|
1308 CSingleContactField* note = CSingleContactField::NewL(); |
|
1309 //CleanupStack::PushL(note); |
|
1310 CSingleContactField* anni = CSingleContactField::NewL(); |
|
1311 //CleanupStack::PushL(anni); |
|
1312 CSingleContactField* bday = CSingleContactField::NewL(); |
|
1313 //CleanupStack::PushL(bday); |
|
1314 CSingleContactField* nkname = CSingleContactField::NewL(); |
|
1315 //CleanupStack::PushL(nkname); |
|
1316 CSingleContactField* photo = CSingleContactField::NewL(); |
|
1317 //CleanupStack::PushL(photo); |
|
1318 CSingleContactField* xspid = CSingleContactField::NewL(); |
|
1319 //CleanupStack::PushL(xspid); |
|
1320 |
|
1321 |
|
1322 FName->SetFieldParamsL(KFirstName,KNullDesC,KFName); |
|
1323 singleContact->AddFieldToContactL(FName); |
|
1324 |
|
1325 prefix->SetFieldParamsL(KPrefix,KNullDesC,KPfix); |
|
1326 singleContact->AddFieldToContactL(prefix); |
|
1327 |
|
1328 note->SetFieldParamsL(KNote,KNullDesC,KNoteVal); |
|
1329 singleContact->AddFieldToContactL(note); |
|
1330 |
|
1331 anni->SetFieldParamsL(KAnniversary,KNullDesC,KNullDesC); |
|
1332 anni->SetDateTime(TTime(TDateTime(2007,EOctober,25,0,0,0,0))); |
|
1333 singleContact->AddFieldToContactL(anni); |
|
1334 |
|
1335 |
|
1336 bday->SetFieldParamsL(KBday,KNullDesC,KNullDesC); |
|
1337 bday->SetDateTime(TTime(TDateTime(2007,EOctober,25,0,0,0,0))); |
|
1338 singleContact->AddFieldToContactL(bday); |
|
1339 |
|
1340 nkname->SetFieldParamsL(KNickName,KNullDesC,KNickNameVal); |
|
1341 singleContact->AddFieldToContactL(nkname); |
|
1342 |
|
1343 photo->SetFieldParamsL(KPhoto,KNullDesC,KPhotoVal); |
|
1344 singleContact->AddFieldToContactL(photo); |
|
1345 |
|
1346 _LIT(KYahooId,"Yahoo:barbie@yahoo.co.in"); |
|
1347 //_LIT8(); |
|
1348 |
|
1349 RPointerArray<HBufC> xspidarr; |
|
1350 //CleanClosePushL(xspidarr); |
|
1351 xspidarr.Append((_L("Yahoo:barbie@yahoo.co.in")).AllocL()); |
|
1352 xspidarr.Append((_L("Google:barbie@gmail.com")).AllocL()); |
|
1353 xspid->SetXspidDataL(KImpp,KImppLabel,xspidarr); |
|
1354 singleContact->AddFieldToContactL(xspid); |
|
1355 |
|
1356 |
|
1357 |
|
1358 |
|
1359 |
|
1360 aItem.GetNextInt(count) ; |
|
1361 |
|
1362 icontactservice=CContactService::NewL(); |
|
1363 /* Add the contactitem */ |
|
1364 HBufC8* cntId; |
|
1365 TRAPD(error,cntId= icontactservice->AddL(singleContact)); |
|
1366 |
|
1367 |
|
1368 if(error == KErrNone) |
|
1369 { |
|
1370 delete cntId; |
|
1371 delete singleContact; |
|
1372 //xspidarr.Reset(); |
|
1373 delete icontactservice; |
|
1374 __UHEAP_MARKEND; |
|
1375 |
|
1376 return KErrNone ; |
|
1377 } |
|
1378 delete cntId; |
|
1379 delete singleContact; |
|
1380 //xspidarr.Reset(); |
|
1381 delete icontactservice; |
|
1382 __UHEAP_MARKEND; |
|
1383 return KErrGeneral; |
|
1384 |
|
1385 |
|
1386 |
|
1387 |
|
1388 } |
|
1389 |
|
1390 /* Adding a group */ |
|
1391 TInt Ctdeleteadd::Add_Test16L( CStifItemParser& aItem ) |
|
1392 { |
|
1393 __UHEAP_MARK; |
|
1394 icontactservice=CContactService::NewL(); |
|
1395 icallback=new(ELeave) CContactCallback; |
|
1396 // Print to UI |
|
1397 _LIT( Ktsapicontacts, "tsapicontacts" ); |
|
1398 _LIT( KExample, "In GetList_Test16L" ); |
|
1399 TestModuleIf().Printf( 0, Ktsapicontacts, KExample ); |
|
1400 // Print to log file |
|
1401 iLog->Log( KExample ); |
|
1402 |
|
1403 |
|
1404 TInt count; |
|
1405 |
|
1406 /* Group1 to add to phonebook */ |
|
1407 _LIT(KGroup,"Group16") ; |
|
1408 |
|
1409 aItem.GetNextInt(count) ; |
|
1410 |
|
1411 /*Add group1 to phonebook */ |
|
1412 icontactservice->AddL(icallback,0,NULL,KNullDesC8,KGroup); |
|
1413 CActiveScheduler::Start(); |
|
1414 |
|
1415 /* check whether add api returns the expected error code */ |
|
1416 if(count == icallback->iError ) |
|
1417 { |
|
1418 delete icallback; |
|
1419 delete icontactservice; |
|
1420 __UHEAP_MARKEND; |
|
1421 return KErrNone ; |
|
1422 } |
|
1423 delete icallback; |
|
1424 delete icontactservice; |
|
1425 __UHEAP_MARKEND; |
|
1426 return KErrGeneral ; |
|
1427 |
|
1428 } |
|
1429 |
|
1430 /* Adding a group */ |
|
1431 TInt Ctdeleteadd::Add_Test17L( CStifItemParser& aItem ) |
|
1432 { |
|
1433 __UHEAP_MARK; |
|
1434 icontactservice=CContactService::NewL(); |
|
1435 icallback=new(ELeave) CContactCallback; |
|
1436 |
|
1437 // Print to UI |
|
1438 _LIT( Ktsapicontacts, "tsapicontacts" ); |
|
1439 _LIT( KExample, "In GetList_Test17L" ); |
|
1440 TestModuleIf().Printf( 0, Ktsapicontacts, KExample ); |
|
1441 // Print to log file |
|
1442 iLog->Log( KExample ); |
|
1443 |
|
1444 HBufC8* grpId; |
|
1445 TInt count; |
|
1446 |
|
1447 /* Group1 to add to phonebook */ |
|
1448 _LIT(KGroup,"Group17") ; |
|
1449 |
|
1450 aItem.GetNextInt(count) ; |
|
1451 |
|
1452 /*Add group1 to phonebook */ |
|
1453 TRAPD(err,grpId = icontactservice->AddL(NULL,KNullDesC8,KGroup)); |
|
1454 |
|
1455 if(err != KErrNone) |
|
1456 { |
|
1457 delete icallback; |
|
1458 delete icontactservice; |
|
1459 delete grpId; |
|
1460 __UHEAP_MARKEND; |
|
1461 return KErrGeneral; |
|
1462 } |
|
1463 delete icallback; |
|
1464 delete icontactservice; |
|
1465 delete grpId; |
|
1466 __UHEAP_MARKEND; |
|
1467 return KErrNone; |
|
1468 |
|
1469 } |
|
800 // End of File |
1470 // End of File |