26 #include <appmngr2drmutils.h> // TAppMngr2DRMUtils |
26 #include <appmngr2drmutils.h> // TAppMngr2DRMUtils |
27 #include <appmngr2cleanuputils.h> // CleanupResetAndDestroyPushL |
27 #include <appmngr2cleanuputils.h> // CleanupResetAndDestroyPushL |
28 #include <appmngr2debugutils.h> // FLOG macros |
28 #include <appmngr2debugutils.h> // FLOG macros |
29 #include <x509cert.h> // CX509Certificate |
29 #include <x509cert.h> // CX509Certificate |
30 #include <swi/sisregistrypackage.h> // CSisRegistryPackage |
30 #include <swi/sisregistrypackage.h> // CSisRegistryPackage |
31 #include <DRMHelper.h> |
|
32 #include <drmutility.h> |
|
33 |
31 |
34 |
32 |
35 // ======== MEMBER FUNCTIONS ======== |
33 // ======== MEMBER FUNCTIONS ======== |
36 |
34 |
37 // --------------------------------------------------------------------------- |
35 // --------------------------------------------------------------------------- |
240 // |
233 // |
241 void CAppMngr2SisxAppInfo::ConstructL( Swi::RSisRegistryEntry& aEntry ) |
234 void CAppMngr2SisxAppInfo::ConstructL( Swi::RSisRegistryEntry& aEntry ) |
242 { |
235 { |
243 FLOG( "CAppMngr2SisxAppInfo::ConstructL()" ); |
236 FLOG( "CAppMngr2SisxAppInfo::ConstructL()" ); |
244 CAppMngr2AppInfo::ConstructL(); // base construct |
237 CAppMngr2AppInfo::ConstructL(); // base construct |
245 |
238 |
246 iAppUid = aEntry.UidL(); |
239 iAppUid = aEntry.UidL(); |
247 FLOG( "CAppMngr2SisxAppInfo::ConstructL, iAppUid = 0x%08x", iAppUid.iUid ); |
240 FLOG( "CAppMngr2SisxAppInfo::ConstructL, iAppUid = 0x%08x", iAppUid.iUid ); |
248 iName = aEntry.PackageNameL(); |
241 iName = aEntry.PackageNameL(); |
249 FLOG( "CAppMngr2SisxAppInfo::ConstructL, iName = %S", iName ); |
242 FLOG( "CAppMngr2SisxAppInfo::ConstructL, iName = %S", iName ); |
250 iDetails = SizeStringWithUnitsL( aEntry.SizeL() ); |
243 iDetails = SizeStringWithUnitsL( aEntry.SizeL() ); |
251 FLOG( "CAppMngr2SisxAppInfo::ConstructL, aEntry.SizeL() = %Ld, iDetails = %S", |
244 FLOG( "CAppMngr2SisxAppInfo::ConstructL, iDetails = %S", iDetails ); |
252 aEntry.SizeL(), iDetails ); |
|
253 |
245 |
254 TUint drivesMask = aEntry.InstalledDrivesL(); |
246 TUint drivesMask = aEntry.InstalledDrivesL(); |
255 if( drivesMask ) |
247 if( drivesMask ) |
256 { |
248 { |
257 // Select the highest drive as location drive |
249 // Select the highest drive as location drive |
269 } |
261 } |
270 iLocation = TAppMngr2DriveUtils::LocationFromDriveL( iLocationDrive, iFs ); |
262 iLocation = TAppMngr2DriveUtils::LocationFromDriveL( iLocationDrive, iFs ); |
271 |
263 |
272 iVersion = aEntry.VersionL(); |
264 iVersion = aEntry.VersionL(); |
273 iVendor = aEntry.LocalizedVendorNameL(); |
265 iVendor = aEntry.LocalizedVendorNameL(); |
274 |
266 |
275 iIsAugmentation = aEntry.IsAugmentationL(); |
267 iIsAugmentation = aEntry.IsAugmentationL(); |
276 if( iIsAugmentation ) |
268 if( iIsAugmentation ) |
277 { |
269 { |
278 Swi::CSisRegistryPackage* pkg = aEntry.PackageL(); |
270 Swi::CSisRegistryPackage* pkg = aEntry.PackageL(); |
279 iAugmentationIndex = pkg->Index(); |
271 iAugmentationIndex = pkg->Index(); |
280 delete pkg; |
272 delete pkg; |
281 } |
273 } |
282 |
274 |
283 Swi::TSisPackageTrust trustLevel = aEntry.TrustL(); |
275 Swi::TSisPackageTrust trustLevel = aEntry.TrustL(); |
284 if( trustLevel >= Swi::ESisPackageCertificateChainValidatedToTrustAnchor ) |
276 if( trustLevel >= Swi::ESisPackageCertificateChainValidatedToTrustAnchor ) |
285 { |
277 { |
286 iIsTrusted = ETrue; |
278 iIsTrusted = ETrue; |
287 } |
279 } |
288 |
280 |
289 iRegSessionOpen = EFalse; |
281 // If installed SIS package is DRM protected, find the protected file and |
290 // iProtectedFile is allocated only in ShowDetails function. |
282 // save it's full name in iProtectedFile member variable for later use. |
291 iProtectedFile = NULL; |
283 // Full name of the protected file is needed in ShowDetailsL() function |
292 |
284 // to show the licence information. |
293 |
285 RPointerArray<HBufC> files; |
|
286 TRAPD( err, aEntry.FilesL( files ) ); |
|
287 if( err == KErrNone ) |
|
288 { |
|
289 CleanupResetAndDestroyPushL( files ); |
|
290 for( TInt fileIndex = 0; fileIndex < files.Count() && !iIsDRMProtected; fileIndex++ ) |
|
291 { |
|
292 HBufC* fileName = files[ fileIndex ]; |
|
293 iIsDRMProtected = TAppMngr2DRMUtils::IsDRMProtected( *fileName ); |
|
294 if( iIsDRMProtected ) |
|
295 { |
|
296 FLOG( "CAppMngr2SisxAppInfo::ConstructL, protected file %S", fileName ); |
|
297 iProtectedFile = fileName; // takes ownership |
|
298 files.Remove( fileIndex ); |
|
299 iIsRightsObjectMissingOrExpired = |
|
300 TAppMngr2DRMUtils::IsDRMRightsObjectExpiredOrMissingL( *fileName ); |
|
301 } |
|
302 } |
|
303 CleanupStack::PopAndDestroy( &files ); |
|
304 } |
|
305 |
294 FLOG( "CAppMngr2SisxAppInfo::ConstructL, loc=%d, aug=%d, trust=%d, drm=%d, RO=%d", |
306 FLOG( "CAppMngr2SisxAppInfo::ConstructL, loc=%d, aug=%d, trust=%d, drm=%d, RO=%d", |
295 iLocation, iIsAugmentation, iIsTrusted, iIsDRMProtected, |
307 iLocation, iIsAugmentation, iIsTrusted, iIsDRMProtected, |
296 iIsRightsObjectMissingOrExpired ); |
308 iIsRightsObjectMissingOrExpired ); |
297 } |
309 } |
298 |
310 |
302 // |
314 // |
303 void CAppMngr2SisxAppInfo::ShowDetailsL() |
315 void CAppMngr2SisxAppInfo::ShowDetailsL() |
304 { |
316 { |
305 FLOG( "CAppMngr2SisxAppInfo::ShowDetailsL()" ); |
317 FLOG( "CAppMngr2SisxAppInfo::ShowDetailsL()" ); |
306 TRAP_IGNORE( ReadCertificatesL() ); |
318 TRAP_IGNORE( ReadCertificatesL() ); |
307 |
319 |
308 CAppMngr2SisxInfoIterator* iterator = |
320 CAppMngr2SisxInfoIterator* iterator = CAppMngr2SisxInfoIterator::NewL( *this, |
309 CAppMngr2SisxInfoIterator::NewL( *this, |
321 EAppMngr2StatusInstalled ); |
310 EAppMngr2StatusInstalled ); |
|
311 CleanupStack::PushL( iterator ); |
322 CleanupStack::PushL( iterator ); |
312 |
323 |
313 // Let's check if installed SIS package is DRM protected. |
324 SwiUI::CommonUI::CCUIDetailsDialog* details = SwiUI::CommonUI::CCUIDetailsDialog::NewL(); |
314 // This check has been in constructor but it takes long time to check all |
|
315 // files for all installed packages so overall delay in UI is too long. |
|
316 // So we have move the DRM check into here. |
|
317 CheckDRMContentL(); |
|
318 |
|
319 |
|
320 FLOG( "CAppMngr2SisxAppInfo::ShowDetailsL, isDRM %d, noRightsObj %d, CertCount %d", |
325 FLOG( "CAppMngr2SisxAppInfo::ShowDetailsL, isDRM %d, noRightsObj %d, CertCount %d", |
321 iIsDRMProtected, iIsRightsObjectMissingOrExpired, iCertificates.Count() ); |
326 iIsDRMProtected, iIsRightsObjectMissingOrExpired, iCertificates.Count() ); |
322 |
327 |
323 RFile fileHandle; |
|
324 TInt fileOpenError = KErrNone; |
|
325 if( iIsDRMProtected && !iIsRightsObjectMissingOrExpired ) |
328 if( iIsDRMProtected && !iIsRightsObjectMissingOrExpired ) |
326 { |
329 { |
327 if ( iProtectedFile ) |
330 RFile fileHandle; |
328 { |
331 TInt err = fileHandle.Open( iFs, *iProtectedFile, EFileShareReadersOnly | EFileRead ); |
329 FLOG( "ShowDetailsL, iProtecteFile %S", iProtectedFile ); |
332 CleanupClosePushL( fileHandle ); |
330 fileOpenError = fileHandle.Open( iFs, |
333 |
331 *iProtectedFile, |
|
332 EFileShareReadersOnly | EFileRead ); |
|
333 FLOG( "ShowDetailsL, fileOpenError %d", fileOpenError ); |
|
334 if( !fileOpenError ) |
|
335 { |
|
336 CleanupClosePushL( fileHandle ); |
|
337 } |
|
338 } |
|
339 } |
|
340 |
|
341 SwiUI::CommonUI::CCUIDetailsDialog* details = SwiUI::CommonUI::CCUIDetailsDialog::NewL(); |
|
342 if( iIsDRMProtected && !iIsRightsObjectMissingOrExpired && !fileOpenError ) |
|
343 { |
|
344 if( iCertificates.Count() ) |
334 if( iCertificates.Count() ) |
345 { |
335 { |
346 details->ExecuteLD( *iterator, iCertificates, fileHandle ); |
336 details->ExecuteLD( *iterator, iCertificates, fileHandle ); |
347 } |
337 } |
348 else |
338 else |
349 { |
339 { |
350 details->ExecuteLD( *iterator, fileHandle ); |
340 details->ExecuteLD( *iterator, fileHandle ); |
351 } |
341 } |
|
342 |
|
343 CleanupStack::PopAndDestroy( &fileHandle ); |
352 } |
344 } |
353 else |
345 else |
354 { |
346 { |
355 if( iCertificates.Count() ) |
347 if( iCertificates.Count() ) |
356 { |
348 { |
434 } |
422 } |
435 else |
423 else |
436 { |
424 { |
437 User::Leave( KErrInUse ); |
425 User::Leave( KErrInUse ); |
438 } |
426 } |
439 |
427 |
440 if( iIsAugmentation ) |
428 if( iIsAugmentation ) |
441 { |
429 { |
442 FLOG( "CAppMngr2SisxAppInfo::HandleUninstallL, is augmentation" ); |
430 FLOG( "CAppMngr2SisxAppInfo::HandleUninstallL, is augmentation" ); |
443 SwiUI::TOpUninstallIndexParam params; |
431 SwiUI::TOpUninstallIndexParam params; |
444 params.iUid = iAppUid; |
432 params.iUid = iAppUid; |
445 params.iIndex = iAugmentationIndex; |
433 params.iIndex = iAugmentationIndex; |
446 |
434 |
447 SwiUI::TOpUninstallIndexParamPckg pckg( params ); |
435 SwiUI::TOpUninstallIndexParamPckg pckg( params ); |
448 if( iSWInstLauncherCustomUninstallParams ) |
436 if( iSWInstLauncherCustomUninstallParams ) |
449 { |
437 { |
450 delete iSWInstLauncherCustomUninstallParams; |
438 delete iSWInstLauncherCustomUninstallParams; |
451 iSWInstLauncherCustomUninstallParams = NULL; |
439 iSWInstLauncherCustomUninstallParams = NULL; |
463 FLOG( "CAppMngr2SisxAppInfo::HandleUninstallL, calling Uninstall" ); |
451 FLOG( "CAppMngr2SisxAppInfo::HandleUninstallL, calling Uninstall" ); |
464 iSWInstLauncher->Uninstall( aStatus, iAppUid, SwiUI::KSisxMimeType() ); |
452 iSWInstLauncher->Uninstall( aStatus, iAppUid, SwiUI::KSisxMimeType() ); |
465 } |
453 } |
466 } |
454 } |
467 |
455 |
468 // --------------------------------------------------------------------------- |
|
469 // CAppMngr2SisxAppInfo::CheckDRMContentL() |
|
470 // --------------------------------------------------------------------------- |
|
471 // |
|
472 void CAppMngr2SisxAppInfo::CheckDRMContentL() |
|
473 { |
|
474 FLOG( "CAppMngr2SisxAppInfo::CheckDRMContentL"); |
|
475 TInt err = KErrNone; |
|
476 |
|
477 if ( !iRegSessionOpen ) |
|
478 { |
|
479 err = iSisRegSession.Connect(); |
|
480 FLOG( "CheckDRMContentL, iSisRegSession.Connect err %d", err ); |
|
481 if ( err ) |
|
482 { |
|
483 iRegSessionOpen = EFalse; |
|
484 } |
|
485 else |
|
486 { |
|
487 iRegSessionOpen = ETrue; |
|
488 } |
|
489 } |
|
490 |
|
491 FLOG( "CheckDRMContentL, iRegSessionOpen = %d", err ); |
|
492 |
|
493 if ( iRegSessionOpen ) |
|
494 { |
|
495 Swi::RSisRegistryEntry entry; |
|
496 err = entry.Open( iSisRegSession, iAppUid ); |
|
497 FLOG( "CheckDRMContentL, entry.Open err = %d", err ); |
|
498 |
|
499 if ( !err ) |
|
500 { |
|
501 CleanupClosePushL( entry ); |
|
502 |
|
503 RPointerArray<HBufC> files; |
|
504 TRAP( err, entry.FilesL( files ) ); |
|
505 FLOG( "CheckDRMContentL, entry.FilesL err = %d", err ); |
|
506 |
|
507 if( !err ) |
|
508 { |
|
509 CleanupResetAndDestroyPushL( files ); |
|
510 |
|
511 // Use DRMUtility for DRM check. Utility class is much faster |
|
512 // then IsDRMProtected function. |
|
513 DRM::CDrmUtility* utility = DRM::CDrmUtility::NewLC(); |
|
514 |
|
515 for ( TInt index = 0; index < files.Count(); index++ ) |
|
516 { |
|
517 RFile fileHandle; |
|
518 TInt error = fileHandle.Open( iFs, |
|
519 *files[ index ], |
|
520 EFileRead ); |
|
521 FLOG( "CheckDRMContentL, File open error %d", error ); |
|
522 |
|
523 if ( error == KErrNone ) |
|
524 { |
|
525 CleanupClosePushL( fileHandle ); |
|
526 err = KErrNone; |
|
527 // We need to tarp this function since it may leave with |
|
528 // some files which do not have enough data. If ConstrucL |
|
529 // leaves package is not shown in UI. |
|
530 TRAP( err, iIsDRMProtected = |
|
531 utility->IsProtectedL( fileHandle ) ); |
|
532 |
|
533 if ( err ) |
|
534 { |
|
535 // If we have leave let's handle this as not DRM |
|
536 // procteded. |
|
537 iIsDRMProtected = EFalse; |
|
538 FLOG("CheckDRMContentL, IsProtectedL err %d",err); |
|
539 } |
|
540 |
|
541 CleanupStack::PopAndDestroy( &fileHandle ); |
|
542 |
|
543 if ( iIsDRMProtected ) |
|
544 { |
|
545 FLOG("CheckDRMContentL: File is DRM protected"); |
|
546 |
|
547 HBufC* fileName = files[ index ]; |
|
548 // Let's alloc this only when DRM package is found. |
|
549 // KMaxFileName (256) sould be enoug for all |
|
550 // file names. |
|
551 if ( iProtectedFile == NULL ) |
|
552 { |
|
553 iProtectedFile = HBufC::NewL( KMaxFileName ); |
|
554 } |
|
555 // Let's copy filename to member because we dont know |
|
556 // for sure that pointer to sis registry entry is valid |
|
557 // after entry delete. |
|
558 if ( iProtectedFile ) |
|
559 { |
|
560 TPtr ptr = iProtectedFile->Des(); |
|
561 ptr.Copy( *fileName ); |
|
562 } |
|
563 FLOG( "CheckDRMContentL: iProtecteFile %S", |
|
564 iProtectedFile ); |
|
565 |
|
566 files.Remove( index ); |
|
567 |
|
568 CDRMHelper* helper = CDRMHelper::NewLC(); |
|
569 CDRMHelperRightsConstraints* playconst = NULL; |
|
570 CDRMHelperRightsConstraints* dispconst = NULL; |
|
571 CDRMHelperRightsConstraints* execconst = NULL; |
|
572 CDRMHelperRightsConstraints* printconst = NULL; |
|
573 TBool sendingallowed = EFalse; |
|
574 |
|
575 FLOG( "CheckDRMContentL: GetRightsDetailsL" ); |
|
576 error = KErrNone; |
|
577 TRAP( error, helper->GetRightsDetailsL( |
|
578 *fileName, |
|
579 ContentAccess::EView, |
|
580 iIsRightsObjectMissingOrExpired, |
|
581 sendingallowed, |
|
582 playconst, |
|
583 dispconst, |
|
584 execconst, |
|
585 printconst ) ); |
|
586 FLOG( "GetRightsDetailsL TRAP err = %d", error ); |
|
587 FLOG( "iIsRightsObjectMissingOrExpired = %d", |
|
588 iIsRightsObjectMissingOrExpired ); |
|
589 delete playconst; |
|
590 delete dispconst; |
|
591 delete execconst; |
|
592 delete printconst; |
|
593 CleanupStack::PopAndDestroy( helper ); |
|
594 } |
|
595 } |
|
596 } |
|
597 CleanupStack::PopAndDestroy( utility ); |
|
598 CleanupStack::PopAndDestroy( &files ); |
|
599 } |
|
600 CleanupStack::PopAndDestroy( &entry ); |
|
601 } |
|
602 } |
|
603 } |
|
604 |
|
605 // EOF |
|
606 |
|