appinstaller/AppMngr2/Sisx/src/appmngr2sisxappinfo.cpp
branchRCL_3
changeset 61 cd189dac02f7
parent 34 741e5bba2bd1
child 65 7333d7932ef7
equal deleted inserted replaced
51:5bddc28da627 61:cd189dac02f7
    60     delete iSWInstLauncherCustomUninstallParams;
    60     delete iSWInstLauncherCustomUninstallParams;
    61     delete iName;
    61     delete iName;
    62     delete iDetails;
    62     delete iDetails;
    63     delete iVendor;
    63     delete iVendor;
    64     iCertificates.ResetAndDestroy();
    64     iCertificates.ResetAndDestroy();
       
    65     
       
    66     if ( iRegSessionOpen )
       
    67         {
       
    68         iSisRegSession.Close();
       
    69         }
    65     }
    70     }
    66 
    71 
    67 // ---------------------------------------------------------------------------
    72 // ---------------------------------------------------------------------------
    68 // CAppMngr2SisxAppInfo::IconIndex()
    73 // CAppMngr2SisxAppInfo::IconIndex()
    69 // ---------------------------------------------------------------------------
    74 // ---------------------------------------------------------------------------
   277 
   282 
   278     Swi::TSisPackageTrust trustLevel = aEntry.TrustL();
   283     Swi::TSisPackageTrust trustLevel = aEntry.TrustL();
   279     if( trustLevel >= Swi::ESisPackageCertificateChainValidatedToTrustAnchor )
   284     if( trustLevel >= Swi::ESisPackageCertificateChainValidatedToTrustAnchor )
   280         {
   285         {
   281         iIsTrusted = ETrue;
   286         iIsTrusted = ETrue;
   282         }
   287         }   
   283 
       
   284     // If installed SIS package is DRM protected, find the protected file and
       
   285     // save it's full name in iProtectedFile member variable for later use.
       
   286     // Full name of the protected file is needed in ShowDetailsL() function
       
   287     // to show the licence information.
       
   288     RPointerArray<HBufC> files;
       
   289     TRAPD( err, aEntry.FilesL( files ) );
       
   290     
   288     
   291     if( err == KErrNone )
   289     iRegSessionOpen = EFalse;    
   292         {
   290     // iProtectedFile is allocated only in ShowDetails function.
   293         CleanupResetAndDestroyPushL( files );
   291     iProtectedFile = NULL;                                                                         
   294         
   292          
   295         // Use DRMUtility for DRM check. Utility class is much faster then
   293     
   296         // IsDRMProtected function.        
       
   297         DRM::CDrmUtility* utility = DRM::CDrmUtility::NewLC();
       
   298                                      
       
   299         for ( TInt fileIndex = 0; fileIndex < files.Count(); fileIndex++ )
       
   300             {  
       
   301 #ifdef _DEBUG        
       
   302             HBufC* tempName = files[ fileIndex ]; 
       
   303             FLOG( "CAppMngr2SisxAppInfo::ConstructL, File name: %S", tempName );
       
   304 #endif        
       
   305             RFile fileHandle;
       
   306             TInt error = fileHandle.Open( iFs, *files[ fileIndex ], EFileRead );
       
   307             FLOG( "CAppMngr2SisxAppInfo::ConstructL, File open error %d", 
       
   308                     error );
       
   309                        
       
   310             if ( error == KErrNone )
       
   311                 {                
       
   312                 CleanupClosePushL( fileHandle );                
       
   313                 TInt err = KErrNone;
       
   314                 // We need to tarp this function since it may leave with some
       
   315                 // files which do not have enough data. If ConstrucL leaves
       
   316                 // package is not shown in UI.
       
   317                 TRAP( err, iIsDRMProtected = utility->IsProtectedL( fileHandle ) );
       
   318            
       
   319                 if ( err )
       
   320                     {
       
   321                     // If we have leave let's handle this as not DRM procteded.
       
   322                     iIsDRMProtected = EFalse;
       
   323                     FLOG( "CAppMngr2SisxAppInfo, IsProtectedL error: %d", err );
       
   324                     }
       
   325                 
       
   326                 CleanupStack::PopAndDestroy( &fileHandle ); 
       
   327                 
       
   328                 if ( iIsDRMProtected )
       
   329                     { 
       
   330                     FLOG( "CAppMngr2SisxAppInfo: File is DRM protected" );
       
   331                 
       
   332                     HBufC* fileName = files[ fileIndex ];                                                
       
   333                     iProtectedFile = fileName;  // takes ownership
       
   334                     files.Remove( fileIndex );                    
       
   335                     
       
   336                     CDRMHelper* helper = CDRMHelper::NewLC();                    
       
   337                     CDRMHelperRightsConstraints* playconst = NULL;
       
   338                     CDRMHelperRightsConstraints* dispconst = NULL;
       
   339                     CDRMHelperRightsConstraints* execconst = NULL;
       
   340                     CDRMHelperRightsConstraints* printconst = NULL;            
       
   341                     TBool sendingallowed = EFalse;
       
   342                                     
       
   343                     FLOG( "CAppMngr2SisxAppInfo: GetRightsDetailsL" );
       
   344                     error = KErrNone;
       
   345                     TRAP( error, helper->GetRightsDetailsL( *fileName, 
       
   346                                                 ContentAccess::EView, 
       
   347                                                 iIsRightsObjectMissingOrExpired, 
       
   348                                                 sendingallowed, 
       
   349                                                 playconst, 
       
   350                                                 dispconst, 
       
   351                                                 execconst, 
       
   352                                                 printconst ) );                     
       
   353                     FLOG( "GetRightsDetailsL TRAP err = %d", error );
       
   354                     
       
   355                     delete playconst;
       
   356                     delete dispconst;
       
   357                     delete execconst;
       
   358                     delete printconst;
       
   359                     
       
   360                     CleanupStack::PopAndDestroy( helper );
       
   361                     
       
   362                     FLOG( "iIsRightsObjectMissingOrExpired: %d", 
       
   363                             iIsRightsObjectMissingOrExpired );                                        
       
   364                     }
       
   365                 }
       
   366             }                
       
   367         CleanupStack::PopAndDestroy( utility );
       
   368         CleanupStack::PopAndDestroy( &files );
       
   369         }
       
   370 
       
   371     FLOG( "CAppMngr2SisxAppInfo::ConstructL, loc=%d, aug=%d, trust=%d, drm=%d, RO=%d",
   294     FLOG( "CAppMngr2SisxAppInfo::ConstructL, loc=%d, aug=%d, trust=%d, drm=%d, RO=%d",
   372             iLocation, iIsAugmentation, iIsTrusted, iIsDRMProtected,
   295             iLocation, iIsAugmentation, iIsTrusted, iIsDRMProtected,
   373             iIsRightsObjectMissingOrExpired );
   296             iIsRightsObjectMissingOrExpired );
   374     }
   297     }
   375 
   298 
   380 void CAppMngr2SisxAppInfo::ShowDetailsL()
   303 void CAppMngr2SisxAppInfo::ShowDetailsL()
   381     {
   304     {
   382     FLOG( "CAppMngr2SisxAppInfo::ShowDetailsL()" );
   305     FLOG( "CAppMngr2SisxAppInfo::ShowDetailsL()" );
   383     TRAP_IGNORE( ReadCertificatesL() );
   306     TRAP_IGNORE( ReadCertificatesL() );
   384 
   307 
   385     CAppMngr2SisxInfoIterator* iterator = CAppMngr2SisxInfoIterator::NewL( *this,
   308     CAppMngr2SisxInfoIterator* iterator = 
   386             EAppMngr2StatusInstalled );
   309             CAppMngr2SisxInfoIterator::NewL( *this,
       
   310                                              EAppMngr2StatusInstalled );
   387     CleanupStack::PushL( iterator );
   311     CleanupStack::PushL( iterator );
       
   312     
       
   313     // Let's check if installed SIS package is DRM protected.
       
   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     
   388 
   319 
   389     FLOG( "CAppMngr2SisxAppInfo::ShowDetailsL, isDRM %d, noRightsObj %d, CertCount %d",
   320     FLOG( "CAppMngr2SisxAppInfo::ShowDetailsL, isDRM %d, noRightsObj %d, CertCount %d",
   390             iIsDRMProtected, iIsRightsObjectMissingOrExpired, iCertificates.Count() );
   321             iIsDRMProtected, iIsRightsObjectMissingOrExpired, iCertificates.Count() );
   391 
   322 
   392     RFile fileHandle;
   323     RFile fileHandle;
   393     TInt fileOpenError = KErrNone;
   324     TInt fileOpenError = KErrNone;
   394     if( iIsDRMProtected && !iIsRightsObjectMissingOrExpired )
   325     if( iIsDRMProtected && !iIsRightsObjectMissingOrExpired )
   395         {
   326         {
   396         FLOG( "CAppMngr2SisxAppInfo::ShowDetailsL, iProtecteFile %S", iProtectedFile );
   327         if ( iProtectedFile )
   397         fileOpenError = fileHandle.Open( iFs, *iProtectedFile, EFileShareReadersOnly | EFileRead );
   328             {
   398         FLOG( "CAppMngr2SisxAppInfo::ShowDetailsL, fileOpenError %d", fileOpenError );
   329             FLOG( "ShowDetailsL, iProtecteFile %S", iProtectedFile );
   399         if( !fileOpenError )
   330             fileOpenError = fileHandle.Open( iFs, 
   400             {
   331                                             *iProtectedFile, 
   401             CleanupClosePushL( fileHandle );
   332                                             EFileShareReadersOnly | EFileRead );
       
   333             FLOG( "ShowDetailsL, fileOpenError %d", fileOpenError );
       
   334             if( !fileOpenError )
       
   335                 {
       
   336                 CleanupClosePushL( fileHandle );
       
   337                 }
   402             }
   338             }
   403         }
   339         }
   404 
   340 
   405     SwiUI::CommonUI::CCUIDetailsDialog* details = SwiUI::CommonUI::CCUIDetailsDialog::NewL();
   341     SwiUI::CommonUI::CCUIDetailsDialog* details = SwiUI::CommonUI::CCUIDetailsDialog::NewL();
   406     if( iIsDRMProtected && !iIsRightsObjectMissingOrExpired && !fileOpenError )
   342     if( iIsDRMProtected && !iIsRightsObjectMissingOrExpired && !fileOpenError )
   527         FLOG( "CAppMngr2SisxAppInfo::HandleUninstallL, calling Uninstall" );
   463         FLOG( "CAppMngr2SisxAppInfo::HandleUninstallL, calling Uninstall" );
   528         iSWInstLauncher->Uninstall( aStatus, iAppUid, SwiUI::KSisxMimeType() );
   464         iSWInstLauncher->Uninstall( aStatus, iAppUid, SwiUI::KSisxMimeType() );
   529         }
   465         }
   530     }
   466     }
   531 
   467 
       
   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