--- a/appinstaller/AppMngr2/Sisx/src/appmngr2sisxappinfo.cpp Tue Aug 31 15:21:33 2010 +0300
+++ b/appinstaller/AppMngr2/Sisx/src/appmngr2sisxappinfo.cpp Wed Sep 01 12:22:02 2010 +0100
@@ -1,5 +1,5 @@
/*
-* Copyright (c) 2003-2008 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2003-2010 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of "Eclipse Public License v1.0"
@@ -28,6 +28,8 @@
#include <appmngr2debugutils.h> // FLOG macros
#include <x509cert.h> // CX509Certificate
#include <swi/sisregistrypackage.h> // CSisRegistryPackage
+#include <DRMHelper.h>
+#include <drmutility.h>
// ======== MEMBER FUNCTIONS ========
@@ -60,6 +62,11 @@
delete iDetails;
delete iVendor;
iCertificates.ResetAndDestroy();
+
+ if ( iRegSessionOpen )
+ {
+ iSisRegSession.Close();
+ }
}
// ---------------------------------------------------------------------------
@@ -235,13 +242,14 @@
{
FLOG( "CAppMngr2SisxAppInfo::ConstructL()" );
CAppMngr2AppInfo::ConstructL(); // base construct
-
+
iAppUid = aEntry.UidL();
FLOG( "CAppMngr2SisxAppInfo::ConstructL, iAppUid = 0x%08x", iAppUid.iUid );
iName = aEntry.PackageNameL();
FLOG( "CAppMngr2SisxAppInfo::ConstructL, iName = %S", iName );
iDetails = SizeStringWithUnitsL( aEntry.SizeL() );
- FLOG( "CAppMngr2SisxAppInfo::ConstructL, iDetails = %S", iDetails );
+ FLOG( "CAppMngr2SisxAppInfo::ConstructL, aEntry.SizeL() = %Ld, iDetails = %S",
+ aEntry.SizeL(), iDetails );
TUint drivesMask = aEntry.InstalledDrivesL();
if( drivesMask )
@@ -263,7 +271,7 @@
iVersion = aEntry.VersionL();
iVendor = aEntry.LocalizedVendorNameL();
-
+
iIsAugmentation = aEntry.IsAugmentationL();
if( iIsAugmentation )
{
@@ -272,37 +280,17 @@
delete pkg;
}
- Swi::TSisPackageTrust trustLevel = aEntry.TrustL();
+ Swi::TSisPackageTrust trustLevel = aEntry.TrustL();
if( trustLevel >= Swi::ESisPackageCertificateChainValidatedToTrustAnchor )
{
iIsTrusted = ETrue;
- }
-
- // If installed SIS package is DRM protected, find the protected file and
- // save it's full name in iProtectedFile member variable for later use.
- // Full name of the protected file is needed in ShowDetailsL() function
- // to show the licence information.
- RPointerArray<HBufC> files;
- TRAPD( err, aEntry.FilesL( files ) );
- if( err == KErrNone )
- {
- CleanupResetAndDestroyPushL( files );
- for( TInt fileIndex = 0; fileIndex < files.Count() && !iIsDRMProtected; fileIndex++ )
- {
- HBufC* fileName = files[ fileIndex ];
- iIsDRMProtected = TAppMngr2DRMUtils::IsDRMProtected( *fileName );
- if( iIsDRMProtected )
- {
- FLOG( "CAppMngr2SisxAppInfo::ConstructL, protected file %S", fileName );
- iProtectedFile = fileName; // takes ownership
- files.Remove( fileIndex );
- iIsRightsObjectMissingOrExpired =
- TAppMngr2DRMUtils::IsDRMRightsObjectExpiredOrMissingL( *fileName );
- }
- }
- CleanupStack::PopAndDestroy( &files );
- }
-
+ }
+
+ iRegSessionOpen = EFalse;
+ // iProtectedFile is allocated only in ShowDetails function.
+ iProtectedFile = NULL;
+
+
FLOG( "CAppMngr2SisxAppInfo::ConstructL, loc=%d, aug=%d, trust=%d, drm=%d, RO=%d",
iLocation, iIsAugmentation, iIsTrusted, iIsDRMProtected,
iIsRightsObjectMissingOrExpired );
@@ -316,21 +304,43 @@
{
FLOG( "CAppMngr2SisxAppInfo::ShowDetailsL()" );
TRAP_IGNORE( ReadCertificatesL() );
-
- CAppMngr2SisxInfoIterator* iterator = CAppMngr2SisxInfoIterator::NewL( *this,
- EAppMngr2StatusInstalled );
+
+ CAppMngr2SisxInfoIterator* iterator =
+ CAppMngr2SisxInfoIterator::NewL( *this,
+ EAppMngr2StatusInstalled );
CleanupStack::PushL( iterator );
- SwiUI::CommonUI::CCUIDetailsDialog* details = SwiUI::CommonUI::CCUIDetailsDialog::NewL();
+ // Let's check if installed SIS package is DRM protected.
+ // This check has been in constructor but it takes long time to check all
+ // files for all installed packages so overall delay in UI is too long.
+ // So we have move the DRM check into here.
+ CheckDRMContentL();
+
+
FLOG( "CAppMngr2SisxAppInfo::ShowDetailsL, isDRM %d, noRightsObj %d, CertCount %d",
iIsDRMProtected, iIsRightsObjectMissingOrExpired, iCertificates.Count() );
-
+
+ RFile fileHandle;
+ TInt fileOpenError = KErrNone;
if( iIsDRMProtected && !iIsRightsObjectMissingOrExpired )
{
- RFile fileHandle;
- TInt err = fileHandle.Open( iFs, *iProtectedFile, EFileShareReadersOnly | EFileRead );
- CleanupClosePushL( fileHandle );
-
+ if ( iProtectedFile )
+ {
+ FLOG( "ShowDetailsL, iProtecteFile %S", iProtectedFile );
+ fileOpenError = fileHandle.Open( iFs,
+ *iProtectedFile,
+ EFileShareReadersOnly | EFileRead );
+ FLOG( "ShowDetailsL, fileOpenError %d", fileOpenError );
+ if( !fileOpenError )
+ {
+ CleanupClosePushL( fileHandle );
+ }
+ }
+ }
+
+ SwiUI::CommonUI::CCUIDetailsDialog* details = SwiUI::CommonUI::CCUIDetailsDialog::NewL();
+ if( iIsDRMProtected && !iIsRightsObjectMissingOrExpired && !fileOpenError )
+ {
if( iCertificates.Count() )
{
details->ExecuteLD( *iterator, iCertificates, fileHandle );
@@ -339,8 +349,6 @@
{
details->ExecuteLD( *iterator, fileHandle );
}
-
- CleanupStack::PopAndDestroy( &fileHandle );
}
else
{
@@ -353,7 +361,11 @@
details->ExecuteLD( *iterator );
}
}
-
+
+ if( iIsDRMProtected && !iIsRightsObjectMissingOrExpired && !fileOpenError )
+ {
+ CleanupStack::PopAndDestroy( &fileHandle );
+ }
CleanupStack::PopAndDestroy( iterator );
}
@@ -366,7 +378,7 @@
if( !iCertsRead )
{
FLOG_PERF_STATIC_BEGIN( SisxAppInfo_ReadCerts );
-
+
Swi::RSisRegistrySession regSession;
CleanupClosePushL( regSession );
User::LeaveIfError( regSession.Connect() );
@@ -400,7 +412,7 @@
CleanupStack::PopAndDestroy( &entry );
CleanupStack::PopAndDestroy( ®Session );
iCertsRead = ETrue;
-
+
FLOG_PERF_STATIC_END( SisxAppInfo_ReadCerts )
}
}
@@ -424,14 +436,14 @@
{
User::Leave( KErrInUse );
}
-
+
if( iIsAugmentation )
{
FLOG( "CAppMngr2SisxAppInfo::HandleUninstallL, is augmentation" );
SwiUI::TOpUninstallIndexParam params;
params.iUid = iAppUid;
params.iIndex = iAugmentationIndex;
-
+
SwiUI::TOpUninstallIndexParamPckg pckg( params );
if( iSWInstLauncherCustomUninstallParams )
{
@@ -453,3 +465,142 @@
}
}
+// ---------------------------------------------------------------------------
+// CAppMngr2SisxAppInfo::CheckDRMContentL()
+// ---------------------------------------------------------------------------
+//
+void CAppMngr2SisxAppInfo::CheckDRMContentL()
+ {
+ FLOG( "CAppMngr2SisxAppInfo::CheckDRMContentL");
+ TInt err = KErrNone;
+
+ if ( !iRegSessionOpen )
+ {
+ err = iSisRegSession.Connect();
+ FLOG( "CheckDRMContentL, iSisRegSession.Connect err %d", err );
+ if ( err )
+ {
+ iRegSessionOpen = EFalse;
+ }
+ else
+ {
+ iRegSessionOpen = ETrue;
+ }
+ }
+
+ FLOG( "CheckDRMContentL, iRegSessionOpen = %d", err );
+
+ if ( iRegSessionOpen )
+ {
+ Swi::RSisRegistryEntry entry;
+ err = entry.Open( iSisRegSession, iAppUid );
+ FLOG( "CheckDRMContentL, entry.Open err = %d", err );
+
+ if ( !err )
+ {
+ CleanupClosePushL( entry );
+
+ RPointerArray<HBufC> files;
+ TRAP( err, entry.FilesL( files ) );
+ FLOG( "CheckDRMContentL, entry.FilesL err = %d", err );
+
+ if( !err )
+ {
+ CleanupResetAndDestroyPushL( files );
+
+ // Use DRMUtility for DRM check. Utility class is much faster
+ // then IsDRMProtected function.
+ DRM::CDrmUtility* utility = DRM::CDrmUtility::NewLC();
+
+ for ( TInt index = 0; index < files.Count(); index++ )
+ {
+ RFile fileHandle;
+ TInt error = fileHandle.Open( iFs,
+ *files[ index ],
+ EFileRead );
+ FLOG( "CheckDRMContentL, File open error %d", error );
+
+ if ( error == KErrNone )
+ {
+ CleanupClosePushL( fileHandle );
+ err = KErrNone;
+ // We need to tarp this function since it may leave with
+ // some files which do not have enough data. If ConstrucL
+ // leaves package is not shown in UI.
+ TRAP( err, iIsDRMProtected =
+ utility->IsProtectedL( fileHandle ) );
+
+ if ( err )
+ {
+ // If we have leave let's handle this as not DRM
+ // procteded.
+ iIsDRMProtected = EFalse;
+ FLOG("CheckDRMContentL, IsProtectedL err %d",err);
+ }
+
+ CleanupStack::PopAndDestroy( &fileHandle );
+
+ if ( iIsDRMProtected )
+ {
+ FLOG("CheckDRMContentL: File is DRM protected");
+
+ HBufC* fileName = files[ index ];
+ // Let's alloc this only when DRM package is found.
+ // KMaxFileName (256) sould be enoug for all
+ // file names.
+ if ( iProtectedFile == NULL )
+ {
+ iProtectedFile = HBufC::NewL( KMaxFileName );
+ }
+ // Let's copy filename to member because we dont know
+ // for sure that pointer to sis registry entry is valid
+ // after entry delete.
+ if ( iProtectedFile )
+ {
+ TPtr ptr = iProtectedFile->Des();
+ ptr.Copy( *fileName );
+ }
+ FLOG( "CheckDRMContentL: iProtecteFile %S",
+ iProtectedFile );
+
+ files.Remove( index );
+
+ CDRMHelper* helper = CDRMHelper::NewLC();
+ CDRMHelperRightsConstraints* playconst = NULL;
+ CDRMHelperRightsConstraints* dispconst = NULL;
+ CDRMHelperRightsConstraints* execconst = NULL;
+ CDRMHelperRightsConstraints* printconst = NULL;
+ TBool sendingallowed = EFalse;
+
+ FLOG( "CheckDRMContentL: GetRightsDetailsL" );
+ error = KErrNone;
+ TRAP( error, helper->GetRightsDetailsL(
+ *fileName,
+ ContentAccess::EView,
+ iIsRightsObjectMissingOrExpired,
+ sendingallowed,
+ playconst,
+ dispconst,
+ execconst,
+ printconst ) );
+ FLOG( "GetRightsDetailsL TRAP err = %d", error );
+ FLOG( "iIsRightsObjectMissingOrExpired = %d",
+ iIsRightsObjectMissingOrExpired );
+ delete playconst;
+ delete dispconst;
+ delete execconst;
+ delete printconst;
+ CleanupStack::PopAndDestroy( helper );
+ }
+ }
+ }
+ CleanupStack::PopAndDestroy( utility );
+ CleanupStack::PopAndDestroy( &files );
+ }
+ CleanupStack::PopAndDestroy( &entry );
+ }
+ }
+ }
+
+// EOF
+