|
1 /* |
|
2 * Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of 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 // INCLUDE FILES |
|
21 #include <e32svr.h> |
|
22 #include <StifParser.h> |
|
23 #include <Stiftestinterface.h> |
|
24 #include <LiwServiceHandler.h> |
|
25 #include <Liwbufferextension.h> |
|
26 |
|
27 |
|
28 #include "tprovidertest.h" |
|
29 |
|
30 #include <f32file.h> |
|
31 #include <e32des16.h> |
|
32 #include <e32base.h> |
|
33 |
|
34 #include "tprovidertestobserver.h" |
|
35 //#include "txmlconvertor.h" |
|
36 _LIT8(KErrorCode,"ErrorCode"); |
|
37 _LIT8(KResponse,"ReturnValue"); |
|
38 _LIT8(KTransactionID,"TransactionID"); |
|
39 _LIT8(KCancel, "Cancel"); |
|
40 |
|
41 void CProviderTest::Delete() |
|
42 { |
|
43 |
|
44 } |
|
45 |
|
46 // ----------------------------------------------------------------------------- |
|
47 // Csapi_getheader:RunMethodL |
|
48 // Run specified method. Contains also table of test mothods and their names. |
|
49 // ----------------------------------------------------------------------------- |
|
50 // |
|
51 TInt CProviderTest::RunMethodL( |
|
52 CStifItemParser& aItem ) |
|
53 { |
|
54 |
|
55 static TStifFunctionInfo const KFunctions[] = |
|
56 { |
|
57 |
|
58 ENTRY( "CheckInputArgumentType", CProviderTest::CheckInputArgumentType ), |
|
59 ENTRY( "CheckInputArgumentTypenos60prefix", CProviderTest::CheckInputArgumentTypenos60prefix ), |
|
60 ENTRY( "GetListManyTimes", CProviderTest::CheckGetListManyTimes ), |
|
61 ENTRY( "CheckOutputArgumentType", CProviderTest::CheckOutputArgumentType), |
|
62 ENTRY( "CheckCancel", CProviderTest::CheckCancel), |
|
63 |
|
64 |
|
65 }; |
|
66 |
|
67 const TInt count = sizeof( KFunctions ) / |
|
68 sizeof( TStifFunctionInfo ); |
|
69 |
|
70 return RunInternalL( KFunctions, count, aItem ); |
|
71 |
|
72 } |
|
73 |
|
74 |
|
75 |
|
76 |
|
77 TInt CProviderTest::CheckGetListManyTimes( CStifItemParser& aItem ) |
|
78 {/* dummy */ |
|
79 for (int i=0;i<6;i++) |
|
80 { |
|
81 int ret = Test(aItem); |
|
82 if (ret != 0) |
|
83 { |
|
84 return ret; |
|
85 } |
|
86 } |
|
87 return 0; |
|
88 } |
|
89 |
|
90 |
|
91 TInt CProviderTest::CheckInputArgumentTypenos60prefix( CStifItemParser& aItem ) |
|
92 { |
|
93 iPrefix = ETrue; |
|
94 return CheckInputArgumentType(aItem); |
|
95 } |
|
96 |
|
97 |
|
98 TInt CProviderTest::Test( CStifItemParser& aItem ) |
|
99 { |
|
100 //__UHEAP_MARK; |
|
101 TPtrC16 serice16; |
|
102 TPtrC16 Interface16; |
|
103 TPtrC16 command16; |
|
104 TInt servicecmdpptions; |
|
105 TPtrC16 callback; |
|
106 |
|
107 TInt expected; |
|
108 TInt err; |
|
109 CProviderObserver* callbackobj = NULL; |
|
110 |
|
111 TInt result =KErrNone ;// KErrGeneral; // 0 means pass and -1 means Fail |
|
112 |
|
113 aItem.GetNextString(serice16); |
|
114 aItem.GetNextString(Interface16); |
|
115 aItem.GetNextString(command16); |
|
116 aItem.GetNextInt(servicecmdpptions); |
|
117 aItem.GetNextString(callback); |
|
118 |
|
119 |
|
120 |
|
121 |
|
122 iLog->Log(_L("read varibale ")); |
|
123 |
|
124 /*-------------------------------------------------------------------------------------------*/ |
|
125 |
|
126 |
|
127 CLiwServiceHandler* iServiceHandler = CLiwServiceHandler::NewL(); |
|
128 CleanupStack::PushL(iServiceHandler);//1 |
|
129 |
|
130 if ( iServiceHandler ) |
|
131 iLog->Log(_L("Got Service Handler ")); |
|
132 else |
|
133 iLog->Log(_L("Didn't get service handler")); |
|
134 |
|
135 |
|
136 //Take the Interface name and provider from cfg file |
|
137 TBuf8<30> interface8; |
|
138 TBuf8<30> service8; |
|
139 interface8.Copy(Interface16); |
|
140 service8.Copy(serice16); |
|
141 |
|
142 CLiwCriteriaItem* crit = CLiwCriteriaItem::NewL(1,interface8,service8); |
|
143 iLog->Log(_L("Create criterai Item")); |
|
144 crit->SetServiceClass(TUid::Uid(KLiwClassBase)); |
|
145 CleanupStack::PushL(crit);//2 |
|
146 |
|
147 |
|
148 RCriteriaArray critArray; |
|
149 iLog->Log(_L("Append in Crit")); |
|
150 critArray.AppendL(crit); |
|
151 CleanupClosePushL(critArray);//3 |
|
152 |
|
153 iServiceHandler->AttachL(critArray); |
|
154 |
|
155 |
|
156 iLog->Log(_L("Creating Output")); |
|
157 CLiwGenericParamList* output = CLiwGenericParamList::NewL(); |
|
158 CleanupStack::PushL(output);//4 |
|
159 CLiwGenericParamList* input = CLiwGenericParamList::NewL(); |
|
160 CleanupStack::PushL(input);//5 |
|
161 |
|
162 iLog->Log(_L("call Service cmd L")); |
|
163 iServiceHandler->ExecuteServiceCmdL(*crit, *input, *output); |
|
164 |
|
165 iLog->Log(_L("Service cmdl is over")); |
|
166 |
|
167 // Create the Instance of SAPI class and the Input Param and output Param |
|
168 TInt pos = 0; |
|
169 MLiwInterface* Interface = NULL; |
|
170 output->FindFirst(pos,interface8 ); |
|
171 if(pos != KErrNotFound) |
|
172 { |
|
173 Interface = (*output)[pos].Value().AsInterface(); |
|
174 CleanupClosePushL(*Interface);//6 |
|
175 } |
|
176 output->Reset(); |
|
177 |
|
178 iLog->Log(_L("got Interface")); |
|
179 input->Reset(); |
|
180 |
|
181 |
|
182 |
|
183 if (Interface && FillInputParmaeterList( aItem, input) == KErrNone ) |
|
184 { |
|
185 //Call Service |
|
186 // PrintInputParameterList(input); |
|
187 TBuf8<30> command8; |
|
188 command8.Copy(command16); |
|
189 |
|
190 if(callback.CompareF(_L("NULL"))==0) |
|
191 { |
|
192 //without call back |
|
193 Interface->ExecuteCmdL(command8,*input,*output,servicecmdpptions, NULL); |
|
194 |
|
195 } |
|
196 else |
|
197 |
|
198 { |
|
199 //need to change the observer |
|
200 callbackobj = CProviderObserver::NewL(); |
|
201 //CleanupStack::PushL( callbackobj); |
|
202 Interface->ExecuteCmdL(command8,*input,*output,servicecmdpptions, callbackobj); |
|
203 //CleanupStack::PopAndDestroy( ); |
|
204 } |
|
205 |
|
206 aItem.GetNextInt(expected); |
|
207 const TLiwGenericParam* p= NULL; |
|
208 p = output->FindFirst(pos, KErrorCode); // Finding Error Code |
|
209 if(p) |
|
210 { |
|
211 err = p->Value().AsTInt32(); |
|
212 |
|
213 if(err == 0 ) |
|
214 { |
|
215 // Requested Accepted by the provider |
|
216 if( (callback != NULL) && (KLiwOptASyncronous == servicecmdpptions) ) |
|
217 { |
|
218 // need to wait for callback |
|
219 CActiveSchedulerWait* wait = new CActiveSchedulerWait(); |
|
220 CleanupStack::PushL( wait); |
|
221 callbackobj->SetWait( wait ); |
|
222 wait->Start(); |
|
223 CleanupStack::PopAndDestroy();//Active Wait Scheduler |
|
224 } |
|
225 |
|
226 } |
|
227 |
|
228 |
|
229 iLog->Log(_L("Got Error Code ")); |
|
230 |
|
231 if(expected != err) |
|
232 { |
|
233 result = KErrGeneral; |
|
234 } |
|
235 } |
|
236 else |
|
237 result = KErrNone; |
|
238 } |
|
239 else |
|
240 { |
|
241 //Input Parameter List is not properly entered in Cfg file |
|
242 // PrintInputParameterList(input); |
|
243 |
|
244 if (Interface) |
|
245 { |
|
246 result = KErrGeneral; |
|
247 } |
|
248 } |
|
249 |
|
250 |
|
251 output->Reset(); |
|
252 input->Reset(); |
|
253 delete callbackobj; |
|
254 |
|
255 if (Interface) |
|
256 CleanupStack::PopAndDestroy( ); |
|
257 CleanupStack::PopAndDestroy( ); |
|
258 CleanupStack::PopAndDestroy( ); |
|
259 CleanupStack::PopAndDestroy( ); |
|
260 CleanupStack::PopAndDestroy( ); |
|
261 CleanupStack::PopAndDestroy( ); |
|
262 |
|
263 //__UHEAP_MARKEND; |
|
264 return result; |
|
265 |
|
266 } |
|
267 // ----------------------------------------------------------------------------- |
|
268 // CAppManagerTest:CheckInputArgumentType |
|
269 // |
|
270 // ----------------------------------------------------------------------------- |
|
271 // |
|
272 TInt CProviderTest::CheckInputArgumentType( CStifItemParser& aItem ) |
|
273 { |
|
274 |
|
275 __UHEAP_MARK; |
|
276 TPtrC16 serice16; |
|
277 TPtrC16 Interface16; |
|
278 TPtrC16 command16; |
|
279 TInt servicecmdpptions; |
|
280 TPtrC16 callback; |
|
281 |
|
282 TInt expected; |
|
283 TInt err; |
|
284 CProviderObserver* callbackobj = NULL; |
|
285 |
|
286 TInt result =KErrNone ;// KErrGeneral; // 0 means pass and -1 means Fail |
|
287 |
|
288 aItem.GetNextString(serice16); |
|
289 aItem.GetNextString(Interface16); |
|
290 aItem.GetNextString(command16); |
|
291 aItem.GetNextInt(servicecmdpptions); |
|
292 aItem.GetNextString(callback); |
|
293 |
|
294 |
|
295 |
|
296 |
|
297 iLog->Log(_L("read varibale ")); |
|
298 |
|
299 /*-------------------------------------------------------------------------------------------*/ |
|
300 |
|
301 |
|
302 CLiwServiceHandler* iServiceHandler = CLiwServiceHandler::NewL(); |
|
303 CleanupStack::PushL(iServiceHandler);//1 |
|
304 |
|
305 if ( iServiceHandler ) |
|
306 iLog->Log(_L("Got Service Handler ")); |
|
307 else |
|
308 iLog->Log(_L("Didn't get service handler")); |
|
309 |
|
310 |
|
311 //Take the Interface name and provider from cfg file |
|
312 TBuf8<30> interface8; |
|
313 TBuf8<30> service8; |
|
314 interface8.Copy(Interface16); |
|
315 service8.Copy(serice16); |
|
316 |
|
317 CLiwCriteriaItem* crit = CLiwCriteriaItem::NewL(1,interface8,service8); |
|
318 iLog->Log(_L("Create criterai Item")); |
|
319 crit->SetServiceClass(TUid::Uid(KLiwClassBase)); |
|
320 CleanupStack::PushL(crit);//2 |
|
321 |
|
322 |
|
323 RCriteriaArray critArray; |
|
324 iLog->Log(_L("Append in Crit")); |
|
325 critArray.AppendL(crit); |
|
326 CleanupClosePushL(critArray);//3 |
|
327 |
|
328 iServiceHandler->AttachL(critArray); |
|
329 |
|
330 |
|
331 iLog->Log(_L("Creating Output")); |
|
332 CLiwGenericParamList* output = CLiwGenericParamList::NewL(); |
|
333 CleanupStack::PushL(output);//4 |
|
334 CLiwGenericParamList* input = CLiwGenericParamList::NewL(); |
|
335 CleanupStack::PushL(input);//5 |
|
336 |
|
337 iLog->Log(_L("call Service cmd L")); |
|
338 iServiceHandler->ExecuteServiceCmdL(*crit, *input, *output); |
|
339 |
|
340 iLog->Log(_L("Service cmdl is over")); |
|
341 |
|
342 // Create the Instance of SAPI class and the Input Param and output Param |
|
343 TInt pos = 0; |
|
344 MLiwInterface* Interface = NULL; |
|
345 output->FindFirst(pos,interface8 ); |
|
346 if(pos != KErrNotFound) |
|
347 { |
|
348 Interface = (*output)[pos].Value().AsInterface(); |
|
349 CleanupClosePushL(*Interface);//6 |
|
350 } |
|
351 output->Reset(); |
|
352 |
|
353 iLog->Log(_L("got Interface")); |
|
354 input->Reset(); |
|
355 |
|
356 |
|
357 if (command16.CompareF(_L("GetList")) == 0) |
|
358 iPrefix = ETrue; |
|
359 |
|
360 if (Interface && FillInputParmaeterList( aItem, input) == KErrNone ) |
|
361 { |
|
362 //Call Service |
|
363 // PrintInputParameterList(input); |
|
364 TBuf8<30> command8; |
|
365 command8.Copy(command16); |
|
366 |
|
367 if(callback.CompareF(_L("NULL"))==0) |
|
368 { |
|
369 //without call back |
|
370 Interface->ExecuteCmdL(command8,*input,*output,servicecmdpptions, NULL); |
|
371 |
|
372 } |
|
373 else |
|
374 |
|
375 { |
|
376 //need to change the observer |
|
377 callbackobj = CProviderObserver::NewL(); |
|
378 |
|
379 if(callback.CompareF(_L("LeavingCallBack"))==0) |
|
380 { |
|
381 callbackobj->iLeave = ETrue; |
|
382 } |
|
383 //CleanupStack::PushL( callbackobj); |
|
384 Interface->ExecuteCmdL(command8,*input,*output,servicecmdpptions, callbackobj); |
|
385 //CleanupStack::PopAndDestroy( ); |
|
386 } |
|
387 |
|
388 aItem.GetNextInt(expected); |
|
389 const TLiwGenericParam* p= NULL; |
|
390 p = output->FindFirst(pos, KErrorCode); // Finding Error Code |
|
391 if(p) |
|
392 { |
|
393 err = p->Value().AsTInt32(); |
|
394 |
|
395 if(err == 0 ) |
|
396 { |
|
397 // Requested Accepted by the provider |
|
398 if( (callback != NULL) && (KLiwOptASyncronous == servicecmdpptions) ) |
|
399 { |
|
400 // need to wait for callback |
|
401 CActiveSchedulerWait* wait = new CActiveSchedulerWait(); |
|
402 CleanupStack::PushL( wait); |
|
403 callbackobj->SetWait( wait ); |
|
404 wait->Start(); |
|
405 CleanupStack::PopAndDestroy();//Active Wait Scheduler |
|
406 } |
|
407 |
|
408 } |
|
409 |
|
410 |
|
411 iLog->Log(_L("Got Error Code ")); |
|
412 |
|
413 if(expected != err) |
|
414 { |
|
415 result = KErrGeneral; |
|
416 } |
|
417 } |
|
418 else |
|
419 result = KErrNone; |
|
420 } |
|
421 else |
|
422 { |
|
423 //Input Parameter List is not properly entered in Cfg file |
|
424 // PrintInputParameterList(input); |
|
425 |
|
426 if(callback.CompareF(_L("checkinterface"))==0 && !Interface) |
|
427 { |
|
428 |
|
429 } |
|
430 else |
|
431 { |
|
432 result = KErrGeneral; |
|
433 } |
|
434 } |
|
435 |
|
436 |
|
437 output->Reset(); |
|
438 input->Reset(); |
|
439 delete callbackobj; |
|
440 |
|
441 if (Interface) |
|
442 CleanupStack::PopAndDestroy( ); |
|
443 CleanupStack::PopAndDestroy( ); |
|
444 CleanupStack::PopAndDestroy( ); |
|
445 CleanupStack::PopAndDestroy( ); |
|
446 CleanupStack::PopAndDestroy( ); |
|
447 CleanupStack::PopAndDestroy( ); |
|
448 |
|
449 __UHEAP_MARKEND; |
|
450 return result; |
|
451 |
|
452 |
|
453 } |
|
454 |
|
455 |
|
456 |
|
457 |
|
458 TInt CProviderTest::CheckOutputArgumentType( CStifItemParser& aItem ) |
|
459 { |
|
460 |
|
461 __UHEAP_MARK; |
|
462 TPtrC16 serice16; |
|
463 TPtrC16 Interface16; |
|
464 TPtrC16 command16; |
|
465 TInt servicecmdpptions; |
|
466 TPtrC16 callback; |
|
467 |
|
468 TInt expected; |
|
469 TInt err; |
|
470 CProviderObserver* callbackobj = NULL; |
|
471 |
|
472 TInt result =KErrNone ;// KErrGeneral; // 0 means pass and -1 means Fail |
|
473 |
|
474 aItem.GetNextString(serice16); |
|
475 aItem.GetNextString(Interface16); |
|
476 aItem.GetNextString(command16); |
|
477 aItem.GetNextInt(servicecmdpptions); |
|
478 aItem.GetNextString(callback); |
|
479 |
|
480 |
|
481 |
|
482 |
|
483 iLog->Log(_L("read varibale ")); |
|
484 |
|
485 /*-------------------------------------------------------------------------------------------*/ |
|
486 |
|
487 |
|
488 CLiwServiceHandler* iServiceHandler = CLiwServiceHandler::NewL(); |
|
489 CleanupStack::PushL(iServiceHandler);//1 |
|
490 |
|
491 if ( iServiceHandler ) |
|
492 iLog->Log(_L("Got Service Handler ")); |
|
493 else |
|
494 iLog->Log(_L("Didn't get service handler")); |
|
495 |
|
496 |
|
497 //Take the Interface name and provider from cfg file |
|
498 TBuf8<30> interface8; |
|
499 TBuf8<30> service8; |
|
500 interface8.Copy(Interface16); |
|
501 service8.Copy(serice16); |
|
502 |
|
503 CLiwCriteriaItem* crit = CLiwCriteriaItem::NewL(1,interface8,service8); |
|
504 iLog->Log(_L("Create criterai Item")); |
|
505 crit->SetServiceClass(TUid::Uid(KLiwClassBase)); |
|
506 CleanupStack::PushL(crit);//2 |
|
507 |
|
508 |
|
509 RCriteriaArray critArray; |
|
510 iLog->Log(_L("Append in Crit")); |
|
511 critArray.AppendL(crit); |
|
512 CleanupClosePushL(critArray);//3 |
|
513 |
|
514 iServiceHandler->AttachL(critArray); |
|
515 |
|
516 |
|
517 iLog->Log(_L("Creating Output")); |
|
518 CLiwGenericParamList* output = CLiwGenericParamList::NewL(); |
|
519 CleanupStack::PushL(output);//4 |
|
520 CLiwGenericParamList* input = CLiwGenericParamList::NewL(); |
|
521 CleanupStack::PushL(input);//5 |
|
522 |
|
523 iLog->Log(_L("call Service cmd L")); |
|
524 iServiceHandler->ExecuteServiceCmdL(*crit, *input, *output); |
|
525 |
|
526 iLog->Log(_L("Service cmdl is over")); |
|
527 |
|
528 // Create the Instance of SAPI class and the Input Param and output Param |
|
529 TInt pos = 0; |
|
530 MLiwInterface* Interface = NULL; |
|
531 output->FindFirst(pos,interface8 ); |
|
532 if(pos != KErrNotFound) |
|
533 { |
|
534 Interface = (*output)[pos].Value().AsInterface(); |
|
535 CleanupClosePushL(*Interface);//6 |
|
536 } |
|
537 output->Reset(); |
|
538 |
|
539 iLog->Log(_L("got Interface")); |
|
540 input->Reset(); |
|
541 |
|
542 |
|
543 if (Interface && FillInputParmaeterList( aItem, input) == KErrNone ) |
|
544 { |
|
545 //Call Service |
|
546 //PrintInputParameterList(input); |
|
547 TBuf8<30> command8; |
|
548 command8.Copy(command16); |
|
549 |
|
550 if(callback.CompareF(_L("NULL"))==0) |
|
551 { |
|
552 //without call back |
|
553 Interface->ExecuteCmdL(command8,*input,*output,servicecmdpptions, NULL); |
|
554 |
|
555 } |
|
556 else |
|
557 |
|
558 { |
|
559 //need to change the observer |
|
560 callbackobj = CProviderObserver::NewL(); |
|
561 //CleanupStack::PushL( callbackobj); |
|
562 Interface->ExecuteCmdL(command8,*input,*output,servicecmdpptions, callbackobj); |
|
563 //CleanupStack::PopAndDestroy( ); |
|
564 } |
|
565 |
|
566 aItem.GetNextInt(expected); |
|
567 const TLiwGenericParam* p= NULL; |
|
568 p = output->FindFirst(pos, KErrorCode); // Finding Error Code |
|
569 if(p) |
|
570 { |
|
571 err = p->Value().AsTInt32(); |
|
572 |
|
573 if(err == 0 ) |
|
574 { |
|
575 // Requested Accepted by the provider |
|
576 if( (callback != NULL) && (KLiwOptASyncronous == servicecmdpptions) ) |
|
577 { |
|
578 // need to wait for callback |
|
579 CActiveSchedulerWait* wait = new CActiveSchedulerWait(); |
|
580 CleanupStack::PushL( wait); |
|
581 callbackobj->SetWait( wait ); |
|
582 wait->Start(); |
|
583 CleanupStack::PopAndDestroy();//Active Wait Scheduler |
|
584 } |
|
585 |
|
586 const TLiwGenericParam* p= NULL; |
|
587 p = output->FindFirst(pos, KResponse); |
|
588 if (!p) |
|
589 { |
|
590 err = KErrGeneral; |
|
591 } |
|
592 |
|
593 } |
|
594 |
|
595 |
|
596 iLog->Log(_L("Got Error Code ")); |
|
597 |
|
598 if(expected != err) |
|
599 { |
|
600 result = KErrGeneral; |
|
601 } |
|
602 } |
|
603 else |
|
604 result = KErrNone; |
|
605 } |
|
606 else |
|
607 { |
|
608 //Input Parameter List is not properly entered in Cfg file |
|
609 // PrintInputParameterList(input); |
|
610 |
|
611 if (Interface) |
|
612 { |
|
613 result = KErrGeneral; |
|
614 } |
|
615 } |
|
616 |
|
617 |
|
618 output->Reset(); |
|
619 input->Reset(); |
|
620 delete callbackobj; |
|
621 |
|
622 if (Interface) |
|
623 CleanupStack::PopAndDestroy( ); |
|
624 CleanupStack::PopAndDestroy( ); |
|
625 CleanupStack::PopAndDestroy( ); |
|
626 CleanupStack::PopAndDestroy( ); |
|
627 CleanupStack::PopAndDestroy( ); |
|
628 CleanupStack::PopAndDestroy( ); |
|
629 |
|
630 __UHEAP_MARKEND; |
|
631 return result; |
|
632 |
|
633 |
|
634 } |
|
635 |
|
636 TInt CProviderTest::CheckCancel( CStifItemParser& aItem ) |
|
637 { |
|
638 |
|
639 __UHEAP_MARK; |
|
640 TPtrC16 serice16; |
|
641 TPtrC16 Interface16; |
|
642 TPtrC16 command16; |
|
643 TInt servicecmdpptions; |
|
644 TPtrC16 callback; |
|
645 |
|
646 TInt expected; |
|
647 TInt err; |
|
648 CProviderObserver* callbackobj = NULL; |
|
649 |
|
650 TInt result =KErrNone ;// KErrGeneral; // 0 means pass and -1 means Fail |
|
651 |
|
652 aItem.GetNextString(serice16); |
|
653 aItem.GetNextString(Interface16); |
|
654 aItem.GetNextString(command16); |
|
655 aItem.GetNextInt(servicecmdpptions); |
|
656 aItem.GetNextString(callback); |
|
657 |
|
658 |
|
659 |
|
660 |
|
661 iLog->Log(_L("read varibale ")); |
|
662 |
|
663 /*-------------------------------------------------------------------------------------------*/ |
|
664 |
|
665 |
|
666 CLiwServiceHandler* iServiceHandler = CLiwServiceHandler::NewL(); |
|
667 CleanupStack::PushL(iServiceHandler);//1 |
|
668 |
|
669 if ( iServiceHandler ) |
|
670 iLog->Log(_L("Got Service Handler ")); |
|
671 else |
|
672 iLog->Log(_L("Didn't get service handler")); |
|
673 |
|
674 |
|
675 //Take the Interface name and provider from cfg file |
|
676 TBuf8<30> interface8; |
|
677 TBuf8<30> service8; |
|
678 interface8.Copy(Interface16); |
|
679 service8.Copy(serice16); |
|
680 |
|
681 CLiwCriteriaItem* crit = CLiwCriteriaItem::NewL(1,interface8,service8); |
|
682 iLog->Log(_L("Create criterai Item")); |
|
683 crit->SetServiceClass(TUid::Uid(KLiwClassBase)); |
|
684 CleanupStack::PushL(crit);//2 |
|
685 |
|
686 |
|
687 RCriteriaArray critArray; |
|
688 iLog->Log(_L("Append in Crit")); |
|
689 critArray.AppendL(crit); |
|
690 CleanupClosePushL(critArray);//3 |
|
691 |
|
692 iServiceHandler->AttachL(critArray); |
|
693 |
|
694 |
|
695 iLog->Log(_L("Creating Output")); |
|
696 CLiwGenericParamList* output = CLiwGenericParamList::NewL(); |
|
697 CleanupStack::PushL(output);//4 |
|
698 CLiwGenericParamList* input = CLiwGenericParamList::NewL(); |
|
699 CleanupStack::PushL(input);//5 |
|
700 |
|
701 iLog->Log(_L("call Service cmd L")); |
|
702 iServiceHandler->ExecuteServiceCmdL(*crit, *input, *output); |
|
703 |
|
704 iLog->Log(_L("Service cmdl is over")); |
|
705 |
|
706 // Create the Instance of SAPI class and the Input Param and output Param |
|
707 TInt pos = 0; |
|
708 MLiwInterface* Interface = NULL; |
|
709 output->FindFirst(pos,interface8 ); |
|
710 if(pos != KErrNotFound) |
|
711 { |
|
712 Interface = (*output)[pos].Value().AsInterface(); |
|
713 CleanupClosePushL(*Interface);//6 |
|
714 } |
|
715 output->Reset(); |
|
716 |
|
717 iLog->Log(_L("got Interface")); |
|
718 input->Reset(); |
|
719 |
|
720 |
|
721 if (Interface && FillInputParmaeterList( aItem, input) == KErrNone ) |
|
722 { |
|
723 //Call Service |
|
724 // PrintInputParameterList(input); |
|
725 TBuf8<30> command8; |
|
726 command8.Copy(command16); |
|
727 |
|
728 if(callback.CompareF(_L("NULL"))==0) |
|
729 { |
|
730 //without call back |
|
731 Interface->ExecuteCmdL(command8,*input,*output,servicecmdpptions, NULL); |
|
732 |
|
733 } |
|
734 else |
|
735 |
|
736 { |
|
737 //need to change the observer |
|
738 callbackobj = CProviderObserver::NewL(); |
|
739 //CleanupStack::PushL( callbackobj); |
|
740 Interface->ExecuteCmdL(command8,*input,*output,servicecmdpptions, callbackobj); |
|
741 //CleanupStack::PopAndDestroy( ); |
|
742 } |
|
743 |
|
744 aItem.GetNextInt(expected); |
|
745 const TLiwGenericParam* p= NULL; |
|
746 p = output->FindFirst(pos, KErrorCode); // Finding Error Code |
|
747 if(p) |
|
748 { |
|
749 err = p->Value().AsTInt32(); |
|
750 |
|
751 if(err == 0 ) |
|
752 { |
|
753 // Requested Accepted by the provider |
|
754 if( (callback != NULL) && (KLiwOptASyncronous == servicecmdpptions) ) |
|
755 { |
|
756 |
|
757 |
|
758 pos = 0; |
|
759 p = output->FindFirst(pos, KTransactionID); |
|
760 |
|
761 TInt intValue; |
|
762 if(p) |
|
763 { |
|
764 intValue = p->Value().AsTInt32(); |
|
765 |
|
766 // intValue = 0; |
|
767 |
|
768 |
|
769 input->Reset(); |
|
770 output->Reset(); |
|
771 |
|
772 TLiwVariant value; |
|
773 TLiwGenericParam valueParam; |
|
774 |
|
775 value.SetL((TInt32)intValue); |
|
776 valueParam.SetNameAndValueL(KTransactionID, value); |
|
777 input->AppendL(valueParam); |
|
778 |
|
779 Interface->ExecuteCmdL(KCancel,*input,*output,KLiwOptCancel, NULL); |
|
780 |
|
781 p = output->FindFirst(pos, KErrorCode); // Finding Error Code |
|
782 if(p) |
|
783 err = p->Value().AsTInt32(); |
|
784 |
|
785 value.Reset(); |
|
786 valueParam.Reset(); |
|
787 } |
|
788 else |
|
789 { |
|
790 err = KErrGeneral; |
|
791 } |
|
792 |
|
793 // need to wait for callback |
|
794 |
|
795 } |
|
796 |
|
797 } |
|
798 |
|
799 |
|
800 iLog->Log(_L("Got Error Code ")); |
|
801 |
|
802 if(expected != err) |
|
803 { |
|
804 result = KErrGeneral; |
|
805 } |
|
806 } |
|
807 else |
|
808 result = KErrNone; |
|
809 } |
|
810 else |
|
811 { |
|
812 //Input Parameter List is not properly entered in Cfg file |
|
813 //PrintInputParameterList(input); |
|
814 |
|
815 if (Interface) |
|
816 { |
|
817 result = KErrGeneral; |
|
818 } |
|
819 } |
|
820 |
|
821 |
|
822 output->Reset(); |
|
823 input->Reset(); |
|
824 delete callbackobj; |
|
825 |
|
826 if (Interface) |
|
827 CleanupStack::PopAndDestroy( ); |
|
828 CleanupStack::PopAndDestroy( ); |
|
829 CleanupStack::PopAndDestroy( ); |
|
830 CleanupStack::PopAndDestroy( ); |
|
831 CleanupStack::PopAndDestroy( ); |
|
832 CleanupStack::PopAndDestroy( ); |
|
833 |
|
834 __UHEAP_MARKEND; |
|
835 return result; |
|
836 |
|
837 |
|
838 } |
|
839 |
|
840 |
|
841 |
|
842 TInt CProviderTest::FillInputParmaeterList( CStifItemParser& aItem , CLiwGenericParamList* input ) |
|
843 |
|
844 { |
|
845 |
|
846 TInt intValue; |
|
847 TPtrC16 value16; |
|
848 TBuf8<40> value8; |
|
849 TLiwVariant value; |
|
850 TLiwGenericParam valueParam; |
|
851 TBuf8<40> next8 ; |
|
852 TPtrC next16; |
|
853 |
|
854 TPtrC16 dataType; |
|
855 |
|
856 aItem.GetNextString(next16); |
|
857 |
|
858 |
|
859 while( next16.CompareF(_L("Finish"))!= 0) |
|
860 { |
|
861 aItem.GetNextString(dataType); |
|
862 //Convert variable name into 8 bit key |
|
863 next8.Copy(next16); |
|
864 |
|
865 if(dataType.CompareF(_L("Int") )== 0) |
|
866 { |
|
867 //Value should be Integer |
|
868 aItem.GetNextInt(intValue); |
|
869 value.SetL((TInt32)intValue); |
|
870 valueParam.SetNameAndValueL(next8, value); |
|
871 input->AppendL(valueParam); |
|
872 value.Reset(); |
|
873 valueParam.Reset(); |
|
874 } |
|
875 |
|
876 else if ( dataType.CompareF(_L("String") ) == 0) |
|
877 { |
|
878 //Value should be 8 bit |
|
879 aItem.GetNextString(value16); |
|
880 value8.Copy(value16); |
|
881 |
|
882 if (next8.Compare(_L8("ApplicationID")) == 0) |
|
883 { |
|
884 if (!iPrefix) |
|
885 value8.Insert(0,_L8("s60uid://")); |
|
886 } |
|
887 |
|
888 value.SetL(value8); |
|
889 valueParam.SetNameAndValueL(next8, value); |
|
890 input->AppendL(valueParam); |
|
891 value.Reset(); |
|
892 valueParam.Reset(); |
|
893 } |
|
894 else if ( dataType.CompareF(_L("UnicodeString") ) == 0) |
|
895 { |
|
896 //Value should be 16 bit string |
|
897 aItem.GetNextString(value16); |
|
898 TBuf<64> temp; |
|
899 temp.Copy(value16); |
|
900 |
|
901 if (next8.Compare(_L8("ApplicationID")) == 0 || |
|
902 next8.Compare(_L8("NULLApplicationID")) == 0 || |
|
903 next8.Compare(_L8("somethingelse")) == 0 ) |
|
904 { |
|
905 if (!iPrefix) |
|
906 temp.Insert(0,_L("s60uid://")); |
|
907 |
|
908 if (next8.CompareF(_L8("NULLApplicationID")) == 0) |
|
909 next8.Copy(KNullDesC8); |
|
910 |
|
911 } |
|
912 value.SetL(temp); |
|
913 |
|
914 |
|
915 |
|
916 valueParam.SetNameAndValueL(next8, value); |
|
917 input->AppendL(valueParam); |
|
918 value.Reset(); |
|
919 valueParam.Reset(); |
|
920 } |
|
921 else if ( dataType.CompareF(_L("Map")) == 0) |
|
922 { |
|
923 //Value should be map |
|
924 CLiwDefaultMap *map = CLiwDefaultMap::NewL(); |
|
925 value.SetL(map); |
|
926 valueParam.SetNameAndValueL(next8, value); |
|
927 input->AppendL(valueParam); |
|
928 map->DecRef(); |
|
929 value.Reset(); |
|
930 valueParam.Reset(); |
|
931 |
|
932 if( FillMap(aItem,map) !=KErrNone) |
|
933 return KErrGeneral; |
|
934 |
|
935 } |
|
936 else if ( dataType.CompareF(_L("List")) == 0) |
|
937 { |
|
938 //Value should be map |
|
939 CLiwDefaultList *list = CLiwDefaultList::NewL(); |
|
940 value.SetL(list); |
|
941 valueParam.SetNameAndValueL(next8, value); |
|
942 input->AppendL(valueParam); |
|
943 list->DecRef(); |
|
944 value.Reset(); |
|
945 valueParam.Reset(); |
|
946 |
|
947 if( FillList(aItem,list) !=KErrNone) |
|
948 return KErrGeneral; |
|
949 } |
|
950 else |
|
951 { |
|
952 return KErrGeneral; |
|
953 } |
|
954 aItem.GetNextString(next16); |
|
955 }//While loop |
|
956 |
|
957 |
|
958 return KErrNone; |
|
959 |
|
960 } |
|
961 |
|
962 |
|
963 |
|
964 |
|
965 |
|
966 TInt CProviderTest::FillMap( CStifItemParser& aItem , CLiwDefaultMap* aMap ) |
|
967 |
|
968 { |
|
969 |
|
970 TInt intValue; |
|
971 TPtrC16 value16; |
|
972 TBuf8<40> value8; |
|
973 TLiwVariant value; |
|
974 TBuf8<40> next8 ; |
|
975 TPtrC next16; |
|
976 TPtrC16 dataType; |
|
977 |
|
978 aItem.GetNextString(next16); |
|
979 while( next16.CompareF(_L("End"))!= 0) |
|
980 { |
|
981 aItem.GetNextString(dataType); |
|
982 //Convert variable name into 8 bit key |
|
983 next8.Copy(next16); |
|
984 |
|
985 if(dataType.CompareF(_L("Int") )== 0) |
|
986 { |
|
987 //Value should be Integer |
|
988 aItem.GetNextInt(intValue); |
|
989 value.SetL((TInt32)intValue); |
|
990 aMap->InsertL(next8,value); |
|
991 value.Reset(); |
|
992 } |
|
993 |
|
994 else if ( dataType.CompareF(_L("String") ) == 0) |
|
995 { |
|
996 //Value should be 8 bit |
|
997 aItem.GetNextString(value16); |
|
998 value8.Copy(value16); |
|
999 value.SetL(value8); |
|
1000 aMap->InsertL(next8,value); |
|
1001 value.Reset(); |
|
1002 } |
|
1003 else if ( dataType.CompareF(_L("UnicodeString") ) == 0) |
|
1004 { |
|
1005 //Value should be 16 bit string |
|
1006 aItem.GetNextString(value16); |
|
1007 value.SetL(value16); |
|
1008 aMap->InsertL(next8,value); |
|
1009 value.Reset(); |
|
1010 } |
|
1011 else if ( dataType.CompareF(_L("Map")) == 0) |
|
1012 { |
|
1013 //Value should be map |
|
1014 CLiwDefaultMap *map = CLiwDefaultMap::NewL(); |
|
1015 value.SetL(map); |
|
1016 aMap->InsertL(next8,value); |
|
1017 map->DecRef(); |
|
1018 value.Reset(); |
|
1019 |
|
1020 if( FillMap(aItem,map) !=KErrNone) |
|
1021 return KErrGeneral; |
|
1022 |
|
1023 } |
|
1024 else if ( dataType.CompareF(_L("List")) == 0) |
|
1025 { |
|
1026 //Value should be map |
|
1027 CLiwDefaultList *list = CLiwDefaultList::NewL(); |
|
1028 value.SetL(list); |
|
1029 aMap->InsertL(next8,value); |
|
1030 list->DecRef(); |
|
1031 value.Reset(); |
|
1032 |
|
1033 if( FillList(aItem,list) !=KErrNone) |
|
1034 return KErrGeneral; |
|
1035 } |
|
1036 else |
|
1037 { |
|
1038 return KErrGeneral; |
|
1039 } |
|
1040 aItem.GetNextString(next16); |
|
1041 }//While loop |
|
1042 |
|
1043 |
|
1044 return KErrNone; |
|
1045 |
|
1046 } |
|
1047 |
|
1048 |
|
1049 |
|
1050 TInt CProviderTest::FillList( CStifItemParser& aItem , CLiwDefaultList* aList ) |
|
1051 |
|
1052 { |
|
1053 |
|
1054 TInt intValue; |
|
1055 TPtrC16 value16; |
|
1056 TBuf8<40> value8; |
|
1057 TLiwVariant value; |
|
1058 TBuf8<40> next8 ; |
|
1059 TPtrC next16; |
|
1060 TPtrC16 dataType; |
|
1061 |
|
1062 aItem.GetNextString(dataType); |
|
1063 while( dataType.CompareF(_L("End"))!= 0) |
|
1064 { |
|
1065 //aItem.GetNextString(dataType); |
|
1066 |
|
1067 if(dataType.CompareF(_L("Int") )== 0) |
|
1068 { |
|
1069 //Value should be Integer |
|
1070 aItem.GetNextInt(intValue); |
|
1071 value.SetL((TInt32)intValue); |
|
1072 aList->AppendL(value); |
|
1073 value.Reset(); |
|
1074 } |
|
1075 |
|
1076 else if ( dataType.CompareF(_L("String") ) == 0) |
|
1077 { |
|
1078 //Value should be 8 bit |
|
1079 aItem.GetNextString(value16); |
|
1080 value8.Copy(value16); |
|
1081 value.SetL(value8); |
|
1082 aList->AppendL(value); |
|
1083 value.Reset(); |
|
1084 } |
|
1085 else if ( dataType.CompareF(_L("UnicodeString") ) == 0) |
|
1086 { |
|
1087 //Value should be 16 bit string |
|
1088 aItem.GetNextString(value16); |
|
1089 value.SetL(value16); |
|
1090 aList->AppendL(value); |
|
1091 value.Reset(); |
|
1092 } |
|
1093 else if ( dataType.CompareF(_L("Map")) == 0) |
|
1094 { |
|
1095 //Value should be map |
|
1096 CLiwDefaultMap *map = CLiwDefaultMap::NewL(); |
|
1097 value.SetL(map); |
|
1098 aList->AppendL(value); |
|
1099 map->DecRef(); |
|
1100 value.Reset(); |
|
1101 |
|
1102 if( FillMap(aItem,map) !=KErrNone) |
|
1103 return KErrGeneral; |
|
1104 |
|
1105 } |
|
1106 else if ( dataType.CompareF(_L("List")) == 0) |
|
1107 { |
|
1108 //Value should be List |
|
1109 CLiwDefaultList *list = CLiwDefaultList::NewL(); |
|
1110 value.SetL(list); |
|
1111 aList->AppendL(value); |
|
1112 list->DecRef(); |
|
1113 value.Reset(); |
|
1114 |
|
1115 if( FillList(aItem,list) !=KErrNone) |
|
1116 return KErrGeneral; |
|
1117 |
|
1118 } |
|
1119 else |
|
1120 { |
|
1121 return KErrGeneral; |
|
1122 } |
|
1123 aItem.GetNextString(dataType); |
|
1124 }//While loop |
|
1125 |
|
1126 |
|
1127 return KErrNone; |
|
1128 |
|
1129 } |
|
1130 |
|
1131 |
|
1132 void CProviderTest::PrintInputParameterList( CLiwGenericParamList* input ) |
|
1133 { |
|
1134 |
|
1135 // Show the Input List |
|
1136 RFs fs; |
|
1137 RFile file; |
|
1138 User::LeaveIfError(fs.Connect()); |
|
1139 |
|
1140 CleanupClosePushL(fs);//1 |
|
1141 TInt errfile=0; |
|
1142 TEntry entry; |
|
1143 |
|
1144 |
|
1145 |
|
1146 if( fs.Entry(_L("c:\\Data\\Provider\\"),entry) != KErrNone) |
|
1147 { |
|
1148 TInt ret = fs.MkDir(_L("c:\\Data\\Provider\\")); |
|
1149 } |
|
1150 |
|
1151 TBuf<100> flname(_L("c:\\Data\\Provider\\InputList.xml")); |
|
1152 |
|
1153 errfile =file.Replace(fs,flname, EFileWrite | EFileStreamText); |
|
1154 CleanupClosePushL(file);//2 |
|
1155 |
|
1156 |
|
1157 /*------------------------------------------------------------------------------*/ |
|
1158 //Generate Xml file |
|
1159 TPtrC filebuf; |
|
1160 |
|
1161 #if 0 |
|
1162 CXmlConvertor* convertor = CXmlConvertor::NewL(); |
|
1163 CleanupStack::PushL(convertor); |
|
1164 convertor->BuildOutputTreeL(*input,filebuf); |
|
1165 |
|
1166 HBufC8* heapBuffer = HBufC8::NewL(filebuf.Length()); |
|
1167 TPtr8 filebuf8(heapBuffer->Des()); |
|
1168 filebuf8.Copy(filebuf); |
|
1169 |
|
1170 file.Write(filebuf8); |
|
1171 |
|
1172 delete heapBuffer; |
|
1173 CleanupStack::PopAndDestroy(); |
|
1174 #endif |
|
1175 /*------------------------------------------------------------------------------*/ |
|
1176 |
|
1177 |
|
1178 CleanupStack::PopAndDestroy();//File 1 |
|
1179 CleanupStack::PopAndDestroy();//File Session 2 |
|
1180 } |
|
1181 |
|
1182 |
|
1183 |
|
1184 |
|
1185 |
|
1186 //Output parameter processing |
|
1187 |
|
1188 // ========================== OTHER EXPORTED FUNCTIONS ========================= |
|
1189 // None |
|
1190 |
|
1191 // End of File |