|
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 // [INCLUDE FILES] - do not remove |
|
20 #include <e32svr.h> |
|
21 #include <StifParser.h> |
|
22 #include <Stiftestinterface.h> |
|
23 #include <LiwServiceHandler.h> |
|
24 #include<e32cmn.h> |
|
25 |
|
26 |
|
27 #include "tmediaprovidertesting.h" |
|
28 #include "tmediaprovidertesting.hrh" |
|
29 #include "tmediaobserver.h" |
|
30 |
|
31 _LIT(KFilenm,"C:\\Data\\Output"); |
|
32 /* -------------------------------------------------------------------------- |
|
33 CMediaObserver :: SetInput |
|
34 Fills the input parameter list. |
|
35 The format of the cfg input is |
|
36 key startRange endRange sortKey sortOrder errorcode |
|
37 [Expected fileName fileExtension drive fileSize fileDate fileNameAndPath mimeType |
|
38 [Next "next map data"]]. |
|
39 ----------------------------------------------------------------------------- |
|
40 */ |
|
41 void CMediaObserver::ParseStiffInput(CStifItemParser& aItem) |
|
42 { |
|
43 |
|
44 iFile.Write(_L8("In ParseStiffInput parsing input \n")); |
|
45 |
|
46 TPtrC16 expectedStart(KNullDesC); |
|
47 TPtrC16 key(KNullDesC); |
|
48 TPtrC16 startRange(KNullDesC); |
|
49 TPtrC16 endRange(KNullDesC); |
|
50 TPtrC16 sortKey(KNullDesC); |
|
51 TPtrC16 sortOrder(KNullDesC); |
|
52 TPtrC16 inpType(KNullDesC); |
|
53 TPtrC16 inpFileType(KNullDesC); |
|
54 |
|
55 aItem.GetNextString(inpType); |
|
56 aItem.GetNextString(inpFileType); |
|
57 aItem.GetNextString(key); |
|
58 aItem.GetNextString(startRange); |
|
59 aItem.GetNextString(endRange); |
|
60 aItem.GetNextString(sortKey); |
|
61 aItem.GetNextString(sortOrder); |
|
62 aItem.GetNextInt(iExpErrorCode); |
|
63 aItem.GetNextString(expectedStart); |
|
64 |
|
65 TBuf8<100> buf; |
|
66 buf.Copy(inpType); |
|
67 buf.Append(_L8("\n")); |
|
68 iFile.Write(buf); |
|
69 buf.Zero(); |
|
70 |
|
71 |
|
72 buf.Copy(inpFileType); |
|
73 buf.Append(_L8("\n")); |
|
74 iFile.Write(buf); |
|
75 buf.Zero(); |
|
76 |
|
77 buf.Copy(key); |
|
78 buf.Append(_L8("\n")); |
|
79 iFile.Write(buf); |
|
80 buf.Zero(); |
|
81 |
|
82 buf.Copy(startRange); |
|
83 buf.Append(_L8("\n")); |
|
84 iFile.Write(buf); |
|
85 buf.Zero(); |
|
86 |
|
87 buf.Copy(endRange); |
|
88 buf.Append(_L8("\n")); |
|
89 iFile.Write(buf); |
|
90 buf.Zero(); |
|
91 |
|
92 buf.Copy(sortKey); |
|
93 buf.Append(_L8("\n")); |
|
94 iFile.Write(buf); |
|
95 buf.Zero(); |
|
96 |
|
97 buf.Copy(sortOrder); |
|
98 buf.Append(_L8("\n")); |
|
99 iFile.Write(buf); |
|
100 buf.Zero(); |
|
101 |
|
102 buf.Num(iExpErrorCode); |
|
103 buf.Append(_L8("\n")); |
|
104 iFile.Write(buf); |
|
105 buf.Zero(); |
|
106 |
|
107 buf.Copy(expectedStart); |
|
108 buf.Append(_L8("\n")); |
|
109 iFile.Write(buf); |
|
110 buf.Zero(); |
|
111 |
|
112 if(inpFileType.CompareF(KFileTypeStreamingURL) == 0) |
|
113 { |
|
114 iFiletype = EStreamingURLFile; |
|
115 } |
|
116 else if(inpFileType.CompareF(KFileTypeMusic) == 0) |
|
117 { |
|
118 iFiletype = EMusicFile; |
|
119 } |
|
120 //check for expected key |
|
121 //if it is there then get the expected result and put it into the map. |
|
122 if(expectedStart.CompareF(KExpectedStart) == 0) |
|
123 { |
|
124 SetExpectedOutputMap(aItem); |
|
125 } |
|
126 /* iLog->Log(_L("The Input Parameters are:")); |
|
127 iLog->Log(key); |
|
128 iLog->Log(startRange); |
|
129 iLog->Log(endRange); |
|
130 iLog->Log(sortKey); |
|
131 iLog->Log(sortOrder); |
|
132 */ |
|
133 CLiwDefaultMap *sortMap = NULL; |
|
134 |
|
135 //set the content type to the fileinfo. |
|
136 if(inpType.Compare(_L("NULL")) != 0) |
|
137 { |
|
138 if(inpType.Compare(_L("NULLVALUE")) == 0) inpType.Set(KNullDesC); |
|
139 const TLiwGenericParam paramContentType(KType, TLiwVariant(inpType)); |
|
140 iInList->AppendL(paramContentType); |
|
141 } |
|
142 |
|
143 CLiwDefaultMap *filterMap = CLiwDefaultMap::NewL(); |
|
144 CleanupStack::PushL(filterMap); |
|
145 |
|
146 TLiwGenericParam filterParam(KFilter, TLiwVariant(filterMap)); |
|
147 iInList->AppendL(filterParam); |
|
148 filterMap->DecRef(); |
|
149 |
|
150 //Set the file type to image. |
|
151 if(inpFileType.Compare(_L("NULL")) != 0) |
|
152 { |
|
153 if(inpFileType.Compare(_L("NULLVALUE")) == 0) inpFileType.Set(KNullDesC); |
|
154 filterMap->InsertL(KFileType,TLiwVariant(inpFileType)); |
|
155 } |
|
156 //Get the key if it is specified. |
|
157 if(key.Compare(_L("NULL")) != 0) |
|
158 { |
|
159 if(key.Compare(_L("NULLVALUE")) == 0) key.Set(KNullDesC); |
|
160 filterMap->InsertL(KKey,TLiwVariant(key)); |
|
161 } |
|
162 //Get the startRange if it is specified. |
|
163 if(startRange.Compare(_L("NULL")) != 0) |
|
164 { |
|
165 if(startRange.Compare(_L("NULLVALUE")) == 0) startRange.Set(KNullDesC); |
|
166 filterMap->InsertL(KStartRange,TLiwVariant(startRange)); |
|
167 } |
|
168 //Get the endRange if it is specified. |
|
169 if(endRange.Compare(_L("NULL")) != 0) |
|
170 { |
|
171 if(endRange.Compare(_L("NULLVALUE")) == 0) endRange.Set(KNullDesC); |
|
172 filterMap->InsertL(KEndRange,TLiwVariant(endRange)); |
|
173 } |
|
174 //only if the sort key is specified create the map |
|
175 if(sortKey.Compare(_L("NULL")) != 0) |
|
176 { |
|
177 sortMap = CLiwDefaultMap::NewL(); |
|
178 CleanupStack::PushL(sortMap); |
|
179 if(sortKey.Compare(_L("NULLVALUE"))== 0) sortKey.Set(KNullDesC); |
|
180 sortMap->InsertL(KKey,TLiwVariant(sortKey)); |
|
181 TLiwGenericParam sortParam(KSort, TLiwVariant(sortMap)); |
|
182 iInList->AppendL(sortParam); |
|
183 sortMap->DecRef(); |
|
184 } |
|
185 //get the sort order if it is specified. |
|
186 if(sortOrder.Compare(_L("NULL")) != 0) |
|
187 { |
|
188 if(!sortMap) |
|
189 { |
|
190 sortMap = CLiwDefaultMap::NewL(); |
|
191 CleanupStack::PushL(sortMap); |
|
192 if(sortOrder.Compare(_L("NULLVALUE"))== 0) sortOrder.Set(KNullDesC); |
|
193 TLiwGenericParam sortParam(KSort, TLiwVariant(sortMap)); |
|
194 iInList->AppendL(sortParam); |
|
195 sortMap->DecRef(); |
|
196 } |
|
197 sortMap->InsertL(KOrder,TLiwVariant(sortOrder)); |
|
198 } |
|
199 //end of input params now look for expected params |
|
200 if(sortMap) |
|
201 { |
|
202 CleanupStack::Pop(sortMap); |
|
203 } |
|
204 CleanupStack::Pop(filterMap); |
|
205 } |
|
206 |
|
207 /* -------------------------------------------------------------------------- |
|
208 CMediaObserver :: SetExpectedImageOutputMap. |
|
209 This method fills the expected output map. |
|
210 ----------------------------------------------------------------------------- |
|
211 */ |
|
212 void CMediaObserver :: SetExpectedOutputMap(CStifItemParser& aItem) |
|
213 { |
|
214 TPtrC16 nextString(KNullDesC); |
|
215 |
|
216 iFile.Write(_L8("Inside SetExpectedOutputMap\n")); |
|
217 // iLog->Log(_L("Inside SetExpectedOutputMap")); |
|
218 |
|
219 aItem.GetNextString(nextString); |
|
220 /* |
|
221 * The expected output is in the format. |
|
222 * [ExpectredStart StartMap Key Value[...]EndMap[...]ExpectedEnd]. |
|
223 */ |
|
224 while(nextString.CompareF(KExpectedEnd)!=0) |
|
225 { |
|
226 if(nextString.CompareF(KMapStart) == 0) |
|
227 { |
|
228 CLiwDefaultMap* expectedOutPutMap = CLiwDefaultMap::NewL(); |
|
229 CleanupStack::PushL(expectedOutPutMap); |
|
230 aItem.GetNextString(nextString); |
|
231 |
|
232 while(nextString.CompareF(KMapEnd)!= 0) |
|
233 { |
|
234 TPtrC key; |
|
235 TPtrC value; |
|
236 TBuf8<255> insertKey; |
|
237 |
|
238 key.Set(nextString); |
|
239 insertKey.Copy(key); |
|
240 iFile.Write(_L8("Key : ")); |
|
241 iFile.Write(insertKey); |
|
242 iFile.Write(_L8("\n")); |
|
243 if(key.CompareF(_L("FileSize"))==0) |
|
244 { |
|
245 TInt fileSize = -1; |
|
246 aItem.GetNextInt(fileSize); |
|
247 expectedOutPutMap->InsertL(insertKey, (TInt32)fileSize); |
|
248 } |
|
249 else |
|
250 { |
|
251 aItem.GetNextString(nextString); |
|
252 value.Set(nextString); |
|
253 TBuf8<70> buf; |
|
254 buf.Append(value); |
|
255 buf.Append(_L8("\n")); |
|
256 iFile.Write(buf); |
|
257 |
|
258 expectedOutPutMap->InsertL(insertKey, value); |
|
259 } |
|
260 aItem.GetNextString(nextString); |
|
261 } |
|
262 |
|
263 iExpectedOutPutArray.Append(expectedOutPutMap); |
|
264 CleanupStack::Pop(expectedOutPutMap); |
|
265 } |
|
266 aItem.GetNextString(nextString); |
|
267 } |
|
268 } |
|
269 |
|
270 /* -------------------------------------------------------------------------- |
|
271 CMediaObserver :: IsExpectedResult. |
|
272 This method checks whether the obtained result and the expected results match. . |
|
273 ----------------------------------------------------------------------------- |
|
274 */ |
|
275 TBool CMediaObserver::IsExpectedResult(CLiwIterable* aResultlist) |
|
276 { |
|
277 TLiwVariant fileDetails; |
|
278 TBool foundMap = EFalse; |
|
279 TInt prevFoundIndex = -1; |
|
280 TInt index = 0; |
|
281 iFile.Write(_L8("Inside IsExpectedResult\n")); |
|
282 // iLog->Log(_L("Inside IsExpectedResult")); |
|
283 |
|
284 for(TInt i = 0; i<iExpectedOutPutArray.Count(); i++) |
|
285 |
|
286 { |
|
287 index = 0; |
|
288 while(aResultlist->NextL(fileDetails)) |
|
289 { |
|
290 const CLiwMap* map = fileDetails.AsMap(); |
|
291 if(map) |
|
292 { |
|
293 iFile.Write(_L8("Map found from iterator\n")); |
|
294 // iLog->Log(_L("Map found from iterator"));// Lok |
|
295 //compare the two maps the result and the expected one. |
|
296 if(CMediaObserver :: CompareMaps(iExpectedOutPutArray[i], map)) |
|
297 { |
|
298 aResultlist->Reset(); |
|
299 foundMap = ETrue; |
|
300 if(index<prevFoundIndex) |
|
301 { |
|
302 iFile.Write(_L8("Result Not in Expected sort order\n")); |
|
303 // iLog->Log(_L("Result Not in Expected sort order")); |
|
304 User::Leave(KErrGeneral); |
|
305 } |
|
306 iFile.Write(_L8("Map is in sorted order with position\n")); |
|
307 // iLog->Log(_L("Map is in sorted order with positio ")); // Lok |
|
308 TBuf8<10>buf; |
|
309 buf.Num(index); |
|
310 iFile.Write(buf); |
|
311 // iLog->Log(buf); |
|
312 buf.Zero(); |
|
313 prevFoundIndex = index; |
|
314 break; |
|
315 } |
|
316 } |
|
317 index++; |
|
318 } |
|
319 if(foundMap) |
|
320 { |
|
321 foundMap = EFalse; |
|
322 } |
|
323 else |
|
324 { |
|
325 iFile.Write(_L8("Expected map not found in the result list\n")); |
|
326 // iLog->Log(_L("Expected map not found in the result list")); |
|
327 return EFalse; |
|
328 } |
|
329 } |
|
330 return ETrue; |
|
331 } |
|
332 |
|
333 /* -------------------------------------------------------------------------- |
|
334 CMediaObserver :: CompareMaps. |
|
335 A static method which compares two maps. |
|
336 ----------------------------------------------------------------------------- |
|
337 */ |
|
338 TBool CMediaObserver::CompareMaps(CLiwMap* aExpectedMap, |
|
339 const CLiwMap* aResultMap) |
|
340 { |
|
341 iFile.Write(_L8("Inside CompareMaps\n")); |
|
342 // iLog->Log(_L("Inside CompareMaps")); |
|
343 if(!CompareStringResult(KType, aExpectedMap, aResultMap)) |
|
344 { |
|
345 return EFalse; |
|
346 } |
|
347 if(!CompareStringResult(KMgFileName, aExpectedMap, aResultMap)) |
|
348 { |
|
349 return EFalse; |
|
350 } |
|
351 if(!CompareStringResult(KMgDrive, aExpectedMap, aResultMap)) |
|
352 { |
|
353 return EFalse; |
|
354 } |
|
355 if(!CompareTIntResult(KMgFileSize, aExpectedMap, aResultMap)) |
|
356 { |
|
357 return EFalse; |
|
358 } |
|
359 if(!CompareStringResult(KMgMimeType, aExpectedMap, aResultMap)) |
|
360 { |
|
361 return EFalse; |
|
362 } |
|
363 if(!CompareStringResult(KMgFileNameAndPath, aExpectedMap, aResultMap)) |
|
364 { |
|
365 return EFalse; |
|
366 } |
|
367 if(!CompareTTimeResult(KMgFileDate, aExpectedMap, aResultMap)) |
|
368 { |
|
369 return EFalse; |
|
370 } |
|
371 //In case of streamingURL file check for few additional keys. |
|
372 if(iFiletype == EStreamingURLFile) |
|
373 { |
|
374 if(!CompareStringResult(KMgLinkFirstURL, aExpectedMap, aResultMap)) |
|
375 { |
|
376 return EFalse; |
|
377 } |
|
378 } |
|
379 //In case of Music file check for few additional keys. |
|
380 if(iFiletype == EMusicFile) |
|
381 { |
|
382 if(!CompareStringResult(KMgComposer, aExpectedMap, aResultMap)) |
|
383 { |
|
384 return EFalse; |
|
385 } |
|
386 |
|
387 if(!CompareStringResult(KMgArtist, aExpectedMap, aResultMap)) |
|
388 { |
|
389 return EFalse; |
|
390 } |
|
391 if(!CompareStringResult(KMgAlbum, aExpectedMap, aResultMap)) |
|
392 { |
|
393 return EFalse; |
|
394 } |
|
395 |
|
396 if(!CompareStringResult(KMgGenre, aExpectedMap, aResultMap)) |
|
397 { |
|
398 return EFalse; |
|
399 } |
|
400 if(!CompareTIntResult(KMgTrackNumber, aExpectedMap, aResultMap)) |
|
401 { |
|
402 return EFalse; |
|
403 } |
|
404 if(!CompareStringResult(KMgSongName, aExpectedMap, aResultMap)) |
|
405 { |
|
406 return EFalse; |
|
407 } |
|
408 } |
|
409 return ETrue; |
|
410 } |
|
411 |
|
412 |
|
413 /* -------------------------------------------------------------------------- |
|
414 CMediaObserver :: CompareStringResult. |
|
415 A static method which compares two string results from the maps. |
|
416 ----------------------------------------------------------------------------- |
|
417 */ |
|
418 TBool CMediaObserver::CompareStringResult(const TDesC8& aKey, |
|
419 CLiwMap* aExpectedMap, |
|
420 const CLiwMap* aResultMap) |
|
421 { |
|
422 TLiwVariant expValue; |
|
423 TLiwVariant resValue; |
|
424 TBool equal = EFalse; |
|
425 |
|
426 iFile.Write(_L8("Inside CompareStringResult\n")); |
|
427 // iLog->Log(_L("Inside CompareStringResult")); |
|
428 |
|
429 if(!aExpectedMap->FindL(aKey, expValue)) |
|
430 { |
|
431 return ETrue; |
|
432 } |
|
433 aResultMap->FindL(aKey, resValue); |
|
434 |
|
435 TPtrC expPtr = expValue.AsDes(); |
|
436 TPtrC resPtr = resValue.AsDes(); |
|
437 TBuf8<100> buf; |
|
438 buf.Copy(expPtr); |
|
439 iFile.Write(_L8("Expected Value\n")); |
|
440 iFile.Write(buf); |
|
441 buf.Zero(); |
|
442 buf.Copy(resPtr); |
|
443 iFile.Write(_L8("\nResult Value\n")); |
|
444 iFile.Write(buf); |
|
445 iFile.Write(_L8("\n")); |
|
446 buf.Zero(); |
|
447 |
|
448 if(expPtr.CompareF(_L("NULL"))!=0) |
|
449 { |
|
450 if(expPtr.CompareF(resPtr) == 0) |
|
451 { |
|
452 equal = ETrue; |
|
453 } |
|
454 } |
|
455 |
|
456 expValue.Reset(); |
|
457 resValue.Reset(); |
|
458 |
|
459 return equal; |
|
460 } |
|
461 |
|
462 /* -------------------------------------------------------------------------- |
|
463 CMediaObserver :: CompareTTimeResult. |
|
464 A static method which compares two TTime results from the maps. |
|
465 ----------------------------------------------------------------------------- |
|
466 */ |
|
467 TBool CMediaObserver::CompareTTimeResult(const TDesC8& aKey, |
|
468 CLiwMap* aExpectedMap, |
|
469 const CLiwMap* aResultMap) |
|
470 { |
|
471 // iLog->Log(_L("Inside CompareStringResult")); |
|
472 TLiwVariant expValue; |
|
473 TLiwVariant resValue; |
|
474 TBool equal = EFalse; |
|
475 TBuf<255> timeString; |
|
476 |
|
477 if(!aExpectedMap->FindL(aKey, expValue)) |
|
478 { |
|
479 return ETrue; |
|
480 } |
|
481 aResultMap->FindL(aKey, resValue); |
|
482 |
|
483 TTime expTime(expValue.AsDes()); |
|
484 |
|
485 /* iLog->Log(_L("Expected Value")); |
|
486 iLog->Log(expValue.AsDes()); |
|
487 */ |
|
488 TTime resTime = resValue.AsTTime(); |
|
489 |
|
490 //resTime.FormatL(timeString, _L("%:0%J%:1%T%:2%S%.%*C3%:3%+B %*E%*D%X%*N%*Y %1 %2 '%3")); |
|
491 resTime.FormatL(timeString, _L("%F%Y%M%D%:0%H%T%S")); |
|
492 |
|
493 /* iLog->Log(_L("Result Value")); |
|
494 iLog->Log(timeString); |
|
495 */ |
|
496 if(expTime.DateTime().Day() == resTime.DateTime().Day()) |
|
497 { |
|
498 if(expTime.DateTime().Month() == resTime.DateTime().Month()) |
|
499 if(expTime.DateTime().Year() == resTime.DateTime().Year()) |
|
500 //these things can be ignored |
|
501 /*if(expTime.DateTime().Hour() == resTime.DateTime().Hour()) |
|
502 if(expTime.DateTime().Minute() == resTime.DateTime().Minute()) |
|
503 if(expTime.DateTime().Second() == resTime.DateTime().Second())*/ |
|
504 { |
|
505 equal = ETrue; |
|
506 } |
|
507 } |
|
508 expValue.Reset(); |
|
509 resValue.Reset(); |
|
510 return equal; |
|
511 } |
|
512 |
|
513 /* -------------------------------------------------------------------------- |
|
514 CMediaObserver :: CompareTIntResult. |
|
515 A static method which compares two TInt results from the maps. |
|
516 ----------------------------------------------------------------------------- |
|
517 */ |
|
518 TBool CMediaObserver::CompareTIntResult(const TDesC8& aKey, |
|
519 CLiwMap* aExpectedMap, |
|
520 const CLiwMap* aResultMap) |
|
521 { |
|
522 TLiwVariant expValue; |
|
523 TLiwVariant resValue; |
|
524 TBool equal = EFalse; |
|
525 TBuf<255> expIntStr; |
|
526 TBuf<255> resIntStr; |
|
527 |
|
528 if(!aExpectedMap->FindL(aKey, expValue)) |
|
529 { |
|
530 return ETrue; |
|
531 } |
|
532 aResultMap->FindL(aKey, resValue); |
|
533 |
|
534 TInt expRes = expValue.AsTInt32(); |
|
535 TInt resRes = resValue.AsTInt32(); |
|
536 |
|
537 expIntStr.AppendNum(expRes); |
|
538 resIntStr.AppendNum(resRes); |
|
539 |
|
540 /* iLog->Log(_L("Expected Value")); |
|
541 iLog->Log(expIntStr); |
|
542 |
|
543 iLog->Log(_L("Result Value")); |
|
544 iLog->Log(resIntStr); |
|
545 */ |
|
546 if(expRes == resRes) |
|
547 { |
|
548 equal = ETrue; |
|
549 } |
|
550 expValue.Reset(); |
|
551 resValue.Reset(); |
|
552 return equal; |
|
553 } |
|
554 /* -------------------------------------------------------------------------- |
|
555 CMediaObserver :: NewL. |
|
556 Two phase construction |
|
557 ----------------------------------------------------------------------------- |
|
558 */ |
|
559 |
|
560 CMediaObserver* CMediaObserver::NewL() |
|
561 { |
|
562 CMediaObserver* self = new(ELeave)CMediaObserver(); |
|
563 CleanupStack::PushL(self); |
|
564 self->ConstructL(); |
|
565 CleanupStack::Pop(self); |
|
566 return self; |
|
567 } |
|
568 |
|
569 /* -------------------------------------------------------------------------- |
|
570 CMediaObserver :: CMediaObserver. |
|
571 Constructor |
|
572 ----------------------------------------------------------------------------- |
|
573 */ |
|
574 CMediaObserver::CMediaObserver():iInList(NULL),iOutList(NULL), |
|
575 iExpErrorCode(-1), |
|
576 iResult(0), |
|
577 iFiletype(EOtherFile), |
|
578 iFilename(NULL) |
|
579 { |
|
580 } |
|
581 |
|
582 /* -------------------------------------------------------------------------- |
|
583 CMediaObserver :: ConstructL |
|
584 |
|
585 ----------------------------------------------------------------------------- |
|
586 */ |
|
587 void CMediaObserver::ConstructL() |
|
588 { |
|
589 |
|
590 iInList = CLiwGenericParamList::NewL(); |
|
591 iOutList = CLiwGenericParamList::NewL(); |
|
592 |
|
593 User::LeaveIfError(iFs.Connect()); |
|
594 count++; |
|
595 TBuf<50> filnm; |
|
596 filnm.Append(KFilenm); |
|
597 filnm.AppendNum(count); |
|
598 filnm.Append(_L(".txt")); |
|
599 iFilename = filnm.Alloc(); |
|
600 User::LeaveIfError(iFile.Replace(iFs,*iFilename,EFileWrite)); |
|
601 |
|
602 } |
|
603 |
|
604 /* -------------------------------------------------------------------------- |
|
605 CMediaObserver :: ~CMediaObserver. |
|
606 Destructor |
|
607 ----------------------------------------------------------------------------- |
|
608 */ |
|
609 CMediaObserver::~CMediaObserver() |
|
610 { |
|
611 TInt count = iExpectedOutPutArray.Count(); |
|
612 for(TInt index =0 ;index<count;index++) |
|
613 { |
|
614 iExpectedOutPutArray[index]->DecRef(); |
|
615 } |
|
616 iExpectedOutPutArray.Close(); |
|
617 delete iInList; |
|
618 delete iOutList; |
|
619 if(iFilename) |
|
620 delete iFilename; |
|
621 iFile.Close(); |
|
622 iFs.Close(); |
|
623 } |
|
624 // ----------------------------------------------------------------------------- |
|
625 // CMediaObserver:: HandleNotifyL |
|
626 // Call Back Function Called by the Media Management SAPI. |
|
627 // ----------------------------------------------------------------------------- |
|
628 // |
|
629 TInt CMediaObserver:: HandleNotifyL(TInt /*aCmdId*/, |
|
630 TInt aEventId, |
|
631 CLiwGenericParamList& aEventParamList, |
|
632 const CLiwGenericParamList& /*aInParamList*/) |
|
633 { |
|
634 |
|
635 |
|
636 |
|
637 TInt pos = 0; |
|
638 TInt error = KErrGeneral; |
|
639 iResult = KErrGeneral; |
|
640 count--; |
|
641 TBuf<25> errorcodedes(KNullDesC); |
|
642 const TLiwGenericParam* errorCode = NULL; |
|
643 const TLiwGenericParam* resultList = NULL; |
|
644 CLiwIterable* iterator = NULL; |
|
645 |
|
646 if( 0 == count) |
|
647 CActiveScheduler::Stop(); |
|
648 |
|
649 errorCode = aEventParamList.FindFirst(pos, KErrorCode); // Finding Error Code |
|
650 resultList = aEventParamList.FindFirst(pos, KResponse); // Finding Iterator for the result list |
|
651 |
|
652 TBuf8<100> flbuf; |
|
653 |
|
654 if(errorCode) |
|
655 { |
|
656 error = errorCode->Value().AsTInt32(); |
|
657 errorcodedes.Num(error); |
|
658 iFile.Write(_L8("Error code:")); |
|
659 //flbuf.AppendNum(error); |
|
660 // flbuf.Append(_L8("\n")); |
|
661 // file.Write(flbuf); |
|
662 // flbuf.Zero(); |
|
663 // iLog->Log(_L("Error code:")); |
|
664 // iLog->Log(errorcodedes); |
|
665 } |
|
666 if(iExpErrorCode != error) |
|
667 { |
|
668 // iLog->Log(_L("Expected Error code does not match")); |
|
669 iFile.Write(_L8("Expected Error code does not match \n")); |
|
670 |
|
671 User::Leave(KErrGeneral); |
|
672 } |
|
673 if(resultList) |
|
674 { |
|
675 iterator = resultList->Value().AsIterable(); |
|
676 if(IsExpectedResult(iterator)) |
|
677 { |
|
678 iResult = KErrNone; |
|
679 } |
|
680 } |
|
681 else |
|
682 { |
|
683 if(iExpectedOutPutArray.Count() != 0) |
|
684 { |
|
685 // iLog->Log(_L("Result Iterator Not Found")); |
|
686 iFile.Write(_L8("Result Iterator Not Found \n")); |
|
687 |
|
688 |
|
689 User::Leave(KErrNotFound); |
|
690 } |
|
691 } |
|
692 |
|
693 iFile.Write(_L8("End of observer")); |
|
694 |
|
695 |
|
696 } |