|
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> |
|
24 #include <Stiftestinterface.h> |
|
25 #include "tContact_getlist.h" |
|
26 |
|
27 // EXTERNAL DATA STRUCTURES |
|
28 //extern ?external_data; |
|
29 |
|
30 // EXTERNAL FUNCTION PROTOTYPES |
|
31 //extern ?external_function( ?arg_type,?arg_type ); |
|
32 |
|
33 // CONSTANTS |
|
34 //const ?type ?constant_var = ?constant; |
|
35 |
|
36 // MACROS |
|
37 //#define ?macro ?macro_def |
|
38 |
|
39 // LOCAL CONSTANTS AND MACROS |
|
40 //const ?type ?constant_var = ?constant; |
|
41 //#define ?macro_name ?macro_def |
|
42 |
|
43 // MODULE DATA STRUCTURES |
|
44 //enum ?declaration |
|
45 //typedef ?declaration |
|
46 |
|
47 // LOCAL FUNCTION PROTOTYPES |
|
48 //?type ?function_name( ?arg_type, ?arg_type ); |
|
49 |
|
50 // FORWARD DECLARATIONS |
|
51 //class ?FORWARD_CLASSNAME; |
|
52 |
|
53 // ============================= LOCAL FUNCTIONS =============================== |
|
54 |
|
55 // ----------------------------------------------------------------------------- |
|
56 // ?function_name ?description. |
|
57 // ?description |
|
58 // Returns: ?value_1: ?description |
|
59 // ?value_n: ?description_line1 |
|
60 // ?description_line2 |
|
61 // ----------------------------------------------------------------------------- |
|
62 // |
|
63 /* |
|
64 ?type ?function_name( |
|
65 ?arg_type arg, // ?description |
|
66 ?arg_type arg) // ?description |
|
67 { |
|
68 |
|
69 ?code // ?comment |
|
70 |
|
71 // ?comment |
|
72 ?code |
|
73 } |
|
74 */ |
|
75 |
|
76 // ============================ MEMBER FUNCTIONS =============================== |
|
77 |
|
78 |
|
79 TInt tCount=0; |
|
80 HBufC8* contactid; |
|
81 CSingleContact* myContact=NULL; |
|
82 |
|
83 void CContactCallback::HandleReturnValue( TOperationEvent aEventId, const TInt& aError, TInt aTransId ) |
|
84 { |
|
85 iError= aError; |
|
86 CActiveScheduler::Stop(); |
|
87 } |
|
88 |
|
89 |
|
90 void CContactCallback:: HandleReturnIter(const TInt& aError, CContactIter* aIter, TInt aTransId ) |
|
91 { |
|
92 |
|
93 |
|
94 CActiveScheduler::Stop(); |
|
95 |
|
96 CSingleContactField* field = NULL; |
|
97 HBufC8* buf = NULL; |
|
98 TPtrC8 buf1; |
|
99 TPtrC buf2; |
|
100 TPtrC buf3; |
|
101 TInt count=0 ; |
|
102 |
|
103 |
|
104 if(aError==KErrNone) |
|
105 { |
|
106 aIter->NextL(myContact,contactid); |
|
107 |
|
108 while(myContact) |
|
109 { |
|
110 tCount++; |
|
111 if(myContact) |
|
112 { |
|
113 count++; |
|
114 TInt len,i ; |
|
115 len=myContact->FieldCount(); |
|
116 for(i=0;i<len;i++) |
|
117 { |
|
118 field = myContact->FieldAt(i); |
|
119 if(field!=NULL) |
|
120 { |
|
121 field->GetFieldDataL(buf1,buf2,buf3); |
|
122 //if(buf1.CompareF(_L8("emailgen"))==0) break; |
|
123 } |
|
124 |
|
125 } //for |
|
126 |
|
127 } //if |
|
128 |
|
129 aIter->NextL(myContact,contactid); |
|
130 |
|
131 |
|
132 } //while |
|
133 delete aIter; |
|
134 } //if |
|
135 |
|
136 |
|
137 |
|
138 } |
|
139 |
|
140 // ----------------------------------------------------------------------------- |
|
141 // Ctmanualcontacts::Delete |
|
142 // Delete here all resources allocated and opened from test methods. |
|
143 // Called from destructor. |
|
144 // ----------------------------------------------------------------------------- |
|
145 // |
|
146 void Ctmanualcontacts::Delete() |
|
147 { |
|
148 |
|
149 } |
|
150 |
|
151 // ----------------------------------------------------------------------------- |
|
152 // Ctmanualcontacts::RunMethodL |
|
153 // Run specified method. Contains also table of test mothods and their names. |
|
154 // ----------------------------------------------------------------------------- |
|
155 // |
|
156 TInt Ctmanualcontacts::RunMethodL( |
|
157 CStifItemParser& aItem ) |
|
158 { |
|
159 |
|
160 static TStifFunctionInfo const KFunctions[] = |
|
161 { |
|
162 // Copy this line for every implemented function. |
|
163 // First string is the function name used in TestScripter script file. |
|
164 // Second is the actual implementation member function. |
|
165 ENTRY( "GetList_Test1", Ctmanualcontacts::GetList_Test1L ), |
|
166 ENTRY( "GetList_Test2", Ctmanualcontacts::GetList_Test2L ), |
|
167 ENTRY( "GetList_Test3", Ctmanualcontacts::GetList_Test3L ), |
|
168 ENTRY( "GetList_Test4", Ctmanualcontacts::GetList_Test4L ), |
|
169 ENTRY( "GetList_Test5", Ctmanualcontacts::GetList_Test5L ), |
|
170 ENTRY( "GetList_Test6", Ctmanualcontacts::GetList_Test6L ), |
|
171 ENTRY( "GetList_Test7", Ctmanualcontacts::GetList_Test7L ), |
|
172 ENTRY( "GetList_Test8", Ctmanualcontacts::GetList_Test8L ), |
|
173 ENTRY( "GetList_Test9", Ctmanualcontacts::GetList_Test9L ), |
|
174 ENTRY( "GetList_Test10", Ctmanualcontacts::GetList_Test10L ), |
|
175 //ENTRY( "GetList_Test11", Ctmanualcontacts::GetList_Test11L ), |
|
176 |
|
177 }; |
|
178 |
|
179 const TInt count = sizeof( KFunctions ) / |
|
180 sizeof( TStifFunctionInfo ); |
|
181 |
|
182 return RunInternalL( KFunctions, count, aItem ); |
|
183 |
|
184 } |
|
185 |
|
186 // ----------------------------------------------------------------------------- |
|
187 // Ctmanualcontacts::ExampleL |
|
188 // Example test method function. |
|
189 // (other items were commented in a header). |
|
190 // ----------------------------------------------------------------------------- |
|
191 // |
|
192 |
|
193 /* get database lists ,manual,only contacts.cdb will be listed*/ |
|
194 TInt Ctmanualcontacts::GetList_Test1L( CStifItemParser& aItem ) |
|
195 { |
|
196 |
|
197 // Print to UI |
|
198 _LIT( Ktsapicontacts, "tsapicontacts" ); |
|
199 _LIT( KExample, "In GetList_Test1L" ); |
|
200 TestModuleIf().Printf( 0, Ktsapicontacts, KExample ); |
|
201 // Print to log file |
|
202 iLog->Log( KExample ); |
|
203 |
|
204 |
|
205 CContactIter* iter = CContactIter::NewL(); |
|
206 icontactservice->GetListL(*iter); |
|
207 |
|
208 TPtrC buf; |
|
209 |
|
210 iter->NextL(buf); |
|
211 while(buf.Compare(KNullDesC)!=0) |
|
212 { |
|
213 iter->NextL(buf); |
|
214 } |
|
215 |
|
216 return KErrNone ; |
|
217 |
|
218 } |
|
219 |
|
220 |
|
221 /* get all contacts from the phonebook ie contacts.cdb,manual*/ |
|
222 TInt Ctmanualcontacts::GetList_Test2L( CStifItemParser& aItem ) |
|
223 { |
|
224 |
|
225 // Print to UI |
|
226 _LIT( Ktsapicontacts, "tsapicontacts" ); |
|
227 _LIT( KExample, "In GetList_Test1L" ); |
|
228 TestModuleIf().Printf( 0, Ktsapicontacts, KExample ); |
|
229 // Print to log file |
|
230 iLog->Log( KExample ); |
|
231 |
|
232 |
|
233 icontactservice->GetListL(icallback,1,EContacts); |
|
234 |
|
235 CActiveScheduler::Start(); |
|
236 |
|
237 |
|
238 return KErrNone ; |
|
239 |
|
240 |
|
241 } |
|
242 |
|
243 |
|
244 /* groups are not created,try to get grouplist,expected result NULL */ |
|
245 TInt Ctmanualcontacts::GetList_Test3L( CStifItemParser& aItem ) |
|
246 { |
|
247 |
|
248 // Print to UI |
|
249 _LIT( Ktsapicontacts, "tsapicontacts" ); |
|
250 _LIT( KExample, "In GetList_Test1L" ); |
|
251 TestModuleIf().Printf( 0, Ktsapicontacts, KExample ); |
|
252 // Print to log file |
|
253 iLog->Log( KExample ); |
|
254 |
|
255 _LIT(KCntDbUri, "cntdb://c:contacts_test_group.cdb"); |
|
256 TBuf8<15> fstname(_L8("FirstName")); |
|
257 |
|
258 TBufC8<25> cid ; |
|
259 CSearchFields *srchfield =CSearchFields :: NewL(icontactservice); |
|
260 TPtrC searchval(_L("Getlist_test")); |
|
261 srchfield->AppendL(fstname); |
|
262 icontactservice->GetListL(icallback,1,EGroups,KNullDesC8,searchval,NULL,EAsc,KCntDbUri); |
|
263 |
|
264 CActiveScheduler::Start(); |
|
265 |
|
266 if(myContact ==NULL) |
|
267 return KErrNone ; |
|
268 |
|
269 return KErrGeneral; |
|
270 } |
|
271 |
|
272 /* get group list ,groups are there but no contacts in it */ |
|
273 TInt Ctmanualcontacts::GetList_Test4L( CStifItemParser& aItem ) |
|
274 { |
|
275 |
|
276 // Print to UI |
|
277 _LIT( Ktsapicontacts, "tsapicontacts" ); |
|
278 _LIT( KExample, "In GetList_Test1L" ); |
|
279 TestModuleIf().Printf( 0, Ktsapicontacts, KExample ); |
|
280 // Print to log file |
|
281 iLog->Log( KExample ); |
|
282 |
|
283 _LIT(KGroup,"friends1") ; |
|
284 |
|
285 |
|
286 /*Add group1 to phonebook */ |
|
287 icontactservice->AddL(icallback,0,NULL,KNullDesC8,KGroup); |
|
288 CActiveScheduler::Start(); |
|
289 |
|
290 icontactservice->GetListL(icallback,1,EGroups); |
|
291 |
|
292 CActiveScheduler::Start(); |
|
293 |
|
294 if(tCount!=0) |
|
295 return KErrNone ; |
|
296 |
|
297 return KErrGeneral; |
|
298 |
|
299 |
|
300 } |
|
301 |
|
302 /// repeated |
|
303 /* search for Lee in tmp.cdb */ |
|
304 |
|
305 TInt Ctmanualcontacts::GetList_Test5L( CStifItemParser& aItem ) |
|
306 { |
|
307 |
|
308 // Print to UI |
|
309 _LIT(KCntDbUri1, "cntdb://c:tmp.cdb"); |
|
310 _LIT( Ktsapicontacts, "tsapicontacts" ); |
|
311 _LIT( KExample, "In GetList_Test1L" ); |
|
312 TestModuleIf().Printf( 0, Ktsapicontacts, KExample ); |
|
313 // Print to log file |
|
314 iLog->Log( KExample ); |
|
315 |
|
316 |
|
317 _LIT8(KFirstName,"FirstName"); |
|
318 _LIT(KName,"Anitha"); |
|
319 _LIT(KFirst,"First Name"); |
|
320 |
|
321 //instantiate service class object |
|
322 |
|
323 /* create contactitem with invalid fieldname "FrstName */ |
|
324 CSingleContact* singleContact = CSingleContact::NewL(); |
|
325 CSingleContactField* singleContactField = CSingleContactField::NewL(); |
|
326 |
|
327 |
|
328 singleContactField->SetFieldParamsL(KFirstName,KFirst,KName); |
|
329 singleContact->AddFieldToContactL(singleContactField); |
|
330 |
|
331 |
|
332 /* Add the contactitem */ |
|
333 |
|
334 icontactservice->AddL(icallback,0,singleContact,KNullDesC8,KNullDesC,KCntDbUri1); |
|
335 CActiveScheduler::Start(); |
|
336 |
|
337 |
|
338 _LIT(Kname,"Lee"); |
|
339 |
|
340 TBuf8<15> fstname(_L8("FirstName")); |
|
341 |
|
342 TBufC8<25> cid ; |
|
343 CSearchFields *srchfield =CSearchFields :: NewL(icontactservice); |
|
344 |
|
345 srchfield->AppendL(fstname); |
|
346 |
|
347 |
|
348 TPtrC searchval(_L("Anitha")); |
|
349 TOrder sortorder =EAsc; |
|
350 |
|
351 icontactservice->GetListL(icallback,1,EContacts,KNullDesC8,searchval,srchfield,EAsc,KCntDbUri1); |
|
352 |
|
353 CActiveScheduler::Start(); |
|
354 |
|
355 if(tCount!=0) |
|
356 return KErrNone ; |
|
357 |
|
358 |
|
359 return KErrGeneral ; |
|
360 } |
|
361 |
|
362 // search for invalid search field ,ex:search for Lee as lastname in tmp.cdb |
|
363 |
|
364 TInt Ctmanualcontacts::GetList_Test6L( CStifItemParser& aItem ) |
|
365 { |
|
366 |
|
367 // Print to UI |
|
368 _LIT( Ktsapicontacts, "tsapicontacts" ); |
|
369 _LIT(KCntDbUri, "cntdb://c:tmp.cdb"); |
|
370 _LIT( KExample, "In GetList_Test1L" ); |
|
371 TestModuleIf().Printf( 0, Ktsapicontacts, KExample ); |
|
372 // Print to log file |
|
373 iLog->Log( KExample ); |
|
374 |
|
375 _LIT8(KFirstName,"FirstName"); |
|
376 _LIT(KName,"Abhay"); |
|
377 _LIT(KFirst,"First Name"); |
|
378 |
|
379 //instantiate service class object |
|
380 |
|
381 /* create contactitem with invalid fieldname "FrstName */ |
|
382 CSingleContact* singleContact = CSingleContact::NewL(); |
|
383 CSingleContactField* singleContactField = CSingleContactField::NewL(); |
|
384 |
|
385 |
|
386 singleContactField->SetFieldParamsL(KFirstName,KFirst,KName); |
|
387 singleContact->AddFieldToContactL(singleContactField); |
|
388 |
|
389 |
|
390 /* Add the contactitem */ |
|
391 |
|
392 icontactservice->AddL(icallback,0,singleContact,KNullDesC8,KNullDesC,KCntDbUri); |
|
393 CActiveScheduler::Start(); |
|
394 |
|
395 |
|
396 _LIT(Kname,"Lee"); |
|
397 |
|
398 TBuf8<15> lstname(_L8("LastName")); |
|
399 |
|
400 TBufC8<25> cid ; |
|
401 CSearchFields *srchfield =CSearchFields :: NewL(icontactservice); |
|
402 |
|
403 srchfield->AppendL(lstname); |
|
404 |
|
405 |
|
406 TPtrC searchval(_L("Getlist_testing")); |
|
407 |
|
408 icontactservice->GetListL(icallback,1,EContacts,KNullDesC8,searchval,srchfield); |
|
409 |
|
410 |
|
411 CActiveScheduler::Start(); |
|
412 |
|
413 if(tCount ==0) |
|
414 return KErrNone ; |
|
415 |
|
416 else |
|
417 return KErrGeneral; |
|
418 |
|
419 } |
|
420 |
|
421 /* list contacts in descending order */ |
|
422 TInt Ctmanualcontacts::GetList_Test7L( CStifItemParser& aItem ) |
|
423 { |
|
424 _LIT(KCntDbUri, "cntdb://c:tmp.cdb"); |
|
425 // Print to UI |
|
426 _LIT( Ktsapicontacts, "tsapicontacts" ); |
|
427 _LIT( KExample, "In GetList_Test1L" ); |
|
428 TestModuleIf().Printf( 0, Ktsapicontacts, KExample ); |
|
429 // Print to log file |
|
430 iLog->Log( KExample ); |
|
431 |
|
432 |
|
433 icontactservice->GetListL(icallback,1,EContacts,KNullDesC8,KNullDesC,NULL,EDesc); //,cid,KCntDbUri1,searchval,srchfield); |
|
434 |
|
435 CActiveScheduler::Start(); |
|
436 |
|
437 |
|
438 return KErrNone ; |
|
439 |
|
440 } |
|
441 |
|
442 /* testcase :list groups in descending order ; |
|
443 Listing in descending order can be done only on contacts not on groups,databases*/ |
|
444 TInt Ctmanualcontacts::GetList_Test8L( CStifItemParser& aItem ) |
|
445 { |
|
446 |
|
447 _LIT(KCntDbUri, "cntdb://c:tmp_groups.cdb"); |
|
448 // Print to UI |
|
449 _LIT( Ktsapicontacts, "tsapicontacts" ); |
|
450 _LIT( KExample, "In GetList_Test1L" ); |
|
451 TestModuleIf().Printf( 0, Ktsapicontacts, KExample ); |
|
452 // Print to log file |
|
453 iLog->Log( KExample ); |
|
454 |
|
455 |
|
456 icontactservice->GetListL(icallback,1,EGroups,KNullDesC8,KNullDesC,NULL,EDesc,KCntDbUri); //,cid,KCntDbUri1,searchval,srchfield); |
|
457 |
|
458 CActiveScheduler::Start(); |
|
459 |
|
460 |
|
461 return KErrNone ; |
|
462 |
|
463 } |
|
464 |
|
465 /* list contacts ,ENULL cannot be used in sortingorder*/ |
|
466 TInt Ctmanualcontacts::GetList_Test9L( CStifItemParser& aItem ) |
|
467 { |
|
468 |
|
469 _LIT(KCntDbUri, "cntdb://c:tmp_ENul.cdb"); |
|
470 // Print to UI |
|
471 _LIT( Ktsapicontacts, "tsapicontacts" ); |
|
472 _LIT( KExample, "In GetList_Test1L" ); |
|
473 TestModuleIf().Printf( 0, Ktsapicontacts, KExample ); |
|
474 // Print to log file |
|
475 iLog->Log( KExample ); |
|
476 |
|
477 |
|
478 |
|
479 icontactservice->GetListL(icallback,1,EContacts,KNullDesC8,KNullDesC,NULL,EAsc); //,cid,KCntDbUri1,searchval,srchfield); |
|
480 |
|
481 CActiveScheduler::Start(); |
|
482 |
|
483 |
|
484 return KErrNone ; |
|
485 |
|
486 } |
|
487 |
|
488 /* list the databases, 2 databases should be listed - contacts.cdb,tmp.cdb */ |
|
489 TInt Ctmanualcontacts::GetList_Test10L( CStifItemParser& aItem ) |
|
490 { |
|
491 |
|
492 // Print to UI |
|
493 _LIT( Ktsapicontacts, "tsapicontacts" ); |
|
494 _LIT( KExample, "In GetList_Test1L" ); |
|
495 TestModuleIf().Printf( 0, Ktsapicontacts, KExample ); |
|
496 // Print to log file |
|
497 iLog->Log( KExample ); |
|
498 |
|
499 |
|
500 _LIT(KCntDbUri1, "cntdb://c:tmp.cdb"); |
|
501 icontactservice->GetListL(icallback,1,EContacts,KNullDesC8,KNullDesC,NULL,EAsc,KCntDbUri1); //,cid,KCntDbUri1,searchval,srchfield); |
|
502 |
|
503 CActiveScheduler::Start(); |
|
504 |
|
505 CContactIter* iter = CContactIter::NewL(); |
|
506 icontactservice->GetListL(*iter); |
|
507 |
|
508 TPtrC buf(_L("")); |
|
509 |
|
510 iter->NextL(buf); |
|
511 TInt count=0; |
|
512 while(buf.Compare(KNullDesC)!=0) |
|
513 { count++; |
|
514 iter->NextL(buf); |
|
515 } |
|
516 if(count==2) |
|
517 return KErrNone ; |
|
518 |
|
519 return KErrGeneral; |
|
520 } |
|
521 |
|
522 |
|
523 /* get group list ,groups are there in the simdatabase |
|
524 TInt Ctmanualcontacts::GetList_Test11L( CStifItemParser& aItem ) |
|
525 { |
|
526 |
|
527 // Print to UI |
|
528 |
|
529 _LIT(KCntDbUri, "sim://global_adn"); |
|
530 _LIT( Ktsapicontacts, "tsapicontacts" ); |
|
531 _LIT( KExample, "In GetList_Test1L" ); |
|
532 TestModuleIf().Printf( 0, Ktsapicontacts, KExample ); |
|
533 // Print to log file |
|
534 iLog->Log( KExample ); |
|
535 |
|
536 _LIT(KGroup,"friends1") ; |
|
537 |
|
538 |
|
539 /*Add group1 to phonebook |
|
540 icontactservice->AddL(icallback,0,NULL,KNullDesC8,KGroup,KCntDbUri); |
|
541 CActiveScheduler::Start(); |
|
542 |
|
543 icontactservice->GetListL(icallback,1,EGroups,KNullDesC8,KNullDesC,NULL,EAsc,KCntDbUri); |
|
544 |
|
545 CActiveScheduler::Start(); |
|
546 |
|
547 if(tCount!=0) |
|
548 return KErrNone ; |
|
549 |
|
550 return KErrGeneral; |
|
551 |
|
552 |
|
553 } */ |
|
554 |
|
555 |
|
556 // ----------------------------------------------------------------------------- |
|
557 // Ctmanualcontacts::?member_function |
|
558 // ?implementation_description |
|
559 // (other items were commented in a header). |
|
560 // ----------------------------------------------------------------------------- |
|
561 // |
|
562 /* |
|
563 TInt Ctmanualcontacts::?member_function( |
|
564 CItemParser& aItem ) |
|
565 { |
|
566 |
|
567 ?code |
|
568 |
|
569 } |
|
570 */ |
|
571 |
|
572 // ========================== OTHER EXPORTED FUNCTIONS ========================= |
|
573 // None |
|
574 |
|
575 // End of File |