240 |
280 |
241 AppendExecutablesFromResourceFileL( resourceFile, aExecutableArray ); |
281 AppendExecutablesFromResourceFileL( resourceFile, aExecutableArray ); |
242 } |
282 } |
243 } |
283 } |
244 CleanupStack::PopAndDestroy( dir ); |
284 CleanupStack::PopAndDestroy( dir ); |
|
285 FLOG( _L("CStartupListUpdater::GetDataToBeImportedL, end") ); |
245 } |
286 } |
246 |
287 |
247 // --------------------------------------------------------------------------- |
288 // --------------------------------------------------------------------------- |
248 // CStartupListUpdater::ImportExecutablesL() |
289 // CStartupListUpdater::ImportExecutablesL() |
249 // --------------------------------------------------------------------------- |
290 // --------------------------------------------------------------------------- |
250 // |
291 // |
251 void CStartupListUpdater::ImportExecutablesL( RDscStore& aDscStore, |
292 void CStartupListUpdater::ImportExecutablesL( RDscStore& aDscStore, |
252 RPointerArray<HBufC>& aExecutableArray ) |
293 RPointerArray<HBufC>& aExecutableArray ) |
253 { |
294 { |
|
295 FLOG( _L("CStartupListUpdater::ImportExecutablesL, begin") ); |
254 for( TInt index = 0; index < aExecutableArray.Count(); ++index ) |
296 for( TInt index = 0; index < aExecutableArray.Count(); ++index ) |
255 { |
297 { |
256 const TDesC& executableName = *( aExecutableArray[ index ] ); |
298 const TDesC& executableName = *( aExecutableArray[ index ] ); |
|
299 FLOG_1( _L("CStartupListUpdater::ImportExecutablesL, exe %S"), &executableName ); |
257 CDscItem* item = CDscItem::NewLC( executableName, KNullDesC ); |
300 CDscItem* item = CDscItem::NewLC( executableName, KNullDesC ); |
258 if( !aDscStore.ItemExistsL( *item ) ) |
301 if( !aDscStore.ItemExistsL( *item ) ) |
259 { |
302 { |
|
303 FLOG( _L("CStartupListUpdater::ImportExecutablesL, add item to DscStore") ); |
260 aDscStore.AddItemL( *item ); |
304 aDscStore.AddItemL( *item ); |
|
305 DevTrace( _L("Success: '%S' will be started at boot"), &executableName ); |
|
306 } |
|
307 else |
|
308 { |
|
309 DevTrace( _L("Error: '%S' already in start list"), &executableName ); |
261 } |
310 } |
262 CleanupStack::PopAndDestroy( item ); |
311 CleanupStack::PopAndDestroy( item ); |
263 } |
312 } |
|
313 FLOG( _L("CStartupListUpdater::ImportExecutablesL, end") ); |
264 } |
314 } |
265 |
315 |
266 // --------------------------------------------------------------------------- |
316 // --------------------------------------------------------------------------- |
267 // CStartupListUpdater::RemoveImportedResourceFiles() |
317 // CStartupListUpdater::RemoveImportedResourceFiles() |
268 // --------------------------------------------------------------------------- |
318 // --------------------------------------------------------------------------- |
269 // |
319 // |
270 void CStartupListUpdater::RemoveImportedResourceFiles( |
320 void CStartupListUpdater::RemoveImportedResourceFiles( |
271 RPointerArray<HBufC>& aResourceFileArray ) |
321 RPointerArray<HBufC>& aResourceFileArray ) |
272 { |
322 { |
|
323 FLOG( _L("CStartupListUpdater::RemoveImportedResourceFiles, begin") ); |
273 for( TInt index = 0; index < aResourceFileArray.Count(); ++index ) |
324 for( TInt index = 0; index < aResourceFileArray.Count(); ++index ) |
274 { |
325 { |
275 const TDesC& fileName = *( aResourceFileArray[ index ] ); |
326 const TDesC& fileName = *( aResourceFileArray[ index ] ); |
|
327 FLOG_1( _L("CStartupListUpdater::RemoveImportedResourceFiles, deleting %S"), &fileName ); |
276 TInt err = iFs.Delete( fileName ); |
328 TInt err = iFs.Delete( fileName ); |
277 if( err ) |
329 FLOG_1( _L("CStartupListUpdater::RemoveImportedResourceFiles, err %d"), err ); |
278 { |
330 if( !err ) |
279 #ifdef _DEBUG |
331 { |
280 RDebug::Print( _L("CStartupListUpdater: cannot delete %S, error %d"), |
332 DevTrace( _L("Resource file '%S' processed"), &fileName ); |
281 &fileName, err ); |
333 } |
282 #endif |
334 } |
283 } |
335 FLOG( _L("CStartupListUpdater::RemoveImportedResourceFiles, end") ); |
284 } |
|
285 } |
336 } |
286 |
337 |
287 // --------------------------------------------------------------------------- |
338 // --------------------------------------------------------------------------- |
288 // CStartupListUpdater::AppendExecutablesFromResourceFileL() |
339 // CStartupListUpdater::AppendExecutablesFromResourceFileL() |
289 // --------------------------------------------------------------------------- |
340 // --------------------------------------------------------------------------- |
290 // |
341 // |
291 void CStartupListUpdater::AppendExecutablesFromResourceFileL( |
342 void CStartupListUpdater::AppendExecutablesFromResourceFileL( |
292 const TDesC& aResourceFile, |
343 const TDesC& aResourceFile, |
293 RPointerArray<HBufC>& aExecutableArray ) |
344 RPointerArray<HBufC>& aExecutableArray ) |
294 { |
345 { |
|
346 FLOG( _L("CStartupListUpdater::AppendExecutablesFromResourceFileL, begin") ); |
|
347 OpenDevTraceL(); |
|
348 DevTrace( _L("Processing resource file: %S"), &aResourceFile ); |
|
349 |
295 RResourceFile resource; |
350 RResourceFile resource; |
296 CleanupClosePushL( resource ); |
351 CleanupClosePushL( resource ); |
297 resource.OpenL( iFs, aResourceFile ); |
352 resource.OpenL( iFs, aResourceFile ); |
|
353 FLOG_1( _L("CStartupListUpdater::AppendExecutablesFromResourceFileL, %S"), &aResourceFile ); |
298 |
354 |
299 for( TInt id = KFirstStartupItemInfo; resource.OwnsResourceId( id ); ++id ) |
355 for( TInt id = KFirstStartupItemInfo; resource.OwnsResourceId( id ); ++id ) |
300 { |
356 { |
|
357 FLOG_1( _L("CStartupListUpdater::AppendExecutablesFromResourceFileL, resource id %d"), id ); |
301 HBufC8* buffer = resource.AllocReadLC( id ); |
358 HBufC8* buffer = resource.AllocReadLC( id ); |
302 |
359 |
303 TResourceReader reader; |
360 TResourceReader reader; |
304 reader.SetBuffer( buffer ); |
361 reader.SetBuffer( buffer ); |
305 |
362 |
306 // Read STARTUP_ITEM_INFO |
363 // Read STARTUP_ITEM_INFO |
307 TInt versionInfo = reader.ReadUint8(); |
364 TInt versionInfo = reader.ReadUint8(); |
308 TFileName executableName; |
365 TFileName executableName; |
309 executableName.Copy( reader.ReadTPtrC() ); |
366 executableName.Copy( reader.ReadTPtrC() ); |
310 TInt recoveryPolicy = reader.ReadUint16(); |
367 TInt recoveryPolicy = reader.ReadUint16(); |
|
368 FLOG_1( _L("CStartupListUpdater::AppendExecutablesFromResourceFileL, executableName %S"), |
|
369 &executableName ); |
|
370 FLOG_1( _L("CStartupListUpdater::AppendExecutablesFromResourceFileL, recoveryPolicy %d"), |
|
371 recoveryPolicy ); |
311 |
372 |
312 CleanupStack::PopAndDestroy( buffer ); |
373 CleanupStack::PopAndDestroy( buffer ); |
313 |
374 |
314 if( versionInfo == 0 && recoveryPolicy == EStartupItemExPolicyNone ) |
375 if( versionInfo == 0 && recoveryPolicy == EStartupItemExPolicyNone ) |
315 { |
376 { |
325 { |
386 { |
326 CleanupStack::PushL( executableDir ); |
387 CleanupStack::PushL( executableDir ); |
327 executableName.Replace( 0, 1, fileFinder.File() ); |
388 executableName.Replace( 0, 1, fileFinder.File() ); |
328 CleanupStack::PopAndDestroy( executableDir ); |
389 CleanupStack::PopAndDestroy( executableDir ); |
329 } |
390 } |
|
391 |
|
392 FLOG_1( _L("CStartupListUpdater::AppendExecutablesFromResourceFileL, new name %S"), |
|
393 &executableName ); |
330 } |
394 } |
331 |
395 |
|
396 DevTrace( _L("Executable file: %S"), &executableName ); |
332 if( IsValidExecutableForStartupL( aResourceFile, executableName ) ) |
397 if( IsValidExecutableForStartupL( aResourceFile, executableName ) ) |
333 { |
398 { |
|
399 FLOG( _L("CStartupListUpdater::AppendExecutablesFromResourceFileL, adding to array") ); |
334 aExecutableArray.AppendL( executableName.AllocL() ); |
400 aExecutableArray.AppendL( executableName.AllocL() ); |
335 } |
401 } |
336 } |
402 } |
|
403 else |
|
404 { |
|
405 if( versionInfo != 0 ) |
|
406 { |
|
407 DevTrace( _L("Error: unsupported STARTUP_ITEM_INFO version: %d"), versionInfo ); |
|
408 } |
|
409 else |
|
410 { |
|
411 DevTrace( _L("Error: unsupported recovery policy: %d"), recoveryPolicy ); |
|
412 } |
|
413 } |
337 } |
414 } |
338 |
415 |
339 CleanupStack::PopAndDestroy( &resource ); |
416 CleanupStack::PopAndDestroy( &resource ); |
|
417 FLOG( _L("CStartupListUpdater::AppendExecutablesFromResourceFileL, end") ); |
340 } |
418 } |
341 |
419 |
342 // --------------------------------------------------------------------------- |
420 // --------------------------------------------------------------------------- |
343 // CStartupListUpdater::IsValidExecutableForStartupL() |
421 // CStartupListUpdater::IsValidExecutableForStartupL() |
344 // --------------------------------------------------------------------------- |
422 // --------------------------------------------------------------------------- |
345 // |
423 // |
346 TBool CStartupListUpdater::IsValidExecutableForStartupL( const TDesC& aResourceFile, |
424 TBool CStartupListUpdater::IsValidExecutableForStartupL( const TDesC& aResourceFile, |
347 const TDesC& aExecutableName ) |
425 const TDesC& aExecutableName ) |
348 { |
426 { |
|
427 FLOG( _L("CStartupListUpdater::IsValidExecutableForStartupL, begin") ); |
|
428 FLOG_1( _L("CStartupListUpdater::IsValidExecutableForStartupL, res %S"), &aResourceFile ); |
|
429 FLOG_1( _L("CStartupListUpdater::IsValidExecutableForStartupL, exe %S"), &aExecutableName ); |
349 TBool isValid = EFalse; |
430 TBool isValid = EFalse; |
350 |
431 |
351 TEntry entry; |
432 TEntry entry; |
352 if( iFs.Entry( aExecutableName, entry ) == KErrNone ) // needs AllFiles capability |
433 if( iFs.Entry( aExecutableName, entry ) == KErrNone ) // needs AllFiles capability |
353 { |
434 { |
354 isValid = ETrue; |
435 FLOG( _L("CStartupListUpdater::IsValidExecutableForStartupL, exe file exists") ); |
355 |
436 |
356 // Extract package UID from the resource file name |
|
357 // - allow both "[1234ABCD]" and "1234ABCD" formats |
|
358 // - allow possible "0x" prefix too |
|
359 TUid packageUid = KNullUid; |
437 TUid packageUid = KNullUid; |
360 TParsePtrC parse( aResourceFile ); |
438 ExtractPackageUidFromResourceFileL( aResourceFile, packageUid ); |
361 TPtrC parseName = parse.Name(); |
439 |
362 TInt fileNameLength = parseName.Length(); |
|
363 if( !parse.IsNameWild() && fileNameLength > 0 ) |
|
364 { |
|
365 TPtr fileName( const_cast<TUint16*>( parseName.Ptr() ), |
|
366 fileNameLength, fileNameLength ); |
|
367 |
|
368 if( fileName[ 0 ] == '[' && fileName[ fileNameLength - 1 ] == ']' ) |
|
369 { |
|
370 const TInt KTwoCharsLength = 2; |
|
371 fileNameLength -= KTwoCharsLength; |
|
372 fileName = fileName.Mid( 1, fileNameLength ); |
|
373 } |
|
374 |
|
375 _LIT( KHexPrefix, "0x" ); |
|
376 const TInt KHexPrefixLength = 2; |
|
377 if( fileName.Left( KHexPrefixLength ) == KHexPrefix ) |
|
378 { |
|
379 fileNameLength -= KHexPrefixLength; |
|
380 fileName = fileName.Mid( KHexPrefixLength, fileNameLength ); |
|
381 } |
|
382 |
|
383 TLex lex( fileName ); |
|
384 TUint32 uidValue = 0; |
|
385 TInt lexError = lex.Val( uidValue, EHex ); |
|
386 if( !lexError ) |
|
387 { |
|
388 packageUid.iUid = uidValue; |
|
389 } |
|
390 } |
|
391 |
|
392 // Get package info from RSisRegistry, and check that |
|
393 // - the package contains the resource file |
|
394 // - the package is properly signed |
|
395 if( packageUid != KNullUid ) |
440 if( packageUid != KNullUid ) |
396 { |
441 { |
397 Swi::RSisRegistrySession sisRegSession; |
442 Swi::RSisRegistrySession sisRegSession; |
398 User::LeaveIfError( sisRegSession.Connect() ); |
443 User::LeaveIfError( sisRegSession.Connect() ); |
399 CleanupClosePushL( sisRegSession ); |
444 CleanupClosePushL( sisRegSession ); |
400 |
445 |
401 Swi::RSisRegistryEntry package; |
446 isValid = IsResourceFileValidForPackageL( sisRegSession, aResourceFile, packageUid ) && |
|
447 IsExeFileIncludedInPackageL( sisRegSession, aExecutableName, packageUid ); |
|
448 |
|
449 CleanupStack::PopAndDestroy( &sisRegSession ); |
|
450 } |
|
451 else |
|
452 { |
|
453 DevTrace( _L("Error: invalid package UID - check resource file name") ); |
|
454 } |
|
455 } |
|
456 else |
|
457 { |
|
458 DevTrace( _L("Error: executable file '%S' not found"), &aExecutableName ); |
|
459 } |
|
460 |
|
461 FLOG_1( _L("CStartupListUpdater::IsValidExecutableForStartupL, return %d"), isValid ); |
|
462 return isValid; |
|
463 } |
|
464 |
|
465 // --------------------------------------------------------------------------- |
|
466 // CStartupListUpdater::ExtractPackageUidFromResourceFileL() |
|
467 // --------------------------------------------------------------------------- |
|
468 // |
|
469 void CStartupListUpdater::ExtractPackageUidFromResourceFileL( const TDesC& aResourceFile, |
|
470 TUid& aPackageUid ) |
|
471 { |
|
472 FLOG( _L("CStartupListUpdater::ExtractPackageUidFromResourceFileL, begin") ); |
|
473 |
|
474 // Extract package UID from the resource file name |
|
475 // - allow both "[1234ABCD]" and "1234ABCD" formats |
|
476 // - allow possible "0x" prefix too |
|
477 aPackageUid = KNullUid; |
|
478 |
|
479 TParse parse; |
|
480 parse.Set( aResourceFile, NULL, NULL ); |
|
481 TPtrC parseName = parse.Name(); |
|
482 TInt fileNameLength = parseName.Length(); |
|
483 if( !parse.IsNameWild() && fileNameLength > 0 ) |
|
484 { |
|
485 TPtr fileName( const_cast<TUint16*>( parseName.Ptr() ), |
|
486 fileNameLength, fileNameLength ); |
|
487 |
|
488 if( fileName[ 0 ] == '[' && fileName[ fileNameLength - 1 ] == ']' ) |
|
489 { |
|
490 const TInt KTwoCharsLength = 2; |
|
491 fileNameLength -= KTwoCharsLength; |
|
492 fileName = fileName.Mid( 1, fileNameLength ); |
|
493 } |
|
494 |
|
495 _LIT( KHexPrefix, "0x" ); |
|
496 const TInt KHexPrefixLength = 2; |
|
497 if( fileName.Left( KHexPrefixLength ) == KHexPrefix ) |
|
498 { |
|
499 fileNameLength -= KHexPrefixLength; |
|
500 fileName = fileName.Mid( KHexPrefixLength, fileNameLength ); |
|
501 } |
|
502 |
|
503 FLOG_1( _L("CStartupListUpdater::ExtractPackageUidFromResourceFileL, fileName %S"), |
|
504 &fileName ); |
|
505 TLex lex( fileName ); |
|
506 TUint32 uidValue = 0; |
|
507 TInt lexError = lex.Val( uidValue, EHex ); |
|
508 if( !lexError ) |
|
509 { |
|
510 aPackageUid.iUid = uidValue; |
|
511 } |
|
512 } |
|
513 |
|
514 FLOG_1( _L("CStartupListUpdater::ExtractPackageUidFromResourceFileL, end, ret 0x%08x"), |
|
515 aPackageUid.iUid ); |
|
516 } |
|
517 |
|
518 // --------------------------------------------------------------------------- |
|
519 // CStartupListUpdater::IsResourceFileValidForPackageL() |
|
520 // --------------------------------------------------------------------------- |
|
521 // |
|
522 TBool CStartupListUpdater::IsResourceFileValidForPackageL( |
|
523 Swi::RSisRegistrySession& aSisRegSession, |
|
524 const TDesC& aResourceFile, |
|
525 const TUid& aPackageUid ) |
|
526 { |
|
527 FLOG( _L("CStartupListUpdater::IsResourceFileValidForPackageL, begin") ); |
|
528 TBool isValidForPackage = EFalse; |
|
529 |
|
530 // Get package info from RSisRegistry, and check that |
|
531 // - the package contains the resource file, and |
|
532 // - the package is properly signed |
|
533 |
|
534 Swi::RSisRegistryEntry package; |
|
535 CleanupClosePushL( package ); |
|
536 TInt openError = package.Open( aSisRegSession, aPackageUid ); |
|
537 FLOG_1( _L("CStartupListUpdater::IsResourceFileValidForPackageL, openError %d"), openError ); |
|
538 if( !openError ) |
|
539 { |
|
540 Swi::TSisTrustStatus trustStatus = package.TrustStatusL(); |
|
541 Swi::TValidationStatus validationStatus = trustStatus.ValidationStatus(); |
|
542 FLOG_1( _L("CStartupListUpdater::IsResourceFileValidForPackageL, validationStatus %d"), |
|
543 validationStatus ); |
|
544 Swi::TRevocationStatus revocationStatus = trustStatus.RevocationStatus(); |
|
545 FLOG_1( _L("CStartupListUpdater::IsResourceFileValidForPackageL, revocationStatus %d"), |
|
546 revocationStatus ); |
|
547 TBool isTrusted = (validationStatus == Swi::EPackageInRom || |
|
548 validationStatus == Swi::EValidatedToAnchor) && |
|
549 revocationStatus != Swi::EOcspRevoked; |
|
550 FLOG_1( _L("CStartupListUpdater::IsResourceFileValidForPackageL, isTrusted %d"), |
|
551 isTrusted ); |
|
552 |
|
553 if( isTrusted ) |
|
554 { |
|
555 isValidForPackage = IsFileIncludedInPackageL( aResourceFile, package ); |
|
556 |
|
557 if( !isValidForPackage ) |
|
558 { |
|
559 DevTrace( _L("Error: package 0x%08x does not install resource file %S"), |
|
560 aPackageUid.iUid, &aResourceFile ); |
|
561 } |
|
562 } |
|
563 else |
|
564 { |
|
565 DevTrace( _L("Error: package 0x%08x not trusted"), aPackageUid.iUid ); |
|
566 } |
|
567 } |
|
568 else |
|
569 { |
|
570 DevTrace( _L("Error: package 0x%08x open failed, error %d - check resource file name"), |
|
571 aPackageUid.iUid, openError ); |
|
572 } |
|
573 |
|
574 CleanupStack::PopAndDestroy( &package ); |
|
575 |
|
576 FLOG_1( _L("CStartupListUpdater::IsResourceFileValidForPackageL, ret %d"), isValidForPackage ); |
|
577 return isValidForPackage; |
|
578 } |
|
579 |
|
580 // --------------------------------------------------------------------------- |
|
581 // CStartupListUpdater::IsFileIncludedInPackageL() |
|
582 // --------------------------------------------------------------------------- |
|
583 // |
|
584 TBool CStartupListUpdater::IsFileIncludedInPackageL( const TDesC& aFile, |
|
585 Swi::RSisRegistryEntry& aPackage ) |
|
586 { |
|
587 FLOG_1( _L("CStartupListUpdater::IsFileIncludedInPackageL, begin, file %S"), &aFile ); |
|
588 TBool isIncluded = EFalse; |
|
589 |
|
590 RPointerArray<HBufC> files; |
|
591 CleanupResetAndDestroyPushL( files ); |
|
592 aPackage.FilesL( files ); |
|
593 TInt fileCount = files.Count(); |
|
594 FLOG_1( _L("CStartupListUpdater::IsFileIncludedInPackageL, pckg fileCount %d"), fileCount ); |
|
595 for( TInt index = 0; index < fileCount && !isIncluded; ++index ) |
|
596 { |
|
597 TPtrC pckgFile( *files[ index ] ); |
|
598 FLOG_1( _L("CStartupListUpdater::IsFileIncludedInPackageL, pckgFile %S"), &pckgFile ); |
|
599 isIncluded = ( aFile.CompareF( pckgFile ) == 0 ); |
|
600 } |
|
601 CleanupStack::PopAndDestroy( &files ); |
|
602 |
|
603 if( isIncluded ) |
|
604 { |
|
605 DevTrace( _L("File '%S' installed by package 0x%08x" ), &aFile, aPackage.UidL().iUid ); |
|
606 } |
|
607 else |
|
608 { |
|
609 DevTrace( _L("File '%S' not installed by package 0x%08x" ), &aFile, aPackage.UidL().iUid ); |
|
610 } |
|
611 FLOG_1( _L("CStartupListUpdater::IsFileIncludedInPackageL, ret %d"), isIncluded ); |
|
612 return isIncluded; |
|
613 } |
|
614 |
|
615 // --------------------------------------------------------------------------- |
|
616 // CStartupListUpdater::IsFileIncludedInEmbeddedPackagesL() |
|
617 // --------------------------------------------------------------------------- |
|
618 // |
|
619 TBool CStartupListUpdater::IsFileIncludedInEmbeddedPackagesL( |
|
620 Swi::RSisRegistrySession& aSisRegSession, const TDesC& aFile, |
|
621 Swi::RSisRegistryEntry& aPackage ) |
|
622 { |
|
623 FLOG( _L("CStartupListUpdater::IsFileIncludedInEmbeddedPackagesL, begin") ); |
|
624 TBool isIncluded = EFalse; |
|
625 |
|
626 RPointerArray<Swi::CSisRegistryPackage> embeddedPackages; |
|
627 CleanupResetAndDestroyPushL( embeddedPackages ); |
|
628 aPackage.EmbeddedPackagesL( embeddedPackages ); |
|
629 |
|
630 TInt embeddedPackagesCount = embeddedPackages.Count(); |
|
631 FLOG_1( _L("CStartupListUpdater::IsFileIncludedInEmbeddedPackagesL, embeddedPackagesCount %d"), |
|
632 embeddedPackagesCount ); |
|
633 for( TInt index = 0; index < embeddedPackagesCount && !isIncluded; ++index ) |
|
634 { |
|
635 TUid uid = embeddedPackages[index]->Uid(); |
|
636 FLOG_1( _L("CStartupListUpdater::IsFileIncludedInEmbeddedPackagesL, uid 0x%08x"), |
|
637 uid.iUid ); |
|
638 |
|
639 Swi::RSisRegistryEntry package; |
|
640 if( package.Open( aSisRegSession, uid ) == KErrNone ) |
|
641 { |
402 CleanupClosePushL( package ); |
642 CleanupClosePushL( package ); |
403 TInt openError = package.Open( sisRegSession, packageUid ); |
643 isIncluded = IsFileIncludedInPackageL( aFile, package ); |
404 if( !openError ) |
644 if( !isIncluded ) |
405 { |
645 { |
406 TBool hasResourceFile = EFalse; |
646 // Check other embedded packages recursively if necessary |
407 |
647 isIncluded = IsFileIncludedInEmbeddedPackagesL( aSisRegSession, aFile, package ); |
408 RPointerArray<HBufC> files; |
|
409 CleanupResetAndDestroyPushL( files ); |
|
410 package.FilesL( files ); |
|
411 for( TInt index = 0; index < files.Count() && !hasResourceFile; ++index ) |
|
412 { |
|
413 hasResourceFile = ( aResourceFile.CompareF( *files[ index ] ) == 0 ); |
|
414 } |
|
415 |
|
416 if( hasResourceFile && package.TrustStatusL().IsTrusted() ) |
|
417 { |
|
418 isValid = ETrue; |
|
419 } |
|
420 |
|
421 CleanupStack::PopAndDestroy( &files ); |
|
422 } |
648 } |
423 |
649 CleanupStack::PopAndDestroy( &package ); |
424 CleanupStack::PopAndDestroy( 2, &sisRegSession ); // package, sisRegSession |
650 } |
425 } |
651 } |
426 } |
652 CleanupStack::PopAndDestroy( &embeddedPackages ); |
427 |
653 |
428 return isValid; |
654 FLOG_1( _L("CStartupListUpdater::IsFileIncludedInEmbeddedPackagesL, ret %d"), isIncluded ); |
|
655 return isIncluded; |
|
656 } |
|
657 |
|
658 // --------------------------------------------------------------------------- |
|
659 // CStartupListUpdater::IsExeFileIncludedInPackageL() |
|
660 // --------------------------------------------------------------------------- |
|
661 // |
|
662 TBool CStartupListUpdater::IsExeFileIncludedInPackageL( |
|
663 Swi::RSisRegistrySession& aSisRegSession, |
|
664 const TDesC& aExeFile, const TUid& aPackageUid ) |
|
665 { |
|
666 FLOG_1( _L("CStartupListUpdater::IsExeFileIncludedInPackageL, begin, file %S"), &aExeFile ); |
|
667 TBool isIncluded = EFalse; |
|
668 |
|
669 Swi::RSisRegistryEntry package; |
|
670 CleanupClosePushL( package ); |
|
671 TInt openError = package.Open( aSisRegSession, aPackageUid ); |
|
672 if( !openError ) |
|
673 { |
|
674 isIncluded = IsFileIncludedInPackageL( aExeFile, package ) || |
|
675 IsFileIncludedInEmbeddedPackagesL( aSisRegSession, aExeFile, package ); |
|
676 if( !isIncluded ) |
|
677 { |
|
678 DevTrace( _L("Error: exe not installed by this package or it's subpackages") ); |
|
679 } |
|
680 } |
|
681 CleanupStack::PopAndDestroy( &package ); |
|
682 |
|
683 FLOG_1( _L("CStartupListUpdater::IsExeFileIncludedInPackageL, return %d"), isIncluded ); |
|
684 return isIncluded; |
429 } |
685 } |
430 |
686 |
431 // --------------------------------------------------------------------------- |
687 // --------------------------------------------------------------------------- |
432 // CStartupListUpdater::GetInstalledAppsL() |
688 // CStartupListUpdater::GetInstalledAppsL() |
433 // --------------------------------------------------------------------------- |
689 // --------------------------------------------------------------------------- |
434 // |
690 // |
435 void CStartupListUpdater::GetInstalledAppsL( |
691 void CStartupListUpdater::GetInstalledAppsL( |
436 RPointerArray<HBufC>& aInstalledExecutableArray ) |
692 RPointerArray<HBufC>& aInstalledExecutableArray ) |
437 { |
693 { |
|
694 FLOG( _L("CStartupListUpdater::GetInstalledAppsL, begin") ); |
438 Swi::RSisRegistrySession sisRegistrySession; |
695 Swi::RSisRegistrySession sisRegistrySession; |
439 User::LeaveIfError( sisRegistrySession.Connect() ); |
696 User::LeaveIfError( sisRegistrySession.Connect() ); |
440 CleanupClosePushL( sisRegistrySession ); |
697 CleanupClosePushL( sisRegistrySession ); |
441 |
698 |
442 RPointerArray<Swi::CSisRegistryPackage> removablePackages; |
699 RPointerArray<Swi::CSisRegistryPackage> removablePackages; |
443 CleanupResetAndDestroyPushL( removablePackages ); |
700 CleanupResetAndDestroyPushL( removablePackages ); |
444 sisRegistrySession.RemovablePackagesL( removablePackages ); |
701 sisRegistrySession.RemovablePackagesL( removablePackages ); |
445 |
702 |
446 for( TInt index = 0; index < removablePackages.Count(); ++index ) |
703 TInt removablePackagesCount = removablePackages.Count(); |
447 { |
704 FLOG_1( _L("CStartupListUpdater::GetInstalledAppsL, removablePackagesCount %d"), |
|
705 removablePackagesCount ); |
|
706 for( TInt index = 0; index < removablePackagesCount; ++index ) |
|
707 { |
|
708 FLOG_1( _L("CStartupListUpdater::GetInstalledAppsL, index %d"), index ); |
448 Swi::RSisRegistryEntry entry; |
709 Swi::RSisRegistryEntry entry; |
449 CleanupClosePushL( entry ); |
710 CleanupClosePushL( entry ); |
450 entry.OpenL( sisRegistrySession, *( removablePackages[ index ] ) ); |
711 entry.OpenL( sisRegistrySession, *( removablePackages[ index ] ) ); |
451 if( entry.RemovableL() ) |
712 if( entry.RemovableL() ) |
452 { |
713 { |
484 void CStartupListUpdater::StartedButNotInstalledAppsL( |
750 void CStartupListUpdater::StartedButNotInstalledAppsL( |
485 RPointerArray<HBufC>& aStartedExecutableArray, // in |
751 RPointerArray<HBufC>& aStartedExecutableArray, // in |
486 RPointerArray<HBufC>& aInstalledExecutableArray, // in |
752 RPointerArray<HBufC>& aInstalledExecutableArray, // in |
487 RPointerArray<HBufC>& aStartedButNotInstalledExecutableArray ) // out |
753 RPointerArray<HBufC>& aStartedButNotInstalledExecutableArray ) // out |
488 { |
754 { |
|
755 FLOG( _L("CStartupListUpdater::StartedButNotInstalledAppsL, begin") ); |
489 aStartedButNotInstalledExecutableArray.ResetAndDestroy(); |
756 aStartedButNotInstalledExecutableArray.ResetAndDestroy(); |
490 |
757 |
491 TIdentityRelation<HBufC> identityRelation( FileNamesEqual ); |
758 TIdentityRelation<HBufC> identityRelation( FileNamesEqual ); |
492 for( TInt index = 0; index < aStartedExecutableArray.Count(); ++index ) |
759 for( TInt index = 0; index < aStartedExecutableArray.Count(); ++index ) |
493 { |
760 { |
494 const HBufC* startedAppName = aStartedExecutableArray[ index ]; |
761 const HBufC* startedAppName = aStartedExecutableArray[ index ]; |
|
762 FLOG_1( _L("CStartupListUpdater::StartedButNotInstalledAppsL, startedAppName %S"), |
|
763 startedAppName ); |
495 if( aInstalledExecutableArray.Find( startedAppName, identityRelation ) == KErrNotFound ) |
764 if( aInstalledExecutableArray.Find( startedAppName, identityRelation ) == KErrNotFound ) |
496 { |
765 { |
|
766 FLOG( _L("CStartupListUpdater::StartedButNotInstalledAppsL, adding to array") ); |
497 aStartedButNotInstalledExecutableArray.AppendL( startedAppName->AllocL() ); |
767 aStartedButNotInstalledExecutableArray.AppendL( startedAppName->AllocL() ); |
498 } |
768 } |
499 } |
769 } |
|
770 FLOG( _L("CStartupListUpdater::StartedButNotInstalledAppsL, end") ); |
500 } |
771 } |
501 |
772 |
502 // --------------------------------------------------------------------------- |
773 // --------------------------------------------------------------------------- |
503 // CStartupListUpdater::RemoveFromStartupListL() |
774 // CStartupListUpdater::RemoveFromStartupListL() |
504 // --------------------------------------------------------------------------- |
775 // --------------------------------------------------------------------------- |
505 // |
776 // |
506 void CStartupListUpdater::RemoveFromStartupListL( RDscStore& aDscStore, |
777 void CStartupListUpdater::RemoveFromStartupListL( RDscStore& aDscStore, |
507 RPointerArray<HBufC>& aExecutableArray ) |
778 RPointerArray<HBufC>& aExecutableArray ) |
508 { |
779 { |
|
780 FLOG( _L("CStartupListUpdater::RemoveFromStartupListL, begin") ); |
509 for( TInt index = 0; index < aExecutableArray.Count(); ++index ) |
781 for( TInt index = 0; index < aExecutableArray.Count(); ++index ) |
510 { |
782 { |
511 const TDesC& executableName = *( aExecutableArray[ index ] ); |
783 const TDesC& executableName = *( aExecutableArray[ index ] ); |
|
784 FLOG_1( _L("CStartupListUpdater::RemoveFromStartupListL, executableName %S"), |
|
785 &executableName ); |
512 CDscItem* item = CDscItem::NewLC( executableName, KNullDesC ); |
786 CDscItem* item = CDscItem::NewLC( executableName, KNullDesC ); |
513 if( aDscStore.ItemExistsL( *item ) ) |
787 if( aDscStore.ItemExistsL( *item ) ) |
514 { |
788 { |
|
789 FLOG( _L("CStartupListUpdater::RemoveFromStartupListL, removing from DscStore") ); |
515 aDscStore.DeleteItemL( *item ); |
790 aDscStore.DeleteItemL( *item ); |
516 } |
791 } |
517 CleanupStack::PopAndDestroy( item ); |
792 CleanupStack::PopAndDestroy( item ); |
518 } |
793 } |
|
794 FLOG( _L("CStartupListUpdater::RemoveFromStartupListL, end") ); |
519 } |
795 } |
520 |
796 |
521 // --------------------------------------------------------------------------- |
797 // --------------------------------------------------------------------------- |
522 // CStartupListUpdater::GetExecutablesFromEntryL() |
798 // CStartupListUpdater::GetExecutablesFromEntryL() |
523 // --------------------------------------------------------------------------- |
799 // --------------------------------------------------------------------------- |
524 // |
800 // |
525 void CStartupListUpdater::GetExecutablesFromEntryL( Swi::RSisRegistryEntry& aEntry, |
801 void CStartupListUpdater::GetExecutablesFromEntryL( Swi::RSisRegistryEntry& aEntry, |
526 RPointerArray<HBufC>& aExecutableArray ) |
802 RPointerArray<HBufC>& aExecutableArray ) |
527 { |
803 { |
|
804 FLOG( _L("CStartupListUpdater::GetExecutablesFromEntryL, begin") ); |
528 RPointerArray<HBufC> filesList; |
805 RPointerArray<HBufC> filesList; |
529 CleanupResetAndDestroyPushL( filesList ); |
806 CleanupResetAndDestroyPushL( filesList ); |
530 aEntry.FilesL( filesList ); |
807 aEntry.FilesL( filesList ); |
531 |
808 |
532 for( TInt index = 0; index < filesList.Count(); ++index ) |
809 for( TInt index = 0; index < filesList.Count(); ++index ) |
533 { |
810 { |
534 TParse parse; |
811 TParse parse; |
535 TInt err = parse.SetNoWild( KNullDesC, filesList[ index ], NULL ); |
812 TInt err = parse.SetNoWild( KNullDesC, filesList[ index ], NULL ); |
|
813 FLOG_3( _L("CStartupListUpdater::GetExecutablesFromEntryL, index %d, parse %S, err %d"), |
|
814 index, &(parse.FullName()), err ); |
536 if( !err && ( parse.Ext().CompareF( KExecutableExtension ) == 0 ) ) |
815 if( !err && ( parse.Ext().CompareF( KExecutableExtension ) == 0 ) ) |
537 { |
816 { |
|
817 FLOG( _L("CStartupListUpdater::GetExecutablesFromEntryL, adding to array") ); |
538 aExecutableArray.AppendL( parse.FullName().AllocL() ); |
818 aExecutableArray.AppendL( parse.FullName().AllocL() ); |
539 } |
819 } |
|
820 else |
|
821 { |
|
822 FLOG( _L("CStartupListUpdater::GetExecutablesFromEntryL, skipped") ); |
|
823 } |
540 } |
824 } |
541 |
825 |
542 CleanupStack::PopAndDestroy( &filesList ); |
826 CleanupStack::PopAndDestroy( &filesList ); |
543 } |
827 FLOG( _L("CStartupListUpdater::GetExecutablesFromEntryL, end") ); |
544 |
828 } |
|
829 |
|
830 // --------------------------------------------------------------------------- |
|
831 // CStartupListUpdater::OpenDevTraceL() |
|
832 // --------------------------------------------------------------------------- |
|
833 // |
|
834 void CStartupListUpdater::OpenDevTraceL() |
|
835 { |
|
836 if( !iLogBuf ) |
|
837 { |
|
838 TEntry entry; |
|
839 if( iFs.Entry( KDevTraceDir, entry ) == KErrNone ) |
|
840 { |
|
841 FLOG( _L("CStartupListUpdater::OpenDevTraceL, log dir exists") ); |
|
842 TFileName fileName; |
|
843 fileName.Copy( KDevTraceDir ); |
|
844 fileName.Append( KDevTraceFile ); |
|
845 if( iLogFile.Replace( iFs, fileName, EFileWrite ) == KErrNone ) |
|
846 { |
|
847 iLogBuf = HBufC::NewL( KDevTraceBuffer ); |
|
848 iFileBuf.CreateL( KDevTraceBuffer ); |
|
849 FLOG( _L("CStartupListUpdater::OpenDevTraceL, log file opened") ); |
|
850 } |
|
851 } |
|
852 } |
|
853 } |
|
854 |
|
855 // --------------------------------------------------------------------------- |
|
856 // CStartupListUpdater::DevTrace() |
|
857 // --------------------------------------------------------------------------- |
|
858 // |
|
859 void CStartupListUpdater::DevTrace( TRefByValue<const TDesC> aFmt, ... ) |
|
860 { |
|
861 if( iLogBuf ) |
|
862 { |
|
863 VA_LIST list; |
|
864 VA_START( list, aFmt ); |
|
865 TPtr line( iLogBuf->Des() ); |
|
866 line.FormatList( aFmt, list ); |
|
867 FLOG_1( _L("CStartupListUpdater::DevTrace: %S"), iLogBuf ); |
|
868 |
|
869 const TChar KNewLine( '\n' ); |
|
870 line.Append( KNewLine ); |
|
871 iFileBuf.Copy( line ); |
|
872 iLogFile.Write( iFileBuf ); // return value ignored |
|
873 } |
|
874 } |
|
875 |