homescreenpluginsrv/hspsmanager/src/hspsmaintenancehandler.cpp
branchRCL_3
changeset 51 15e4dd19031c
parent 19 502e5d91ad42
child 59 a0713522ab97
equal deleted inserted replaced
19:502e5d91ad42 51:15e4dd19031c
    89 //
    89 //
    90 ChspsMaintenanceHandler::ChspsMaintenanceHandler( 
    90 ChspsMaintenanceHandler::ChspsMaintenanceHandler( 
    91         ChspsThemeServer& aThemeServer, 
    91         ChspsThemeServer& aThemeServer, 
    92         const TUint aSecureId ): 
    92         const TUint aSecureId ): 
    93     CTimer(EPriorityLow), 
    93     CTimer(EPriorityLow), 
    94     iLanguage ( aThemeServer.DeviceLanguage() ),
       
    95     iThemeServer( aThemeServer ), 
    94     iThemeServer( aThemeServer ), 
    96     iSecureId( aSecureId ),
    95     iSecureId( aSecureId ),
    97     iCentralRepository( aThemeServer.CentralRepository() ),    
    96     iCentralRepository( aThemeServer.CentralRepository() ),    
    98     iDefinitionRepository( aThemeServer.DefinitionRepository() ),
    97     iDefinitionRepository( aThemeServer.DefinitionRepository() ),
    99     iSecurityEnforcer( aThemeServer.SecurityEnforcer() ),
    98     iSecurityEnforcer( aThemeServer.SecurityEnforcer() ),
   100     iHeaderListCache( aThemeServer.HeaderListCache() ),
    99     iHeaderListCache( aThemeServer.HeaderListCache() ),
   101     iFileMan( NULL )
   100     iServerSession( NULL ),         
       
   101     iFileMan( NULL ),
       
   102     iMaintainLogoResources( EFalse )
   102     { 
   103     { 
   103     iDeliveryCount = 0;
   104     iDeliveryCount = 0;
   104     iSubscription = EFalse;
   105     iSubscription = EFalse;
   105     }
   106     }
   106     
   107     
   192             delete iSearchMask;
   193             delete iSearchMask;
   193             iSearchMask = NULL;
   194             iSearchMask = NULL;
   194             }
   195             }
   195         iSearchMask = ChspsODT::NewL();
   196         iSearchMask = ChspsODT::NewL();
   196         iSearchMask->UnMarshalHeaderL(searchMaskData);
   197         iSearchMask->UnMarshalHeaderL(searchMaskData);
   197         
   198                 
   198         // check the device language
   199         iMaintainLogoResources = EFalse;
   199         iLanguage  = iThemeServer.DeviceLanguage();        
   200         TPckg<TInt> intPkg( iMaintainLogoResources );                                    
   200  	    iSearchMask->SetOdtLanguage( (TInt)iLanguage );
   201         messagePtr.ReadL(3, intPkg );
   201                  
   202                                                            
   202         // now there is a subscription
   203         // now there is a subscription
   203         iSubscription = ETrue;
   204         iSubscription = ETrue;
   204         // fetch the header list from repository
   205         // fetch the header list from repository
   205         ret = hspsGetListHeaders(searchMaskData, *iHeaderDataList);
   206         ret = hspsGetListHeaders(searchMaskData, *iHeaderDataList);
   206         if (ret == EhspsGetListHeadersSuccess)
   207         if (ret == EhspsGetListHeadersSuccess)
   240     if ( !IsActive() && iSubscription)  // requesting next as should
   241     if ( !IsActive() && iSubscription)  // requesting next as should
   241         {
   242         {
   242         // is there headers to delivere left
   243         // is there headers to delivere left
   243         if (iHeaderDataList->Count() > iDeliveryCount)
   244         if (iHeaderDataList->Count() > iDeliveryCount)
   244             {                                    
   245             {                                    
   245             // Handle copying of logo icon resources
       
   246             CopyIconsToHomescreenL( aMessage.SecureId().iId );
       
   247             
       
   248             // at least one header on the list
   246             // at least one header on the list
   249             TPtr8 bufPtr( iHeaderDataList->At(iDeliveryCount)->Des() );
   247             TPtr8 bufPtr( iHeaderDataList->At(iDeliveryCount)->Des() );
   250             iMessagePtr.WriteL(2, bufPtr, 0);
   248             iMessagePtr.WriteL(2, bufPtr, 0);
   251             // add list count
   249             // add list count
   252             iDeliveryCount++;
   250             iDeliveryCount++;
   260         iResult->iXuikonError = KErrPermissionDenied;
   258         iResult->iXuikonError = KErrPermissionDenied;
   261         CompleteRequest( EhspsServiceRequestError, iMessagePtr );
   259         CompleteRequest( EhspsServiceRequestError, iMessagePtr );
   262         }
   260         }
   263     }
   261     }
   264     
   262     
   265 // -----------------------------------------------------------------------------
       
   266 // ChspsMaintenanceHandler::CopyIconsToHomescreenL
       
   267 // -----------------------------------------------------------------------------
       
   268 //
       
   269 void ChspsMaintenanceHandler::CopyIconsToHomescreenL(
       
   270         const TUint aAppUid ) 
       
   271     {        
       
   272     HBufC8* headerData = iHeaderDataList->At(iDeliveryCount);
       
   273     ChspsODT* header = ChspsODT::UnMarshalHeaderLC( headerData->Des() );
       
   274     if ( iServerSession && header )
       
   275         {    
       
   276         if( header->LogoFile().Length() )
       
   277             {                              
       
   278             // If a file reference was found from the logo declaration
       
   279             TFileName filename;
       
   280             if ( hspsServerUtil::IsFile( header->LogoFile(), filename ) )
       
   281                 {
       
   282                 if ( !iFileMan )
       
   283                     {                
       
   284                     iFileMan = CFileMan::NewL( iServerSession->FileSystem() );
       
   285                     }
       
   286     
       
   287                 // Get client's private directory: 
       
   288                 // We should use some common directory if there are more than one SAPI clients,
       
   289                 // for now we can copy files to AI3's private folder
       
   290                 _LIT( KPrivatePath, "c:\\private\\%X\\");
       
   291                 TPath privatePath;            
       
   292                 privatePath.Format( KPrivatePath, aAppUid );                
       
   293                                                                                         
       
   294                 // Append private path to the logo file reference
       
   295                 TInt offset = header->LogoFile().FindF( filename );
       
   296                 if ( offset >= 0 )
       
   297                     {                                      
       
   298                     // Insert private path prior to the file reference                    
       
   299                     HBufC* logoBuf = HBufC::NewLC( 
       
   300                             privatePath.Length() + header->LogoFile().Length() );
       
   301                     logoBuf->Des().Copy( header->LogoFile() );
       
   302                     logoBuf->Des().Insert( offset, privatePath );
       
   303                     header->SetLogoFileL( logoBuf->Des() );
       
   304                     CleanupStack::PopAndDestroy( logoBuf );
       
   305                                         
       
   306                     // Replace the serialized header descriptor                    
       
   307                     HBufC8* newHeaderData = header->MarshalHeaderL();                    
       
   308                     CleanupStack::PushL( newHeaderData );
       
   309                     iHeaderDataList->InsertL( 
       
   310                            iDeliveryCount,
       
   311                            newHeaderData );                       
       
   312                     CleanupStack::Pop( newHeaderData );                    
       
   313                     delete headerData;
       
   314                     headerData = 0;
       
   315                     iHeaderDataList->Delete( iDeliveryCount + 1 );
       
   316                     }                               
       
   317 
       
   318                 // Set target directory for file copying
       
   319                 TPath targetPath;            
       
   320                 targetPath.Copy( privatePath );
       
   321                 targetPath.Append( filename );
       
   322                 
       
   323                 // Set source directory for file copying
       
   324                 TFileName sourceFile;     
       
   325                 _LIT( KThemesFolder, "themes\\" );
       
   326                 iServerSession->FileSystem().SessionPath( sourceFile );
       
   327                 sourceFile.Append( KThemesFolder );                
       
   328                 sourceFile.Append( filename );
       
   329                 
       
   330                 // Create the target path and copy files when required
       
   331                 hspsServerUtil::CopyResourceFileL(
       
   332                         iServerSession->FileSystem(),
       
   333                         *iFileMan, 
       
   334                         targetPath,
       
   335                         sourceFile );
       
   336                 }
       
   337             }
       
   338         }
       
   339     CleanupStack::PopAndDestroy( header );
       
   340     }
       
   341 
   263 
   342 // -----------------------------------------------------------------------------
   264 // -----------------------------------------------------------------------------
   343 // ChspsMaintenanceHandler::SetServerSession
   265 // ChspsMaintenanceHandler::SetServerSession
   344 // -----------------------------------------------------------------------------
   266 // -----------------------------------------------------------------------------
   345 //
   267 //
  1857 TBool ChspsMaintenanceHandler::IsViewConfiguration(
  1779 TBool ChspsMaintenanceHandler::IsViewConfiguration(
  1858         ChspsDomNode& aPluginNode )
  1780         ChspsDomNode& aPluginNode )
  1859     {
  1781     {
  1860     TBool isView = EFalse;
  1782     TBool isView = EFalse;
  1861     
  1783     
  1862     ChspsDomNode* confNode = 
  1784     ChspsDomNode* confNode = static_cast<ChspsDomNode*>(
  1863             (ChspsDomNode*)aPluginNode.ChildNodes().FindByName( KConfigurationElement );
  1785             aPluginNode.ChildNodes().FindByName( KConfigurationElement ));
       
  1786     
  1864     if( confNode )
  1787     if( confNode )
  1865         {
  1788         {
  1866         ChspsDomAttribute* typeAttr = 
  1789         ChspsDomAttribute* typeAttr = static_cast<ChspsDomAttribute*>(
  1867                 (ChspsDomAttribute*)confNode->AttributeList().FindByName( KConfigurationAttrType );
  1790                 confNode->AttributeList().FindByName( KConfigurationAttrType ));
  1868         isView = ( typeAttr->Value().CompareF( KConfTypeView ) == 0 );            
  1791         
  1869         }
  1792         if( typeAttr )
       
  1793             {
       
  1794             isView = ( typeAttr->Value().CompareF( KConfTypeView ) == 0 ); 
       
  1795             }     
       
  1796         }
       
  1797     
  1870     return isView;
  1798     return isView;
  1871     }
  1799     }
  1872 
  1800 
  1873 // -----------------------------------------------------------------------------
  1801 // -----------------------------------------------------------------------------
  1874 // ChspsMaintenanceHandler::RemoveConfigurationL()
  1802 // ChspsMaintenanceHandler::RemoveConfigurationL()
  3839 // ChspsMaintenanceHandler::hspsGetListHeaders()
  3767 // ChspsMaintenanceHandler::hspsGetListHeaders()
  3840 // Not supported
  3768 // Not supported
  3841 // (other items were commented in a header).
  3769 // (other items were commented in a header).
  3842 // -----------------------------------------------------------------------------
  3770 // -----------------------------------------------------------------------------
  3843 //
  3771 //
  3844 ThspsServiceCompletedMessage ChspsMaintenanceHandler::hspsGetListHeaders(const ChspsODT& /*aSearchMask*/,
  3772 ThspsServiceCompletedMessage ChspsMaintenanceHandler::hspsGetListHeaders(
  3845                                                      CArrayPtrFlat<ChspsODT>& /*aHeaderList*/)        
  3773         const ChspsODT& /*aSearchMask*/,
       
  3774         const TBool /*aCopyLogos*/,
       
  3775         CArrayPtrFlat<ChspsODT>& /*aHeaderList*/)        
  3846     {
  3776     {
  3847     return EhspsServiceNotSupported;
  3777     return EhspsServiceNotSupported;
  3848     }
  3778     }
  3849 
  3779 
  3850 // -----------------------------------------------------------------------------
  3780 // -----------------------------------------------------------------------------
  4050     else if ( ( aRepositoryInfo.iEventType & EhspsCacheUpdate ) && iDefinitionRepository.Locked() 
  3980     else if ( ( aRepositoryInfo.iEventType & EhspsCacheUpdate ) && iDefinitionRepository.Locked() 
  4051         && !IsActive() && iSubscription )
  3981         && !IsActive() && iSubscription )
  4052         {
  3982         {
  4053         After(KHeaderListUpdatePollingTimeSpan);    
  3983         After(KHeaderListUpdatePollingTimeSpan);    
  4054         }      
  3984         }      
       
  3985     
       
  3986     else if( aRepositoryInfo.iEventType & EhspsODTAdded
       
  3987             || aRepositoryInfo.iEventType & EhspsODTUpdated )
       
  3988         {
       
  3989         // If a widget has been installed or updated
       
  3990         if( iServerSession )
       
  3991             {
       
  3992             // Make sure all logos are copied when user retrieves the list
       
  3993             iServerSession->SetIconFileCopyRequired( ETrue );
       
  3994             }
       
  3995         }
       
  3996  
  4055     return EFalse;
  3997     return EFalse;
  4056     }
  3998     }
  4057 
  3999 
  4058 // -----------------------------------------------------------------------------
  4000 // -----------------------------------------------------------------------------
  4059 // ChspsMaintenanceHandler::DoCancel()
  4001 // ChspsMaintenanceHandler::DoCancel()
  4313 // -----------------------------------------------------------------------------
  4255 // -----------------------------------------------------------------------------
  4314 //
  4256 //
  4315 void ChspsMaintenanceHandler::GetHeaderListL( 
  4257 void ChspsMaintenanceHandler::GetHeaderListL( 
  4316         CArrayPtrSeg<HBufC8>& aHeaderDataList, 
  4258         CArrayPtrSeg<HBufC8>& aHeaderDataList, 
  4317         const ChspsODT& aSearchMask )
  4259         const ChspsODT& aSearchMask )
  4318     {    
  4260     {            
  4319     HBufC8* headerBuf = aSearchMask.MarshalHeaderL();
       
  4320     if ( !headerBuf )
       
  4321         {
       
  4322         User::Leave(KErrGeneral);
       
  4323         }
       
  4324     CleanupStack::PushL( headerBuf );    
       
  4325     ChspsODT* searchOdt = ChspsODT::UnMarshalHeaderLC( *headerBuf );
       
  4326     
       
  4327     // Reset search results
  4261     // Reset search results
  4328     aHeaderDataList.ResetAndDestroy();
  4262     aHeaderDataList.ResetAndDestroy();
       
  4263                     
       
  4264     if( !iFileMan )
       
  4265        {                
       
  4266        iFileMan = CFileMan::NewL( iServerSession->FileSystem() );
       
  4267        }    
  4329         
  4268         
  4330     for ( TInt i = 0; i < iHeaderListCache.Count(); i++ )
  4269     for ( TInt i = 0; i < iHeaderListCache.Count(); i++ )
  4331         {
  4270         {
  4332         ChspsODT* header = iHeaderListCache.At( i );
  4271         ChspsODT* header = iHeaderListCache.At( i );
  4333         
  4272         
  4334         // Check whether the header matches the search criteria
  4273         // Check whether the header matches the search criteria (family etc)
  4335         if ( FilterHeader( *searchOdt, *header ) )
  4274         if ( FilterHeader( aSearchMask, *header ) )
  4336             {
  4275             {
  4337             // Append to the search results
  4276         
  4338             HBufC8* data = header->MarshalHeaderL();
  4277             // Update file paths into the existing logo declarations
       
  4278             if( header->LogoFile().Length() &&
       
  4279                 iMaintainLogoResources &&
       
  4280                 ( header->ConfigurationType() == EhspsWidgetConfiguration ||
       
  4281                   header->ConfigurationType() == EhspsTemplateConfiguration ) )
       
  4282                 {    
       
  4283             
       
  4284                 RBuf targetFile;
       
  4285                 CleanupClosePushL( targetFile );       
       
  4286                 targetFile.CreateL( KMaxFileName );
       
  4287                 
       
  4288                 RBuf sourceFile;
       
  4289                 CleanupClosePushL( sourceFile );
       
  4290                 sourceFile.CreateL( KMaxFileName );
       
  4291                 
       
  4292                 RBuf newDeclaration;
       
  4293                 CleanupClosePushL( newDeclaration );
       
  4294                 newDeclaration.CreateL( header->LogoFile().Length() + KMaxFileName );
       
  4295                 
       
  4296                 // Find location of the logo file and location where it shold be copied                
       
  4297                 hspsServerUtil::PopulateLogoPathsL(
       
  4298                     header->LogoFile(),
       
  4299                     iSecureId,
       
  4300                     targetFile,
       
  4301                     sourceFile,
       
  4302                     newDeclaration );
       
  4303                 
       
  4304                 if( targetFile.Length()
       
  4305                         && sourceFile.Length() 
       
  4306                         && newDeclaration.Length() )
       
  4307                     {
       
  4308                     // Update private path information to the logo declaration                
       
  4309                     header->SetLogoFileL( newDeclaration );
       
  4310                                         
       
  4311                     hspsServerUtil::CopyResourceFileL(
       
  4312                         iServerSession->FileSystem(),
       
  4313                         *iFileMan,                         
       
  4314                         targetFile,
       
  4315                         sourceFile );
       
  4316                     }
       
  4317                 
       
  4318                 CleanupStack::PopAndDestroy( 3, &targetFile ); // targetFile, sourceFile, newDeclaration                
       
  4319                 }      
       
  4320         
       
  4321             // Convert the header to a descriptor
       
  4322             HBufC8* data = header->MarshalHeaderL();            
  4339             if ( data )
  4323             if ( data )
  4340                 {
  4324                 {
       
  4325                 // Append to the search results
  4341                 CleanupStack::PushL( data );
  4326                 CleanupStack::PushL( data );
  4342                 aHeaderDataList.AppendL( data );
  4327                 aHeaderDataList.AppendL( data );
  4343                 CleanupStack::Pop( data );
  4328                 CleanupStack::Pop( data );
  4344                 }
  4329                 }
  4345             }
  4330             }
  4346         }                              
  4331         }          
  4347         
       
  4348     CleanupStack::PopAndDestroy( 2, headerBuf ); // searchOdt, headerBuf    
       
  4349     }
  4332     }
  4350 
  4333 
  4351 // -----------------------------------------------------------------------------
  4334 // -----------------------------------------------------------------------------
  4352 // ChspsMaintenanceHandler::RestoredDefaultL
  4335 // ChspsMaintenanceHandler::RestoredDefaultL
  4353 // Goes through the themes for the application in order to find the Licensee 
  4336 // Goes through the themes for the application in order to find the Licensee 
  4553                 ||
  4536                 ||
  4554                 (!aMask.ThemeVersion().Length() && aHeader.ThemeVersion().Length())
  4537                 (!aMask.ThemeVersion().Length() && aHeader.ThemeVersion().Length())
  4555             )
  4538             )
  4556         &&
  4539         &&
  4557             (
  4540             (
  4558             ( aMask.ConfigurationType() && aMask.ConfigurationType() == aHeader.ConfigurationType() )
  4541             ( aMask.ConfigurationType() && ( aHeader.ConfigurationType() == aMask.ConfigurationType() ) )
  4559             ||
  4542             ||
  4560             ( !aMask.ConfigurationType() )
  4543             ( !aMask.ConfigurationType() )
  4561             )            
  4544             )            
  4562         && 
  4545         && 
  4563             // Show widgets designed for the active resolution or scalable
  4546             // Show widgets designed for the active resolution or scalable
  4721         iDefinitionRepository.Lock();                                
  4704         iDefinitionRepository.Lock();                                
  4722         CleanupStack::PushL( TCleanupItem( UnlockRepository, &iDefinitionRepository ) );
  4705         CleanupStack::PushL( TCleanupItem( UnlockRepository, &iDefinitionRepository ) );
  4723         
  4706         
  4724         // Get active root configuration for the client application
  4707         // Get active root configuration for the client application
  4725         ChspsODT* appODT = ChspsODT::NewL();
  4708         ChspsODT* appODT = ChspsODT::NewL();
  4726         CleanupStack::PushL( appODT );
  4709         CleanupStack::PushL( appODT );    
  4727         iThemeServer.GetActivateAppConfigurationL( 
       
  4728                 params.appUid,
       
  4729                 *appODT );     
       
  4730 
  4710 
  4731 #ifdef HSPS_LOG_ACTIVE                
  4711 #ifdef HSPS_LOG_ACTIVE                
  4732         if( iLogBus )
  4712         if( iLogBus )
  4733             {
  4713             {
  4734             iLogBus->LogText( 
  4714             iLogBus->LogText( 
  4739 #endif
  4719 #endif
  4740         
  4720         
  4741         TInt err = KErrNone;
  4721         TInt err = KErrNone;
  4742         if ( !params.restoreAll )
  4722         if ( !params.restoreAll )
  4743             {
  4723             {
  4744             // Remove all widgets from the active view
  4724             // reinstall all widgets
  4745             err = RestoreActiveViewL( *appODT );
  4725             TRAP( err, iThemeServer.InstallWidgetsL();
  4746             }        
  4726                        iThemeServer.InstallUDAWidgetsL() );
       
  4727             
       
  4728             // Force updating of the header cache
       
  4729             iThemeServer.UpdateHeaderListCacheL();          
       
  4730             }  
       
  4731         
       
  4732         iThemeServer.GetActivateAppConfigurationL( 
       
  4733                 params.appUid,
       
  4734                 *appODT );
  4747         
  4735         
  4748         // As a backup, if restoration of the active view fails,  
  4736         // As a backup, if restoration of the active view fails,  
  4749         // or if all views but the locked view should be removed
  4737         // or if all views but the locked view should be removedc
  4750         if ( err || params.restoreAll )
  4738         if ( err || params.restoreAll )
  4751             {                        
  4739             {                        
  4752             // Remove all views but the locked one and reset active view            
  4740             // Remove all views but the locked one and reset active view            
  4753             RemoveUnlockedViewsL( *appODT );
  4741             RemoveUnlockedViewsL( *appODT );
  4754             
  4742