diff -r 5cc91383ab1e -r 7333d7932ef7 installationservices/swi/source/swis/server/uninstallationprocessor.cpp --- a/installationservices/swi/source/swis/server/uninstallationprocessor.cpp Thu Aug 19 10:02:49 2010 +0300 +++ b/installationservices/swi/source/swis/server/uninstallationprocessor.cpp Tue Aug 31 15:21:33 2010 +0300 @@ -1,5 +1,5 @@ /* -* Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies). +* Copyright (c) 1997-2010 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of the License "Eclipse Public License v1.0" @@ -44,7 +44,8 @@ #include "sislauncherclient.h" #include "sisinfo.h" #include "sisuid.h" - +#include "plan.h" +#include "sisregistrypackage.h" using namespace Swi; @@ -193,13 +194,126 @@ return ETrue; // Nothing to do } +#ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK +TBool CUninstallationProcessor::DoParseApplicationRegistrationFilesL() + { + return ETrue; // Nothing to do + } +#endif + TBool CUninstallationProcessor::DoStateUpdateRegistryL() { -#ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK +#ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK + const CApplication& application = ApplicationL(); + RArray affectedApps; + CleanupClosePushL(affectedApps); + RArray componentIds; + CleanupClosePushL(componentIds); + RArray existingAppUids; + CleanupClosePushL(existingAppUids); + RArray newAppUids; + CleanupClosePushL(newAppUids); + + TAppUpdateInfo existingAppInfo, newAppInfo; + TUid packageUid = application.PackageL().Uid(); + + // Get all existing componentsIds for the package to to be uninstalled + TRAPD(err,iRegistryWrapper.RegistrySession().GetComponentIdsForUidL(packageUid, componentIds)); + TInt count = componentIds.Count(); + if(0 == count) + { + DEBUG_PRINTF(_L("ComponentIDs not found for the base package")); + User::Leave(KErrNotFound); + } + + //Get the apps for CompIds and mark them as to be uninstalled + for(TInt i = 0 ; i < count; i++) + { + existingAppUids.Reset(); + TRAP(err,iRegistryWrapper.RegistrySession().GetAppUidsForComponentL(componentIds[i], existingAppUids)); + + for(TInt i = 0 ; i < existingAppUids.Count(); i++) + { + existingAppInfo = TAppUpdateInfo(existingAppUids[i], EAppUninstalled); + affectedApps.Append(existingAppInfo); + } + } + // Now that we are ready to make changes to the registry so we start a transaction - // Note that the commit/rollback action is subsequently taken by the later steps of the state machine + // Note that the commit/rollback action is subsequently taken by the later steps of the state machine iRegistryWrapper.StartMutableOperationsL(); - iRegistryWrapper.RegistrySession().DeleteEntryL(ApplicationL().PackageL(), TransactionSession().TransactionIdL()); + iRegistryWrapper.RegistrySession().DeleteEntryL(ApplicationL().PackageL(), TransactionSession().TransactionIdL()); + + componentIds.Reset(); + TRAP(err,iRegistryWrapper.RegistrySession().GetComponentIdsForUidL(packageUid, componentIds)); + TInt currentComponentCount = componentIds.Count(); + + //If there is no component assosiated with this app in the scr and there are affected apps then mark all of them as deleted. + RArray apps; + CleanupClosePushL(apps); + Plan().GetAffectedApps(apps); + TInt appCount = apps.Count(); + + //If the there is no component assosiated with the package uid(ie it has been completely deleted) and we have affected apps + //then compare the apps of the package currently being processed with the existing affected apps if alredy exists then + //update else add it to the list. + if(currentComponentCount == 0 && appCount) + { + TInt count = affectedApps.Count(); + for(TInt i = 0 ; i < appCount; ++i) + { + TUid appUid = apps[i].iAppUid; + TBool found = EFalse; + for(TInt index = 0; index < count ; ++index) + { + if(appUid == affectedApps[index].iAppUid) + { + existingAppInfo = TAppUpdateInfo(appUid, EAppUninstalled); + affectedApps.Remove(index); + affectedApps.Append(existingAppInfo); + found = ETrue; + break; + } + } + if(!found) + { + existingAppInfo = TAppUpdateInfo(appUid,EAppUninstalled); + affectedApps.Append(existingAppInfo); + } + } + } + else + { + // mark the apps in the affected list as upgraded if they are still in scr + for(TInt i = 0 ; i < currentComponentCount; i++) + { + newAppUids.Reset(); + TRAP(err,iRegistryWrapper.RegistrySession().GetAppUidsForComponentL(componentIds[i], newAppUids)); + for(TInt i = 0 ; i < newAppUids.Count(); i++) + { + existingAppInfo = TAppUpdateInfo(newAppUids[i], EAppUninstalled); + TInt index = 0; + index = affectedApps.Find(existingAppInfo); + if(KErrNotFound != index) + { + affectedApps.Remove(index); + existingAppInfo = TAppUpdateInfo(newAppUids[i],EAppInstalled); + affectedApps.Append(existingAppInfo); + } + } + } + } + CleanupStack::PopAndDestroy(&apps); + for(TInt i = 0; i < affectedApps.Count(); i++) + { + DEBUG_PRINTF2(_L("AppUid is 0x%x"), affectedApps[i].iAppUid); + DEBUG_PRINTF2(_L("Action is %d"), affectedApps[i].iAction); + } + + const_cast(Plan()).ResetAffectedApps(); + const_cast(Plan()).SetAffectedApps(affectedApps); + + CleanupStack::PopAndDestroy(4, &affectedApps); #else RSisRegistryWritableSession session; User::LeaveIfError(session.Connect()); @@ -220,3 +334,5 @@ return *iEmbeddedProcessor; } + +