homescreenpluginsrv/hspsmanager/src/hspsmaintenancehandler.cpp
branchRCL_3
changeset 130 67f2ed48ad91
parent 118 8baec10861af
equal deleted inserted replaced
122:6cadd6867c17 130:67f2ed48ad91
   317             CleanupStack::PushL(headerdata);
   317             CleanupStack::PushL(headerdata);
   318             messagePtr.WriteL(2,headerdata->Des(),0);
   318             messagePtr.WriteL(2,headerdata->Des(),0);
   319             CleanupStack::PopAndDestroy(headerdata);
   319             CleanupStack::PopAndDestroy(headerdata);
   320             
   320             
   321             ThspsRepositoryInfo info( EhspsODTActivated );
   321             ThspsRepositoryInfo info( EhspsODTActivated );
   322             info.iAppUid = odt->RootUid();
       
   323             iDefinitionRepository.RegisterNotification( info );
   322             iDefinitionRepository.RegisterNotification( info );
   324         }
   323         }
   325     }
   324     }
   326     iDefinitionRepository.Unlock();
   325     iDefinitionRepository.Unlock();
   327     CleanupStack::Pop(&iDefinitionRepository);
   326     CleanupStack::Pop(&iDefinitionRepository);
  1864                             
  1863                             
  1865                             // Get plugin nodes
  1864                             // Get plugin nodes
  1866                             TInt pluginCount = pluginsNode->ChildNodes().Length();
  1865                             TInt pluginCount = pluginsNode->ChildNodes().Length();
  1867                             for( TInt pluginIndex=0; pluginIndex < pluginCount; pluginIndex++ )                                    
  1866                             for( TInt pluginIndex=0; pluginIndex < pluginCount; pluginIndex++ )                                    
  1868                                 {
  1867                                 {
  1869                                 nodeArray.AppendL( (ChspsDomNode*)pluginsNode->ChildNodes().Item( pluginIndex ) );
  1868                                 nodeArray.Append( (ChspsDomNode*)pluginsNode->ChildNodes().Item( pluginIndex ) );
  1870                                 }                                
  1869                                 }                                
  1871                             
  1870                             
  1872                             // Remove the nodes and related resources
  1871                             // Remove the nodes and related resources
  1873                             for( TInt pluginIndex=0; pluginIndex < pluginCount; pluginIndex++ )
  1872                             for( TInt pluginIndex=0; pluginIndex < pluginCount; pluginIndex++ )
  1874                                 {
  1873                                 {
  3208     ThspsServiceCompletedMessage ret( EhspsRemoveThemeFailed );
  3207     ThspsServiceCompletedMessage ret( EhspsRemoveThemeFailed );
  3209 
  3208 
  3210     if( !( aSetMask.Flags() & EhspsThemeStatusLicenceeDefault ) )                      
  3209     if( !( aSetMask.Flags() & EhspsThemeStatusLicenceeDefault ) )                      
  3211         {       
  3210         {       
  3212         RArray<ThspsRepositoryInfo> notifParams;
  3211         RArray<ThspsRepositoryInfo> notifParams;
  3213         CleanupClosePushL( notifParams );
  3212         
  3214 
       
  3215         if( !iDefinitionRepository.Locked() )
  3213         if( !iDefinitionRepository.Locked() )
  3216             {
  3214             {
  3217             iDefinitionRepository.Lock();
  3215             iDefinitionRepository.Lock();
  3218                                                                        
  3216                                                                        
  3219             // In case of error. repository is unlocked    
  3217             // In case of error. repository is unlocked    
  3221                                                                                                        
  3219                                                                                                        
  3222             // Check what is being being uninstalled
  3220             // Check what is being being uninstalled
  3223             TInt error( KErrNone );
  3221             TInt error( KErrNone );
  3224             if ( aSetMask.ConfigurationType() != EhspsAppConfiguration )
  3222             if ( aSetMask.ConfigurationType() != EhspsAppConfiguration )
  3225                 {
  3223                 {
  3226                 TRAP( error, RemovePluginConfFromRepositoryL( aSetMask, notifParams ) );                    
  3224                 // Fix plugin instances and get notifications from valid cases
       
  3225                 TRAP( error, RemovePluginFromAppConfsL( aSetMask, notifParams ) );                    
  3227                 }                                
  3226                 }                                
  3228             else
  3227             
  3229                 {
  3228             if( !error )
  3230                 TRAP( error, RemoveAppConfFromRepositoryL( aSetMask, notifParams ) );                    
  3229                 {
       
  3230                 // Remove the actual plugin from file system
       
  3231                 TRAP( error, RemoveThemeL( aSetMask ) );                
  3231                 }
  3232                 }
  3232                                                
  3233                                                
  3233             if( !error )
  3234             if( !error )
  3234                 {
  3235                 {
  3235                 // Remove header from the cache
  3236                 // Remove header from the cache
  3254                 
  3255                 
  3255                 ret = EhspsRemoveThemeSuccess;                
  3256                 ret = EhspsRemoveThemeSuccess;                
  3256                 }                                                             
  3257                 }                                                             
  3257             }
  3258             }
  3258         
  3259         
  3259         CleanupStack::PopAndDestroy( &notifParams );
  3260         notifParams.Close();
  3260         }
  3261         }
  3261          
  3262          
  3262      return ret;
  3263      return ret;
  3263     }    
  3264     }    
  3264 
  3265 
  3269 void ChspsMaintenanceHandler::RemovePluginFromAppConfsL( 
  3270 void ChspsMaintenanceHandler::RemovePluginFromAppConfsL( 
  3270         const ChspsODT& aOdt,
  3271         const ChspsODT& aOdt,
  3271         RArray<ThspsRepositoryInfo>& aNotificationParams )        
  3272         RArray<ThspsRepositoryInfo>& aNotificationParams )        
  3272     {        
  3273     {        
  3273     __ASSERT_DEBUG( aOdt.ThemeUid(), User::Leave( KErrArgument ) );
  3274     __ASSERT_DEBUG( aOdt.ThemeUid(), User::Leave( KErrArgument ) );
  3274     
  3275            
  3275     // Loop application configurations
  3276     // Loop application configurations
  3276     const TInt count = iHeaderListCache.Count();                  
  3277     const TInt count = iHeaderListCache.Count();                  
  3277     for ( TInt i = 0; i < count; i++ )
  3278     for ( TInt i = 0; i < count; i++ )
  3278         {
  3279         {
  3279         ChspsODT* header = iHeaderListCache.At(i);
  3280         ChspsODT* header = iHeaderListCache.At(i);
  3357                             aOdt.ThemeUid(),
  3358                             aOdt.ThemeUid(),
  3358                             pluginIds[i], 
  3359                             pluginIds[i], 
  3359                             lastNotification,
  3360                             lastNotification,
  3360                             aOdt.ThemeFullName(),
  3361                             aOdt.ThemeFullName(),
  3361                             (TLanguage)( aOdt.OdtLanguage() ) );
  3362                             (TLanguage)( aOdt.OdtLanguage() ) );
  3362                        aNotificationParams.AppendL(info);
  3363                        aNotificationParams.Append(info);
  3363                        }
  3364                        }
  3364 #ifdef HSPS_LOG_ACTIVE  
  3365 #ifdef HSPS_LOG_ACTIVE  
  3365                     if( iLogBus )
  3366                     if( iLogBus )
  3366                         {
  3367                         {
  3367                         iLogBus->LogText( 
  3368                         iLogBus->LogText( 
  3387                         aOdt.ThemeUid(),
  3388                         aOdt.ThemeUid(),
  3388                         0, 
  3389                         0, 
  3389                         ETrue,
  3390                         ETrue,
  3390                         aOdt.ThemeFullName(),
  3391                         aOdt.ThemeFullName(),
  3391                         (TLanguage)( aOdt.OdtLanguage() ) );
  3392                         (TLanguage)( aOdt.OdtLanguage() ) );
  3392                     aNotificationParams.AppendL(info);
  3393                     aNotificationParams.Append(info);
  3393                     }
  3394                     }
  3394                 }
  3395                 }
  3395             
  3396             
       
  3397             pluginIds.Close();
  3396             CleanupStack::PopAndDestroy( 2, appOdt ); // appOdt, pluginIds                         
  3398             CleanupStack::PopAndDestroy( 2, appOdt ); // appOdt, pluginIds                         
  3397             appOdt = NULL;             
  3399             appOdt = NULL;             
  3398             
  3400             
  3399             } // app configuration
  3401             } // app configuration
  3400         
  3402         
  3401         } // header loop
  3403         } // header loop
  3402     }
  3404        
  3403     
       
  3404 // -----------------------------------------------------------------------------
       
  3405 // RemoveAppConfFromRepositoryL
       
  3406 // -----------------------------------------------------------------------------
       
  3407 //
       
  3408 void ChspsMaintenanceHandler::RemoveAppConfFromRepositoryL( 
       
  3409     const ChspsODT& aOdt,
       
  3410     RArray<ThspsRepositoryInfo>& /* aNotificationParams */ )        
       
  3411     {        
       
  3412     __ASSERT_DEBUG( aOdt.ThemeUid(), User::Leave( KErrArgument ) );
       
  3413     
       
  3414     ChspsODT* activeAppConf = ChspsODT::NewL();
       
  3415     CleanupStack::PushL( activeAppConf );
       
  3416     iThemeServer.GetActivateAppConfigurationL( aOdt.RootUid(), *activeAppConf );
       
  3417     if ( aOdt.ThemeUid() == activeAppConf->ThemeUid() )
       
  3418         {
       
  3419         // Active application configuration removed 
       
  3420         ActivateDefaultAppConfL( aOdt, *activeAppConf );
       
  3421         }
       
  3422 
       
  3423     CleanupStack::PopAndDestroy( activeAppConf );
       
  3424     
       
  3425     // Remove the actual application configuration from file system
       
  3426     RemoveThemeL( aOdt );
       
  3427     
       
  3428     }
       
  3429 
       
  3430 // -----------------------------------------------------------------------------
       
  3431 // RemovePluginConfFromRepositoryL
       
  3432 // -----------------------------------------------------------------------------
       
  3433 //
       
  3434 void ChspsMaintenanceHandler::RemovePluginConfFromRepositoryL( 
       
  3435     const ChspsODT& aOdt,
       
  3436     RArray<ThspsRepositoryInfo>& aNotificationParams )        
       
  3437     {        
       
  3438     __ASSERT_DEBUG( aOdt.ThemeUid(), User::Leave( KErrArgument ) );
       
  3439 
       
  3440     // Fix plugin instances and get notifications from valid cases
       
  3441     RemovePluginFromAppConfsL( aOdt, aNotificationParams );                    
       
  3442     
       
  3443     // Remove the actual plugin configuration from file system
       
  3444     RemoveThemeL( aOdt );                
       
  3445     }
  3405     }
  3446 
  3406 
  3447 // -----------------------------------------------------------------------------
  3407 // -----------------------------------------------------------------------------
  3448 // ChspsMaintenanceHandler::InvalidateUninstalledPluginInstancesL
  3408 // ChspsMaintenanceHandler::InvalidateUninstalledPluginInstancesL
  3449 // -----------------------------------------------------------------------------
  3409 // -----------------------------------------------------------------------------
  3553         odt->SetFlags( aOdt.Flags() ); 
  3513         odt->SetFlags( aOdt.Flags() ); 
  3554         odt->SetMultiInstance( aOdt.MultiInstance() );
  3514         odt->SetMultiInstance( aOdt.MultiInstance() );
  3555         User::LeaveIfError( iDefinitionRepository.GetOdtL( *odt ) );
  3515         User::LeaveIfError( iDefinitionRepository.GetOdtL( *odt ) );
  3556         
  3516         
  3557         RArray<ThspsRepositoryInfo> notifParams;
  3517         RArray<ThspsRepositoryInfo> notifParams;
  3558         CleanupClosePushL( notifParams );
  3518         
  3559 
       
  3560         TRAP( errorCode, UpdatePluginFromAppConfsL( *odt, notifParams ));
  3519         TRAP( errorCode, UpdatePluginFromAppConfsL( *odt, notifParams ));
  3561         
  3520         
  3562         if( errorCode )
  3521         if( errorCode )
  3563             {
  3522             {
  3564             ret = EhspsUpdatePluginFailed;           
  3523             ret = EhspsUpdatePluginFailed;           
  3579                     iDefinitionRepository.RegisterNotification( notifParams[i] );
  3538                     iDefinitionRepository.RegisterNotification( notifParams[i] );
  3580                     }
  3539                     }
  3581                 }
  3540                 }
  3582             
  3541             
  3583             } 
  3542             } 
  3584         
  3543         notifParams.Close();
  3585         CleanupStack::PopAndDestroy( &notifParams );
  3544         
  3586         CleanupStack::PopAndDestroy( odt );
  3545         CleanupStack::PopAndDestroy( odt );
  3587         }
  3546         }
  3588          
  3547          
  3589     return ret;
  3548     return ret;
  3590     }
  3549     }
  3656                                     aOdt.ThemeUid(),
  3615                                     aOdt.ThemeUid(),
  3657                                     pluginIds[i], 
  3616                                     pluginIds[i], 
  3658                                     status,
  3617                                     status,
  3659                                     aOdt.ThemeFullName(),
  3618                                     aOdt.ThemeFullName(),
  3660                                     (TLanguage)( aOdt.OdtLanguage() ) );
  3619                                     (TLanguage)( aOdt.OdtLanguage() ) );
  3661                         aNotificationParams.AppendL(info);
  3620                         aNotificationParams.Append(info);
  3662                         }
  3621                         }
  3663                     }
  3622                     }
  3664 
  3623 
  3665                 CleanupStack::PopAndDestroy(); // pluginIds.                
  3624                 CleanupStack::PopAndDestroy(); // pluginIds.                
  3666                 CleanupStack::PopAndDestroy( odt );                                   
  3625                 CleanupStack::PopAndDestroy( odt );                                   
  3667                 }
  3626                 }
  3668             }
  3627             }
       
  3628         
  3669         }
  3629         }
  3670     }
  3630     }
  3671 // -----------------------------------------------------------------------------
  3631 // -----------------------------------------------------------------------------
  3672 // ChspsMaintenanceHandler::UpdatePluginConfigurationL
  3632 // ChspsMaintenanceHandler::UpdatePluginConfigurationL
  3673 // Not supported
  3633 // Not supported
  4545     ChspsODT& aOdt)
  4505     ChspsODT& aOdt)
  4546     {    
  4506     {    
  4547     // If active application configuration is not "LicenceeRestorable" 
  4507     // If active application configuration is not "LicenceeRestorable" 
  4548     if ( !(aHeader->Flags() & EhspsThemeStatusLicenceeRestorable) )
  4508     if ( !(aHeader->Flags() & EhspsThemeStatusLicenceeRestorable) )
  4549         {        
  4509         {        
  4550         // Try to activate default configuation
  4510         // Try to activate a configuation with the LicenceeRestorable status
  4551         ActivateDefaultAppConfL( *aHeader, aOdt );
  4511         ChspsODT* searchMask = ChspsODT::NewL();
       
  4512         CleanupStack::PushL( searchMask );
       
  4513         searchMask->SetRootUid( aHeader->RootUid() );
       
  4514         searchMask->SetFamily( aHeader->Family() );
       
  4515         searchMask->SetFlags( EhspsThemeStatusLicenceeRestorable );
       
  4516         TInt pos( 0 );
       
  4517         iThemeServer.GetConfigurationHeader( *searchMask, aHeader, pos );
       
  4518         if ( aHeader )
       
  4519             {
       
  4520             // Activate licensee restorable configuration
       
  4521             iThemeServer.ActivateThemeL( *aHeader, aOdt );
       
  4522             ThspsRepositoryInfo info( EhspsODTActivated );
       
  4523             iDefinitionRepository.RegisterNotification( info );
       
  4524             }
       
  4525         else
       
  4526             {
       
  4527             // Licensee restorable configuration not found. There must be  
       
  4528             // at least one licensee restorable configuration per application
       
  4529             User::Leave( KErrNotFound );
       
  4530             }
       
  4531         CleanupStack::PopAndDestroy( searchMask );
  4552         }
  4532         }
  4553     else
  4533     else
  4554         {        
  4534         {        
  4555         // Reinstall the application configuration from ROM
  4535         // Reinstall the application configuration from ROM
  4556         iThemeServer.ReinstallConfL( aHeader->RootUid(), aHeader->ThemeUid() );
  4536         iThemeServer.ReinstallConfL( aHeader->RootUid(), aHeader->ThemeUid() );
  4557         }
  4537         }
  4558     }
       
  4559 
       
  4560 // -----------------------------------------------------------------------------
       
  4561 // ChspsMaintenanceHandler::ActivateDefaultAppConfL
       
  4562 // (other items were commented in a header).
       
  4563 // -----------------------------------------------------------------------------
       
  4564 //
       
  4565 void ChspsMaintenanceHandler::ActivateDefaultAppConfL(
       
  4566     const ChspsODT& aHeader,
       
  4567     ChspsODT& aOdt )
       
  4568     {    
       
  4569     ChspsODT* searchMask = ChspsODT::NewL();
       
  4570     CleanupStack::PushL( searchMask );
       
  4571     searchMask->SetRootUid( aHeader.RootUid() );
       
  4572     searchMask->SetFamily( aHeader.Family() );
       
  4573     searchMask->SetFlags( EhspsThemeStatusLicenceeRestorable );
       
  4574     
       
  4575     ChspsODT* defaultAppConf( NULL );
       
  4576     TInt pos( 0 );
       
  4577     iThemeServer.GetConfigurationHeader( *searchMask, defaultAppConf, pos );
       
  4578     if ( defaultAppConf )
       
  4579         {
       
  4580         // Activate licensee restorable configuration
       
  4581         iThemeServer.ActivateThemeL( *defaultAppConf, aOdt );
       
  4582         }
       
  4583     else
       
  4584         {
       
  4585         // Licensee restorable configuration not found. There must be  
       
  4586         // at least one licensee restorable configuration per application
       
  4587         User::Leave( KErrNotFound );
       
  4588         }
       
  4589     
       
  4590     CleanupStack::PopAndDestroy( searchMask );
       
  4591     }
  4538     }
  4592 
  4539 
  4593 // -----------------------------------------------------------------------------
  4540 // -----------------------------------------------------------------------------
  4594 // ChspsMaintenanceHandler::AddErrorConfigurationL()
  4541 // ChspsMaintenanceHandler::AddErrorConfigurationL()
  4595 // -----------------------------------------------------------------------------
  4542 // -----------------------------------------------------------------------------
  4892     
  4839     
  4893     ChspsDomList& attrList = aConfNode.AttributeList();
  4840     ChspsDomList& attrList = aConfNode.AttributeList();
  4894     ChspsDomAttribute* attr = 
  4841     ChspsDomAttribute* attr = 
  4895         static_cast<ChspsDomAttribute*>( attrList.FindByName( KConfigurationAttrLocking ) );                
  4842         static_cast<ChspsDomAttribute*>( attrList.FindByName( KConfigurationAttrLocking ) );                
  4896     if( attr )
  4843     if( attr )
  4897         {      
  4844         {        
  4898         if( attr->Value().CompareF( KConfLockingLocked ) == 0 ||
  4845         isLocked = ( attr->Value().CompareF( KConfLockingLocked ) == 0 );
  4899             attr->Value().CompareF( KConfLockingPermanent ) == 0 )
       
  4900             {
       
  4901             isLocked = ETrue;
       
  4902             }
       
  4903        }
  4846        }
  4904     
  4847     
  4905     return isLocked;
  4848     return isLocked;
  4906     }
  4849     }
  4907 
  4850 
  4961                     // If the plugin configuration hasn't been locked or 
  4904                     // If the plugin configuration hasn't been locked or 
  4962                     // if there are several locked plugin nodes then remove all the rest
  4905                     // if there are several locked plugin nodes then remove all the rest
  4963                     if( !isLocked || foundLocked )
  4906                     if( !isLocked || foundLocked )
  4964                         {
  4907                         {
  4965                         // Mark for removal
  4908                         // Mark for removal
  4966                         nodeArray.AppendL( pluginNode );
  4909                         nodeArray.Append( pluginNode );
  4967                         }
  4910                         }
  4968                     else
  4911                     else
  4969                         {
  4912                         {
  4970                         // If this is the 1st locked node
  4913                         // If this is the 1st locked node
  4971                         if( !foundLocked )
  4914                         if( !foundLocked )