installationservices/swi/source/swis/server/uninstallationprocessor.cpp
changeset 75 2d2d25361590
parent 44 329d304c1aa1
equal deleted inserted replaced
69:b18a4bf55ddb 75:2d2d25361590
   200     return ETrue;   // Nothing to do
   200     return ETrue;   // Nothing to do
   201     }
   201     }
   202 #endif
   202 #endif
   203 
   203 
   204 TBool CUninstallationProcessor::DoStateUpdateRegistryL()
   204 TBool CUninstallationProcessor::DoStateUpdateRegistryL()
   205 	{
   205     {
   206 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK	 
   206 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK   
   207     const CApplication& application = ApplicationL();
   207     const CApplication& application = ApplicationL();
   208     RArray<TAppUpdateInfo> affectedApps;    
   208     RArray<TAppUpdateInfo> affectedApps;    
   209     CleanupClosePushL(affectedApps);	    
   209     CleanupClosePushL(affectedApps);        
   210     RArray<Usif::TComponentId> componentIds;
   210     RArray<Usif::TComponentId> componentIds;
   211     CleanupClosePushL(componentIds);
   211     CleanupClosePushL(componentIds);
   212     RArray<TUid> existingAppUids;
   212     RArray<TUid> existingAppUids;
   213     CleanupClosePushL(existingAppUids);
   213     CleanupClosePushL(existingAppUids);
   214     RArray<TUid> newAppUids;    
   214     RArray<TUid> newAppUids;    
   215     CleanupClosePushL(newAppUids);
   215     CleanupClosePushL(newAppUids);
   216     
   216     
   217     TAppUpdateInfo existingAppInfo, newAppInfo;     
   217     TAppUpdateInfo existingAppInfo, newAppInfo;     
   218     TUid packageUid = application.PackageL().Uid();
   218     TUid packageUid = application.PackageL().Uid();   
       
   219     Plan().GetAffectedApps(affectedApps);
   219     
   220     
   220     // Get all existing componentsIds for the package to to be uninstalled
   221     // Get all existing componentsIds for the package to to be uninstalled
   221     TRAPD(err,iRegistryWrapper.RegistrySession().GetComponentIdsForUidL(packageUid, componentIds));            
   222     TRAPD(err,iRegistryWrapper.RegistrySession().GetComponentIdsForUidL(packageUid, componentIds));            
   222     TInt count = componentIds.Count();
   223     TInt componentCount = componentIds.Count();
   223     if(0 == count)
   224     if(0 == componentCount)
   224         {
   225         {
   225         DEBUG_PRINTF(_L("ComponentIDs not found for the base package"));
   226         DEBUG_PRINTF(_L("ComponentIDs not found for the base package"));
   226         User::Leave(KErrNotFound);
   227         User::Leave(KErrNotFound);
   227         }
   228         }
   228     
   229     
   229     //Get the apps for CompIds and mark them as to be uninstalled     
   230     /* 
   230     for(TInt i = 0 ; i < count; i++)
   231      * Find the apps of the corrosponding component and if they exist in affected list then mark them 'EAppUninstalled' and if not present
       
   232      * append it to the affected apps with EAppUninstalled.
       
   233      */
       
   234     for(TInt i = 0 ; i < componentCount ; ++i)
   231         {
   235         {
   232         existingAppUids.Reset();                    
   236         existingAppUids.Reset();
   233         TRAP(err,iRegistryWrapper.RegistrySession().GetAppUidsForComponentL(componentIds[i], existingAppUids)); 
   237         TRAP(err,iRegistryWrapper.RegistrySession().GetAppUidsForComponentL(componentIds[i], existingAppUids));  
   234       
   238         TInt currentAppCount = existingAppUids.Count();
   235         for(TInt i = 0 ; i < existingAppUids.Count(); i++)
   239         for(TInt i = 0 ; i < currentAppCount; ++i)
   236             {
   240             {
       
   241             existingAppInfo = TAppUpdateInfo(existingAppUids[i], EAppInstalled);
       
   242             TInt index(0);
       
   243             index = affectedApps.Find(existingAppInfo);
       
   244             if(KErrNotFound != index)
       
   245                 {                
       
   246                 affectedApps.Remove(index);
       
   247                 }
   237             existingAppInfo = TAppUpdateInfo(existingAppUids[i], EAppUninstalled);
   248             existingAppInfo = TAppUpdateInfo(existingAppUids[i], EAppUninstalled);
   238             affectedApps.Append(existingAppInfo);                   
   249             affectedApps.Append(existingAppInfo);
   239             }
   250             }
   240         }        
   251         }
   241     
   252         
   242 	// Now that we are ready to make changes to the registry so we start a transaction
   253     // Now that we are ready to make changes to the registry so we start a transaction
   243 	// Note that the commit/rollback action is subsequently taken by the later steps of the state machine	
   254     // Note that the commit/rollback action is subsequently taken by the later steps of the state machine   
   244 	iRegistryWrapper.StartMutableOperationsL();
   255     iRegistryWrapper.StartMutableOperationsL();
   245 	iRegistryWrapper.RegistrySession().DeleteEntryL(ApplicationL().PackageL(), TransactionSession().TransactionIdL()); 
   256     iRegistryWrapper.RegistrySession().DeleteEntryL(ApplicationL().PackageL(), TransactionSession().TransactionIdL()); 
   246     
   257     
   247     componentIds.Reset();
   258     componentIds.Reset();
   248     TRAP(err,iRegistryWrapper.RegistrySession().GetComponentIdsForUidL(packageUid, componentIds));            
   259     TRAP(err,iRegistryWrapper.RegistrySession().GetComponentIdsForUidL(packageUid, componentIds));            
   249     TInt currentComponentCount = componentIds.Count();        
   260     TInt currentComponentCount = componentIds.Count();          
   250     
   261     
   251     //If there is no component assosiated with this app in the scr and there are affected apps then mark all of them as deleted. 
   262     // Mark the apps which are still in scr as 'EAppInstalled'(remove first, if present in affected apps) 
   252     RArray<TAppUpdateInfo> apps;  
   263     for(TInt i = 0 ; i < currentComponentCount; ++i)
   253     CleanupClosePushL(apps);
   264        {
   254     Plan().GetAffectedApps(apps);
   265        newAppUids.Reset();                    
   255     TInt appCount = apps.Count();    
   266        TRAP(err,iRegistryWrapper.RegistrySession().GetAppUidsForComponentL(componentIds[i], newAppUids));          
   256     
   267        for(TInt i = 0 ; i < newAppUids.Count(); ++i)
   257     //If the there is no component assosiated with the package uid(ie it has been completely deleted) and we have affected apps 
       
   258     //then compare the apps of the package currently being processed with the existing affected apps if alredy exists then
       
   259     //update else add it to the list.
       
   260     if(currentComponentCount == 0 && appCount)
       
   261         {            
       
   262         TInt count = affectedApps.Count();        
       
   263         for(TInt i = 0 ; i < appCount; ++i)
       
   264            {    
       
   265            TUid appUid = apps[i].iAppUid;
       
   266            TBool found = EFalse;
       
   267            for(TInt index = 0; index < count ; ++index)
       
   268              {
       
   269              if(appUid == affectedApps[index].iAppUid)
       
   270                  {                       
       
   271                  existingAppInfo = TAppUpdateInfo(appUid, EAppUninstalled);
       
   272                  affectedApps.Remove(index);
       
   273                  affectedApps.Append(existingAppInfo); 
       
   274                  found = ETrue;     
       
   275                  break;
       
   276                  }               
       
   277              }
       
   278           if(!found)
       
   279              {
       
   280              existingAppInfo = TAppUpdateInfo(appUid,EAppUninstalled);
       
   281              affectedApps.Append(existingAppInfo);
       
   282              }   
       
   283            } 
       
   284         }
       
   285     else
       
   286         {
       
   287         // mark the apps in the affected list as upgraded if they are still in scr
       
   288         for(TInt i = 0 ; i < currentComponentCount; i++)
       
   289            {
   268            {
   290            newAppUids.Reset();                    
   269            existingAppInfo = TAppUpdateInfo(newAppUids[i], EAppUninstalled);
   291            TRAP(err,iRegistryWrapper.RegistrySession().GetAppUidsForComponentL(componentIds[i], newAppUids));          
   270            TInt index = 0;
   292            for(TInt i = 0 ; i < newAppUids.Count(); i++)
   271            index = affectedApps.Find(existingAppInfo);
       
   272            if(KErrNotFound != index)
   293                {
   273                {
   294                existingAppInfo = TAppUpdateInfo(newAppUids[i], EAppUninstalled);
   274                affectedApps.Remove(index);
   295                TInt index = 0;
   275                }                 
   296                index = affectedApps.Find(existingAppInfo);
   276            existingAppInfo = TAppUpdateInfo(newAppUids[i],EAppInstalled);
   297                if(KErrNotFound != index)
   277            affectedApps.Append(existingAppInfo);
   298                    {
   278            }        
   299                    affectedApps.Remove(index);
   279        }
   300                    existingAppInfo = TAppUpdateInfo(newAppUids[i],EAppInstalled);
   280     
   301                    affectedApps.Append(existingAppInfo);    
   281     for(TInt i = 0; i < affectedApps.Count(); ++i)
   302                    }                           
       
   303                }        
       
   304            } 
       
   305         }
       
   306     CleanupStack::PopAndDestroy(&apps);
       
   307     for(TInt i = 0; i < affectedApps.Count(); i++)
       
   308         {
   282         {
   309         DEBUG_PRINTF2(_L("AppUid is 0x%x"), affectedApps[i].iAppUid);
   283         DEBUG_PRINTF2(_L("AppUid is 0x%x"), affectedApps[i].iAppUid);
   310         DEBUG_PRINTF2(_L("Action is %d"), affectedApps[i].iAction);
   284         DEBUG_PRINTF2(_L("Action is %d"), affectedApps[i].iAction);
   311         }   
   285         }   
   312             
   286             
   313     const_cast<CPlan&>(Plan()).ResetAffectedApps();
   287     const_cast<CPlan&>(Plan()).ResetAffectedApps();
   314     const_cast<CPlan&>(Plan()).SetAffectedApps(affectedApps);
   288     const_cast<CPlan&>(Plan()).SetAffectedApps(affectedApps);
   315     
   289     
   316     CleanupStack::PopAndDestroy(4, &affectedApps);    
   290     CleanupStack::PopAndDestroy(4, &affectedApps);    
   317 #else
   291 #else
   318 	RSisRegistryWritableSession session;
   292     RSisRegistryWritableSession session;
   319 	User::LeaveIfError(session.Connect());
   293     User::LeaveIfError(session.Connect());
   320 	CleanupClosePushL(session);
   294     CleanupClosePushL(session);
   321 
   295 
   322 	session.DeleteEntryL(ApplicationL().PackageL(), IntegrityServices().TransactionId());
   296     session.DeleteEntryL(ApplicationL().PackageL(), IntegrityServices().TransactionId());
   323 	CleanupStack::PopAndDestroy(&session);
   297     CleanupStack::PopAndDestroy(&session);
   324 #endif
   298 #endif
   325 	return ETrue;
   299     return ETrue;
   326 	}
   300 	}
   327 
   301 
   328 CUninstallationProcessor& CUninstallationProcessor::EmbeddedProcessorL()
   302 CUninstallationProcessor& CUninstallationProcessor::EmbeddedProcessorL()
   329 	{
   303 	{
   330 	if (!iEmbeddedProcessor)
   304 	if (!iEmbeddedProcessor)