installationservices/swi/source/swis/server/installationprocessor.cpp
branchRCL_3
changeset 26 8b7f4e561641
parent 25 7333d7932ef7
equal deleted inserted replaced
25:7333d7932ef7 26:8b7f4e561641
     1 /*
     1 /*
     2 * Copyright (c) 1997-2010 Nokia Corporation and/or its subsidiary(-ies).
     2 * Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     4 * This component and the accompanying materials are made available
     5 * under the terms of the License "Eclipse Public License v1.0"
     5 * under the terms of the License "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
    28 
    28 
    29 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK
    29 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK
    30 #include <usif/sts/sts.h>
    30 #include <usif/sts/sts.h>
    31 #include "swtypereginfo.h"
    31 #include "swtypereginfo.h"
    32 #include "installswtypehelper.h"
    32 #include "installswtypehelper.h"
    33 #include "cleanuputils.h"
       
    34 #include "userselections.h"
       
    35 #include "sissupportedlanguages.h"
       
    36 #else
    33 #else
    37 #include "integrityservices.h"
    34 #include "integrityservices.h"
    38 #endif
    35 #endif
    39 
    36 
    40 #include "sisregistryentry.h"
    37 #include "sisregistryentry.h"
    61 #include "securitycheckutil.h"
    58 #include "securitycheckutil.h"
    62 #include "sisfieldtypes.h"
    59 #include "sisfieldtypes.h"
    63 #include "progressbar.h"
    60 #include "progressbar.h"
    64 #include "fileextractor.h"
    61 #include "fileextractor.h"
    65 #include "securitycheckutil.h"
    62 #include "securitycheckutil.h"
    66 #include <s32strm.h>
    63 
    67 using namespace Swi;
    64 using namespace Swi;
    68 
    65 
    69 
    66 
    70 _LIT(KApparcRegDir, "\\private\\10003a3f\\import\\apps\\");
    67 _LIT(KApparcRegDir, "\\private\\10003a3f\\import\\apps\\");
    71 _LIT(KSisExt, ".sis");
    68 _LIT(KSisExt, ".sis");
   171 	delete iEmbeddedProcessor;
   168 	delete iEmbeddedProcessor;
   172 	delete iFileExtractor;
   169 	delete iFileExtractor;
   173 		
   170 		
   174 	iFilesToCopy.ResetAndDestroy();
   171 	iFilesToCopy.ResetAndDestroy();
   175 	iApparcRegFiles.ResetAndDestroy();
   172 	iApparcRegFiles.ResetAndDestroy();
   176 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK	
   173 	
   177 	iApparcRegFilesForParsing.ResetAndDestroy();
       
   178 	iApparcRegFileData.ResetAndDestroy();
       
   179 	delete iAppRegExtractor;	
       
   180 #endif	
       
   181 	iLoader.Close();
   174 	iLoader.Close();
   182 	iSkipFile.Close();
   175 	iSkipFile.Close();
   183 	
   176 	
   184 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK
   177 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK
   185 	iSoftwareTypeRegInfoArray.Close();
   178 	iSoftwareTypeRegInfoArray.Close();
   205 	
   198 	
   206 	if (iFileExtractor->IsActive())
   199 	if (iFileExtractor->IsActive())
   207 		{
   200 		{
   208 		iFileExtractor->Cancel();
   201 		iFileExtractor->Cancel();
   209 		}
   202 		}
   210 
       
   211 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK  	
       
   212 	if (iAppRegExtractor != NULL)
       
   213         {
       
   214 		if (iAppRegExtractor->IsActive())
       
   215 			{
       
   216 			iAppRegExtractor->Cancel();
       
   217 			}
       
   218 		}
       
   219 #endif
       
   220 	}
   203 	}
   221 
   204 
   222 void CInstallationProcessor::DisplayFileL(const CSisRegistryFileDescription& aFileDescription, Sis::TSISFileOperationOptions aFileOperationOption)
   205 void CInstallationProcessor::DisplayFileL(const CSisRegistryFileDescription& aFileDescription, Sis::TSISFileOperationOptions aFileOperationOption)
   223 	{
   206 	{
   224 	// Default to continue
   207 	// Default to continue
   580 	iUiState = EInitialize;
   563 	iUiState = EInitialize;
   581 	iCurrent = 0;
   564 	iCurrent = 0;
   582 	iFilesToCopyCurrent = 0;
   565 	iFilesToCopyCurrent = 0;
   583 	iFilesToCopy.ResetAndDestroy();
   566 	iFilesToCopy.ResetAndDestroy();
   584 	iApparcRegFiles.ResetAndDestroy();
   567 	iApparcRegFiles.ResetAndDestroy();
   585 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK
       
   586 	iApparcRegFilesForParsing.ResetAndDestroy();
       
   587 	iApparcRegFileData.ResetAndDestroy();
       
   588 #endif
       
   589 	return ETrue;
   568 	return ETrue;
   590 	}
   569 	}
   591 	
   570 	
   592 TBool CInstallationProcessor::DoStateProcessEmbeddedL()
   571 TBool CInstallationProcessor::DoStateProcessEmbeddedL()
   593 	{
   572 	{
   771 			
   750 			
   772 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK
   751 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK
   773 			CleanupStack::PopAndDestroy(2, &entry); // presintalledSids
   752 			CleanupStack::PopAndDestroy(2, &entry); // presintalledSids
   774 #else
   753 #else
   775 			CleanupStack::PopAndDestroy(3, &session); // entry, presintalledSids
   754 			CleanupStack::PopAndDestroy(3, &session); // entry, presintalledSids
   776 #endif			
   755 #endif
   777 			}
   756 			
   778 		
   757 			}
   779 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK		
   758 		
   780 		
       
   781 		// Find out all the regisration resource files associated with this package UID and add to the list of 
       
   782 		// files to be processed later for parsing		
       
   783 		TRAPD(err, AddAppArcRegResourceFilesL());
       
   784 		if ( err != KErrNotFound && err != KErrNone)
       
   785 		    User::Leave(err);
       
   786 #endif
       
   787 		iCurrent = 0;
   759 		iCurrent = 0;
   788 		return ETrue;
   760 		return ETrue;
   789 		}
   761 		}
   790 	}
   762 	}
   791 
       
   792 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK
       
   793 void CInstallationProcessor::AddAppArcRegResourceFilesL()
       
   794     {
       
   795     RSisRegistryEntry entry;
       
   796     TInt err = KErrNone;
       
   797     if ( !ApplicationL().IsUninstall() )
       
   798         err = entry.Open(iRegistryWrapper.RegistrySession(), ApplicationL().ControllerL().Info().Uid().Uid());
       
   799     else
       
   800         return;
       
   801     
       
   802     User::LeaveIfError(err);
       
   803     CleanupClosePushL(entry);
       
   804     AddAppArcRegResourceFilesForRegEntryL(entry);
       
   805     
       
   806     RPointerArray<CSisRegistryPackage> augmentationArray;
       
   807     CleanupResetAndDestroyPushL(augmentationArray);
       
   808     entry.AugmentationsL(augmentationArray);
       
   809     CleanupStack::Pop(&augmentationArray);
       
   810     CleanupStack::PopAndDestroy(&entry);    
       
   811         
       
   812     CleanupResetAndDestroyPushL(augmentationArray);
       
   813     TInt count = augmentationArray.Count();
       
   814     for ( TInt i=0; i < count; ++i)
       
   815         {
       
   816         TInt err = entry.OpenL(iRegistryWrapper.RegistrySession(),*augmentationArray[i]);
       
   817         User::LeaveIfError(err);
       
   818         CleanupClosePushL(entry);
       
   819         AddAppArcRegResourceFilesForRegEntryL(entry);
       
   820         CleanupStack::PopAndDestroy(&entry);
       
   821         }
       
   822     
       
   823     CleanupStack::PopAndDestroy(&augmentationArray);
       
   824     }
       
   825 
       
   826 void CInstallationProcessor::AddAppArcRegResourceFilesForRegEntryL(RSisRegistryEntry& aEntry)
       
   827     {
       
   828     RPointerArray<HBufC> filesArray;
       
   829     CleanupResetAndDestroyPushL(filesArray);
       
   830     aEntry.FilesL(filesArray);    
       
   831     TInt count = filesArray.Count();
       
   832     CSisRegistryPackage *regPkg = aEntry.PackageL();
       
   833     CleanupStack::PushL(regPkg);
       
   834     
       
   835     for (TInt i=0; i<count; ++i)
       
   836         {
       
   837         if (FileIsApparcReg(*filesArray[i]))
       
   838             {
       
   839             CAppRegFileData *tmpAppRegFileData = CAppRegFileData::NewLC(*filesArray[i],*regPkg);
       
   840             iApparcRegFilesForParsing.AppendL(tmpAppRegFileData);
       
   841             CleanupStack::Pop(tmpAppRegFileData);
       
   842             }
       
   843         }
       
   844     CleanupStack::PopAndDestroy(2,&filesArray);
       
   845     }
       
   846 #endif
       
   847 
   763 
   848 TBool CInstallationProcessor::DoStateVerifyPathsL()
   764 TBool CInstallationProcessor::DoStateVerifyPathsL()
   849 	{
   765 	{
   850 	if (iCurrent < ApplicationL().FilesToAdd().Count())
   766 	if (iCurrent < ApplicationL().FilesToAdd().Count())
   851 		{
   767 		{
   900 		return EFalse;
   816 		return EFalse;
   901 		}
   817 		}
   902 	iCurrent = 0;
   818 	iCurrent = 0;
   903 	return ETrue;
   819 	return ETrue;
   904 	}
   820 	}
   905 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK
   821 
   906 TBool CInstallationProcessor::DoParseApplicationRegistrationFilesL()
   822 
   907     {
       
   908     if (iCurrent == 0)
       
   909         DEBUG_PRINTF2(_L("Install Server - DoParseApplicationRegistrationFilesL - Number of Application registration resource files to be parsed %d"), iApparcRegFilesForParsing.Count());
       
   910     
       
   911 	if (iAppRegExtractor != NULL)
       
   912         {
       
   913         if (iAppRegExtractor->GetErrorCode() == KErrCorrupt)
       
   914             {
       
   915             delete iApparcRegFilesForParsing[--iCurrent];
       
   916             iApparcRegFilesForParsing.Remove(iCurrent);
       
   917             }
       
   918         }
       
   919     
       
   920     if (iCurrent < iApparcRegFilesForParsing.Count())
       
   921         { 
       
   922         TDesC& fileDescription = (iApparcRegFilesForParsing[iCurrent++]->GetAppRegFile());   
       
   923         // Continue processing the next file if a registration resource file is not found(in case of SA over SA)
       
   924         TRAPD(err,ParseRegistrationResourceFileL(fileDescription));        
       
   925         if(KErrNotFound == err || KErrPathNotFound == err)
       
   926             {               
       
   927             delete iApparcRegFilesForParsing[--iCurrent];
       
   928             iApparcRegFilesForParsing.Remove(iCurrent); 
       
   929             TRequestStatus* status = &iStatus;
       
   930             User::RequestComplete(status, KErrNone);     
       
   931             WaitState(ECurrentState);
       
   932             }
       
   933         else if(KErrNone != err )
       
   934             {
       
   935             User::Leave(err);
       
   936             }
       
   937         else
       
   938             {
       
   939             WaitState(ECurrentState);
       
   940             }
       
   941         return EFalse;
       
   942         }
       
   943     else
       
   944         {
       
   945         iCurrent = 0;
       
   946         return ETrue;
       
   947         }
       
   948     }
       
   949 
       
   950 TBool CInstallationProcessor::ParseRegistrationResourceFileL(const TDesC& aTargetFileName)
       
   951     {
       
   952     DEBUG_PRINTF2(_L("Install Server - ParseRegistrationResourceFileL - Parsing '%S' registration resource file"), &aTargetFileName);
       
   953     if ( NULL == iAppRegExtractor )
       
   954         {
       
   955         DEBUG_PRINTF(_L("Install Server - ParseRegistrationResourceFileL - Creating CAppRegExtractor for async parsing of registration resource file"));
       
   956         CApplication& app = const_cast<CApplication&>(ApplicationL());
       
   957         RArray<TInt> matchingLanguages = app.GetDeviceSupportedLanguages();
       
   958         RArray<TLanguage> devLanguages;
       
   959         CleanupClosePushL(devLanguages);
       
   960         TInt count = matchingLanguages.Count();
       
   961         
       
   962         DEBUG_PRINTF2(_L("Install Server - ParseRegistrationResourceFileL - %d matching languages found"),count);
       
   963         for ( TInt i=0; i<count; i++)
       
   964             {
       
   965             devLanguages.Append((TLanguage)matchingLanguages[i]);            
       
   966             }
       
   967         iAppRegExtractor = CAppRegExtractor::NewL(Fs(),devLanguages,iApparcRegFileData);
       
   968         CleanupStack::Pop(&devLanguages);       
       
   969         }
       
   970         
       
   971     iAppRegExtractor->ExtractAppRegInfoSizeL(aTargetFileName, iStatus);
       
   972     return EFalse;
       
   973     }
       
   974 #endif
       
   975 
   823 
   976 TBool CInstallationProcessor::DoStateDisplayFilesL()
   824 TBool CInstallationProcessor::DoStateDisplayFilesL()
   977 	{
   825 	{
   978 	if (ApplicationL().IsPreInstalledApp() || ApplicationL().IsPreInstalledPatch())
   826 	if (ApplicationL().IsPreInstalledApp() || ApplicationL().IsPreInstalledPatch())
   979 		{
   827 		{
   996 TBool CInstallationProcessor::DoStateUpdateRegistryL()
   844 TBool CInstallationProcessor::DoStateUpdateRegistryL()
   997 	{
   845 	{
   998 	// destroy the memory heavy file copy descriptions
   846 	// destroy the memory heavy file copy descriptions
   999 	iFilesToCopy.ResetAndDestroy();
   847 	iFilesToCopy.ResetAndDestroy();
  1000 
   848 
  1001 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK	
       
  1002 	RArray<TAppUpdateInfo> affectedApps;    
       
  1003 	CleanupClosePushL(affectedApps);
       
  1004 	const CApplication& application = ApplicationL();
       
  1005 	//if there are reg files in the package or if its an upgrade (in case of SA (with app) over SA(with no app))
       
  1006 	if(iApparcRegFilesForParsing.Count() != 0 || application.IsUpgrade())
       
  1007 	    {
       
  1008 	    //Create the list of Application Uids which are affected by the Installation    	    	    
       
  1009 	    Usif::TComponentId componentId = 0;
       
  1010 	    RArray<Usif::TComponentId> componentIds;
       
  1011 	    CleanupClosePushL(componentIds);
       
  1012 	    RArray<TUid> existingAppUids;
       
  1013 	    CleanupClosePushL(existingAppUids);
       
  1014 	    TAppUpdateInfo existingAppInfo;     
       
  1015 	    TUid packageUid = application.ControllerL().Info().Uid().Uid();
       
  1016 	    
       
  1017         if(application.IsUpgrade()) 
       
  1018             {	 	    
       
  1019             //Get all componentIds
       
  1020             iRegistryWrapper.RegistrySession().GetComponentIdsForUidL(packageUid, componentIds);            
       
  1021             TInt count = componentIds.Count();
       
  1022             if(0 == count)
       
  1023                 {
       
  1024                 DEBUG_PRINTF(_L("ComponentIDs not found for the base package"));
       
  1025                 User::Leave(KErrNotFound);
       
  1026                 }
       
  1027                                 
       
  1028             //SA over SA
       
  1029             if(application.ControllerL().Info().InstallType() == Sis::EInstInstallation )
       
  1030                 {        
       
  1031                 //Get the compid for base package
       
  1032                 componentId = iRegistryWrapper.RegistrySession().GetComponentIdForUidL(packageUid);               
       
  1033                       
       
  1034                 TInt index = componentIds.Find(componentId);
       
  1035 
       
  1036                 //Exclude the Base SA compId from the list 
       
  1037                 componentIds.Remove(index);
       
  1038                 //Get the apps for Base SA compId and mark them as to be deleted
       
  1039                 existingAppUids.Reset();
       
  1040                 TRAPD(err,iRegistryWrapper.RegistrySession().GetAppUidsForComponentL(componentId, existingAppUids);)  
       
  1041                 //If Base Package does not contain any app then GetAppUidsForComponentL will return KErrNotFound, ignore the error else leave
       
  1042                 if (KErrNone != err && KErrNotFound != err)
       
  1043                     {
       
  1044                     User::Leave(err);
       
  1045                     }
       
  1046                 
       
  1047                 for(TInt i = 0 ; i < existingAppUids.Count(); ++i)
       
  1048                     {
       
  1049                     existingAppInfo = TAppUpdateInfo(existingAppUids[i], EAppUninstalled);    
       
  1050                     affectedApps.AppendL(existingAppInfo);
       
  1051                     }                
       
  1052                 //Get the apps for Remaining CompIds and mark them as to be upgraded               
       
  1053                 for(TInt i = 0 ; i < componentIds.Count(); ++i)
       
  1054                     {
       
  1055                     existingAppUids.Reset();                    
       
  1056                     //If there are no apps within the existing components (SP's) then it will return KErrNotFound
       
  1057                     TRAPD(err, iRegistryWrapper.RegistrySession().GetAppUidsForComponentL(componentIds[i], existingAppUids);) 
       
  1058                     if (KErrNone != err && KErrNotFound != err)
       
  1059                         {
       
  1060                         User::Leave(err);
       
  1061                         }
       
  1062                     
       
  1063                     for(TInt k = 0 ; k < existingAppUids.Count(); ++k)
       
  1064                         {
       
  1065                         existingAppInfo = TAppUpdateInfo(existingAppUids[k], EAppInstalled);    
       
  1066                         affectedApps.AppendL(existingAppInfo);
       
  1067                         }
       
  1068                     }                                
       
  1069                 }
       
  1070                 
       
  1071             //SP over SP
       
  1072             if(application.ControllerL().Info().InstallType() == Sis::EInstAugmentation)
       
  1073                 {
       
  1074                 componentId = iRegistryWrapper.RegistrySession().GetComponentIdForPackageL(application.PackageL().Name(), application.PackageL().Vendor());     
       
  1075                 //Get the apps for Base SP compId and mark them as to be deleted
       
  1076                 existingAppUids.Reset();
       
  1077                 //If there are no apps within the existing component (SP) then it will return KErrNotFound
       
  1078                 TRAPD(err, iRegistryWrapper.RegistrySession().GetAppUidsForComponentL(componentId, existingAppUids);) 
       
  1079                 if (KErrNone != err && KErrNotFound != err)
       
  1080 					{
       
  1081                     User::Leave(err);
       
  1082 					}
       
  1083                 
       
  1084                 for(TInt i = 0 ; i < existingAppUids.Count(); ++i)
       
  1085                    {
       
  1086                    existingAppInfo = TAppUpdateInfo(existingAppUids[i], EAppUninstalled);    
       
  1087                    affectedApps.Append(existingAppInfo);
       
  1088                    }                                  
       
  1089                 }        
       
  1090             }	                   
       
  1091         CleanupStack::PopAndDestroy(2, &componentIds);
       
  1092 	    }		
       
  1093 #endif
       
  1094 	
       
  1095 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK
   849 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK
  1096 	// Now that we are ready to make changes to the registry we start a transaction
   850 	// Now that we are ready to make changes to the registry we start a transaction
  1097 	// Note that the commit/rollback action is subsequently taken by the later steps of the state machine
   851 	// Note that the commit/rollback action is subsequently taken by the later steps of the state machine
  1098 	iRegistryWrapper.StartMutableOperationsL();
   852 	iRegistryWrapper.StartMutableOperationsL();
  1099 #else
   853 #else
  1180 			}
   934 			}
  1181 		else
   935 		else
  1182 			{
   936 			{
  1183 			iRegistryWrapper.RegistrySession().UpdateEntryL(ApplicationL(), thisController, TransactionSession().TransactionIdL());
   937 			iRegistryWrapper.RegistrySession().UpdateEntryL(ApplicationL(), thisController, TransactionSession().TransactionIdL());
  1184 			}
   938 			}
  1185 		TInt count = iApparcRegFileData.Count();
       
  1186         for (int i = 0; i < count; i++)
       
  1187             {
       
  1188 		    iRegistryWrapper.RegistrySession().UpdateEntryL(ApplicationL(), *iApparcRegFileData[i], iApparcRegFilesForParsing[i]->GetSisRegistryPackage());
       
  1189 		    }
       
  1190 #else
   939 #else
  1191 		session.UpdateEntryL(ApplicationL(), thisController, IntegrityServices().TransactionId());
   940 		session.UpdateEntryL(ApplicationL(), thisController, IntegrityServices().TransactionId());
  1192 #endif
   941 #endif
  1193 		}
   942 		}
  1194 	else if (ApplicationL().IsInstall()
   943 	else if (ApplicationL().IsInstall()
  1203 			}
   952 			}
  1204 		else
   953 		else
  1205 			{
   954 			{
  1206 			iRegistryWrapper.RegistrySession().AddEntryL(ApplicationL(), thisController, TransactionSession().TransactionIdL());
   955 			iRegistryWrapper.RegistrySession().AddEntryL(ApplicationL(), thisController, TransactionSession().TransactionIdL());
  1207 			}
   956 			}
  1208 		TInt count = iApparcRegFileData.Count();
       
  1209 		for (int i = 0; i < count; i++)
       
  1210 		    {
       
  1211                 iRegistryWrapper.RegistrySession().AddEntryL(*iApparcRegFileData[i], iApparcRegFilesForParsing[i]->GetSisRegistryPackage());
       
  1212 		    }
       
  1213 #else
   957 #else
  1214 		session.AddEntryL(ApplicationL(), thisController, IntegrityServices().TransactionId());
   958 		session.AddEntryL(ApplicationL(), thisController, IntegrityServices().TransactionId());
  1215 #endif
   959 #endif
  1216 		}
   960 		}
  1217 	else if (ApplicationL().IsUninstall())
   961 	else if (ApplicationL().IsUninstall())
  1230 	// This operation is not transactional so it must be done after the software types
   974 	// This operation is not transactional so it must be done after the software types
  1231 	// have been successfully registered to the SCR by the following calls:
   975 	// have been successfully registered to the SCR by the following calls:
  1232 	// RSisRegistryWritableSession::AddEntryL()
   976 	// RSisRegistryWritableSession::AddEntryL()
  1233 	// RSisRegistryWritableSession::UpdateEntryL()
   977 	// RSisRegistryWritableSession::UpdateEntryL()
  1234 	InstallSoftwareTypeHelper::RegisterMimeTypesL(iSoftwareTypeRegInfoArray);
   978 	InstallSoftwareTypeHelper::RegisterMimeTypesL(iSoftwareTypeRegInfoArray);
  1235 	
       
  1236 	//if there are reg files in the package or if its an upgrade (in case of SA (with app) over SA(with no app))
       
  1237 	if(iApparcRegFilesForParsing.Count() != 0 || application.IsUpgrade())
       
  1238 	    {
       
  1239 	    //Create the list of Application Uids which are affected by the Installation                           
       
  1240         RArray<Usif::TComponentId> componentIds;
       
  1241         CleanupClosePushL(componentIds);
       
  1242         RArray<TUid> newAppUids;    
       
  1243         CleanupClosePushL(newAppUids);
       
  1244         TAppUpdateInfo existingAppInfo, newAppInfo;     
       
  1245         TUid packageUid = application.ControllerL().Info().Uid().Uid();
       
  1246         //Get all componentIds for the application
       
  1247         componentIds.Reset();
       
  1248         iRegistryWrapper.RegistrySession().GetComponentIdsForUidL(packageUid, componentIds);
       
  1249         TInt count = componentIds.Count();
       
  1250         
       
  1251         //Get the apps for All CompIds               
       
  1252         for(TInt i = 0 ; i < count; i++)
       
  1253             {
       
  1254             newAppUids.Reset();                    
       
  1255             TRAPD(err,iRegistryWrapper.RegistrySession().GetAppUidsForComponentL(componentIds[i], newAppUids))
       
  1256             if (KErrNone != err && KErrNotFound != err)
       
  1257                 {
       
  1258                 User::Leave(err);
       
  1259                 }
       
  1260             
       
  1261             for(TInt i = 0 ; i < newAppUids.Count(); ++i)
       
  1262                 {
       
  1263                 existingAppInfo = TAppUpdateInfo(newAppUids[i], EAppUninstalled);
       
  1264                 TInt index = 0;
       
  1265                 index = affectedApps.Find(existingAppInfo);
       
  1266                 if(KErrNotFound != index)
       
  1267                     {
       
  1268                     affectedApps.Remove(index);
       
  1269                     }
       
  1270                 existingAppInfo = TAppUpdateInfo(newAppUids[i],EAppInstalled);
       
  1271                 affectedApps.AppendL(existingAppInfo);            
       
  1272                 }        
       
  1273             }
       
  1274         
       
  1275         for(TInt i = 0; i < affectedApps.Count(); i++)
       
  1276            {
       
  1277            DEBUG_PRINTF2(_L("AppUid is 0x%x"), affectedApps[i].iAppUid);
       
  1278            DEBUG_PRINTF2(_L("Action is %d"), affectedApps[i].iAction);
       
  1279            }
       
  1280         
       
  1281         //Updating apps to be notified
       
  1282         RArray<TAppUpdateInfo> currentNotifiableApps;
       
  1283         CleanupClosePushL(currentNotifiableApps);
       
  1284         const_cast<CPlan&>(Plan()).GetAffectedApps(currentNotifiableApps);
       
  1285         TInt appCount = affectedApps.Count();
       
  1286         for(TInt k = 0; k < appCount ; ++k)
       
  1287             {
       
  1288             TInt count = currentNotifiableApps.Count();
       
  1289             TUid appUid = affectedApps[k].iAppUid;
       
  1290             //compare the apps present in the package currently being processed with the existing set of affected apps,
       
  1291             //if alredy exists then update else add it to the list
       
  1292             for(TInt index = 0; index < count ; ++index)
       
  1293                {
       
  1294                if(appUid == currentNotifiableApps[index].iAppUid)
       
  1295                    {           
       
  1296                    currentNotifiableApps.Remove(index);                                    
       
  1297                    }
       
  1298                }
       
  1299             currentNotifiableApps.AppendL(affectedApps[k]);
       
  1300             }
       
  1301         
       
  1302         const_cast<CPlan&>(Plan()).ResetAffectedApps();
       
  1303         const_cast<CPlan&>(Plan()).SetAffectedApps(currentNotifiableApps);
       
  1304         
       
  1305         CleanupStack::PopAndDestroy(3, &componentIds);
       
  1306 	    }
       
  1307 	CleanupStack::PopAndDestroy(&affectedApps);
       
  1308 #endif
   979 #endif
  1309 	return ETrue;
   980 	return ETrue;
  1310 	}
   981 	}
  1311 
   982 
  1312 // CFileCopyDescription 
   983 // CFileCopyDescription 
  1634 		{
  1305 		{
  1635 		// Ask the launcher to notify Apparc of any new reg files
  1306 		// Ask the launcher to notify Apparc of any new reg files
  1636 		RSisLauncherSession launcher;
  1307 		RSisLauncherSession launcher;
  1637 		CleanupClosePushL(launcher);
  1308 		CleanupClosePushL(launcher);
  1638 		User::LeaveIfError(launcher.Connect());
  1309 		User::LeaveIfError(launcher.Connect());
  1639 
  1310 	
  1640 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK
       
  1641 		RPointerArray<Usif::CApplicationRegistrationData> appRegInfoArray;
       
  1642 		CleanupClosePushL(appRegInfoArray);
       
  1643 
       
  1644 		RFs fs;
       
  1645 		CleanupClosePushL(fs);
       
  1646         User::LeaveIfError(fs.Connect());
       
  1647 		User::LeaveIfError(fs.ShareProtected());
       
  1648 		RArray<TLanguage> appLanguages;
       
  1649 		CleanupClosePushL(appLanguages);
       
  1650 				        
       
  1651 		const TInt appCount = iApparcRegFiles.Count();
       
  1652 		for (TInt i=0; i<appCount; ++i)
       
  1653 			{
       
  1654 			TInt bufLen = iApparcRegFiles[i]->Size();
       
  1655 			HBufC* buf = HBufC::NewLC(bufLen);
       
  1656 			TPtr appFile = buf->Des();
       
  1657 			appFile.Format(_L("%S"), iApparcRegFiles[i]);
       
  1658 
       
  1659 			RFile file;
       
  1660 			User::LeaveIfError(file.Open(fs, appFile, EFileRead));
       
  1661 			CleanupClosePushL(file);
       
  1662 			Usif::CApplicationRegistrationData* appRegData  = NULL;
       
  1663 			TRAPD(err, appRegData = launcher.SyncParseResourceFileL(file, appLanguages));
       
  1664 			if (KErrNone == err)
       
  1665 			    {
       
  1666 		         CleanupStack::PushL(appRegData);
       
  1667 		         appRegInfoArray.AppendL(appRegData);
       
  1668 		         CleanupStack::Pop(appRegData);
       
  1669 			    }
       
  1670 			CleanupStack::PopAndDestroy(2,buf);
       
  1671 			}
       
  1672 		
       
  1673 		launcher.NotifyNewAppsL(appRegInfoArray);
       
  1674         fs.Close();
       
  1675         appRegInfoArray.ResetAndDestroy();
       
  1676 		CleanupStack::PopAndDestroy(3, &appRegInfoArray);
       
  1677 #else
       
  1678 		launcher.NotifyNewAppsL(iApparcRegFiles);
  1311 		launcher.NotifyNewAppsL(iApparcRegFiles);
  1679 #endif
       
  1680 		// clean up our list so we don't notify of the files twice
  1312 		// clean up our list so we don't notify of the files twice
  1681 		iApparcRegFiles.ResetAndDestroy();
  1313 		iApparcRegFiles.ResetAndDestroy();
  1682 		
  1314 		
  1683 		CleanupStack::PopAndDestroy(&launcher);
  1315 		CleanupStack::PopAndDestroy(&launcher);
  1684 		}
  1316 		}
  1699 		return ETrue;
  1331 		return ETrue;
  1700 #endif	
  1332 #endif	
  1701 		}
  1333 		}
  1702 	return EFalse;
  1334 	return EFalse;
  1703 	}
  1335 	}
  1704 
  1336 	
  1705 void CInstallationProcessor::AddApparcFilesInListL(const TDesC& aTargetFileName)
  1337 void CInstallationProcessor::AddApparcFilesInListL(const TDesC& aTargetFileName)
  1706 	{
  1338 	{
  1707 	if (FileIsApparcReg(aTargetFileName))
  1339 	if (FileIsApparcReg(aTargetFileName))
  1708 		{
  1340 		{
  1709 		// we're installing a reg file so add it to our list. 
  1341 		// we're installing a reg file so add it to our list. 
  1710 		HBufC* tmp = aTargetFileName.AllocLC();
  1342 		HBufC* tmp = aTargetFileName.AllocLC();
  1711 		iApparcRegFiles.AppendL(tmp);
  1343 		iApparcRegFiles.AppendL(tmp);
  1712 		CleanupStack::Pop(tmp);
  1344 		CleanupStack::Pop(tmp);
  1713 
       
  1714 #ifdef 	SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK	
       
  1715 	    // we're installing a reg file so add it to our list for parsing it and 
       
  1716 		// populating SCR in EParseApplicationRegistrationFiles state of CProcessor	    
       
  1717 		TInt index = UserSelectedLanguageIndexL(ApplicationL());
       
  1718 		CSisRegistryPackage *regPkg = CSisRegistryPackage::NewLC(ApplicationL().ControllerL().Info().Uid().Uid(),\
       
  1719 		        ApplicationL().ControllerL().Info().Names()[index]->Data(),\
       
  1720 		        ApplicationL().ControllerL().Info().UniqueVendorName().Data());
       
  1721 		CAppRegFileData *appRegData =CAppRegFileData::NewLC(aTargetFileName,*regPkg);
       
  1722 	    iApparcRegFilesForParsing.AppendL(appRegData);
       
  1723 	    CleanupStack::Pop(appRegData);
       
  1724 	    CleanupStack::PopAndDestroy(regPkg);
       
  1725 #endif		
       
  1726 		}		
  1345 		}		
  1727 	}
  1346 	}
  1728 
       
  1729 #ifdef  SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK
       
  1730 
       
  1731 TInt CInstallationProcessor::UserSelectedLanguageIndexL(const CApplication& aApplication) const
       
  1732 // used to find out which is the index of the selected language, 
       
  1733 // based on the language selection. This will be used for the relevant package and vendor names
       
  1734     {
       
  1735     TLanguage language = aApplication.UserSelections().Language();
       
  1736     
       
  1737     TInt index = KErrNotFound;
       
  1738     for (TInt i = 0; i < aApplication.ControllerL().SupportedLanguages().Count(); i++)
       
  1739         {
       
  1740         if (aApplication.ControllerL().SupportedLanguages()[i] == language)
       
  1741             {
       
  1742             index = i;
       
  1743             break;  
       
  1744             }
       
  1745         }
       
  1746     User::LeaveIfError(index);
       
  1747     return index;
       
  1748     }   
       
  1749 
       
  1750 CAppRegFileData* CAppRegFileData::NewL(const TDesC& aAppRegFile, const CSisRegistryPackage& aSisRegistryPackage)
       
  1751     {
       
  1752     CAppRegFileData* self = CAppRegFileData::NewLC(aAppRegFile, aSisRegistryPackage);
       
  1753     CleanupStack::Pop(self);
       
  1754     return self;
       
  1755     }
       
  1756 
       
  1757 CAppRegFileData* CAppRegFileData::NewLC(const TDesC& aAppRegFile, const CSisRegistryPackage& aSisRegistryPackage)
       
  1758     {
       
  1759     CAppRegFileData* self = new(ELeave) CAppRegFileData();
       
  1760     CleanupStack::PushL(self);
       
  1761     self->ConstructL(aAppRegFile, aSisRegistryPackage);
       
  1762     return self;
       
  1763     }
       
  1764 void CAppRegFileData::ConstructL(const TDesC& aAppRegFile, const CSisRegistryPackage& aSisRegistryPackage)
       
  1765     {
       
  1766     iAppRegFile = aAppRegFile.AllocL();
       
  1767     iSisRegistryPackage = CSisRegistryPackage::NewL(aSisRegistryPackage);
       
  1768     }
       
  1769 CAppRegFileData::CAppRegFileData()
       
  1770     {
       
  1771     }
       
  1772 
       
  1773 CAppRegFileData::~CAppRegFileData()
       
  1774     {
       
  1775     delete iAppRegFile;
       
  1776     delete iSisRegistryPackage;
       
  1777     }
       
  1778 
       
  1779 TDesC& CAppRegFileData::GetAppRegFile()
       
  1780     {
       
  1781     return *iAppRegFile;
       
  1782     }
       
  1783 
       
  1784 CSisRegistryPackage& CAppRegFileData::GetSisRegistryPackage()
       
  1785     {
       
  1786     return *iSisRegistryPackage;
       
  1787     }
       
  1788 #endif