homescreenpluginsrv/hspsmanager/src/hspsinstallationhandler.cpp
branchRCL_3
changeset 19 502e5d91ad42
parent 9 d0529222e3f0
child 51 15e4dd19031c
equal deleted inserted replaced
18:bd874ee5e5e2 19:502e5d91ad42
    54 _LIT8(KUnknownMimeType, "unknown");    
    54 _LIT8(KUnknownMimeType, "unknown");    
    55 
    55 
    56 _LIT8(KhspsDefinitionEngine, "hspsdefinitionengine");
    56 _LIT8(KhspsDefinitionEngine, "hspsdefinitionengine");
    57 
    57 
    58 _LIT(KPathDelim, "\\");
    58 _LIT(KPathDelim, "\\");
       
    59 _LIT(KPrivateInstall, "\\private\\200159c0\\install\\");
    59 _LIT(KHsps, "\\hsps\\" );
    60 _LIT(KHsps, "\\hsps\\" );
    60 _LIT(KXuikon, "xuikon\\" );
    61 _LIT(KXuikon, "xuikon\\" );
    61 
    62 
    62 const TInt KMaxMediaTypeLength = 100;
    63 const TInt KMaxMediaTypeLength = 100;
    63 
    64 
    97     iFileNotFound = EFalse;
    98     iFileNotFound = EFalse;
    98     iLocalized = EFalse;             
    99     iLocalized = EFalse;             
    99     iDefaultSpecificationSet = EFalse;
   100     iDefaultSpecificationSet = EFalse;
   100     iDefaultSpecification = ELangNone;
   101     iDefaultSpecification = ELangNone;
   101     iInstallationMode = EServiceHandler;
   102     iInstallationMode = EServiceHandler;
   102     iRomInstallation = EFalse;
   103     iTrustedInstallation = EFalse;
   103 	iInstallationType = EInstallationTypeNew;
   104 	iInstallationType = EInstallationTypeNew;
   104 	iFamilyMask = 0;
   105 	iFamilyMask = 0;
   105     }
   106     }
   106     
   107     
   107 // -----------------------------------------------------------------------------
   108 // -----------------------------------------------------------------------------
   295 // -----------------------------------------------------------------------------
   296 // -----------------------------------------------------------------------------
   296 // ChspsInstallationHandler::ResetL()
   297 // ChspsInstallationHandler::ResetL()
   297 // -----------------------------------------------------------------------------
   298 // -----------------------------------------------------------------------------
   298 void ChspsInstallationHandler::ResetL()
   299 void ChspsInstallationHandler::ResetL()
   299     {
   300     {
       
   301     iThemeFilePath.FillZ();    
   300     iFamilyMask = 0;
   302     iFamilyMask = 0;
   301     iInstallationPhase = EhspsPhaseInitialise;    
   303     iInstallationPhase = EhspsPhaseInitialise;    
   302     iThemeStatus = EhspsThemeStatusNone;  
   304     iThemeStatus = EhspsThemeStatusNone;
       
   305     iTrustedInstallation = EFalse;
   303     iFileNotFound = EFalse;
   306     iFileNotFound = EFalse;
   304     delete iMediaType;
   307     delete iMediaType;
   305     iMediaType = NULL;
   308     iMediaType = NULL;
   306     delete iThemeDesc;
   309     delete iThemeDesc;
   307     iThemeDesc = NULL;
   310     iThemeDesc = NULL;
   355 ThspsServiceCompletedMessage ChspsInstallationHandler::hspsInstallTheme(
   358 ThspsServiceCompletedMessage ChspsInstallationHandler::hspsInstallTheme(
   356         const TDesC& aManifestFileName, 
   359         const TDesC& aManifestFileName, 
   357         TDes8& aHeaderData)
   360         TDes8& aHeaderData)
   358     {
   361     {
   359     // Assume that the installation fails
   362     // Assume that the installation fails
   360     ThspsServiceCompletedMessage ret = EhspsInstallThemeFailed;           
   363     ThspsServiceCompletedMessage ret = EhspsInstallThemeFailed;                       
   361     iResult->iXuikonError = KErrManifestFileCorrupted;
   364     iResult->iXuikonError = 0;    
   362         
   365     iResult->iIntValue2 = 0;
   363     // Reset memeber variables
   366     
   364     TInt errorCode = KErrNone;
   367     TRAPD( err, DoInstallThemeL(aManifestFileName) );
   365     TRAP( errorCode, ResetL() );
   368     if( !err )
   366     if ( !errorCode )
   369         {
   367         {        
   370         // correct headerdata is in iHeaderData set by CheckHeaderL()
   368         // Get manifest file path
   371         aHeaderData = iHeaderData->Des();        
   369         iThemeFilePath.Set( TParsePtrC( aManifestFileName ).DriveAndPath() );
   372                    
   370         // Check if ROM installation is requested
   373         // Set next phase
   371         iRomInstallation = EFalse;
   374         iInstallationPhase = EhspsPhaseCleanup;
   372         TParse driveParser;
   375         ret = EhspsInstallThemeSuccess;
   373         driveParser.Set( iThemeFilePath, NULL, NULL );
   376         }
   374         TInt driveNumber;
   377     else
   375         if ( RFs::CharToDrive( driveParser.Drive()[0], driveNumber ) == KErrNone )
       
   376             {
       
   377             if ( driveNumber == EDriveZ )
       
   378                 {
       
   379                 iRomInstallation = ETrue;
       
   380                 }
       
   381             }
       
   382             
       
   383 #ifdef HSPS_LOG_ACTIVE    
       
   384         if ( iLogBus )
       
   385             {            
       
   386             iLogBus->LogText( _L( "ChspsInstallationHandler::hspsInstallTheme() - *** Parsing a manifest file:" ) );
       
   387             }
       
   388 #endif       
       
   389         if( BaflUtils::FileExists( iFsSession, aManifestFileName ) )
       
   390              {
       
   391              // Parse XML from the manifest file
       
   392              TRAP( errorCode, Xml::ParseL( *iXmlParser, iFsSession, aManifestFileName ));     
       
   393              }        
       
   394         else
       
   395             {
       
   396 #ifdef HSPS_LOG_ACTIVE    
       
   397             if ( iLogBus )
       
   398                 {           
       
   399                 iLogBus->LogText( _L( "ChspsInstallationHandler::hspsInstallTheme() - Manifest was not found!" ) );
       
   400                 }
       
   401 #endif            
       
   402             iFileNotFound = ETrue;
       
   403             errorCode = KErrNotFound;
       
   404             }
       
   405         }
       
   406         
       
   407     if ( !errorCode && !iFileNotFound )
       
   408         {        
       
   409         // The manifest file has been read at this point and following callbacks have been executed:
       
   410         // (unless the manifest was invalid): OnContent, OnStartElement, OnEndElement
       
   411 
       
   412         // Detect installation type.
       
   413         // Performance optimization: do not check if installing from rom.
       
   414         if( !iRomInstallation )
       
   415             {
       
   416             // Check type of installation
       
   417             TBool instancesFound = EFalse;
       
   418             TRAP( errorCode, instancesFound = IsPluginUsedInAppConfsL() );            
       
   419             if( iThemeServer.PluginInHeaderCache( TUid::Uid( iThemeUid ) ) && instancesFound )                    
       
   420                 {
       
   421                 // Plugin should be found from cache, update notifications are
       
   422                 // sent only when plugins are used by one/more app configurations
       
   423                 iInstallationType = EInstallationTypeUpdate;
       
   424                 }
       
   425             else
       
   426                 {
       
   427                 iInstallationType = EInstallationTypeNew;
       
   428                 }
       
   429             }                
       
   430         if ( !errorCode )
       
   431             {
       
   432             // Check the manifest        
       
   433             TRAP( errorCode, ValidateL() );
       
   434             }
       
   435         if ( !errorCode )
       
   436             {
       
   437             // correct headerdata is in iHeaderData set by CheckHeaderL()
       
   438             aHeaderData = iHeaderData->Des();
       
   439             
       
   440             ret = EhspsInstallThemeSuccess;
       
   441                
       
   442             // Set next phase
       
   443             iInstallationPhase = EhspsPhaseCleanup;
       
   444            
       
   445             // number of all resources to iResult
       
   446             iResult->iIntValue2 = 0;
       
   447             }
       
   448         }
       
   449 
       
   450     if ( errorCode )
       
   451         {     
   378         {     
   452 #ifdef HSPS_LOG_ACTIVE  
   379 #ifdef HSPS_LOG_ACTIVE  
   453         if( iLogBus )
   380         if( iLogBus )
   454             {
   381             {
   455             iLogBus->LogText( _L( "ChspsInstallationHandler::hspsInstallTheme(): - Installation failed with error code %d" ),
   382             iLogBus->LogText( _L( "ChspsInstallationHandler::hspsInstallTheme(): - Installation failed with error code %d" ),
   456                     errorCode );
   383                     errorCode );
   457             }
   384             }
   458 #endif              
   385 #endif       
   459         }
   386         }
   460     
   387         
   461     iResult->iSystemError = errorCode;
   388     iResult->iSystemError = err;
   462     return ret;
   389     return ret;
       
   390     }
       
   391 
       
   392 // -----------------------------------------------------------------------------
       
   393 // ChspsInstallationHandler::DoInstallThemeL()
       
   394 // -----------------------------------------------------------------------------
       
   395 void ChspsInstallationHandler::DoInstallThemeL(
       
   396         const TDesC& aManifest )
       
   397     {        
       
   398     // Reset memeber variables    
       
   399     ResetL();
       
   400         
       
   401     TParsePtrC parsePtr( aManifest );        
       
   402                 
       
   403     // Store the path to the installation file     
       
   404     __ASSERT_DEBUG( aManifest.Length() < KMaxFileName, User::Leave( KErrBadName ) );
       
   405     iThemeFilePath.Copy( parsePtr.DriveAndPath() );    
       
   406         
       
   407     // If trying to install widgets from one of our private install directories
       
   408     const TPath path = parsePtr.Path();
       
   409     if( path.Length() > KPrivateInstall().Length() 
       
   410             && path.Left( KPrivateInstall().Length() ) == KPrivateInstall() ) 
       
   411         {                    
       
   412         // Check if ROM or UDA installation was requested
       
   413         if( parsePtr.DrivePresent() )
       
   414             {            
       
   415             TInt driveNumber;
       
   416             if ( RFs::CharToDrive( parsePtr.Drive()[0], driveNumber ) == KErrNone )
       
   417                 {
       
   418                 iTrustedInstallation = ( driveNumber == EDriveZ || driveNumber == EDriveC );                
       
   419                 }
       
   420             }
       
   421         }    
       
   422             
       
   423     if( !BaflUtils::FileExists( iFsSession, aManifest ) )
       
   424         {
       
   425 #ifdef HSPS_LOG_ACTIVE    
       
   426         if ( iLogBus )
       
   427             {           
       
   428             iLogBus->LogText( _L( "ChspsInstallationHandler::DoInstallThemeL() - *** Manifest was not found!" ) );
       
   429             }
       
   430 #endif    
       
   431         User::Leave( KErrNotFound );
       
   432         }
       
   433        
       
   434 #ifdef HSPS_LOG_ACTIVE    
       
   435     if ( iLogBus )
       
   436         {            
       
   437         iLogBus->LogText( _L( "ChspsInstallationHandler::DoInstallThemeL() - *** Parsing a manifest file" ) );
       
   438         }
       
   439 #endif       
       
   440     
       
   441     // Parse XML from the manifest file
       
   442     Xml::ParseL( *iXmlParser, iFsSession, aManifest );    
       
   443                     
       
   444     // The manifest file has been read at this point and following callbacks have been executed:
       
   445     // OnContent(), OnStartElement() and OnEndElement()
       
   446     
       
   447     // Performance optimization: do not check if installing from rom.
       
   448     if( !iTrustedInstallation )
       
   449         {
       
   450         // Check type of installation        
       
   451         TBool instancesFound = IsPluginUsedInAppConfsL();            
       
   452         if( iThemeServer.PluginInHeaderCache( TUid::Uid( iThemeUid ) ) && instancesFound )                    
       
   453             {
       
   454             // Plugin should be found from cache, update notifications are
       
   455             // sent only when plugins are used by one/more app configurations
       
   456             iInstallationType = EInstallationTypeUpdate;
       
   457             }
       
   458         else
       
   459             {
       
   460             iInstallationType = EInstallationTypeNew;
       
   461             }
       
   462         }                
       
   463         
       
   464     // Check the parsed input        
       
   465     ValidateL();                    
   463     }
   466     }
   464 
   467 
   465 // -----------------------------------------------------------------------------
   468 // -----------------------------------------------------------------------------
   466 // ChspsInstallationHandler::GetInterfacePath() 
   469 // ChspsInstallationHandler::GetInterfacePath() 
   467 // -----------------------------------------------------------------------------
   470 // -----------------------------------------------------------------------------
   487 // -----------------------------------------------------------------------------
   490 // -----------------------------------------------------------------------------
   488 // ChspsInstallationHandler::ValidateL() 
   491 // ChspsInstallationHandler::ValidateL() 
   489 // -----------------------------------------------------------------------------
   492 // -----------------------------------------------------------------------------
   490 //
   493 //
   491 void ChspsInstallationHandler::ValidateL()
   494 void ChspsInstallationHandler::ValidateL()
   492     {                                    
   495     {               
       
   496     // Check resources
   493     TFileName interfacePath( GetInterfacePath() );       
   497     TFileName interfacePath( GetInterfacePath() );       
   494     if ( interfacePath.Length() )        
   498     if ( interfacePath.Length() )        
   495        {
   499        {
   496        // If name of the DTD file was specified in the manifest
   500        // If name of the DTD file was specified in the manifest
   497        if ( iDtdFile )
   501        if ( iDtdFile )
   511        {
   515        {
   512        // Find DTD files and locale specific resources from subdirectories under the installation path
   516        // Find DTD files and locale specific resources from subdirectories under the installation path
   513        AddLocalesL( iThemeFilePath );                       
   517        AddLocalesL( iThemeFilePath );                       
   514        }       
   518        }       
   515           
   519           
   516    // Validate input from the manifest
   520    // Validate other input from the manifest
   517    CheckHeaderL();
   521    CheckHeaderL();
   518            
   522            
   519    if ( iSecurityEnforcer.CheckThemeLockingL( *iOdt ) )
   523    if ( iSecurityEnforcer.CheckThemeLockingL( *iOdt ) )
   520        {
   524        {
   521        iResult->iXuikonError = KErrThemeStatusLocked;    
   525        iResult->iXuikonError = KErrThemeStatusLocked;    
   745             uid,
   749             uid,
   746             KConfigurationAttrMaxChild,
   750             KConfigurationAttrMaxChild,
   747             _L8( "0" ) );
   751             _L8( "0" ) );
   748         }
   752         }
   749 
   753 
   750     if ( iRomInstallation )
   754     if ( iTrustedInstallation )
   751         {
   755         {
   752         // Update configuration state to KConfStateConfirmed
   756         // Update configuration state to KConfStateConfirmed
   753         hspsServerUtil::SetAttributeValueL( 
   757         hspsServerUtil::SetAttributeValueL( 
   754             *iOdt,
   758             *iOdt,
   755             KConfigurationElement,
   759             KConfigurationElement,
  1737     if ( !iMultiInstanceFound )
  1741     if ( !iMultiInstanceFound )
  1738         {
  1742         {
  1739         iMultiInstance = KMultiInstanceDefaultValue;
  1743         iMultiInstance = KMultiInstanceDefaultValue;
  1740         }
  1744         }
  1741     }
  1745     }
  1742  
  1746   
  1743  // -----------------------------------------------------------------------------
       
  1744  // ChspsInstallationHandler::FindFile
       
  1745  // Eclipsing support for customization 
       
  1746  // -----------------------------------------------------------------------------
       
  1747  //
       
  1748  void ChspsInstallationHandler::FindFile(
       
  1749          const TDesC& aPath,
       
  1750          const TDesC& aFilename,         
       
  1751          TFileName& aDrivePathName )
       
  1752      {                   
       
  1753      TParsePtrC parser( aPath );
       
  1754      const TPath path = parser.Path();              
       
  1755                
       
  1756      // Find the input file, search from the user area (UDA) first, 
       
  1757      // exclude external/remote drives from the search - otherwise end-users  
       
  1758      // could introduce fixed configurations (e.g. operator locks wouldn't work)
       
  1759      TFindFile fileFinder( iFsSession );
       
  1760      fileFinder.SetFindMask( 
       
  1761          KDriveAttExclude|KDriveAttRemovable|KDriveAttRemote|KDriveAttSubsted );
       
  1762      iFsSession.SetSessionToPrivate( EDriveZ );
       
  1763      TInt err = fileFinder.FindByDir( aFilename, path );
       
  1764      iFsSession.SetSessionToPrivate( EDriveC );
       
  1765      if( !err )          
       
  1766          {         
       
  1767          // Return the path with a drive reference 
       
  1768          aDrivePathName = fileFinder.File();        
       
  1769          TParsePtrC drvParser( aDrivePathName );
       
  1770          if( !drvParser.DrivePresent() )
       
  1771              {             
       
  1772              err = KErrNotFound;
       
  1773              }
       
  1774          }
       
  1775      
       
  1776      if( err )
       
  1777          {
       
  1778          // Not found from C nor Z drives
       
  1779 #ifdef HSPS_LOG_ACTIVE  
       
  1780          if( iLogBus )
       
  1781              {
       
  1782              iLogBus->LogText( 
       
  1783                      _L( "ChspsInstallationHandler::FindFile(): - couldnt' find file '%S'" ),
       
  1784                      &aDrivePathName );
       
  1785              }
       
  1786     #endif
       
  1787          }
       
  1788      }
       
  1789  
       
  1790 // -----------------------------------------------------------------------------
  1747 // -----------------------------------------------------------------------------
  1791 // Parsing of the manifest elements.
  1748 // Parsing of the manifest elements.
  1792 // -----------------------------------------------------------------------------
  1749 // -----------------------------------------------------------------------------
  1793 //
  1750 //
  1794 void ChspsInstallationHandler::OnEndElementL( const RTagInfo& aElement, TInt /*aErrorCode*/ )
  1751 void ChspsInstallationHandler::OnEndElementL( const RTagInfo& aElement, TInt /*aErrorCode*/ )
  1985             {
  1942             {
  1986             // Convert from 8 to 16bit string
  1943             // Convert from 8 to 16bit string
  1987             HBufC* nameBuf = CnvUtfConverter::ConvertToUnicodeFromUtf8L( *iContent );                        
  1944             HBufC* nameBuf = CnvUtfConverter::ConvertToUnicodeFromUtf8L( *iContent );                        
  1988             // Find full path to the file 
  1945             // Find full path to the file 
  1989             TFileName fullName;
  1946             TFileName fullName;
  1990             FindFile( 
  1947             hspsServerUtil::FindFile(
  1991                 iThemeFilePath, 
  1948                     iFsSession,                    
  1992                 nameBuf->Des(),
  1949                     iThemeFilePath, 
  1993                 fullName );
  1950                     nameBuf->Des(),
       
  1951                     fullName );
  1994             delete nameBuf;
  1952             delete nameBuf;
  1995             nameBuf = NULL;
  1953             nameBuf = NULL;
  1996             if( !fullName.Length() )
  1954             if( !fullName.Length() )
  1997                 {
  1955                 {
  1998                 iFileNotFound = ETrue;
  1956                 iFileNotFound = ETrue;