|
1 /* |
|
2 * Copyright (c) 2008 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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <e32Base.h> |
|
21 #include <tz.h> |
|
22 #include <badesca.h> |
|
23 #include <commdb.h> |
|
24 #include <mmf/common/mmfcontrollerpluginresolver.h> |
|
25 |
|
26 #include "VCXTestCommon.h" |
|
27 #include "CIptvTestVerifyData.h" |
|
28 #include "TestUtilConnectionWaiter.h" |
|
29 #include "VCXTestLog.h" |
|
30 |
|
31 // EXTERNAL DATA STRUCTURES |
|
32 |
|
33 // EXTERNAL FUNCTION PROTOTYPES |
|
34 |
|
35 // CONSTANTS |
|
36 |
|
37 // MACROS |
|
38 |
|
39 // LOCAL CONSTANTS AND MACROS |
|
40 _LIT(KDummyfilePathFormat, "%S:\\data\\temp"); |
|
41 _LIT(KDummyfileFormat, "%d.dat"); |
|
42 _LIT(KDoubleBacklash, "\\"); |
|
43 |
|
44 // MODULE DATA STRUCTURES |
|
45 |
|
46 // LOCAL FUNCTION PROTOTYPES |
|
47 |
|
48 // FORWARD DECLARATIONS |
|
49 |
|
50 // ============================= LOCAL FUNCTIONS =============================== |
|
51 |
|
52 // ============================ MEMBER FUNCTIONS =============================== |
|
53 |
|
54 // ----------------------------------------------------------------------------- |
|
55 // CVCXTestCommon::CVCXTestCommon |
|
56 // C++ default constructor can NOT contain any code, that |
|
57 // might leave. |
|
58 // ----------------------------------------------------------------------------- |
|
59 // |
|
60 CVCXTestCommon::CVCXTestCommon() |
|
61 { |
|
62 } |
|
63 |
|
64 // ----------------------------------------------------------------------------- |
|
65 // CVCXTestCommon::ConstructL |
|
66 // Symbian 2nd phase constructor can leave. |
|
67 // ----------------------------------------------------------------------------- |
|
68 // |
|
69 void CVCXTestCommon::ConstructL() |
|
70 { |
|
71 VCXLOGLO1(">>>CVCXTestCommon::ConstructL"); |
|
72 |
|
73 User::LeaveIfError( iFs.Connect() ); |
|
74 |
|
75 PrintIaps(); |
|
76 |
|
77 PrintDriveInfo( _L("C") ); |
|
78 PrintDriveInfo( _L("E") ); |
|
79 PrintDriveInfo( _L("D") ); |
|
80 PrintDriveInfo( _L("F") ); |
|
81 |
|
82 //ListDir( _L("C:\\"), 0 ); |
|
83 //ListDir( _L("E:\\"), 0 ); |
|
84 |
|
85 iIptvVerifyData = CIptvTestVerifyData::NewL(); |
|
86 iVideoCreator = CIptvTestVideoCreator::NewL(); |
|
87 |
|
88 VCXLOGLO1("<<<CVCXTestCommon::ConstructL"); |
|
89 } |
|
90 |
|
91 // ----------------------------------------------------------------------------- |
|
92 // CIptvServicesFromFile::~CVCXTestCommon |
|
93 // Destructor |
|
94 // ----------------------------------------------------------------------------- |
|
95 // |
|
96 CVCXTestCommon::~CVCXTestCommon() |
|
97 { |
|
98 VCXLOGLO1(">>>CVCXTestCommon::~CVCXTestCommon"); |
|
99 |
|
100 delete iIptvVerifyData; |
|
101 iIptvVerifyData = NULL; |
|
102 |
|
103 delete iVideoCreator; |
|
104 iVideoCreator = NULL; |
|
105 |
|
106 iFs.Close(); |
|
107 |
|
108 VCXLOGLO1("<<<CVCXTestCommon::~CVCXTestCommon"); |
|
109 } |
|
110 |
|
111 // ----------------------------------------------------------------------------- |
|
112 // CVCXTestCommon::NewL |
|
113 // Two-phased constructor. |
|
114 // ----------------------------------------------------------------------------- |
|
115 // |
|
116 EXPORT_C CVCXTestCommon* CVCXTestCommon::NewL() |
|
117 { |
|
118 VCXLOGLO1(">>>CVCXTestCommon::NewL"); |
|
119 CVCXTestCommon* self = new( ELeave ) CVCXTestCommon; |
|
120 |
|
121 CleanupStack::PushL( self ); |
|
122 self->ConstructL(); |
|
123 CleanupStack::Pop(); |
|
124 VCXLOGLO1("<<<CVCXTestCommon::NewL"); |
|
125 return self; |
|
126 } |
|
127 |
|
128 // ----------------------------------------------------------------------------- |
|
129 // CVCXTestCommon::GetFileSize |
|
130 // ----------------------------------------------------------------------------- |
|
131 // |
|
132 EXPORT_C TBool CVCXTestCommon::GetFileSize(TDesC& aFullPath, TUint32& aFileSize) |
|
133 { |
|
134 VCXLOGLO1(">>>CVCXTestCommon::GetFileSize"); |
|
135 TBool rv = FALSE; |
|
136 TEntry entry; |
|
137 TInt err = KErrNone; |
|
138 |
|
139 aFileSize=0; |
|
140 |
|
141 err = iFs.Entry( aFullPath, entry ); |
|
142 |
|
143 if(KErrNone == err && !entry.IsDir()) |
|
144 { |
|
145 aFileSize = entry.iSize; |
|
146 rv = TRUE; |
|
147 } |
|
148 |
|
149 VCXLOGLO1("<<<CVCXTestCommon::GetFileSize"); |
|
150 return rv; |
|
151 } |
|
152 |
|
153 // ----------------------------------------------------------------------------- |
|
154 // CVCXTestCommon::GetIapIdL |
|
155 // ----------------------------------------------------------------------------- |
|
156 // |
|
157 EXPORT_C TBool CVCXTestCommon::GetIapIdL(const TDesC& aIapName, TUint32& aIapId) |
|
158 { |
|
159 VCXLOGLO1(">>>CVCXTestCommon::GetIapIdL"); |
|
160 |
|
161 TBool found( EFalse ); |
|
162 |
|
163 #ifdef __WINSCW__ |
|
164 if( aIapName != KIptvTestBadIapName && aIapName != _L("invalidiap") ) |
|
165 { |
|
166 _LIT(KEmulatorIap, "Ethernet with Daemon Dynamic IP"); |
|
167 found = GetIapIdByNameL(KEmulatorIap, aIapId); |
|
168 VCXLOGLO1("<<<CVCXTestCommon::GetIapIdL"); |
|
169 return found; |
|
170 } |
|
171 #endif |
|
172 |
|
173 VCXLOGLO2("CVCXTestCommon:: Searching IAP: %S", &aIapName); |
|
174 |
|
175 found = GetIapIdByNameL(aIapName, aIapId); |
|
176 |
|
177 // Iap with exact name found |
|
178 if( found ) |
|
179 { |
|
180 VCXLOGLO1("<<<CVCXTestCommon::GetIapIdL"); |
|
181 return found; |
|
182 } |
|
183 else |
|
184 if(aIapName == KIptvTestBadIapName) // Search bad iap only for a name. |
|
185 { |
|
186 VCXLOGLO2("CVCXTestCommon:: Iap with name %S not found!", &aIapName); |
|
187 VCXLOGLO1("<<<CVCXTestCommon::GetIapIdL"); |
|
188 return found; |
|
189 } |
|
190 |
|
191 VCXLOGLO1("<<<CVCXTestCommon:: Iap with exact name was not found."); |
|
192 |
|
193 TBuf<128> searchFor(aIapName); |
|
194 searchFor.LowerCase(); |
|
195 |
|
196 if(searchFor == _L("invalidiap") ) |
|
197 { |
|
198 aIapId = 6000; |
|
199 VCXLOGLO1("<<<CVCXTestCommon::GetIapIdL"); |
|
200 return ETrue; |
|
201 } |
|
202 |
|
203 TBool isWlanIapName( EFalse ); |
|
204 |
|
205 if( aIapName == _L("wlan") ) |
|
206 { |
|
207 found = GetIapIdByTypeL(CVCXTestCommon::EWlanIap, aIapId, 0); |
|
208 isWlanIapName = ETrue; |
|
209 } |
|
210 else |
|
211 if( aIapName == _L("wlan2") ) |
|
212 { |
|
213 found = GetIapIdByTypeL(CVCXTestCommon::EWlanIap, aIapId, 1); |
|
214 isWlanIapName = ETrue; |
|
215 } |
|
216 else |
|
217 if( aIapName == _L("internet") ) |
|
218 { |
|
219 found = GetIapIdByTypeL(CVCXTestCommon::EGprsIap, aIapId, 0); |
|
220 } |
|
221 else |
|
222 if( aIapName == _L("internet2") ) |
|
223 { |
|
224 found = GetIapIdByTypeL(CVCXTestCommon::EGprsIap, aIapId, 1); |
|
225 } |
|
226 |
|
227 if( !found && !isWlanIapName ) |
|
228 { |
|
229 VCXLOGLO1("<<<CVCXTestCommon:: Trying to find alternative IAP."); |
|
230 |
|
231 // Try search other known GPRS IAPs |
|
232 _LIT(KIapElisaInternet, "elisa internet"); |
|
233 _LIT(KIapElisaMMS, "elisa mms"); |
|
234 _LIT(KIapInternet, "internet"); |
|
235 _LIT(KIapProinternet, "prointernet"); |
|
236 _LIT(KGprsInternet, "gprs internet"); |
|
237 |
|
238 if( GetIapIdByNameL(KIapElisaInternet, aIapId) || |
|
239 GetIapIdByNameL(KIapElisaMMS, aIapId) || |
|
240 GetIapIdByNameL(KIapInternet, aIapId) || |
|
241 GetIapIdByNameL(KIapProinternet, aIapId) || |
|
242 GetIapIdByNameL(KGprsInternet, aIapId) ) |
|
243 { |
|
244 found = ETrue; |
|
245 } |
|
246 |
|
247 if( !found ) |
|
248 { |
|
249 VCXLOGLO1("<<<CVCXTestCommon:: Any GPRS IAP is good..."); |
|
250 found = GetIapIdByTypeL(CVCXTestCommon::EGprsIap, aIapId, 0); |
|
251 } |
|
252 } |
|
253 else |
|
254 { |
|
255 VCXLOGLO1("<<<CVCXTestCommon:: WLAN IAP wanted. Not found."); |
|
256 } |
|
257 |
|
258 VCXLOGLO1("<<<CVCXTestCommon::GetIapIdL"); |
|
259 return found; |
|
260 } |
|
261 |
|
262 // ----------------------------------------------------------------------------- |
|
263 // CVCXTestCommon::GetIapIdByNameL |
|
264 // ----------------------------------------------------------------------------- |
|
265 // |
|
266 EXPORT_C TBool CVCXTestCommon::GetIapIdByNameL(const TDesC& aIapName, TUint32& aIapId) |
|
267 { |
|
268 VCXLOGLO1(">>>CVCXTestCommon::GetIapIdByNameL"); |
|
269 TBool found = EFalse; |
|
270 aIapId = 0; |
|
271 |
|
272 TBuf<128> searchFor(aIapName); |
|
273 searchFor.LowerCase(); |
|
274 |
|
275 // Get IAP names and ids from the database |
|
276 CCommsDatabase* cdb( NULL ); |
|
277 TRAPD( err, cdb = CCommsDatabase::NewL( EDatabaseTypeIAP ) ); |
|
278 if( err != KErrNone ) |
|
279 { |
|
280 VCXLOGLO2("CVCXTestCommon::GetIapIdByNameL: CCommsDatabase::NewL left: %d, leaving", err); |
|
281 User::Leave( err ); |
|
282 } |
|
283 CleanupStack::PushL( cdb ); |
|
284 |
|
285 cdb->ShowHiddenRecords(); |
|
286 |
|
287 CCommsDbTableView* view( NULL ); |
|
288 TRAP( err, view = cdb->OpenTableLC( TPtrC(IAP) ); CleanupStack::Pop( view ); ); |
|
289 CleanupStack::PushL( view ); |
|
290 |
|
291 if( err != KErrNone ) |
|
292 { |
|
293 VCXLOGLO2("CVCXTestCommon::GetIapIdByNameL: CCommsDatabase::OpenTableLC left: %d, leaving", err); |
|
294 User::Leave( err ); |
|
295 } |
|
296 |
|
297 TBuf<40> name; |
|
298 TUint32 id; |
|
299 TInt res = view->GotoFirstRecord(); |
|
300 while( res == KErrNone ) |
|
301 { |
|
302 TRAP( err, view->ReadTextL( TPtrC(COMMDB_NAME), name ) ); |
|
303 if( err != KErrNone ) continue; |
|
304 TRAP( err, view->ReadUintL( TPtrC(COMMDB_ID), id ) ); |
|
305 if( err != KErrNone ) continue; |
|
306 |
|
307 name.LowerCase(); |
|
308 if(searchFor == name) |
|
309 { |
|
310 aIapId = id; |
|
311 VCXLOGLO3("CVCXTestCommon:: Found IAP: %d, %S", aIapId, &aIapName); |
|
312 found = ETrue; |
|
313 break; |
|
314 } |
|
315 res = view->GotoNextRecord(); |
|
316 } |
|
317 |
|
318 CleanupStack::PopAndDestroy( view ); |
|
319 CleanupStack::PopAndDestroy( cdb ); |
|
320 |
|
321 VCXLOGLO1("<<<CVCXTestCommon::GetIapIdByNameL"); |
|
322 return found; |
|
323 } |
|
324 |
|
325 // ----------------------------------------------------------------------------- |
|
326 // CVCXTestCommon::GetIapIdByTypeL |
|
327 // ----------------------------------------------------------------------------- |
|
328 // |
|
329 EXPORT_C TBool CVCXTestCommon::GetIapIdByTypeL(TIptvTestIapType aType, TUint32& aIapId, TInt aOrderNumber) |
|
330 { |
|
331 VCXLOGLO1(">>>CVCXTestCommon::GetIapIdByTypeL"); |
|
332 |
|
333 aIapId = 0; |
|
334 TBool found( EFalse ); |
|
335 |
|
336 #ifdef __WINSCW__ |
|
337 found = GetIapIdByNameL( _L("Ethernet with Daemon Dynamic IP"), aIapId ); |
|
338 VCXLOGLO1("<<<CVCXTestCommon::GetIapIdByTypeL"); |
|
339 return found; |
|
340 #endif |
|
341 |
|
342 // Get AP names and ids from the database |
|
343 CCommsDatabase* TheDb = CCommsDatabase::NewL( EDatabaseTypeIAP ); |
|
344 CleanupStack::PushL( TheDb ); |
|
345 |
|
346 TheDb->ShowHiddenRecords(); |
|
347 |
|
348 CCommsDbTableView* view = TheDb->OpenTableLC( TPtrC(IAP) ); |
|
349 |
|
350 TBuf<40> name; |
|
351 TUint32 id; |
|
352 TBuf<255> iapType; |
|
353 TInt matchCount(0); |
|
354 |
|
355 TInt res = view->GotoFirstRecord(); |
|
356 |
|
357 while( res == KErrNone ) |
|
358 { |
|
359 view->ReadTextL( TPtrC(COMMDB_NAME), name ); |
|
360 view->ReadUintL( TPtrC(COMMDB_ID), id ); |
|
361 view->ReadTextL( TPtrC(IAP_SERVICE_TYPE), iapType); |
|
362 |
|
363 VCXLOGLO3("CVCXTestCommon:: name: %S, id: %d", &name, id); |
|
364 VCXLOGLO2("CVCXTestCommon:: type: %S", &iapType); |
|
365 |
|
366 if( ( iapType == _L("LANService") && aType == EWlanIap && name != _L("Easy WLAN") ) || |
|
367 ( iapType == _L("OutgoingGPRS") && aType == EGprsIap ) ) |
|
368 { |
|
369 if( matchCount == aOrderNumber ) |
|
370 { |
|
371 found = ETrue; |
|
372 aIapId = id; |
|
373 break; |
|
374 } |
|
375 matchCount++; |
|
376 } |
|
377 |
|
378 res = view->GotoNextRecord(); |
|
379 } |
|
380 |
|
381 CleanupStack::PopAndDestroy( view ); // view |
|
382 CleanupStack::PopAndDestroy( TheDb ); // TheDb |
|
383 |
|
384 VCXLOGLO1("<<<CVCXTestCommon::GetIapIdByTypeL"); |
|
385 return found; |
|
386 } |
|
387 |
|
388 // ----------------------------------------------------------------------------- |
|
389 // CVCXTestCommon::GetIapNameById |
|
390 // ----------------------------------------------------------------------------- |
|
391 // |
|
392 EXPORT_C TBool CVCXTestCommon::GetIapNameById(TDes& aIapName, TUint32 aIapId) |
|
393 { |
|
394 TBool found = FALSE; |
|
395 |
|
396 // Get AP names and ids from the database |
|
397 CCommsDatabase* TheDb = CCommsDatabase::NewL( EDatabaseTypeIAP ); |
|
398 CleanupStack::PushL( TheDb ); |
|
399 |
|
400 TheDb->ShowHiddenRecords(); |
|
401 |
|
402 CCommsDbTableView* view = TheDb->OpenTableLC( TPtrC(IAP) ); |
|
403 |
|
404 TBuf<40> name; |
|
405 TUint32 id; |
|
406 TInt res = view->GotoFirstRecord(); |
|
407 |
|
408 while( res == KErrNone ) |
|
409 { |
|
410 view->ReadTextL( TPtrC(COMMDB_NAME), name ); |
|
411 view->ReadUintL( TPtrC(COMMDB_ID), id ); |
|
412 |
|
413 res = view->GotoNextRecord(); |
|
414 //VCXLOGLO3("IAP name, id: %S, %d", &name, id); |
|
415 if(id == aIapId) |
|
416 { |
|
417 found = TRUE; |
|
418 aIapName.Zero(); |
|
419 aIapName.Append(name); |
|
420 break; |
|
421 } |
|
422 } |
|
423 |
|
424 CleanupStack::PopAndDestroy( view ); // view |
|
425 CleanupStack::PopAndDestroy( TheDb ); // TheDb |
|
426 |
|
427 return found; |
|
428 } |
|
429 |
|
430 // ----------------------------------------------------------------------------- |
|
431 // CVCXTestCommon::PrintIaps |
|
432 // ----------------------------------------------------------------------------- |
|
433 // |
|
434 EXPORT_C void CVCXTestCommon::PrintIaps() |
|
435 { |
|
436 VCXLOGLO1(">>>CVCXTestCommon::PrintIaps"); |
|
437 // Get IAP names and ids from the database |
|
438 CCommsDatabase* TheDb( NULL ); |
|
439 TRAPD( err, TheDb = CCommsDatabase::NewL( EDatabaseTypeIAP ) ); |
|
440 |
|
441 if( err == KErrNone && TheDb ) |
|
442 { |
|
443 CleanupStack::PushL( TheDb ); |
|
444 |
|
445 TheDb->ShowHiddenRecords(); |
|
446 |
|
447 CCommsDbTableView* view( NULL ); |
|
448 TRAP( err, view = TheDb->OpenTableLC( TPtrC(IAP) ); CleanupStack::Pop( view ); ); |
|
449 CleanupStack::PushL( view ); |
|
450 |
|
451 if( err == KErrNone && view ) |
|
452 { |
|
453 TBuf<40> name; |
|
454 TUint32 id; |
|
455 err = view->GotoFirstRecord(); |
|
456 while( err == KErrNone ) |
|
457 { |
|
458 TRAP( err, view->ReadTextL( TPtrC(COMMDB_NAME), name ) ); |
|
459 if( err != KErrNone ) break; |
|
460 TRAP( err, view->ReadUintL( TPtrC(COMMDB_ID), id ) ); |
|
461 if( err != KErrNone ) break; |
|
462 VCXLOGLO3("CVCXTestCommon:: IAP name, id: %S, %d", &name, id); |
|
463 |
|
464 err = view->GotoNextRecord(); |
|
465 if( err != KErrNone ) break; |
|
466 } |
|
467 } |
|
468 CleanupStack::PopAndDestroy( view ); // view |
|
469 CleanupStack::PopAndDestroy( TheDb ); // TheDb |
|
470 } |
|
471 VCXLOGLO1("<<<CVCXTestCommon::PrintIaps"); |
|
472 } |
|
473 |
|
474 // ----------------------------------------------------------------------------- |
|
475 // CIptvTestVerifyData::CreateVerifyData |
|
476 // ----------------------------------------------------------------------------- |
|
477 // |
|
478 EXPORT_C TInt CVCXTestCommon::CreateVerifyData(TDesC& aVerifyId, TBool aAppend) |
|
479 { |
|
480 VCXLOGLO2(">>>CVCXTestCommon::CreateVerifyData: %S", &aVerifyId); |
|
481 TInt result = KErrNone; |
|
482 TRAPD(err, result = iIptvVerifyData->CreateVerifyDataL(aVerifyId, aAppend)); |
|
483 if(err != KErrNone) |
|
484 { |
|
485 VCXLOGLO2("CIptvVerifyData::CreateVerifyDataL caused a leave. %d", err); |
|
486 result = err; |
|
487 } |
|
488 VCXLOGLO1("<<<CVCXTestCommon::CreateVerifyData"); |
|
489 return result; |
|
490 } |
|
491 |
|
492 // ----------------------------------------------------------------------------- |
|
493 // CIptvTestVerifyData::WriteVerifyData |
|
494 // ----------------------------------------------------------------------------- |
|
495 // |
|
496 EXPORT_C TInt CVCXTestCommon::WriteVerifyData(TDesC& aVerifyId, TDesC& aVerifyData) |
|
497 { |
|
498 //VCXLOGLO1(">>>CVCXTestCommon::WriteVerifyData"); |
|
499 TInt result = KErrNone; |
|
500 TRAPD(err, result = iIptvVerifyData->WriteVerifyDataL(aVerifyId, aVerifyData)); |
|
501 if(err != KErrNone) |
|
502 { |
|
503 VCXLOGLO2("CIptvVerifyData::WriteVerifyDataL caused a leave. %d", err); |
|
504 result = err; |
|
505 } |
|
506 //VCXLOGLO1("<<<CVCXTestCommon::WriteVerifyData"); |
|
507 return result; |
|
508 } |
|
509 |
|
510 // ----------------------------------------------------------------------------- |
|
511 // CIptvTestVerifyData::WriteVerifyData |
|
512 // ----------------------------------------------------------------------------- |
|
513 // |
|
514 EXPORT_C TInt CVCXTestCommon::WriteVerifyData(TDesC& aVerifyId, TRefByValue<const TDesC> aFmt, ... ) |
|
515 { |
|
516 //VCXLOGLO1(">>>CVCXTestCommon::WriteVerifyData(formatted)"); |
|
517 |
|
518 VA_LIST argptr; //pointer to argument list |
|
519 VA_START( argptr, aFmt ); |
|
520 |
|
521 HBufC* str; |
|
522 str = HBufC::NewLC(1024*3); |
|
523 |
|
524 //TBuf<512*3> str; |
|
525 //TBuf<512> format(_L("TESTI: %d, %S")); |
|
526 |
|
527 str->Des().FormatList(aFmt, argptr); |
|
528 |
|
529 TInt result = KErrNone; |
|
530 TRAPD(err, result = iIptvVerifyData->WriteVerifyDataL(aVerifyId, *str)); |
|
531 |
|
532 CleanupStack::PopAndDestroy(str); |
|
533 |
|
534 if(err != KErrNone) |
|
535 { |
|
536 VCXLOGLO2("CIptvVerifyData::WriteVerifyDataL caused a leave. %d", err); |
|
537 result = err; |
|
538 } |
|
539 |
|
540 //VCXLOGLO1("<<<CVCXTestCommon::WriteVerifyData(formatted)"); |
|
541 return result; |
|
542 } |
|
543 |
|
544 // ----------------------------------------------------------------------------- |
|
545 // CIptvTestVerifyData::VerifyData |
|
546 // ----------------------------------------------------------------------------- |
|
547 // |
|
548 EXPORT_C TInt CVCXTestCommon::VerifyData(TDesC& aVerifyId, CIptvTestVerifyData::TVerifyResult& aVerifyResult) |
|
549 { |
|
550 VCXLOGLO1(">>>CVCXTestCommon::VerifyData"); |
|
551 TInt result = KErrNone; |
|
552 TRAPD(err, result = iIptvVerifyData->VerifyDataL(aVerifyId, aVerifyResult)); |
|
553 if(err != KErrNone) |
|
554 { |
|
555 VCXLOGLO2("CIptvVerifyData::VerifyDataL caused a leave. %d", err); |
|
556 result = err; |
|
557 } |
|
558 VCXLOGLO1("<<<CVCXTestCommon::VerifyData"); |
|
559 return result; |
|
560 } |
|
561 |
|
562 // ----------------------------------------------------------------------------- |
|
563 // CIptvTestVerifyData::EnableVerifyTimestamps |
|
564 // ----------------------------------------------------------------------------- |
|
565 // |
|
566 EXPORT_C void CVCXTestCommon::EnableVerifyTimestamps( TBool aUseTimestamps ) |
|
567 { |
|
568 VCXLOGLO1(">>>CVCXTestCommon::EnableVerifyTimestamps"); |
|
569 iIptvVerifyData->EnableTimestamps( aUseTimestamps ); |
|
570 VCXLOGLO1("<<<CVCXTestCommon::EnableVerifyTimestamps"); |
|
571 } |
|
572 |
|
573 // ----------------------------------------------------------------------------- |
|
574 // CVCXTestCommon::ParseIntFromString |
|
575 // ----------------------------------------------------------------------------- |
|
576 EXPORT_C TInt CVCXTestCommon::ParseIntFromString(TInt& aInt, TDesC& aString) |
|
577 { |
|
578 VCXLOGLO1(">>>CVCXTestCommon::ParseIntFromString"); |
|
579 |
|
580 TLex lex(aString); |
|
581 TInt err = lex.Val(aInt); |
|
582 |
|
583 VCXLOGLO1("<<<CVCXTestCommon::ParseIntFromString"); |
|
584 return err; |
|
585 } |
|
586 |
|
587 // ----------------------------------------------------------------------------- |
|
588 // CVCXTestCommon::CreateBadIapL |
|
589 // Creates a not working, crappy iap with given name. |
|
590 // Use with caution, because there is no easy way of removing created iaps |
|
591 // |
|
592 // @param aName name of the iap to be created |
|
593 // @return iapId new iap's id. |
|
594 // ----------------------------------------------------------------------------- |
|
595 // |
|
596 EXPORT_C TUint32 CVCXTestCommon::CreateBadIapL(TDesC& aName) |
|
597 { |
|
598 VCXLOGLO1(">>>CVCXTestCommon::CreateBadIapL"); |
|
599 CCommsDatabase* cdb = CCommsDatabase::NewL( EDatabaseTypeIAP ); |
|
600 CleanupStack::PushL( cdb ); |
|
601 |
|
602 TBuf16<40> name; |
|
603 name.Copy( aName ); |
|
604 |
|
605 TUint32 iapId( 0 ); |
|
606 TUint32 iapServiceId( 1 ); |
|
607 TUint32 id( 2 ); |
|
608 TUint32 iapNetworkId( 3 ); |
|
609 TUint32 weighting( 4 ); |
|
610 TUint32 loc( 5 ); |
|
611 |
|
612 User::LeaveIfError( cdb->BeginTransaction() ); |
|
613 |
|
614 CCommsDbTableView* iapTable = cdb->OpenTableLC( TPtrC( IAP ) ); |
|
615 |
|
616 User::LeaveIfError( iapTable->InsertRecord( iapId ) ); |
|
617 |
|
618 iapTable->WriteTextL( TPtrC( COMMDB_NAME ), name ); |
|
619 iapTable->WriteUintL( TPtrC( IAP_SERVICE ), iapServiceId ); |
|
620 iapTable->WriteTextL( TPtrC( IAP_SERVICE_TYPE ), TPtrC( LAN_SERVICE ) ); |
|
621 iapTable->WriteTextL( TPtrC( IAP_BEARER_TYPE ), TPtrC( LAN_BEARER ) ); |
|
622 iapTable->WriteUintL( TPtrC( IAP_BEARER ), id ); |
|
623 iapTable->WriteUintL( TPtrC( IAP_NETWORK ), iapNetworkId ); |
|
624 iapTable->WriteUintL( TPtrC( IAP_NETWORK_WEIGHTING ), weighting ); |
|
625 iapTable->WriteUintL( TPtrC( IAP_LOCATION ), loc ); |
|
626 |
|
627 User::LeaveIfError( iapTable->PutRecordChanges( EFalse, EFalse ) ); |
|
628 |
|
629 CleanupStack::PopAndDestroy( iapTable ); |
|
630 |
|
631 User::LeaveIfError( cdb->CommitTransaction() ); |
|
632 |
|
633 CleanupStack::PopAndDestroy( cdb ); |
|
634 VCXLOGLO1("<<<CVCXTestCommon::CreateBadIapL"); |
|
635 return iapId; |
|
636 } |
|
637 |
|
638 // ----------------------------------------------------------------------------- |
|
639 // CVCXTestCommon::AdvanceSystemTimeSeconds |
|
640 // ----------------------------------------------------------------------------- |
|
641 // |
|
642 EXPORT_C TInt CVCXTestCommon::AdvanceSystemTimeSeconds( TInt aCount ) |
|
643 { |
|
644 VCXLOGLO1(">>>CVCXTestCommon::AdvanceSystemTimeSeconds"); |
|
645 |
|
646 TTime now; |
|
647 now.HomeTime(); |
|
648 |
|
649 TTimeIntervalSeconds second(1*aCount); |
|
650 now += second; |
|
651 |
|
652 TInt err = CVCXTestCommon::SetSystemTime(now); |
|
653 |
|
654 VCXLOGLO1("<<<CVCXTestCommon::AdvanceSystemTimeSeconds"); |
|
655 |
|
656 return err; |
|
657 } |
|
658 |
|
659 // ----------------------------------------------------------------------------- |
|
660 // CVCXTestCommon::AdvanceSystemTimeMinutes |
|
661 // ----------------------------------------------------------------------------- |
|
662 // |
|
663 EXPORT_C TInt CVCXTestCommon::AdvanceSystemTimeMinutes( TInt aCount ) |
|
664 { |
|
665 VCXLOGLO1(">>>CVCXTestCommon::AdvanceSystemTimeMinutes"); |
|
666 |
|
667 TTime now; |
|
668 now.HomeTime(); |
|
669 |
|
670 TTimeIntervalSeconds minute(1*60*aCount); |
|
671 now += minute; |
|
672 |
|
673 TInt err = CVCXTestCommon::SetSystemTime(now); |
|
674 |
|
675 VCXLOGLO1("<<<CVCXTestCommon::AdvanceSystemTimeMinutes"); |
|
676 |
|
677 return err; |
|
678 } |
|
679 |
|
680 // ----------------------------------------------------------------------------- |
|
681 // CVCXTestCommon::AdvanceSystemTimeHours |
|
682 // ----------------------------------------------------------------------------- |
|
683 // |
|
684 EXPORT_C TInt CVCXTestCommon::AdvanceSystemTimeHours( TInt aCount ) |
|
685 { |
|
686 VCXLOGLO1(">>>CVCXTestCommon::AdvanceSystemTimeHours"); |
|
687 |
|
688 TTime now; |
|
689 now.HomeTime(); |
|
690 |
|
691 TTimeIntervalSeconds hour(1*60*60*aCount); |
|
692 now += hour; |
|
693 |
|
694 TInt err = CVCXTestCommon::SetSystemTime(now); |
|
695 |
|
696 VCXLOGLO1("<<<CVCXTestCommon::AdvanceSystemTimeHours"); |
|
697 return err; |
|
698 } |
|
699 |
|
700 // ----------------------------------------------------------------------------- |
|
701 // CVCXTestCommon::SetSystemTime() |
|
702 // ----------------------------------------------------------------------------- |
|
703 // |
|
704 EXPORT_C TInt CVCXTestCommon::SetSystemTime(TTime aTime) |
|
705 { |
|
706 VCXLOGLO1(">>>CVCXTestCommon::SetSystemTime"); |
|
707 |
|
708 TTime noDST(aTime); |
|
709 RTz tz; |
|
710 TInt err = tz.Connect(); |
|
711 if(err != KErrNone) |
|
712 { |
|
713 VCXLOGLO2("RTz::Connect failed: %d", err); |
|
714 VCXLOGLO1("<<<CVCXTestCommon::SetSystemTime"); |
|
715 return err; |
|
716 } |
|
717 CleanupClosePushL(tz); |
|
718 err = tz.SetHomeTime(noDST); |
|
719 if(err != KErrNone) |
|
720 { |
|
721 VCXLOGLO2("RTz::SetHomeTime failed: %d", err); |
|
722 VCXLOGLO1("<<<CVCXTestCommon::SetSystemTime"); |
|
723 CleanupStack::PopAndDestroy(&tz); |
|
724 return err; |
|
725 } |
|
726 |
|
727 CleanupStack::PopAndDestroy(&tz); |
|
728 |
|
729 VCXLOGLO1("<<<CVCXTestCommon::SetSystemTime"); |
|
730 |
|
731 return err; |
|
732 } |
|
733 |
|
734 // ----------------------------------------------------------------------------- |
|
735 // CVCXTestCommon::SetTimeZone() |
|
736 // ----------------------------------------------------------------------------- |
|
737 // |
|
738 EXPORT_C TInt CVCXTestCommon::SetTimeZone(TDesC& aTimeZone) |
|
739 { |
|
740 VCXLOGLO1(">>>CVCXTestCommon::SetTimeZone"); |
|
741 |
|
742 RTz tz; |
|
743 TInt err = tz.Connect(); |
|
744 if(err != KErrNone) |
|
745 { |
|
746 VCXLOGLO2("RTz::Connect failed: %d", err); |
|
747 VCXLOGLO1("<<<CVCXTestCommon::SetTimeZone"); |
|
748 return err; |
|
749 } |
|
750 CleanupClosePushL(tz); |
|
751 |
|
752 TBuf8<256> timezone; |
|
753 timezone.Copy( aTimeZone ); // Conversion |
|
754 |
|
755 CTzId* tzId = CTzId::NewL( timezone ); |
|
756 CleanupStack::PushL(tzId); |
|
757 |
|
758 TRAP(err, tz.SetTimeZoneL( *tzId ) ); |
|
759 CleanupStack::PopAndDestroy(tzId); |
|
760 CleanupStack::PopAndDestroy(&tz); |
|
761 |
|
762 if(err != KErrNone) |
|
763 { |
|
764 VCXLOGLO2("RTz::SetTimeZone failed: %d", err); |
|
765 VCXLOGLO1("<<<CVCXTestCommon::SetTimeZone"); |
|
766 return err; |
|
767 } |
|
768 |
|
769 VCXLOGLO1("<<<CVCXTestCommon::SetTimeZone"); |
|
770 |
|
771 return err; |
|
772 } |
|
773 |
|
774 // ----------------------------------------------------------------------------- |
|
775 // CVCXTestCommon::CreateVideoFileL() |
|
776 // |
|
777 // Creates a video file to file system. |
|
778 // ----------------------------------------------------------------------------- |
|
779 // |
|
780 EXPORT_C void CVCXTestCommon::CreateVideoFileL( CIptvTestVideoCreator::TIptvTestVideoType aVideoType, TDesC& aFileName, TInt aSize ) |
|
781 { |
|
782 VCXLOGLO1(">>>CVCXTestCommon::CreateVideoFileL"); |
|
783 iVideoCreator->CreateVideoL( aVideoType, aFileName, aSize ); |
|
784 VCXLOGLO1("<<<CVCXTestCommon::CreateVideoFileL"); |
|
785 } |
|
786 |
|
787 // ----------------------------------------------------------------------------- |
|
788 // CVCXTestCommon::CreateVideoFilesL() |
|
789 // ----------------------------------------------------------------------------- |
|
790 // |
|
791 EXPORT_C void CVCXTestCommon::CreateVideoFilesL( CIptvTestVideoCreator::TIptvTestVideoType aVideoType, TDesC& aFileName, TInt aCount, RPointerArray<HBufC>& aFileArray ) |
|
792 { |
|
793 VCXLOGLO1(">>>CVCXTestCommon::CreateVideoFilesL"); |
|
794 iVideoCreator->CreateVideosL( aVideoType, aFileName, aCount, aFileArray ); |
|
795 VCXLOGLO1("<<<CVCXTestCommon::CreateVideoFilesL"); |
|
796 } |
|
797 |
|
798 // ----------------------------------------------------------------------------- |
|
799 // CVCXTestCommon::SetDriveFreeSpaceL() |
|
800 // ----------------------------------------------------------------------------- |
|
801 // |
|
802 EXPORT_C void CVCXTestCommon::SetDriveFreeSpaceL( TInt aDriveNumber, TUint aDesiredFreeSpace ) |
|
803 { |
|
804 VCXLOGLO1(">>>CVCXTestCommon::SetDriveFreeSpaceL"); |
|
805 |
|
806 const TInt KIptvTest1KB = 1024; |
|
807 const TInt KIptvTest1MB = KIptvTest1KB*KIptvTest1KB; |
|
808 |
|
809 #ifdef __WINSCW__ |
|
810 if(aDriveNumber == EDriveC) |
|
811 { |
|
812 VCXLOGLO1("CVCXTestCommon:: ABORT! No C drive fill in emulator."); |
|
813 User::Leave( KErrAbort ); |
|
814 } |
|
815 #endif |
|
816 |
|
817 TChar driveLetter; |
|
818 User::LeaveIfError( RFs::DriveToChar( aDriveNumber, driveLetter ) ); |
|
819 |
|
820 TBuf<255> path; |
|
821 path.Append( driveLetter ); |
|
822 path.Append( _L(":\\data\\temp") ); |
|
823 path.Append( KDoubleBacklash ); |
|
824 |
|
825 // First check that if there's free space to fill. |
|
826 |
|
827 TInt64 spaceToReserve = 0; |
|
828 CalculateSpaceToReserveL(iFs, aDriveNumber, aDesiredFreeSpace, spaceToReserve); |
|
829 |
|
830 if( spaceToReserve == 0 ) |
|
831 { |
|
832 VCXLOGLO1("<<<CVCXTestCommon::SetDriveFreeSpaceL"); |
|
833 return; |
|
834 } |
|
835 |
|
836 // No space, try freeing by deleting existing dummy files. |
|
837 if( spaceToReserve < 0 ) |
|
838 { |
|
839 VCXLOGLO1("CVCXTestCommon:: Trying to free some space."); |
|
840 |
|
841 for( TInt i=50; i>0; i-- ) |
|
842 { |
|
843 TBuf<256> filePath; |
|
844 filePath.Zero(); |
|
845 filePath.Append( path ); |
|
846 filePath.AppendFormat( KDummyfileFormat, i ); |
|
847 if( BaflUtils::FileExists( iFs, filePath ) ) |
|
848 { |
|
849 VCXLOGLO2("CVCXTestCommon:: Deleting %S.", &filePath); |
|
850 iFs.Delete( filePath ); |
|
851 CalculateSpaceToReserveL(iFs, aDriveNumber, aDesiredFreeSpace, spaceToReserve); |
|
852 |
|
853 // Is there's enough free space now. |
|
854 if( spaceToReserve > 0 ) |
|
855 { |
|
856 break; |
|
857 } |
|
858 } |
|
859 } |
|
860 |
|
861 // Recheck free space. |
|
862 if( spaceToReserve < 0 ) |
|
863 { |
|
864 VCXLOGLO1("CVCXTestCommon:: Error! There's already less than wanted space!"); |
|
865 User::Leave( KErrAbort ); |
|
866 } |
|
867 } |
|
868 |
|
869 BaflUtils::EnsurePathExistsL(iFs, path); |
|
870 |
|
871 // Start creating files of 256 MB size. |
|
872 TInt64 dummyFileSize = 256 * KIptvTest1MB; |
|
873 |
|
874 TInt count = 0; |
|
875 while( ETrue ) |
|
876 { |
|
877 // Check that there's still enough free space for the dummyfile |
|
878 CalculateSpaceToReserveL( iFs, aDriveNumber, aDesiredFreeSpace, spaceToReserve ); |
|
879 |
|
880 if( spaceToReserve <= 0 ) |
|
881 { |
|
882 VCXLOGLO1("CVCXTestCommon:: Nothing to reserve anymore."); |
|
883 break; |
|
884 } |
|
885 |
|
886 // Fill all at once if less than 1MB to go. |
|
887 if( spaceToReserve < KIptvTest1MB ) |
|
888 { |
|
889 dummyFileSize = spaceToReserve; |
|
890 } |
|
891 |
|
892 // Not enough space for dummy file, find smaller size. |
|
893 while( dummyFileSize > spaceToReserve ) |
|
894 { |
|
895 dummyFileSize /= 2; |
|
896 } |
|
897 |
|
898 // Find free filename. |
|
899 TBuf<256> filePath; |
|
900 do |
|
901 { |
|
902 filePath.Zero(); |
|
903 filePath.Append( path ); |
|
904 count++; |
|
905 filePath.AppendFormat(KDummyfileFormat, count); |
|
906 } |
|
907 while ( BaflUtils::FileExists( iFs, filePath ) ); |
|
908 |
|
909 VCXLOGLO3("Creating %Ld b file to '%S'", dummyFileSize, &filePath); |
|
910 |
|
911 // Create the file. |
|
912 RFile file; |
|
913 TInt err = file.Replace(iFs, filePath, EFileWrite); |
|
914 if(err != KErrNone) |
|
915 { |
|
916 VCXLOGLO2("file.Replace fail: %d", err); |
|
917 } |
|
918 User::LeaveIfError(err); |
|
919 err = file.SetSize( dummyFileSize ); |
|
920 if(err != KErrNone) |
|
921 { |
|
922 VCXLOGLO2("file.SetSize fail: %d", err); |
|
923 } |
|
924 User::LeaveIfError(err); |
|
925 file.Close(); |
|
926 |
|
927 TVolumeInfo volumeInfo; |
|
928 User::LeaveIfError(iFs.Volume(volumeInfo, aDriveNumber)); |
|
929 VCXLOGLO2("Free space after: %Ld b", volumeInfo.iFree); |
|
930 } |
|
931 |
|
932 VCXLOGLO1("<<<CVCXTestCommon::SetDriveFreeSpaceL"); |
|
933 } |
|
934 |
|
935 // ----------------------------------------------------------------------------- |
|
936 // CVCXTestCommon::CalculateSpaceToReserve |
|
937 // ----------------------------------------------------------------------------- |
|
938 // |
|
939 void CVCXTestCommon::CalculateSpaceToReserveL( RFs &aFs, TInt aDriveNumber, TInt aDesiredSpace, TInt64& aSpaceToReserve) |
|
940 { |
|
941 TVolumeInfo volumeInfo; |
|
942 User::LeaveIfError(aFs.Volume(volumeInfo, aDriveNumber)); |
|
943 |
|
944 TInt64 driveSize = volumeInfo.iSize; |
|
945 TInt64 reservedSpace = 0; |
|
946 if(aDriveNumber == EDriveC) |
|
947 { |
|
948 reservedSpace = 1024*500; // Leave 500KB extra free to C drive |
|
949 } |
|
950 |
|
951 TInt64 driveFreeSpace = volumeInfo.iFree; |
|
952 TInt64 usableSpace = driveFreeSpace - reservedSpace; |
|
953 aSpaceToReserve = usableSpace - aDesiredSpace; |
|
954 |
|
955 VCXLOGLO2("CVCXTestCommon: driveSize = %Ld", driveSize); |
|
956 VCXLOGLO2("CVCXTestCommon: reservedSpace = %Ld", reservedSpace); |
|
957 VCXLOGLO2("CVCXTestCommon: freeSpace = %Ld", driveFreeSpace); |
|
958 VCXLOGLO2("CVCXTestCommon: usableSpace = %Ld", usableSpace); |
|
959 VCXLOGLO2("CVCXTestCommon: desiredSpace = %d", aDesiredSpace); |
|
960 VCXLOGLO2("CVCXTestCommon: spaceToReserve = %Ld", aSpaceToReserve); |
|
961 } |
|
962 |
|
963 // ----------------------------------------------------------------------------- |
|
964 // CVCXTestCommon::DeleteDummyFilesL() |
|
965 // ----------------------------------------------------------------------------- |
|
966 // |
|
967 EXPORT_C void CVCXTestCommon::DeleteDummyFilesL( TInt aDriveNumber ) |
|
968 { |
|
969 VCXLOGLO1(">>>CVCXTestCommon::DeleteDummyFilesL"); |
|
970 |
|
971 CFileMan* fileMan = CFileMan::NewL(iFs); |
|
972 CleanupStack::PushL(fileMan); |
|
973 |
|
974 TBuf<3> driveLetter; |
|
975 TChar driveChar; |
|
976 RFs::DriveToChar( aDriveNumber, driveChar ); |
|
977 driveLetter.Append(driveChar); |
|
978 |
|
979 TBuf<255>path; |
|
980 |
|
981 path.Format( KDummyfilePathFormat, &driveLetter ); |
|
982 path.Append(KDoubleBacklash); |
|
983 fileMan->RmDir(path); |
|
984 |
|
985 CleanupStack::PopAndDestroy(fileMan); |
|
986 |
|
987 VCXLOGLO1("<<<CVCXTestCommon::DeleteDummyFilesL"); |
|
988 } |
|
989 |
|
990 // ----------------------------------------------------------------------------- |
|
991 // CVCXTestCommon::EnsureFileIsNotInUse() |
|
992 // ----------------------------------------------------------------------------- |
|
993 // |
|
994 EXPORT_C TInt CVCXTestCommon::EnsureFileIsNotInUse( const TPtrC& aFileName ) |
|
995 { |
|
996 TInt error( KErrNone ); |
|
997 RFile file; |
|
998 // MDS or someone else could have the file in exclusive use. Try 6 times in 10 second intervals. |
|
999 for(TInt retry = 0; retry < 6; retry++) |
|
1000 { |
|
1001 error = file.Open(iFs, aFileName, EFileShareExclusive); |
|
1002 if( error == KErrInUse ) |
|
1003 { |
|
1004 User::After( 1000000 * 10 ); |
|
1005 } |
|
1006 else |
|
1007 { |
|
1008 break; |
|
1009 } |
|
1010 } |
|
1011 |
|
1012 file.Close(); |
|
1013 VCXLOGLO2("CVCXTestCommon::EnsureFileIsNotInUse: %d", error); |
|
1014 return error; |
|
1015 } |
|
1016 |
|
1017 |
|
1018 // ----------------------------------------------------------------------------- |
|
1019 // CVCXTestCommon::PrintDriveInfo() |
|
1020 // ----------------------------------------------------------------------------- |
|
1021 // |
|
1022 void CVCXTestCommon::PrintDriveInfo( const TPtrC& aDriveLetter ) |
|
1023 { |
|
1024 TInt driveNumber(-1); |
|
1025 TInt64 driveSize(0); |
|
1026 TInt64 driveFreeSpace(0); |
|
1027 |
|
1028 if( aDriveLetter.Length() > 0 && iFs.CharToDrive( aDriveLetter[0], driveNumber ) == KErrNone ) |
|
1029 { |
|
1030 TVolumeInfo volumeInfo; |
|
1031 if( iFs.Volume(volumeInfo, driveNumber) == KErrNone ) |
|
1032 { |
|
1033 driveSize = volumeInfo.iSize / 1024 / 1024; |
|
1034 driveFreeSpace = volumeInfo.iFree / 1024 / 1024; |
|
1035 VCXLOGLO2("CVCXTestCommon:: drive: %S", &aDriveLetter ); |
|
1036 VCXLOGLO2("CVCXTestCommon:: - size: %d MB", driveSize); |
|
1037 VCXLOGLO2("CVCXTestCommon:: - free: %d MB", driveFreeSpace); |
|
1038 } |
|
1039 } |
|
1040 } |
|
1041 |
|
1042 // ----------------------------------------------------------------------------- |
|
1043 // CVCXTestCommon::ListDir |
|
1044 // ----------------------------------------------------------------------------- |
|
1045 // |
|
1046 EXPORT_C TInt CVCXTestCommon::ListDir( const TDesC& aDir, TInt aLevel ) |
|
1047 { |
|
1048 CDir* fileList = NULL; |
|
1049 CDir* dirList = NULL; |
|
1050 |
|
1051 if( aLevel == 0 ) |
|
1052 { |
|
1053 VCXLOGLO2("CVCXTestCommon:: Listing directory %S", &aDir); |
|
1054 } |
|
1055 |
|
1056 TInt err( KErrNone ); |
|
1057 err = iFs.GetDir( aDir, KEntryAttMatchExclusive | KEntryAttDir, ESortByName, dirList ); |
|
1058 if( err == KErrNone ) |
|
1059 { |
|
1060 err = iFs.GetDir( aDir, KEntryAttMatchExclude | KEntryAttDir, ESortByName, fileList ); |
|
1061 } |
|
1062 |
|
1063 CleanupStack::PushL( dirList ); |
|
1064 CleanupStack::PushL( fileList ); |
|
1065 |
|
1066 HBufC* pre = HBufC::NewL( 256 ); |
|
1067 CleanupStack::PushL( pre ); |
|
1068 |
|
1069 for( TInt i=0; i<aLevel; i++ ) |
|
1070 { |
|
1071 pre->Des().Append( _L(" ") ); |
|
1072 } |
|
1073 |
|
1074 if( err == KErrNone ) |
|
1075 { |
|
1076 HBufC* fileName = HBufC::NewL( 256 ); |
|
1077 CleanupStack::PushL( fileName ); |
|
1078 |
|
1079 if( dirList ) |
|
1080 for ( TInt file = 0; file < dirList->Count(); file++ ) |
|
1081 { |
|
1082 fileName->Des().Zero(); |
|
1083 fileName->Des().Append( aDir ); |
|
1084 fileName->Des().Append( (*dirList)[file].iName ); |
|
1085 VCXLOGLO3("%S (d) %S", pre, fileName); |
|
1086 fileName->Des().Append( _L("\\") ); |
|
1087 fileName->Des().LowerCase(); |
|
1088 #if 0 |
|
1089 ListDir( *fileName, aLevel+1 ); |
|
1090 #else |
|
1091 if( fileName->Des().Find( _L(":\\private\\") ) < 0 && |
|
1092 fileName->Des().Find( _L(":\\resource\\") ) < 0 && |
|
1093 fileName->Des().Find( _L(":\\sys\\") ) < 0 && |
|
1094 fileName->Des().Find( _L(":\\testframework\\") ) < 0 && |
|
1095 fileName->Des().Find( _L(":\\nokia\\") ) < 0 && |
|
1096 fileName->Des().Find( _L(":\\system\\") ) < 0 ) |
|
1097 { |
|
1098 ListDir( fileName->Des(), aLevel+1 ); |
|
1099 } |
|
1100 #endif |
|
1101 } |
|
1102 |
|
1103 TUint32 totalSize(0); |
|
1104 if( fileList ) |
|
1105 for ( TInt file = 0; file < fileList->Count(); file++ ) |
|
1106 { |
|
1107 fileName->Des().Zero(); |
|
1108 fileName->Des().Append( aDir ); |
|
1109 fileName->Des().Append( (*fileList)[file].iName ); |
|
1110 |
|
1111 RFile rf; |
|
1112 if( rf.Open( iFs, *fileName, EFileRead|EFileShareAny ) == KErrNone ) |
|
1113 { |
|
1114 TInt size(0); |
|
1115 if( rf.Size( size ) == KErrNone ) |
|
1116 { |
|
1117 totalSize += size; |
|
1118 VCXLOGLO4("%S (f) %S - %d KB", pre, fileName, size/1024 ); |
|
1119 } |
|
1120 rf.Close(); |
|
1121 } |
|
1122 else |
|
1123 { |
|
1124 VCXLOGLO3("%S (f) %S", pre, fileName); |
|
1125 } |
|
1126 |
|
1127 } |
|
1128 VCXLOGLO3("%S Total size: %d KB", pre, totalSize/1024 ); |
|
1129 CleanupStack::PopAndDestroy( fileName ); |
|
1130 } |
|
1131 |
|
1132 CleanupStack::PopAndDestroy( pre ); |
|
1133 CleanupStack::PopAndDestroy( fileList ); |
|
1134 CleanupStack::PopAndDestroy( dirList ); |
|
1135 |
|
1136 if( aLevel == 0 ) |
|
1137 { |
|
1138 VCXLOGLO1("CVCXTestCommon:: Directory listed."); |
|
1139 } |
|
1140 |
|
1141 return err; |
|
1142 } |
|
1143 |
|
1144 // ----------------------------------------------------------------------------- |
|
1145 // CVCXTestCommon::GetPSProperty |
|
1146 // ----------------------------------------------------------------------------- |
|
1147 // |
|
1148 EXPORT_C TInt CVCXTestCommon::GetPSProperty( const TUid aCategory, const TUint aKey, TInt& aValue ) |
|
1149 { |
|
1150 VCXLOGLO2("CVCXTestCommon:: RProperty::Get key %d.", aKey); |
|
1151 TInt err = RProperty::Get( aCategory, aKey, aValue ); |
|
1152 if( err != KErrNone ) |
|
1153 { |
|
1154 VCXLOGLO2("CVCXTestCommon:: RProperty::Get int returned error: %d.", err); |
|
1155 } |
|
1156 return err; |
|
1157 } |
|
1158 |
|
1159 |
|
1160 // ----------------------------------------------------------------------------- |
|
1161 // CVCXTestCommon::SetPSProperty |
|
1162 // ----------------------------------------------------------------------------- |
|
1163 // |
|
1164 EXPORT_C TInt CVCXTestCommon::SetPSProperty( const TUid aCategory, const TUint aKey, const TInt aValue ) |
|
1165 { |
|
1166 VCXLOGLO2("CVCXTestCommon:: RProperty::Set key %d.", aKey); |
|
1167 TInt err = RProperty::Set( aCategory, aKey, aValue ); |
|
1168 if( err != KErrNone ) |
|
1169 { |
|
1170 VCXLOGLO2("CVCXTestCommon:: RProperty::Set int returned error: %d.", err); |
|
1171 } |
|
1172 return err; |
|
1173 } |
|
1174 |
|
1175 // ----------------------------------------------------------------------------- |
|
1176 // CVCXTestCommon::GetPSProperty |
|
1177 // ----------------------------------------------------------------------------- |
|
1178 // |
|
1179 EXPORT_C TInt CVCXTestCommon::GetPSProperty( const TUid aCategory, const TUint aKey, TDes& aValue ) |
|
1180 { |
|
1181 VCXLOGLO2("CVCXTestCommon:: RProperty::Get key %d.", aKey); |
|
1182 TInt err = RProperty::Get( aCategory, aKey, aValue ); |
|
1183 if( err != KErrNone ) |
|
1184 { |
|
1185 VCXLOGLO2("CVCXTestCommon:: RProperty::Get desc returned error: %d.", err); |
|
1186 } |
|
1187 return err; |
|
1188 } |
|
1189 |
|
1190 |
|
1191 // ----------------------------------------------------------------------------- |
|
1192 // CVCXTestCommon::SetPSProperty |
|
1193 // ----------------------------------------------------------------------------- |
|
1194 // |
|
1195 EXPORT_C TInt CVCXTestCommon::SetPSProperty( const TUid aCategory, const TUint aKey, const TDesC& aValue ) |
|
1196 { |
|
1197 VCXLOGLO2("CVCXTestCommon:: RProperty::Set key %d.", aKey); |
|
1198 TInt err = RProperty::Set( aCategory, aKey, aValue ); |
|
1199 if( err != KErrNone ) |
|
1200 { |
|
1201 VCXLOGLO2("CVCXTestCommon:: RProperty::Set desc returned error: %d.", err); |
|
1202 } |
|
1203 return err; |
|
1204 } |
|
1205 |
|
1206 // ----------------------------------------------------------------------------- |
|
1207 // CVCXTestCommon::ListFilesProcessesAndThreadsL |
|
1208 // ----------------------------------------------------------------------------- |
|
1209 // |
|
1210 EXPORT_C void CVCXTestCommon::ListFilesProcessesAndThreadsL( RFs& aFs ) |
|
1211 { |
|
1212 RArray<TInt> fileThreadIds; |
|
1213 CleanupClosePushL( fileThreadIds ); |
|
1214 |
|
1215 RPointerArray<HBufC> fileNames; |
|
1216 CleanupResetAndDestroyPushL( fileNames ); |
|
1217 |
|
1218 // Get list of open files. |
|
1219 CFileList* fileList = 0; |
|
1220 TOpenFileScan fileScan( aFs ); |
|
1221 fileScan.NextL( fileList ); |
|
1222 |
|
1223 CleanupStack::PushL( fileList ); |
|
1224 |
|
1225 while( fileList ) |
|
1226 { |
|
1227 for (TInt i = 0; i < fileList->Count(); ++i) |
|
1228 { |
|
1229 fileNames.Append( (*fileList)[i].iName.AllocL() ); |
|
1230 fileThreadIds.Append( fileScan.ThreadId() ); |
|
1231 //VCXLOGLO4("File: %S Size: %d Thread Id: %d", &(*fileList)[i].iName, (*fileList)[i].iSize, fileScan.ThreadId() ); |
|
1232 } |
|
1233 CleanupStack::PopAndDestroy( fileList ); |
|
1234 fileScan.NextL( fileList ); |
|
1235 CleanupStack::PushL( fileList ); |
|
1236 } |
|
1237 |
|
1238 CleanupStack::PopAndDestroy( fileList ); |
|
1239 |
|
1240 // Get list of processes and their threads. |
|
1241 TFindProcess findProcess; |
|
1242 TFullName processName; |
|
1243 |
|
1244 TInt err( KErrNone ); |
|
1245 |
|
1246 // List processes. |
|
1247 while( findProcess.Next( processName ) == KErrNone ) |
|
1248 { |
|
1249 RProcess process; |
|
1250 err = process.Open( processName ); |
|
1251 if( err != KErrNone ) |
|
1252 { |
|
1253 continue; |
|
1254 } |
|
1255 CleanupClosePushL( process ); |
|
1256 |
|
1257 TProcessId pid; |
|
1258 pid = process.Id(); |
|
1259 TInt id = pid.Id(); |
|
1260 VCXLOGLO4("Process: %S, ID: %d (%x)", &processName, id, pid.Id() ); |
|
1261 |
|
1262 TFindThread findThread; |
|
1263 TFullName threadName; |
|
1264 |
|
1265 // List threads that belong to current process. |
|
1266 while( findThread.Next( threadName ) == KErrNone ) |
|
1267 { |
|
1268 RThread thread; |
|
1269 err = thread.Open( threadName ); |
|
1270 if( err == KErrNone ) |
|
1271 { |
|
1272 CleanupClosePushL( thread ); |
|
1273 RProcess threadProcess; |
|
1274 err = thread.Process( threadProcess ) ; |
|
1275 if( err == KErrNone ) |
|
1276 { |
|
1277 CleanupClosePushL( threadProcess ); |
|
1278 if( threadProcess.Id() == process.Id() ) |
|
1279 { |
|
1280 TThreadId tid; |
|
1281 tid = thread.Id(); |
|
1282 id = tid.Id(); |
|
1283 VCXLOGLO4(" - Thread: %S, ID: %d (%x)", &threadName, id, tid.Id() ); |
|
1284 |
|
1285 // And list open files for the thread. |
|
1286 for( TInt i = 0; i < fileThreadIds.Count(); i++ ) |
|
1287 { |
|
1288 if( fileThreadIds[i] == tid.Id() ) |
|
1289 { |
|
1290 VCXLOGLO2(" - %S", fileNames[i] ); |
|
1291 } |
|
1292 } |
|
1293 } |
|
1294 CleanupStack::PopAndDestroy( &threadProcess ); |
|
1295 } |
|
1296 CleanupStack::PopAndDestroy( &thread ); |
|
1297 } |
|
1298 } |
|
1299 |
|
1300 VCXLOGLO1("---"); |
|
1301 CleanupStack::PopAndDestroy( &process ); |
|
1302 } |
|
1303 |
|
1304 CleanupStack::PopAndDestroy( &fileNames ); |
|
1305 CleanupStack::PopAndDestroy( &fileThreadIds ); |
|
1306 } |
|
1307 |
|
1308 // End of File |