installationservices/swi/source/swis/server/uninstallationprocessor.cpp
changeset 52 92f864ef0288
parent 25 98b66e4fb0be
child 75 2d2d25361590
equal deleted inserted replaced
42:d17dc5398051 52:92f864ef0288
   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     
   219     
   220     Plan().GetAffectedApps(affectedApps);
   220     // Get all existing componentsIds for the package to to be uninstalled
   221     if(affectedApps.Count() == 0)
   221     TRAPD(err,iRegistryWrapper.RegistrySession().GetComponentIdsForUidL(packageUid, componentIds));            
       
   222     TInt count = componentIds.Count();
       
   223     if(0 == count)
   222         {
   224         {
   223         // Get all existing componentsIds for the package to to be uninstalled
   225         DEBUG_PRINTF(_L("ComponentIDs not found for the base package"));
   224         TRAPD(err,iRegistryWrapper.RegistrySession().GetComponentIdsForUidL(packageUid, componentIds));            
   226         User::Leave(KErrNotFound);
   225         TInt count = componentIds.Count();
   227         }
   226         if(0 == count)
   228     
       
   229     //Get the apps for CompIds and mark them as to be uninstalled     
       
   230     for(TInt i = 0 ; i < count; i++)
       
   231         {
       
   232         existingAppUids.Reset();                    
       
   233         TRAP(err,iRegistryWrapper.RegistrySession().GetAppUidsForComponentL(componentIds[i], existingAppUids)); 
       
   234       
       
   235         for(TInt i = 0 ; i < existingAppUids.Count(); i++)
   227             {
   236             {
   228             DEBUG_PRINTF(_L("ComponentIDs not found for the base package"));
   237             existingAppInfo = TAppUpdateInfo(existingAppUids[i], EAppUninstalled);
   229             User::Leave(KErrNotFound);
   238             affectedApps.Append(existingAppInfo);                   
   230             }
   239             }
   231         
   240         }        
   232         //Get the apps for CompIds and mark them as to be upgraded      
       
   233         for(TInt i = 0 ; i < count; i++)
       
   234             {
       
   235             existingAppUids.Reset();                    
       
   236             TRAP(err,iRegistryWrapper.RegistrySession().GetAppUidsForComponentL(componentIds[i], existingAppUids)); 
       
   237           
       
   238             for(TInt i = 0 ; i < existingAppUids.Count(); i++)
       
   239                 {
       
   240                 existingAppInfo = TAppUpdateInfo(existingAppUids[i], EAppUninstalled);
       
   241                 affectedApps.Append(existingAppInfo);                   
       
   242                 }
       
   243             }
       
   244         }
       
   245     
   241     
   246 	// Now that we are ready to make changes to the registry so we start a transaction
   242 	// Now that we are ready to make changes to the registry so we start a transaction
   247 	// Note that the commit/rollback action is subsequently taken by the later steps of the state machine	
   243 	// Note that the commit/rollback action is subsequently taken by the later steps of the state machine	
   248 	iRegistryWrapper.StartMutableOperationsL();
   244 	iRegistryWrapper.StartMutableOperationsL();
   249 	iRegistryWrapper.RegistrySession().DeleteEntryL(ApplicationL().PackageL(), TransactionSession().TransactionIdL()); 
   245 	iRegistryWrapper.RegistrySession().DeleteEntryL(ApplicationL().PackageL(), TransactionSession().TransactionIdL()); 
   250     
   246     
   251     componentIds.Reset();
   247     componentIds.Reset();
   252     TRAPD(err,iRegistryWrapper.RegistrySession().GetComponentIdsForUidL(packageUid, componentIds));            
   248     TRAP(err,iRegistryWrapper.RegistrySession().GetComponentIdsForUidL(packageUid, componentIds));            
   253     TInt currentComponentCount = componentIds.Count();        
   249     TInt currentComponentCount = componentIds.Count();        
   254     
   250     
   255     //If there is no component assosiated with this app in the scr and there are affected apps then mark all of them as deleted. 
   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. 
   256     RArray<TAppUpdateInfo> apps;  
   252     RArray<TAppUpdateInfo> apps;  
   257     CleanupClosePushL(apps);
   253     CleanupClosePushL(apps);
   258     Plan().GetAffectedApps(apps);
   254     Plan().GetAffectedApps(apps);
   259     TInt appCount = apps.Count();
   255     TInt appCount = apps.Count();    
   260     CleanupStack::PopAndDestroy();
   256     
   261     
   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.
   262     if(currentComponentCount == 0 && appCount)
   260     if(currentComponentCount == 0 && appCount)
   263         {            
   261         {            
   264         for(TInt i = 0 ; i < appCount; i++)
   262         TInt count = affectedApps.Count();        
   265            {          
   263         for(TInt i = 0 ; i < appCount; ++i)
   266            existingAppInfo = TAppUpdateInfo(affectedApps[0].iAppUid, EAppUninstalled);
   264            {    
   267            affectedApps.Remove(0);
   265            TUid appUid = apps[i].iAppUid;
   268            affectedApps.Append(existingAppInfo);    
   266            TBool found = EFalse;
   269            }
   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            } 
   270         }
   284         }
   271     else
   285     else
   272         {
   286         {
   273         // mark the apps in the sffected list as upgraded if they are still in scr
   287         // mark the apps in the affected list as upgraded if they are still in scr
   274         for(TInt i = 0 ; i < currentComponentCount; i++)
   288         for(TInt i = 0 ; i < currentComponentCount; i++)
   275            {
   289            {
   276            newAppUids.Reset();                    
   290            newAppUids.Reset();                    
   277            TRAP(err,iRegistryWrapper.RegistrySession().GetAppUidsForComponentL(componentIds[i], newAppUids));          
   291            TRAP(err,iRegistryWrapper.RegistrySession().GetAppUidsForComponentL(componentIds[i], newAppUids));          
   278            for(TInt i = 0 ; i < newAppUids.Count(); i++)
   292            for(TInt i = 0 ; i < newAppUids.Count(); i++)
   287                    affectedApps.Append(existingAppInfo);    
   301                    affectedApps.Append(existingAppInfo);    
   288                    }                           
   302                    }                           
   289                }        
   303                }        
   290            } 
   304            } 
   291         }
   305         }
   292     
   306     CleanupStack::PopAndDestroy(&apps);
   293     for(TInt i = 0; i < affectedApps.Count(); i++)
   307     for(TInt i = 0; i < affectedApps.Count(); i++)
   294         {
   308         {
   295         DEBUG_PRINTF2(_L("AppUid is 0x%x"), affectedApps[i].iAppUid);
   309         DEBUG_PRINTF2(_L("AppUid is 0x%x"), affectedApps[i].iAppUid);
   296         DEBUG_PRINTF2(_L("Action is %d"), affectedApps[i].iAction);
   310         DEBUG_PRINTF2(_L("Action is %d"), affectedApps[i].iAction);
   297         }   
   311         }   
       
   312             
   298     const_cast<CPlan&>(Plan()).ResetAffectedApps();
   313     const_cast<CPlan&>(Plan()).ResetAffectedApps();
   299     const_cast<CPlan&>(Plan()).SetAffectedApps(affectedApps);
   314     const_cast<CPlan&>(Plan()).SetAffectedApps(affectedApps);
   300     
   315     
   301     CleanupStack::PopAndDestroy(4, &affectedApps);    
   316     CleanupStack::PopAndDestroy(4, &affectedApps);    
   302 #else
   317 #else