Revision: 201016 RCL_3
authorDremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Tue, 11 May 2010 16:20:28 +0300
branchRCL_3
changeset 34 741e5bba2bd1
parent 28 98a43fae6e2b
child 36 f9033e605ee2
Revision: 201016 Kit: 201019
appinstaller/AppMngr2/Sisx/src/appmngr2sisxappinfo.cpp
appinstaller/AppMngr2/group/appmngr2.mmp
iaupdate/IAD/loc/iaupdate.loc
iaupdate/IAD/ui/group/iaupdate.rss
iaupdate/IAD/ui/inc/iaupdateagreement.h
iaupdate/IAD/ui/inc/iaupdateappui.h
iaupdate/IAD/ui/inc/iaupdateuicontroller.h
iaupdate/IAD/ui/src/iaupdateagreement.cpp
iaupdate/IAD/ui/src/iaupdateappui.cpp
iaupdate/IAD/ui/src/iaupdatehistorycontainer.cpp
iaupdate/IAD/ui/src/iaupdatemaincontainer.cpp
iaupdate/IAD/ui/src/iaupdatesession.cpp
iaupdate/IAD/ui/src/iaupdateuicontroller.cpp
installationservices/swi/inc/integrityservices.h
installationservices/swi/source/integrityservices/integrityservices.cpp
installationservices/swi/source/integrityservices/operationfunctions.cpp
installationservices/swi/source/integrityservices/operationfunctions.h
installationservices/swi/source/pkgremover/pkgremover.cpp
installationservices/swi/source/securitymanager/securitymanager.cpp
installationservices/swi/source/sisfile/swtypereginfo.cpp
installationservices/swi/source/sishelper/sishelper.cpp
installationservices/swi/source/sishelper/sishelperclient.cpp
installationservices/swi/source/sishelper/uissclienthandler.cpp
installationservices/swi/source/sishelper/uissclienthandler.h
installationservices/swi/source/sisregistry/client/sisregistryentry.cpp
installationservices/swi/source/sisregistry/client/sisregistrysession.cpp
installationservices/swi/source/sisregistry/common/sisregistryhelperclient.cpp
installationservices/swi/source/sisregistry/server_legacy/sisregistrycache.cpp
installationservices/swi/source/swis/server/adornedutilities.cpp
installationservices/swi/source/swis/server/planner.cpp
installationservices/swi/source/swis/server/sidcache.cpp
installationservices/swi/test/testexes/embed/cyclic_dependency_base.pkg
installationservices/swi/test/testexes/packages/cyclic_dependency_embedded.pkg
installationservices/swi/test/tuiscriptadaptors/scripts/tuiscriptadaptors.ini
installationservices/swi/test/tuiscriptadaptors/scripts/tuiscriptadaptors.script
installationservices/swi/test/tuiscriptadaptors/tswisserver.cpp
installationservices/swi/test/tuiscriptadaptors/tswisstep.cpp
installationservices/swi/test/tuiscriptadaptors/tswisstep.h
installationservices/swidevicetools/source/swicertstoretool/CSWICertStoreTool.cpp
secureswitools/swisistools/source/interpretsislib/expressionevaluator.cpp
secureswitools/swisistools/source/interpretsislib/expressionevaluator.h
secureswitools/swisistools/source/interpretsislib/installer.cpp
secureswitools/swisistools/source/interpretsislib/installer.h
secureswitools/swisistools/source/interpretsislib/sisfile.cpp
secureswitools/swisistools/source/interpretsislib/sisfile.h
--- a/appinstaller/AppMngr2/Sisx/src/appmngr2sisxappinfo.cpp	Tue Apr 27 16:46:15 2010 +0300
+++ b/appinstaller/AppMngr2/Sisx/src/appmngr2sisxappinfo.cpp	Tue May 11 16:20:28 2010 +0300
@@ -297,26 +297,39 @@
         DRM::CDrmUtility* utility = DRM::CDrmUtility::NewLC();
                                      
         for ( TInt fileIndex = 0; fileIndex < files.Count(); fileIndex++ )
-            {        
+            {  
+#ifdef _DEBUG        
+            HBufC* tempName = files[ fileIndex ]; 
+            FLOG( "CAppMngr2SisxAppInfo::ConstructL, File name: %S", tempName );
+#endif        
             RFile fileHandle;
             TInt error = fileHandle.Open( iFs, *files[ fileIndex ], EFileRead );
             FLOG( "CAppMngr2SisxAppInfo::ConstructL, File open error %d", 
                     error );
-            
+                       
             if ( error == KErrNone )
                 {                
-                CleanupClosePushL( fileHandle );
+                CleanupClosePushL( fileHandle );                
+                TInt err = KErrNone;
+                // We need to tarp this function since it may leave with some
+                // files which do not have enough data. If ConstrucL leaves
+                // package is not shown in UI.
+                TRAP( err, iIsDRMProtected = utility->IsProtectedL( fileHandle ) );
+           
+                if ( err )
+                    {
+                    // If we have leave let's handle this as not DRM procteded.
+                    iIsDRMProtected = EFalse;
+                    FLOG( "CAppMngr2SisxAppInfo, IsProtectedL error: %d", err );
+                    }
                 
-                iIsDRMProtected = utility->IsProtectedL( fileHandle );
-            
                 CleanupStack::PopAndDestroy( &fileHandle ); 
                 
                 if ( iIsDRMProtected )
-                    {                       
-                    HBufC* fileName = files[ fileIndex ];                            
-                    FLOG( "CAppMngr2SisxAppInfo::ConstructL, iProtectedFile %S", 
-                            fileName );
-                    
+                    { 
+                    FLOG( "CAppMngr2SisxAppInfo: File is DRM protected" );
+                
+                    HBufC* fileName = files[ fileIndex ];                                                
                     iProtectedFile = fileName;  // takes ownership
                     files.Remove( fileIndex );                    
                     
@@ -327,7 +340,7 @@
                     CDRMHelperRightsConstraints* printconst = NULL;            
                     TBool sendingallowed = EFalse;
                                     
-                    FLOG( "CAppMngr2SisxAppInfo::ConstructL: GetRightsDetailsL" );
+                    FLOG( "CAppMngr2SisxAppInfo: GetRightsDetailsL" );
                     error = KErrNone;
                     TRAP( error, helper->GetRightsDetailsL( *fileName, 
                                                 ContentAccess::EView, 
--- a/appinstaller/AppMngr2/group/appmngr2.mmp	Tue Apr 27 16:46:15 2010 +0300
+++ b/appinstaller/AppMngr2/group/appmngr2.mmp	Tue May 11 16:20:28 2010 +0300
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2003-2010 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of "Eclipse Public License v1.0"
@@ -20,6 +20,7 @@
 #include <data_caging_paths.hrh>
 
 TARGET              appmngr2.exe
+EPOCHEAPSIZE        0x1000 0x200000     // min 4kB (default), max 2MB (2*default)
 EPOCSTACKSIZE       0x5000
 TARGETTYPE          exe
 UID                 0x100039CE 0x101F8512
--- a/iaupdate/IAD/loc/iaupdate.loc	Tue Apr 27 16:46:15 2010 +0300
+++ b/iaupdate/IAD/loc/iaupdate.loc	Tue May 11 16:20:28 2010 +0300
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of "Eclipse Public License v1.0"
@@ -304,6 +304,11 @@
 // l: None
 #define qtn_swupdate_main_device_fw "DEVICE SOFTWARE" 
 
+// d: Second row in double graphic style list
+// d: Firmware update with PC
+// l: list_double_graphic_pane_t2
+#define qtn_swupdate_update_with_pc "Use your PC to update"
+
 
 //HISTORY VIEW LIST
 
--- a/iaupdate/IAD/ui/group/iaupdate.rss	Tue Apr 27 16:46:15 2010 +0300
+++ b/iaupdate/IAD/ui/group/iaupdate.rss	Tue May 11 16:20:28 2010 +0300
@@ -157,6 +157,11 @@
     {
     buf = qtn_swupdate_normal_update_mb;
     }
+
+RESOURCE TBUF r_iaupdate_update_with_pc
+    {
+    buf = qtn_swupdate_update_with_pc;
+    }
     
 RESOURCE TBUF r_iaupdate_text_no_updates    
     {    
--- a/iaupdate/IAD/ui/inc/iaupdateagreement.h	Tue Apr 27 16:46:15 2010 +0300
+++ b/iaupdate/IAD/ui/inc/iaupdateagreement.h	Tue May 11 16:20:28 2010 +0300
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of "Eclipse Public License v1.0"
@@ -74,6 +74,8 @@
     * @return True value if agreement accepted 
     */
     TBool AgreementAcceptedL();
+    
+    void SetAgreementAcceptedL();
 
 private:
 
--- a/iaupdate/IAD/ui/inc/iaupdateappui.h	Tue Apr 27 16:46:15 2010 +0300
+++ b/iaupdate/IAD/ui/inc/iaupdateappui.h	Tue May 11 16:20:28 2010 +0300
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of "Eclipse Public License v1.0"
@@ -85,7 +85,8 @@
      * are filtered for the UI list.
      */
     void CheckUpdatesRequestL( MIAUpdateRequestObserver& aObserver,
-                               CIAUpdateParameters* aFilterParams );
+                               CIAUpdateParameters* aFilterParams,
+                               TBool aForcedRefresh );
 
     /**
      * When the show update operation is started through
--- a/iaupdate/IAD/ui/inc/iaupdateuicontroller.h	Tue Apr 27 16:46:15 2010 +0300
+++ b/iaupdate/IAD/ui/inc/iaupdateuicontroller.h	Tue May 11 16:20:28 2010 +0300
@@ -230,7 +230,10 @@
     * Ownership is not transferred.
     */
     CIAUpdateParameters* ParamsReadAndRemoveFileL();
-        
+    
+    TBool ForcedRefresh() const;
+      
+    void SetForcedRefresh( TBool aForcedRefresh );
     /**
      * Is client role "testing"
      *
@@ -596,6 +599,8 @@
     TBool iRefreshFromNetworkDenied; 
     
     TBool iOffConfigurated;
+    
+    TBool iForcedRefresh;
         
     TBool iTestRole;
 
--- a/iaupdate/IAD/ui/src/iaupdateagreement.cpp	Tue Apr 27 16:46:15 2010 +0300
+++ b/iaupdate/IAD/ui/src/iaupdateagreement.cpp	Tue May 11 16:20:28 2010 +0300
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of "Eclipse Public License v1.0"
@@ -121,6 +121,22 @@
     }
 
 // ---------------------------------------------------------------------------
+// CIAUpdateAgreement::SetAgreementAcceptedL
+// 
+// ---------------------------------------------------------------------------
+//
+void CIAUpdateAgreement::SetAgreementAcceptedL()
+    {
+    CIAUpdateFirstTimeInfo* firstTimeInfo = CIAUpdateFirstTimeInfo::NewLC();
+    firstTimeInfo->SetAgreementAcceptedL();
+    CleanupStack::PopAndDestroy( firstTimeInfo );
+    }
+
+
+
+
+
+// ---------------------------------------------------------------------------
 // CIAUpdateAgreement::ShowAgreementL
 // 
 // ---------------------------------------------------------------------------
--- a/iaupdate/IAD/ui/src/iaupdateappui.cpp	Tue Apr 27 16:46:15 2010 +0300
+++ b/iaupdate/IAD/ui/src/iaupdateappui.cpp	Tue May 11 16:20:28 2010 +0300
@@ -65,6 +65,7 @@
 #include "iaupdategloballockhandler.h"
 #include "iaupdatenodefilter.h"
 #include "iaupdateuitimer.h"
+#include "iaupdateagreement.h"
 #include "iaupdatedebug.h"
 
 
@@ -164,7 +165,8 @@
 // -----------------------------------------------------------------------------
 //
 void CIAUpdateAppUi::CheckUpdatesRequestL( MIAUpdateRequestObserver& aObserver,
-                                           CIAUpdateParameters* aFilterParams )
+                                           CIAUpdateParameters* aFilterParams,
+                                           TBool aForcedRefresh )
                                            
     {
     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateAppUi::CheckUpdatesRequestL() begin");
@@ -184,7 +186,8 @@
     iRequestObserver = &aObserver;
     iRequestType = IAUpdateUiDefines::ECheckUpdates; 
     iController->SetRequestType( iRequestType );
-    
+    IAUPDATE_TRACE_1("[IAUPDATE] CIAUpdateAppUi::CheckUpdatesRequestL() Forced refresh: %d", aForcedRefresh );
+    iController->SetForcedRefresh( aForcedRefresh ); 
     iController->CheckUpdatesDeferredL( aFilterParams, EFalse );
     
 	IAUPDATE_TRACE("[IAUPDATE] CIAUpdateAppUi::CheckUpdatesRequestL() end");
@@ -593,8 +596,11 @@
                     {
                     if ( iController->Filter()->FilterParams()->Refresh() )
                         {
-                        //from bgchecker, make it silent
-                        totalSilent = ETrue;
+                        if ( !iController->ForcedRefresh() )
+                            {
+                            //from bgchecker, make it silent
+                            totalSilent = ETrue;
+                            }
                         }
                     }
                 }
@@ -683,7 +689,16 @@
             {
         	ActivateLocalViewL( TUid::Uid( EIAUpdateMainViewId ) );
             }
- 
+        CIAUpdateAgreement* agreement = CIAUpdateAgreement::NewLC();
+        TBool agreementAccepted = agreement->AgreementAcceptedL();
+        if ( iController->ForcedRefresh() )    
+            {
+            if ( !agreementAccepted )
+                {
+                agreement->SetAgreementAcceptedL();
+                }
+            }
+        CleanupStack::PopAndDestroy( agreement );
         // By calling CIdle possible waiting dialog can be closed before
         // automatic check where a new dialog may be launched
         delete iIdleAutCheck;
@@ -974,13 +989,6 @@
                //the bgchecker will try again later after 1 month. 
                //The LEAVE will be catched up later and complete the request from background checker.
                User::LeaveIfError( KErrNotFound );
-               
-               //the following code will pop up dialog to ask from user, just for proto
-              /* connectionMethodId = 0;               
-               TIAUpdateConnectionMethod connectionMethod( 
-                   connectionMethodId, TIAUpdateConnectionMethod::EConnectionMethodTypeDefault );
-
-               iController->SetDefaultConnectionMethodL( connectionMethod );*/
                }
            
 
--- a/iaupdate/IAD/ui/src/iaupdatehistorycontainer.cpp	Tue Apr 27 16:46:15 2010 +0300
+++ b/iaupdate/IAD/ui/src/iaupdatehistorycontainer.cpp	Tue May 11 16:20:28 2010 +0300
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2007-2008 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of "Eclipse Public License v1.0"
@@ -124,6 +124,7 @@
     iListBox->ConstructFromResourceL( reader );
     CleanupStack::PopAndDestroy();
 
+    iListBox->EnableStretching( EFalse );
     iListBox->ItemDrawer()->ColumnData()->EnableMarqueeL( ETrue );
 
     // Setup scroll bars
--- a/iaupdate/IAD/ui/src/iaupdatemaincontainer.cpp	Tue Apr 27 16:46:15 2010 +0300
+++ b/iaupdate/IAD/ui/src/iaupdatemaincontainer.cpp	Tue May 11 16:20:28 2010 +0300
@@ -343,9 +343,15 @@
                     }
                 }
 
-            if ( !size || isNSU )
+            if ( isNSU )
                 {
-                //for firmware when size info is not provided by server
+                //for NSU firmware 
+                importanceDescription = StringLoader::LoadLC(
+                                       R_IAUPDATE_UPDATE_WITH_PC );
+                }
+            else if ( size == 0 )
+                {
+                //for FOTA firmware when size info is not provided by server
                 importanceDescription = StringLoader::LoadLC(
                                                        R_IAUPDATE_DES_CRITICAL_UPDATE_NO_SIZE );
                 }
--- a/iaupdate/IAD/ui/src/iaupdatesession.cpp	Tue Apr 27 16:46:15 2010 +0300
+++ b/iaupdate/IAD/ui/src/iaupdatesession.cpp	Tue May 11 16:20:28 2010 +0300
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of "Eclipse Public License v1.0"
@@ -36,6 +36,7 @@
 
 // CONSTANTS
 const TSecureId KSIDBackgroundChecker = 0x200211f4;
+const TSecureId KSIDCwrtWidget = 0x200267C0;
 const TSecureId KSIDLauncher = KIAUpdateLauncherUid;
 // ============================ MEMBER FUNCTIONS ===============================
 
@@ -323,7 +324,7 @@
         CleanupStack::Pop( params );
         CleanupStack::PopAndDestroy( data );
         
-        if ( aMessage.SecureId() != KSIDBackgroundChecker )      
+        if ( ( aMessage.SecureId() != KSIDBackgroundChecker ) && ( aMessage.SecureId() != KSIDCwrtWidget ) )      
             {
             // other processes than backroundchecker are not allowed to cause refresh from network 
             params->SetRefresh( EFalse );
@@ -331,7 +332,7 @@
         switch( functionId )
             {
             case IAUpdateClientDefines::EIAUpdateServerCheckUpdates:
-                appUi->CheckUpdatesRequestL( *this, params );
+                appUi->CheckUpdatesRequestL( *this, params, params->Refresh() && aMessage.SecureId() == KSIDCwrtWidget );
                 break;
 
             case IAUpdateClientDefines::EIAUpdateServerShowUpdates:
--- a/iaupdate/IAD/ui/src/iaupdateuicontroller.cpp	Tue Apr 27 16:46:15 2010 +0300
+++ b/iaupdate/IAD/ui/src/iaupdateuicontroller.cpp	Tue May 11 16:20:28 2010 +0300
@@ -323,20 +323,22 @@
         }
      
     TBool agreementAccepted( EFalse ); 
-    CIAUpdateAgreement* agreement = CIAUpdateAgreement::NewLC();
-    agreementAccepted = agreement->AgreementAcceptedL();
-    if ( ( !agreementAccepted )&& ( iRequestType != IAUpdateUiDefines::ECheckUpdates ) )
+    if ( !ForcedRefresh() )
         {
-        // agreement (disclaimer) dialog is not prompted when CheckUpdates is called
-        //
-        // Refresh from network is allowed when first time case 
-        iRefreshFromNetworkDenied = EFalse;
-    	agreementAccepted = agreement->AcceptAgreementL();	
+        CIAUpdateAgreement* agreement = CIAUpdateAgreement::NewLC();
+        agreementAccepted = agreement->AgreementAcceptedL();
+        if ( ( !agreementAccepted )&& ( iRequestType != IAUpdateUiDefines::ECheckUpdates ) )
+            {
+            // agreement (disclaimer) dialog is not prompted when CheckUpdates is called
+            //
+            // Refresh from network is allowed when first time case 
+            iRefreshFromNetworkDenied = EFalse;
+            agreementAccepted = agreement->AcceptAgreementL();  
+            }
+        CleanupStack::PopAndDestroy( agreement );
         }
-        	
-    CleanupStack::PopAndDestroy( agreement );
-             
-    if ( !agreementAccepted )
+  	             
+    if ( !agreementAccepted && !ForcedRefresh() )
         {
         if ( iRequestType == IAUpdateUiDefines::ECheckUpdates )
             {
@@ -2290,25 +2292,32 @@
     	        {
     	    	if ( params->Refresh() )
     	    	    {
-      	      		// Check from the central repocitory what are the automatic checking and 
-                    // roaming settings.     
-                    TInt autoUpdateCheckValue( 0 );
-                    CRepository* cenrep( 
+    	    	    if ( ForcedRefresh() )
+    	    	        {
+    	    	        allowRefresh = ETrue;
+    	    	        }
+    	    	    else
+    	    	        {
+      	      		    // Check from the central repocitory what are the automatic checking and 
+                        // roaming settings.     
+                        TInt autoUpdateCheckValue( 0 );
+                        CRepository* cenrep( 
                              CRepository::NewLC( KCRUidIAUpdateSettings ) );
-                    // Notice, that KIAUpdateSettingAutoUpdateCheck can give following values
-                    // 0 = No automatic update check
-                    // 1 = Automatic update check enabled when not roaming
-                    // 2 = Automatic update enabled
+                        // Notice, that KIAUpdateSettingAutoUpdateCheck can give following values
+                        // 0 = No automatic update check
+                        // 1 = Automatic update check enabled when not roaming
+                        // 2 = Automatic update enabled
 
-                    User::LeaveIfError( cenrep->Get( KIAUpdateAutoUpdateCheck, 
-                                                     autoUpdateCheckValue ) );
-                    CleanupStack::PopAndDestroy( cenrep );
-                    if ( ( autoUpdateCheckValue == EIAUpdateSettingValueEnable ) || 
-    	               ( autoUpdateCheckValue == EIAUpdateSettingValueDisableWhenRoaming &&
-    	                 !iRoamingHandler->IsRoaming() ) )
-                        {
-                    	allowRefresh = ETrue;
-                        }
+                        User::LeaveIfError( cenrep->Get( KIAUpdateAutoUpdateCheck, 
+                                                         autoUpdateCheckValue ) );
+                        CleanupStack::PopAndDestroy( cenrep );
+                        if ( ( autoUpdateCheckValue == EIAUpdateSettingValueEnable ) || 
+    	                    ( autoUpdateCheckValue == EIAUpdateSettingValueDisableWhenRoaming &&
+    	                      !iRoamingHandler->IsRoaming() ) )
+                            {
+                    	    allowRefresh = ETrue;
+                            }
+    	    	        }
      	    	    }
     	        }
     	    }
@@ -2626,6 +2635,26 @@
     return params;
     }
 
+// ---------------------------------------------------------------------------
+// CIAUpdateUiController::ForcedRefresh
+// 
+// ---------------------------------------------------------------------------
+//
+TBool CIAUpdateUiController::ForcedRefresh() const
+    {
+    return iForcedRefresh;
+    }
+
+
+// ---------------------------------------------------------------------------
+// CIAUpdateUiController::SetForcedRefresh
+// 
+// ---------------------------------------------------------------------------
+//
+void CIAUpdateUiController::SetForcedRefresh( TBool aForcedRefresh )
+    {
+    iForcedRefresh = aForcedRefresh;
+    }
 
 // ---------------------------------------------------------------------------
 // CIAUpdateUiController::ParamsWriteFileL
--- a/installationservices/swi/inc/integrityservices.h	Tue Apr 27 16:46:15 2010 +0300
+++ b/installationservices/swi/inc/integrityservices.h	Tue May 11 16:20:28 2010 +0300
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2004-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"
@@ -275,13 +275,6 @@
 		 */
 		static void NormalizeDirectoryName(TDes& aFileName);
 		
-		/**
-		Creates a backup file by copying the source to a defined backup name. This MUST be used for executables.
-		The source files will then be deleted by invoking RLoader::Delete
-		@param aSource	the file to backup
-		@param aBackup	the name of the backup file
-		*/
-		void CopyToBackupL(const TDesC& aSource, const TDesC& aBackup);
 
 	private:
 	
--- a/installationservices/swi/source/integrityservices/integrityservices.cpp	Tue Apr 27 16:46:15 2010 +0300
+++ b/installationservices/swi/source/integrityservices/integrityservices.cpp	Tue May 11 16:20:28 2010 +0300
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2004-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"
@@ -138,41 +138,6 @@
 	CleanupStack::PopAndDestroy(localFilenameHeap);
 	}
 
-void CIntegrityServices::CopyToBackupL(const TDesC& aSource, const TDesC& aBackup)
-	{
-	// Copying a file isn't atomic so we create a temporary backup file first
-	RBuf backupTmpName;
-	backupTmpName.Create(aBackup.Length() + 4);
-	CleanupClosePushL(backupTmpName);
-	backupTmpName.Copy(aBackup);
-	_LIT(KTmpExt, ".tmp");
-	backupTmpName.Append(KTmpExt);
-	
-	// Copying a file is not an atomic operation so add the temporary
-	// file to the journal to enable cleanup if a power failure occurs before
-	// the rename
-	SimulatePowerFailureL(EFailAddingTempFile, EBeforeJournal, backupTmpName);
-	iJournal->TemporaryL(backupTmpName);
-	SimulatePowerFailureL(EFailAddingTempFile, EAfterJournal, backupTmpName);	
-		
-	CFileMan* fileMan = CFileMan::NewL(iFs);
-	CleanupStack::PushL(fileMan);
-		
-	TInt err = fileMan->Copy(aSource, backupTmpName);
-	DEBUG_PRINTF4(_L("CopyToBackupL: Copying %S to %S, err %d"), &aSource, &backupTmpName, err);
-	User::LeaveIfError(err);
-	
-	// Backup is complete, use RFs::Rename as atomic 'commit' of backup
-	err = iFs.Rename(backupTmpName, aBackup);			
-	DEBUG_PRINTF2(_L("CopyToBackupL: Commit backup returned error %d"), err);	
-	User::LeaveIfError(err);	
-	CleanupStack::PopAndDestroy(2, &backupTmpName); // backupTmpName, fileMan 
-	
-	//  Now the backup is safe the original can be deleted
-	err = iLoader.Delete(aSource);
-	DEBUG_PRINTF3(_L("CopyToBackupL: RLoader::Delete %S returned error %d"), &aSource, err);
-	User::LeaveIfError(err);
-	}
 	
 EXPORT_C void CIntegrityServices::RemoveL(const TDesC& aFileName)
 	{
@@ -213,20 +178,11 @@
 			}
 
 		SimulatePowerFailureL(EFailRemovingFile, EBeforeAction, aFileName);
-		
-		_LIT(KSysBinMatch, "?:\\sys\\bin\\*");
-		if (localFilename.MatchF(KSysBinMatch) == 0)
-			{
-			// A copy is slower than a rename to only use the 
-			// demand paging safe API for files in sys\bin
-			CopyToBackupL(localFilename, backupFileName);			
-			}
-		else
-			{
-			err = iFs.Rename(localFilename, backupFileName);
-			DEBUG_PRINTF4(_L("Renamed %S as %S error %d"), &localFilename, &backupFileName, err);
-			User::LeaveIfError(err);
-			}				
+
+		err = iFs.Rename(localFilename, backupFileName);
+		DEBUG_PRINTF4(_L("Renamed %S as %S error %d"), &localFilename, &backupFileName, err);
+		User::LeaveIfError(err);				
+
 		SimulatePowerFailureL(EFailRemovingFile, EAfterAction, aFileName);
 		}
 	else
--- a/installationservices/swi/source/integrityservices/operationfunctions.cpp	Tue Apr 27 16:46:15 2010 +0300
+++ b/installationservices/swi/source/integrityservices/operationfunctions.cpp	Tue May 11 16:20:28 2010 +0300
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2006-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"
@@ -29,9 +29,15 @@
 
 using namespace Swi;
 
+TBool IsBinary(const TEntry& aEntry)
+    {
+    return (aEntry[0].iUid == KExecutableImageUidValue || aEntry[0].iUid == KDynamicLibraryUidValue) ? ETrue : EFalse;
+    }
+
 void Swi::IntegrityDeleteFileL(const TDesC& aPath, CIntegrityTreeLeaf* aLeaf, RFs& aFs, 
 							   RLoader& aLoader, CFileMan& aFileMan)
 	{
+    _LIT(KSysBin, "\\sys\\bin");
 	RBuf name;
 	name.CreateL(aPath, KMaxFileName);
 	CleanupClosePushL(name);
@@ -56,9 +62,42 @@
 			}
 		else
 			{			
-			TInt err = aLoader.Delete(name);
-			DEBUG_PRINTF3(_L("Integrity Services - Delete File %S err = %d"), &name, err);
-			User::LeaveIfError(err);
+            if ( aLeaf->Type() == EBackupFile ) // Implies a commit operation is in progress
+                {
+                
+                 if ( IsBinary(entry) )
+                     {
+                     // Forming the file name so the renamed file can be under sys/bin
+					 // for special delete mechanism using RLoader::Delete
+                     RBuf tmpName;
+                     TParsePtrC fileName(name);
+                     tmpName.CreateL(name.Length() + KSysBin.iTypeLength);
+                     CleanupClosePushL(tmpName);
+
+                     tmpName.Append(fileName.Drive());
+                     tmpName.Append(KSysBin);
+                     tmpName.Append(fileName.Path());
+                     tmpName.Append(fileName.NameAndExt());
+
+					 DEBUG_PRINTF3(_L("Integrity Services - Renaming %S to %S"), &name, &tmpName);
+                     aFileMan.Rename(name,tmpName,CFileMan::EOverWrite);
+                     User::LeaveIfError(aLoader.Delete(tmpName)); // Using RLoader delete for paged binaries
+					 DEBUG_PRINTF2(_L("Integrity Services - Deleted renamed file %S"), &tmpName);
+
+					 // prune the directory tree if possible
+                     RemoveDirectoryTreeL(aFs, tmpName);
+                     CleanupStack::PopAndDestroy(&tmpName);
+                     }
+                 else
+                     {
+                     User::LeaveIfError(aFileMan.Delete(name));
+                     }
+                }
+            else
+                {
+				// Need to use RLoader Delete which can be used during deletion of Added files during Rollback
+                User::LeaveIfError(aLoader.Delete(name));
+                }
 			}
 			
 		// prune the directory tree if possible
@@ -69,6 +108,29 @@
 		DEBUG_PRINTF3(_L("Integrity Services - error %d removing %S"), err, &name);
 		User::Leave(err);
 		}
+	else
+	    {
+
+		DEBUG_PRINTF3(_L("Integrity Services - error %d removing %S"), err, &name);
+
+	    // Check for any renamed files to move it to sys/bin for special delete mechanism
+	    RBuf tmpName;
+	    TParsePtrC fileName(name);
+	    tmpName.CreateL(name.Length() + KSysBin.iTypeLength);
+	    CleanupClosePushL(tmpName);
+
+	    tmpName.Append(fileName.Drive());
+	    tmpName.Append(KSysBin);
+	    tmpName.Append(fileName.Path());
+	    tmpName.Append(fileName.NameAndExt());
+		DEBUG_PRINTF2(_L("Integrity Services - Removing  %S renamed binary files if any"), &tmpName);
+
+	    aLoader.Delete(tmpName);
+		// prune the directory tree if possible
+	    RemoveDirectoryTreeL(aFs, tmpName);
+	    CleanupStack::PopAndDestroy(&tmpName);
+	    }
+
 	CleanupStack::PopAndDestroy(&name);
 	}
 
--- a/installationservices/swi/source/integrityservices/operationfunctions.h	Tue Apr 27 16:46:15 2010 +0300
+++ b/installationservices/swi/source/integrityservices/operationfunctions.h	Tue May 11 16:20:28 2010 +0300
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2006-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"
@@ -28,6 +28,7 @@
 #include <e32base.h>
 #include <f32file.h>
 #include <e32ldr_private.h>
+#include <e32uid.h>
 
 namespace Swi
 {
--- a/installationservices/swi/source/pkgremover/pkgremover.cpp	Tue Apr 27 16:46:15 2010 +0300
+++ b/installationservices/swi/source/pkgremover/pkgremover.cpp	Tue May 11 16:20:28 2010 +0300
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2007-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"
@@ -25,6 +25,7 @@
 #include "installclientserver.h"
 #include <swi/pkgremover.h>
 #include <connect/sbdefs.h>
+#include "cleanuputils.h"
 
 // Maximum buffer size
 const TInt KMaxBufferSize = 1024;
@@ -43,6 +44,7 @@
 /*static*/
 EXPORT_C void UninstalledSisPackages::ListL(TDriveNumber aDrive, RPointerArray<CUninstalledPackageEntry>& aPackageList)
 	{
+	CleanupResetAndDestroyPushL(aPackageList);
 	aPackageList.ResetAndDestroy();
 
 	// Check if SWIS is busy
@@ -150,6 +152,7 @@
 
 	// Shutdown InstallServer and SisHelper
 	CleanupStack::PopAndDestroy(2, &server);
+	CleanupStack::Pop(&aPackageList);
 	}
 
 /*static*/
--- a/installationservices/swi/source/securitymanager/securitymanager.cpp	Tue Apr 27 16:46:15 2010 +0300
+++ b/installationservices/swi/source/securitymanager/securitymanager.cpp	Tue May 11 16:20:28 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"
@@ -41,7 +41,7 @@
 #include "hashcontainer.h"
 #include "certchainconstraints.h"
 #include "devinfosupportclient.h"
-
+#include "cleanuputils.h"
 #include "log.h"
 
 // PKIX dependencies
@@ -711,6 +711,7 @@
 											 RPointerArray<CX509Certificate>& aCertOut,
 											 TRequestStatus& aStatus)
 	{	
+	CleanupResetAndDestroyPushL(aCertOut);
 	Cancel();
 	
 	DEBUG_PRINTF2(_L8("Security Manager - Performing OCSP with revocation server at %S."),
@@ -727,7 +728,7 @@
  		aCertOut.AppendL(certOut);
  		CleanupStack::Pop(certOut);
  		}
- 		
+ 	
  	DEBUG_PRINTF2(_L8("Security Manager - Validating %d certificate chains for this controller."), numChains);
 
 	iClientStatus = &aStatus;
@@ -748,6 +749,7 @@
 	
 	iRevocationHandler->SendRequestL(iValidPkixChains, aIap, iStatus);
 	
+	CleanupStack::Pop(&aCertOut);
 	SetActive();
 	}
 
@@ -1144,6 +1146,7 @@
 	const Sis::CController& aController,
 	RPointerArray<CX509Certificate>& aCerts)
 	{
+	CleanupResetAndDestroyPushL(aCerts);
 	// Go through all SIS chains and extract end certificates from them.
 	const RPointerArray<Sis::CSignatureCertificateChain>& chains=
 		aController.SignatureCertificateChains();
@@ -1165,6 +1168,7 @@
 		// Cleanup.
 		CleanupStack::PopAndDestroy(pkixChain);
 		}
+	CleanupStack::Pop(&aCerts);
 	}
 
 EXPORT_C void CSecurityManager::FillCertInfoArrayL(
--- a/installationservices/swi/source/sisfile/swtypereginfo.cpp	Tue Apr 27 16:46:15 2010 +0300
+++ b/installationservices/swi/source/sisfile/swtypereginfo.cpp	Tue May 11 16:20:28 2010 +0300
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2008-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"
@@ -230,6 +230,7 @@
 
 EXPORT_C void SoftwareTypeRegInfoUtils::UnserializeArrayL(RReadStream& aStream, RPointerArray<CSoftwareTypeRegInfo>& aSwTypeRegInfoArray)
 	{
+	CleanupResetAndDestroyPushL(aSwTypeRegInfoArray);
 	const TInt numElems = aStream.ReadInt32L();
 	for (TInt i=0; i<numElems; ++i)
 		{
@@ -238,6 +239,7 @@
 		aSwTypeRegInfoArray.AppendL(info);
 		CleanupStack::Pop(info);
 		}
+	CleanupStack::Pop(&aSwTypeRegInfoArray);
 	}
 
 EXPORT_C void SoftwareTypeRegInfoUtils::SerializeUniqueSwTypeNamesL(const RPointerArray<CSoftwareTypeRegInfo>& aSwTypeRegInfoArray, RBuf& aSerializedNames)
@@ -263,6 +265,7 @@
 
 EXPORT_C void SoftwareTypeRegInfoUtils::UnserializeUniqueSwTypeNamesL(const TDesC& aSerializedNames, RArray<TPtrC>& aUniqueSwTypeNames)
 	{
+	CleanupClosePushL(aUniqueSwTypeNames);
 	TPtrC buf(aSerializedNames);
 	for (;;)
 		{
@@ -281,6 +284,7 @@
 			break;
 			}
 		}
+	CleanupStack::Pop(&aUniqueSwTypeNames);
 	}
 
 EXPORT_C void SoftwareTypeRegInfoUtils::ExtractMimeTypesL(const RPointerArray<CSoftwareTypeRegInfo>& aSwTypeRegInfoArray, RPointerArray<HBufC8>& aMimeTypes)
--- a/installationservices/swi/source/sishelper/sishelper.cpp	Tue Apr 27 16:46:15 2010 +0300
+++ b/installationservices/swi/source/sishelper/sishelper.cpp	Tue May 11 16:20:28 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"
@@ -511,6 +511,8 @@
 void CSisHelperSession::FillDrivesAndSpacesL(RArray<TChar>& aDriveLetters, 
 					                        RArray<TInt64>& aDriveSpaces)
 	{
+	CleanupClosePushL(aDriveLetters);
+	CleanupClosePushL(aDriveSpaces);
 	// This is the LFSS free space threshold
 	TInt freeSpaceAdjustment = 1024 * 128;    // Bytes	
 
@@ -566,6 +568,7 @@
         User::LeaveIfError(aDriveSpaces.Append(volSpace));
         }
     CleanupStack::PopAndDestroy(&fs);
+    CleanupStack::Pop(2, &aDriveLetters);
 	}
 
 
--- a/installationservices/swi/source/sishelper/sishelperclient.cpp	Tue Apr 27 16:46:15 2010 +0300
+++ b/installationservices/swi/source/sishelper/sishelperclient.cpp	Tue May 11 16:20:28 2010 +0300
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2004-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"
@@ -104,6 +104,9 @@
 EXPORT_C void RSisHelper::FillDrivesAndSpacesL(RArray<TChar>& aDriveLetters, 
 	RArray<TInt64>& aDriveSpaces)
 	{
+	CleanupClosePushL(aDriveLetters);
+	CleanupClosePushL(aDriveSpaces);
+	
 	// calculate the likely size of the data transfer buffer
 	const TInt KMaxBufSize=
 		sizeof(TInt)+                 // number of entries
@@ -143,6 +146,7 @@
 	
 	// cleanup
 	CleanupStack::PopAndDestroy(2, buf); // ins, buf
+	CleanupStack::Pop(2, &aDriveLetters);
 	}
 
 EXPORT_C void RSisHelper::OpenDrmContentL(ContentAccess::TIntent aIntent)
@@ -264,6 +268,7 @@
 #endif
 void RSisHelper::GetEquivalentLanguageListL(TLanguage aLangId,RArray<TLanguage>& aEquivLangs)
 	{
+	CleanupClosePushL(aEquivLangs);
 	// calculate the likely size of the data transfer buffer
 	const TInt KMaxBufSize=
 		sizeof(TInt)+                 // number of entries
@@ -291,4 +296,5 @@
 		}
 	// cleanup
 	CleanupStack::PopAndDestroy(2, buf); // buf
+	CleanupStack::Pop(&aEquivLangs);
 	}
--- a/installationservices/swi/source/sishelper/uissclienthandler.cpp	Tue Apr 27 16:46:15 2010 +0300
+++ b/installationservices/swi/source/sishelper/uissclienthandler.cpp	Tue May 11 16:20:28 2010 +0300
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2004-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"
@@ -51,130 +51,140 @@
 #include "commands/textdialog.h"
 #include "log.h"
 
+#include "cleanuputils.h"
 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK
-#include "cleanuputils.h"
 #include <usif/sif/sifcommon.h>
 const TInt KCompInfoBufferSize=4*1024;
 #endif
 
+
+
 namespace Swi
 {
+
+//Temporary error logging solution.
+void LogSwiErrorsToFileL(TInt aErrorCode, const TDesC& aAppName);
+
 //
 // A cancel handler
 //
 class InternalCancelHandler : public MCancelHandler
-	{
+    {
 public:
-	InternalCancelHandler(CUissClientHandler& aUissClientHandler);
-	void HandleCancel();
+    InternalCancelHandler(CUissClientHandler& aUissClientHandler);
+    void HandleCancel();
 private:
-	CUissClientHandler& iUissClientHandler;
-	};
+    CUissClientHandler& iUissClientHandler;
+    };
 
 InternalCancelHandler::InternalCancelHandler(
-	CUissClientHandler& aUissClientHandler)
-:	iUissClientHandler(aUissClientHandler)
-	{
-	}
+    CUissClientHandler& aUissClientHandler)
+:   iUissClientHandler(aUissClientHandler)
+    {
+    }
 
 void InternalCancelHandler::HandleCancel()
-	{
-	iUissClientHandler.CancelOperation();
-	}
+    {
+    iUissClientHandler.CancelOperation();
+    }
 
 CUissClientHandler* CUissClientHandler::NewLC(MUiHandler& aUiHandler, TBool aActiveObjectMode)
-	{
-	CUissClientHandler* self=new(ELeave) CUissClientHandler(aUiHandler, aActiveObjectMode);
-	CleanupStack::PushL(self);
-	self->ConstructL();
-	return self;
-	}
+    {
+    CUissClientHandler* self=new(ELeave) CUissClientHandler(aUiHandler, aActiveObjectMode);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    return self;
+    }
 
 CUissClientHandler* CUissClientHandler::NewL(MUiHandler& aUiHandler, TBool aActiveObjectMode)
-	{
-	CUissClientHandler* self=NewLC(aUiHandler, aActiveObjectMode);
-	CleanupStack::Pop(self);
-	return self;
-	}
+    {
+    CUissClientHandler* self=NewLC(aUiHandler, aActiveObjectMode);
+    CleanupStack::Pop(self);
+    return self;
+    }
 
 CUissClientHandler::CUissClientHandler(MUiHandler& aUiHandler, TBool aActiveObjectMode)
         : CActive(EPriorityStandard),
           iUiHandler(aUiHandler),
-		  iPtrIntoBuf(0,0),
+          iPtrIntoBuf(0,0),
           iActiveObjectMode(aActiveObjectMode),
-		  iPtrIntoArgsStream(0,0)
-		  #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK
-		  ,iCompInfoBufPtr(0,0)
-		  #endif
-	{
+          iPtrIntoArgsStream(0,0)
+          #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK
+          ,iCompInfoBufPtr(0,0)
+          #endif
+    {
     if (iActiveObjectMode)
-		{
-		CActiveScheduler::Add(this);
-		}
-	}
+        {
+        CActiveScheduler::Add(this);
+        }
+    }
 
 void CUissClientHandler::WaitForSisHelperShutdown()
-	{	
-	if(iSisHelper.Handle() > 0)
-		{
-		TRequestStatus reqStatus;
-		iSisHelper.Logon(reqStatus);
-		User::WaitForRequest(reqStatus);
-		iSisHelper.Close();
-		}		
-	}
-	
+    {   
+    if(iSisHelper.Handle() > 0)
+        {
+        TRequestStatus reqStatus;
+        iSisHelper.Logon(reqStatus);
+        User::WaitForRequest(reqStatus);
+        iSisHelper.Close();
+        }       
+    }
+    
 CUissClientHandler::~CUissClientHandler()
-	{
-	//Cancel any outstanding request
-	CancelOperation();
+    {
+    //Cancel any outstanding request
+    CancelOperation();
 
-	WaitForSisHelperShutdown();
+    WaitForSisHelperShutdown();
     if (iActiveObjectMode)
-		{
-		CActive::Cancel(); // Make sure we are cancelled before deletion
-		}
+        {
+        CActive::Cancel(); // Make sure we are cancelled before deletion
+        }
 
-	delete iCancelHandler;
+    delete iCancelHandler;
     delete iArgsStream;
-	iUissSession.Close();
-	delete iBuf;
-	#ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK
+    iUissSession.Close();
+    delete iBuf;
+    delete iBufLogger;
+    #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK
     delete iCompInfoBuffer;
-	#endif
-	}
+    #endif
+    }
 
 /**
  * Allocates a buffer for reverse-completion commands. The buffer is going to 
  * be resized in case it is not sufficient for a dialog command.
  */
 void CUissClientHandler::ConstructL()
-	{
-	iCancelHandler=new(ELeave) InternalCancelHandler(*this);
-	AllocBufL(KBufSize);// Allocate the initial r/c buffer
-	User::LeaveIfError(StartUiss()); // Start UISS
-	User::LeaveIfError(iUissSession.Connect()); // Connect to UISS
-	}
+    {
+    iCancelHandler=new(ELeave) InternalCancelHandler(*this);
+    AllocBufL(KBufSize);// Allocate the initial r/c buffer
+
+	//Logger buffer.
+	iBufLogger = KNullDesC8().AllocL();
+    User::LeaveIfError(StartUiss()); // Start UISS
+    User::LeaveIfError(iUissSession.Connect()); // Connect to UISS
+    }
 
 void CUissClientHandler::AllocBufL(TInt aSize)
-	{
+    {
     HBufC8* buf=HBufC8::NewL(aSize);
     delete iBuf;
     iBuf=buf;
     }
 
 void CUissClientHandler::HandleOverflowL()
-	{
-	// Reallocate the buffer to the size received in parameter 1
-	TInt size=0;
-	TPckg<TInt> theSize(size);
-	theSize.Copy(iBuf->Left(sizeof(TInt)));
-	AllocBufL(size);
-	}
-	
+    {
+    // Reallocate the buffer to the size received in parameter 1
+    TInt size=0;
+    TPckg<TInt> theSize(size);
+    theSize.Copy(iBuf->Left(sizeof(TInt)));
+    AllocBufL(size);
+    }
+    
 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK
 void CUissClientHandler::AllocCompInfoBufL(TInt aSize)
-	{
+    {
     HBufC8* buf = HBufC8::NewL(aSize);
     delete iCompInfoBuffer;
     iCompInfoBuffer = buf;
@@ -183,132 +193,132 @@
 
 ///\short Creates a command handler object for the specified dialog request
 CUissCmdHandler* CUissClientHandler::UissCmdHandlerFactoryL(TInt aCommand) const
-	{
-	switch (aCommand)
-		{
-		case CUissSession::KMessageApplicationsInUseDialog:
-			return new(ELeave) CApplicationsInUseDialogCmdHandler(iUiHandler);
-		case CUissSession::KMessageCannotOverwriteFileDialog:
-			return new(ELeave) CCannotOverwriteFileDialogCmdHandler(iUiHandler);
-		
-		case CUissSession::KMessageDependencyBreakDialog:
-			return new(ELeave) CDependencyBreakDialogCmdHandler(iUiHandler);
-		case CUissSession::KMessageDeviceIncompatibility:
-			return new(ELeave) CDeviceIncompatibilityDialogCmdHandler(iUiHandler);
-		case CUissSession::KMessageMissingDependency:
-			return new(ELeave) CMissingDependencyDialogCmdHandler(iUiHandler);
-		case CUissSession::KMessageDriveDialog:
-			return new(ELeave) CDriveDialogCmdHandler(iUiHandler);
-		case CUissSession::KMessageErrorDialog:
-			return new(ELeave) CErrorDialogCmdHandler(iUiHandler);
-		case CUissSession::KMessageGrantCapabilitiesDialog:
-			return new(ELeave) CGrantCapabilitiesDialogCmdHandler(iUiHandler);	
-		case CUissSession::KMessageHandleCancellableInstallEvent:
-			return new(ELeave) CHandleCancellableInstallEventCmdHandler(iUiHandler, 
-				*iCancelHandler);
-		case CUissSession::KMessageHandleInstallEvent:
-			return new(ELeave) CHandleInstallEventCmdHandler(iUiHandler);
-		case CUissSession::KMessageInstallDialog:
-			return new(ELeave) CInstallDialogCmdHandler(iUiHandler);
-		case CUissSession::KMessageLanguageDialog:
-			return new(ELeave) CLanguageDialogCmdHandler(iUiHandler);
-		case CUissSession::KMessageOcspResultDialog:
-			return new(ELeave) COcspResultDialogCmdHandler(iUiHandler);
-		case CUissSession::KMessageOptionsDialog:
-			return new(ELeave) COptionsDialogCmdHandler(iUiHandler);
-		case CUissSession::KMessageQuestionDialog:
-			return new(ELeave) CQuestionDialogCmdHandler(iUiHandler);
-		case CUissSession::KMessageSecurityWarningDialog:
-			return new(ELeave) CSecurityWarningDialogCmdHandler(iUiHandler);
-		case CUissSession::KMessageUninstallDialog:
-			return new(ELeave) CUninstallDialogCmdHandler(iUiHandler);
-		
-		case CUissSession::KMessageUpgradeDialog:
-			return new(ELeave) CUpgradeDialogCmdHandler(iUiHandler);
-		
-		case CUissSession::KMessageTextDialog:
-			return new(ELeave) CTextDialogCmdHandler(iUiHandler);
-					
-		default:
-			return NULL;
-		}
-	}
+    {
+    switch (aCommand)
+        {
+        case CUissSession::KMessageApplicationsInUseDialog:
+            return new(ELeave) CApplicationsInUseDialogCmdHandler(iUiHandler);
+        case CUissSession::KMessageCannotOverwriteFileDialog:
+            return new(ELeave) CCannotOverwriteFileDialogCmdHandler(iUiHandler);
+        
+        case CUissSession::KMessageDependencyBreakDialog:
+            return new(ELeave) CDependencyBreakDialogCmdHandler(iUiHandler);
+        case CUissSession::KMessageDeviceIncompatibility:
+            return new(ELeave) CDeviceIncompatibilityDialogCmdHandler(iUiHandler);
+        case CUissSession::KMessageMissingDependency:
+            return new(ELeave) CMissingDependencyDialogCmdHandler(iUiHandler);
+        case CUissSession::KMessageDriveDialog:
+            return new(ELeave) CDriveDialogCmdHandler(iUiHandler);
+        case CUissSession::KMessageErrorDialog:
+            return new(ELeave) CErrorDialogCmdHandler(iUiHandler);
+        case CUissSession::KMessageGrantCapabilitiesDialog:
+            return new(ELeave) CGrantCapabilitiesDialogCmdHandler(iUiHandler);  
+        case CUissSession::KMessageHandleCancellableInstallEvent:
+            return new(ELeave) CHandleCancellableInstallEventCmdHandler(iUiHandler, 
+                *iCancelHandler);
+        case CUissSession::KMessageHandleInstallEvent:
+            return new(ELeave) CHandleInstallEventCmdHandler(iUiHandler);
+        case CUissSession::KMessageInstallDialog:
+            return new(ELeave) CInstallDialogCmdHandler(iUiHandler);
+        case CUissSession::KMessageLanguageDialog:
+            return new(ELeave) CLanguageDialogCmdHandler(iUiHandler);
+        case CUissSession::KMessageOcspResultDialog:
+            return new(ELeave) COcspResultDialogCmdHandler(iUiHandler);
+        case CUissSession::KMessageOptionsDialog:
+            return new(ELeave) COptionsDialogCmdHandler(iUiHandler);
+        case CUissSession::KMessageQuestionDialog:
+            return new(ELeave) CQuestionDialogCmdHandler(iUiHandler);
+        case CUissSession::KMessageSecurityWarningDialog:
+            return new(ELeave) CSecurityWarningDialogCmdHandler(iUiHandler);
+        case CUissSession::KMessageUninstallDialog:
+            return new(ELeave) CUninstallDialogCmdHandler(iUiHandler);
+        
+        case CUissSession::KMessageUpgradeDialog:
+            return new(ELeave) CUpgradeDialogCmdHandler(iUiHandler);
+        
+        case CUissSession::KMessageTextDialog:
+            return new(ELeave) CTextDialogCmdHandler(iUiHandler);
+                    
+        default:
+            return NULL;
+        }
+    }
 
 void CUissClientHandler::InitializeArgStreamL(const CInstallPrefs& aInstallPrefs)
-	{
-	// Stream out install parameters. Cannot do this in UISSCLIENT because 
-	// the code is in LAUNCHER which depends on UISSCLIENT.
+    {
+    // Stream out install parameters. Cannot do this in UISSCLIENT because 
+    // the code is in LAUNCHER which depends on UISSCLIENT.
     delete iArgsStream;
     iArgsStream = 0;
-	iArgsStream = CWriteStream::NewL();
-	*iArgsStream << aInstallPrefs;
+    iArgsStream = CWriteStream::NewL();
+    *iArgsStream << aInstallPrefs;
     // Save ptr for args (must persist whilst server is processing)
-	iPtrIntoArgsStream.Set(iArgsStream->Ptr());	
-	}
-	
+    iPtrIntoArgsStream.Set(iArgsStream->Ptr()); 
+    }
+    
 void CUissClientHandler::InstallL(const CInstallPrefs& aInstallPrefs, const RArray<TInt>& aDeviceSupportedLanguages, TRequestStatus& aRequestStatus, RThread& aServer)
-	{
+    {
     iState = KUissClientInstalling;
     iClientStatus = &aRequestStatus;
     
     // Save ptr for data returned by request (must persist whilst server is processing)
-	iPtrIntoBuf.Set(iBuf->Des());
+    iPtrIntoBuf.Set(iBuf->Des());
 
-	InitializeArgStreamL(aInstallPrefs);
-	iArgsStream->Stream().WriteInt32L(aDeviceSupportedLanguages.Count());
-	//Streaming set of languages that device supports
-	TInt noOfDeviceSupportedLanguages = aDeviceSupportedLanguages.Count();
-	for(TInt i=0;i<noOfDeviceSupportedLanguages;i++)
-		{
-		iArgsStream->Stream().WriteInt32L(aDeviceSupportedLanguages[i]);
-		}
-	// Save ptr for args (must persist whilst server is processing)
-	iPtrIntoArgsStream.Set(iArgsStream->Ptr());	
-		
+    InitializeArgStreamL(aInstallPrefs);
+    iArgsStream->Stream().WriteInt32L(aDeviceSupportedLanguages.Count());
+    //Streaming set of languages that device supports
+    TInt noOfDeviceSupportedLanguages = aDeviceSupportedLanguages.Count();
+    for(TInt i=0;i<noOfDeviceSupportedLanguages;i++)
+        {
+        iArgsStream->Stream().WriteInt32L(aDeviceSupportedLanguages[i]);
+        }
+    // Save ptr for args (must persist whilst server is processing)
+    iPtrIntoArgsStream.Set(iArgsStream->Ptr()); 
+        
     // Issue initial request
     iUissSession.Install(iPtrIntoArgsStream, iPtrIntoBuf, iStatus);
     if (iActiveObjectMode)
-		{
-		SetActive();
-		}
+        {
+        SetActive();
+        }
 
     // Update client's TRequestStatus object
     *iClientStatus = KRequestPending;
     iSisHelper = aServer;
-	}
+    }
 
 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK
 void CUissClientHandler::GetComponentInfoL(const CInstallPrefs& aInstallPrefs, Usif::CComponentInfo& aComponentInfo, TRequestStatus& aRequestStatus, RThread& aServer)
-	{	
+    {    
     iState = KUissClientGettingCompInfo;
     iClientStatus = &aRequestStatus;
-    	
+        
     // Store the component info reference to the class reference. So that, the same will be 
     // populated after getting the asynchronous method completed.
     iComponentInfo = &aComponentInfo;
     
-	InitializeArgStreamL(aInstallPrefs);
-	
-	AllocCompInfoBufL(KCompInfoBufferSize);	
-	
-	// Save the pointer for component info collection buffer
-	iCompInfoBufPtr.Set(iCompInfoBuffer->Des());
+    InitializeArgStreamL(aInstallPrefs);
+    
+    AllocCompInfoBufL(KCompInfoBufferSize); 
+    
+    // Save the pointer for component info collection buffer
+    iCompInfoBufPtr.Set(iCompInfoBuffer->Des());
 
     // Issue get component info request
     iUissSession.GetComponentInfo(iPtrIntoArgsStream, iCompInfoBufPtr, iStatus);
 
-	// There is no synchronous API for GetComponentInfo
-	__ASSERT_ALWAYS(iActiveObjectMode, User::Invariant());
-	SetActive();
+    // There is no synchronous API for GetComponentInfo
+    __ASSERT_ALWAYS(iActiveObjectMode, User::Invariant());
+    SetActive();
 
     // Update client's TRequestStatus object
     *iClientStatus = KRequestPending;
-    iSisHelper = aServer;	
-	}
+    iSisHelper = aServer;   
+    }
 #endif
 
 void CUissClientHandler::UninstallL(const CSisRegistryPackage& aPackage, TRequestStatus& aRequestStatus)
-	{
+    {
     iState = KUissClientUninstalling;
     iClientStatus = &aRequestStatus;
 
@@ -317,241 +327,264 @@
 
     delete iArgsStream;
     iArgsStream = 0;
-	iArgsStream = CWriteStream::NewL();
+    iArgsStream = CWriteStream::NewL();
     *iArgsStream << aPackage;
     // Save ptr for args (must persist whilst server is processing)
-	iPtrIntoArgsStream.Set(iArgsStream->Ptr());
+    iPtrIntoArgsStream.Set(iArgsStream->Ptr());
 
-	// Issue initial request
+    // Issue initial request
     iUissSession.Uninstall(iPtrIntoArgsStream, iPtrIntoBuf, iStatus);
     if (iActiveObjectMode)
-		{
-		SetActive();
-		}
+        {
+        SetActive();
+        }
 
     // Update client's TRequestStatus object
     *iClientStatus = KRequestPending;
-	}
+    }
 
 void CUissClientHandler::CancelOperation()
-	{
-	if (iState == KUissClientIdle)
-		{
-		return;
-		}
-	
-	// User called this so must have an outstanding request with us.
+    {
+    if (iState == KUissClientIdle)
+        {
+        return;
+        }
+    
+    // User called this so must have an outstanding request with us.
 
-	// First tell the Uiss that we want to cancel the current
-	// operation.
-	//
-	// If we have an outstanding Uiss request, this will complete (with
-	// KErrCancel) when the operation has terminated.
-	//
-	// If we are called inside a dialog callback, then there is no
-	// outstanding Uiss request at the moment. When the dialog
-	// returns, we will issue a request, which will complete (with
-	// KErrCancel) when the operation has terminated.
-	(void)iUissSession.Cancel();
-	}
+    // First tell the Uiss that we want to cancel the current
+    // operation.
+    //
+    // If we have an outstanding Uiss request, this will complete (with
+    // KErrCancel) when the operation has terminated.
+    //
+    // If we are called inside a dialog callback, then there is no
+    // outstanding Uiss request at the moment. When the dialog
+    // returns, we will issue a request, which will complete (with
+    // KErrCancel) when the operation has terminated.
+    (void)iUissSession.Cancel();
+    }
 
 void CUissClientHandler::WorkUntilCompleteL()
-	{
-	// Keep processing UISS responses and issuing new requests
-	// until we update the client status to non-pending.
-	while(iClientStatus && *iClientStatus == KRequestPending) 
-		{
-		User::WaitForRequest(iStatus);
-		TRAPD(err,RunL());
-		if(err != KErrNone)
-			{	
-			RunError(err);
-			}
-		}
-	}
+    {
+    // Keep processing UISS responses and issuing new requests
+    // until we update the client status to non-pending.
+    while(iClientStatus && *iClientStatus == KRequestPending) 
+        {
+        User::WaitForRequest(iStatus);
+        TRAPD(err,RunL());
+        if(err != KErrNone)
+            {   
+            RunError(err);
+            }
+        }
+    }
 
 TBool CUissClientHandler::IsBusy()
-	{
-	return iState != KUissClientIdle;
-	}
+    {
+    return iState != KUissClientIdle;
+    }
 
 
 //
 // Code necessary to run UISS in the same process but in a different thread
 //
 TInt CUissClientHandler::StartUiss()
-	{
-	const TInt KUissServerStackSize=0x2000;
-	const TInt KUissServerInitHeapSize=0x1000;
-	const TInt KUissServerMaxHeapSize=0x1000000;
-	
-	
-	TThreadFunction entryPoint=UissThreadFunction;
-	//TUiSupportStartParams uiSupportParams(aUiHandler);
-	// The owner of the new thread will be the process, otherwise if the 
-	// current thread dies, the server thread will die, too.
-	RThread server;
-	TInt err = KErrNone;
-		
-	for (TInt retry=0; retry < 2; ++retry)
-		{
-		err = server.Create(KUissServerName, entryPoint, 
-		KUissServerStackSize, KUissServerInitHeapSize, KUissServerMaxHeapSize,
-		NULL, EOwnerThread);
-		
-		if (err == KErrAlreadyExists)
-			{
-			User::After(30000);	
-			}
-		else
-			{
-			break;
-			}
-		}
-		
-	if (err==KErrAlreadyExists)
-		{
-		return KErrServerBusy;
-		}
-	if (err != KErrNone)
-		{
-		return err;
-		}
-	
-	// Synchronise with the process to make sure it hasn't died straight away
-	TRequestStatus stat;
-	server.Rendezvous(stat);
-	if (stat != KRequestPending)
-		{
-		// logon failed - server is not yet running, so cannot have terminated
-		server.Kill(0); // Abort startup
-		}
-	else
-		{
-		// logon OK - start the server
-		server.Resume();
-		}
-	// Wait to synchronise with server - if it dies in the meantime, it
-	// also gets completed
-	User::WaitForRequest(stat);	
-	// We can't use the 'exit reason' if the server panicked as this
-	// is the panic 'reason' and may be '0' which cannot be distinguished
-	// from KErrNone
-	TInt r=(server.ExitType()==EExitPanic) ? KErrGeneral : stat.Int();
-	server.Close();
-	return r;
-	}
+    {
+    const TInt KUissServerStackSize=0x2000;
+    const TInt KUissServerInitHeapSize=0x1000;
+    const TInt KUissServerMaxHeapSize=0x1000000;
+    
+    
+    TThreadFunction entryPoint=UissThreadFunction;
+    //TUiSupportStartParams uiSupportParams(aUiHandler);
+    // The owner of the new thread will be the process, otherwise if the 
+    // current thread dies, the server thread will die, too.
+    RThread server;
+    TInt err = KErrNone;
+        
+    for (TInt retry=0; retry < 2; ++retry)
+        {
+        err = server.Create(KUissServerName, entryPoint, 
+        KUissServerStackSize, KUissServerInitHeapSize, KUissServerMaxHeapSize,
+        NULL, EOwnerThread);
+        
+        if (err == KErrAlreadyExists)
+            {
+            User::After(30000); 
+            }
+        else
+            {
+            break;
+            }
+        }
+        
+    if (err==KErrAlreadyExists)
+        {
+        return KErrServerBusy;
+        }
+    if (err != KErrNone)
+        {
+        return err;
+        }
+    
+    // Synchronise with the process to make sure it hasn't died straight away
+    TRequestStatus stat;
+    server.Rendezvous(stat);
+    if (stat != KRequestPending)
+        {
+        // logon failed - server is not yet running, so cannot have terminated
+        server.Kill(0); // Abort startup
+        }
+    else
+        {
+        // logon OK - start the server
+        server.Resume();
+        }
+    // Wait to synchronise with server - if it dies in the meantime, it
+    // also gets completed
+    User::WaitForRequest(stat); 
+    // We can't use the 'exit reason' if the server panicked as this
+    // is the panic 'reason' and may be '0' which cannot be distinguished
+    // from KErrNone
+    TInt r=(server.ExitType()==EExitPanic) ? KErrGeneral : stat.Int();
+    server.Close();
+    return r;
+    }
 
 // Entry point for the thread the UISS runs in
 TInt CUissClientHandler::UissThreadFunction(TAny *)
-	{
-	__UHEAP_MARK;
-	CTrapCleanup* cleanup = CTrapCleanup::New(); // get clean-up stack
-	
-	CActiveScheduler* scheduler=new(ELeave) CActiveScheduler;
-	CActiveScheduler::Install(scheduler);
-	CUissServer* server=NULL;
-	
-	TRAPD(err, server=CUissServer::NewL());
-	if (err==KErrNone)
-		{
-		RThread::Rendezvous(KErrNone);
-		scheduler->Start();
-		}
-	
-	delete server;
-	
-	CActiveScheduler::Install(NULL);
-	delete scheduler;
-	delete cleanup; // destroy clean-up stack
-	__UHEAP_MARKEND;
-	return KErrNone;
-	}
+    {
+    __UHEAP_MARK;
+    CTrapCleanup* cleanup = CTrapCleanup::New(); // get clean-up stack
+    
+    CActiveScheduler* scheduler=new(ELeave) CActiveScheduler;
+    CActiveScheduler::Install(scheduler);
+    CUissServer* server=NULL;
+    
+    TRAPD(err, server=CUissServer::NewL());
+    if (err==KErrNone)
+        {
+        RThread::Rendezvous(KErrNone);
+        scheduler->Start();
+        }
+    
+    delete server;
+    
+    CActiveScheduler::Install(NULL);
+    delete scheduler;
+    delete cleanup; // destroy clean-up stack
+    __UHEAP_MARKEND;
+    return KErrNone;
+    }
 
 void CUissClientHandler::RunL()
     {
     TInt err = iStatus.Int();
-	iPtrIntoBuf.Set(iBuf->Des()); // Get ptr to our return buffer
-
+    iPtrIntoBuf.Set(iBuf->Des()); // Get ptr to our return buffer
+    
 	DEBUG_PRINTF2(_L8("Sis Helper - UISS Client Handler, RunL(). Status: %d."), err);
-
-	
+    if(err > 0)
+        {
+		// For Logging purpose, store the buffer to retrieve 
+		// application info later.
+        delete iBufLogger;
+        iBufLogger = 0;
+        iBufLogger = iBuf->AllocL();
+        }
+    
     if (err==KErrOverflow 
-#ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK	
-		&& iState != KUissClientGettingCompInfo // We don't support overflow management for component info
+#ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK  
+        && iState != KUissClientGettingCompInfo // We don't support overflow management for component info
 #endif
-		)
+        )
         {
         // Grow the respective buffer buffer and re-issue "request".
         // There should now be space for the UISS server to copy in its dialogue message.
         HandleOverflowL();
         iPtrIntoBuf.Set(iBuf->Des());
-		iUissSession.BufferReallocated(iPtrIntoBuf, iStatus);
+        iUissSession.BufferReallocated(iPtrIntoBuf, iStatus);
 
-		if (iActiveObjectMode)
-			{
-			SetActive();
-			}
-		return;
-		}
-	else
-		{
-		if (err>CUissSession::KMsgSeparatorMinimumSwisMessage && 
-			err<CUissSession::KMsgSeparatorMaximumSwisMessage)
-			{
-			// this is a dialog request, unmarshal parameters and display 
-			// the dialog
-			CUissCmdHandler* cmdHandler=UissCmdHandlerFactoryL(err);
-			if (!cmdHandler)
-				{
-				User::Leave(KErrNotSupported);
-				}
+        if (iActiveObjectMode)
+            {
+            SetActive();
+            }
+        return;
+        }
+    else
+        {
+        if (err>CUissSession::KMsgSeparatorMinimumSwisMessage && 
+            err<CUissSession::KMsgSeparatorMaximumSwisMessage)
+            {
+            // this is a dialog request, unmarshal parameters and display 
+            // the dialog
+            CUissCmdHandler* cmdHandler=UissCmdHandlerFactoryL(err);
+            if (!cmdHandler)
+                {               
+                User::Leave(KErrNotSupported);
+                }
+            
+            CleanupStack::PushL(cmdHandler);
+            // Note that the callback might call CancelOperation which
+            // would update iState...
+            cmdHandler->HandleMessageL(iPtrIntoBuf, iPtrIntoBuf);
+            CleanupStack::PopAndDestroy(cmdHandler);
+            }
+        else
+            {
+            #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK
+            // Request has been completed successfully. So, now construct the 
+            // component info from the buffer which is populated from the SWI server.
+            if (err == KErrNone  && iState == KUissClientGettingCompInfo)
+                {
+                ConstructCompInfoFromBufferL();
+                }           
+            #endif
+            // Either KErrNone or some sort of error status - in any case the processing has finished
+            iState = KUissClientIdle;           
+            }
+        }
+    
+    // Re-issue request, if we are still installing/uninstalling
+    switch(iState)
+        {
+    case KUissClientInstalling:
+    case KUissClientUninstalling:
+        iUissSession.CompleteDialog(KErrNone, iPtrIntoBuf, iStatus);
+        if (iActiveObjectMode)
+            {
+            SetActive();
+            }
+        return;
+            
+    case KUissClientIdle:
+        // All done, or failed...
+        delete iArgsStream;
+        iArgsStream = 0;
+        //Wait for the death of SisHelper
+        WaitForSisHelperShutdown(); 
+        // Complete user request (also sets iClientStatus to 0)
+        ASSERT(iClientStatus);
+        User::RequestComplete(iClientStatus, err);
+        
+        // Logging the error to a file 
+        // Temporary solution, should be removed once instrumentation is fully operational.
+        if(err != KErrNone)
+            {
+			TRAP_IGNORE(
+            RDesReadStream readStream(iBufLogger->Des());
+            CleanupClosePushL(readStream);
 			
-			CleanupStack::PushL(cmdHandler);
-			// Note that the callback might call CancelOperation which
-			// would update iState...
-			cmdHandler->HandleMessageL(iPtrIntoBuf, iPtrIntoBuf);
-			CleanupStack::PopAndDestroy(cmdHandler);
-			}
-		else
-			{
-			#ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK
-			// Request has been completed successfully. So, now construct the 
-			// component info from the buffer which is populated from the SWI server.
-			if (err == KErrNone  && iState == KUissClientGettingCompInfo)
-				{
-				ConstructCompInfoFromBufferL();
-				}			
-			#endif
-			// Either KErrNone or some sort of error status - in any case the processing has finished
-			iState = KUissClientIdle;			
-			}
-		}
-	
-	// Re-issue request, if we are still installing/uninstalling
-	switch(iState)
-		{
-	case KUissClientInstalling:
-	case KUissClientUninstalling:
-		iUissSession.CompleteDialog(KErrNone, iPtrIntoBuf, iStatus);
-		if (iActiveObjectMode)
-			{
-			SetActive();
-			}
-		return;
-			
-	case KUissClientIdle:
-		// All done, or failed...
-		delete iArgsStream;
-		iArgsStream = 0;
-		//Wait for the death of SisHelper
-		WaitForSisHelperShutdown();	
-		// Complete user request (also sets iClientStatus to 0)
-		ASSERT(iClientStatus);
-		User::RequestComplete(iClientStatus, err);
-		return;
-		}
-	ASSERT(false);
+			//Retrieve package name.
+            CAppInfo* appInfo=CAppInfo::NewLC(readStream);
+            LogSwiErrorsToFileL(err, appInfo->AppName());
+            
+            CleanupStack::PopAndDestroy(2, &readStream);
+			);
+            }
+        return;
+        }
+    ASSERT(false);
     }
 
 
@@ -562,11 +595,11 @@
 	iPtrIntoBuf.Zero();
 	iUissSession.CompleteDialog(aError, iPtrIntoBuf, iStatus);
     if (iActiveObjectMode)
-		{
-		SetActive();
-		}
-	return KErrNone; // Do not crash the CActiveScheduler.
-	}
+        {
+        SetActive();
+        }
+    return KErrNone; // Do not crash the CActiveScheduler.
+    }
 
 void CUissClientHandler::DoCancel()
     {
@@ -580,91 +613,164 @@
 	// iStatus, which would stop the active scheduler and hence stop
 	// the CancelOperation from being actioned.
 
-	// Do an emergency abort.....
+    // Do an emergency abort.....
 
-	// First kill our helper threads
-	
-	// SIS helper thread/server
-	CSisHelperServer::Abort();
-	
-	// UI helper thread/server
-	TFullName fullName = RProcess().FullName();
-	fullName.Append(':');
-	fullName.Append(':');
-	fullName.Append(KUissServerName);
+    // First kill our helper threads
+    
+    // SIS helper thread/server
+    CSisHelperServer::Abort();
+    
+    // UI helper thread/server
+    TFullName fullName = RProcess().FullName();
+    fullName.Append(':');
+    fullName.Append(':');
+    fullName.Append(KUissServerName);
 
-	RThread server;
-	TInt err = server.Open(fullName);
-	if (err == KErrNone)
-		{
-		server.Terminate(KErrAbort);
-		server.Close();
-		}
-	
-	// Now complete any client request
-	if (iClientStatus)
-		{
-		User::RequestComplete(iClientStatus, err);
-		}
+    RThread server;
+    TInt err = server.Open(fullName);
+    if (err == KErrNone)
+        {
+        server.Terminate(KErrAbort);
+        server.Close();
+        }
+    
+    // Now complete any client request
+    if (iClientStatus)
+        {
+        User::RequestComplete(iClientStatus, err);
+        }
     }
     
 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK
 void CUissClientHandler::ConstructCompInfoFromBufferL()
     {    
     // create a stream based on the buffer
-	RDesReadStream stream(*iCompInfoBuffer);
-	CleanupClosePushL(stream);
-	
-	CNativeComponentInfo* nativeCompInfo = CNativeComponentInfo::NewLC();
-	nativeCompInfo->InternalizeL(stream);
-		
-	// UISS and SWI cannot use Usif::CComponentInfo directly, as it is implemented in a non-TCB DLL. For this reason, a private structure maintained (CNativeComponentInfo),
-	// which is returned by SWI and is converted here to the CComponentInfo according to the USIF interface
-	Usif::CComponentInfo::CNode* rootNode = MapToComponentInfoL(*nativeCompInfo);
-	iComponentInfo->SetRootNodeL(rootNode);
+    RDesReadStream stream(*iCompInfoBuffer);
+    CleanupClosePushL(stream);
+    
+    CNativeComponentInfo* nativeCompInfo = CNativeComponentInfo::NewLC();
+    nativeCompInfo->InternalizeL(stream);
+        
+    // UISS and SWI cannot use Usif::CComponentInfo directly, as it is implemented in a non-TCB DLL. For this reason, a private structure maintained (CNativeComponentInfo),
+    // which is returned by SWI and is converted here to the CComponentInfo according to the USIF interface
+    Usif::CComponentInfo::CNode* rootNode = MapToComponentInfoL(*nativeCompInfo);
+    iComponentInfo->SetRootNodeL(rootNode);
 
-	CleanupStack::PopAndDestroy(nativeCompInfo);
-	CleanupStack::PopAndDestroy(&stream);
+    CleanupStack::PopAndDestroy(nativeCompInfo);
+    CleanupStack::PopAndDestroy(&stream);
     }
 
 Usif::CComponentInfo::CNode* CUissClientHandler::MapToComponentInfoL(CNativeComponentInfo& aNativeComponentInfo)
-	{
-	// Create the array to store the children nodes.
-	RPointerArray<Usif::CComponentInfo::CNode> children;
-	CleanupResetAndDestroyPushL(children);
-	
-	// If there is any child for the current node, call this method with that child object.
-	// Continue this (recursively) until we get the leaf node in the embedded tree (with no children)
-	// and add the resultant node as one of the children and pass it to create the parent node further.
-	TInt count = aNativeComponentInfo.iChildren.Count();
-	for (TInt i = 0; i < count; ++i)
-		{
-		Usif::CComponentInfo::CNode* node = MapToComponentInfoL(*aNativeComponentInfo.iChildren[i]);
-		CleanupStack::PushL(node);
-		children.AppendL(node);
-		CleanupStack::Pop(node);
-		}
-		
-	// Create the CNode object using the appropriate parameters.
-	// children for leaf nodes (bottom most nodes in the embedded tree) will be null.
-	Usif::CComponentInfo::CNode* node = Usif::CComponentInfo::CNode::NewLC(
-										Usif::KSoftwareTypeNative(),
-										*(aNativeComponentInfo.iComponentName), 
-										*(aNativeComponentInfo.iVersion),
-										*(aNativeComponentInfo.iVendor),
-										static_cast<Usif::TScomoState>(aNativeComponentInfo.iScomoState),
-										static_cast<Usif::TInstallStatus>(aNativeComponentInfo.iInstallStatus),
-										aNativeComponentInfo.iComponentId,
-										*(aNativeComponentInfo.iGlobalComponentId),
-										static_cast<Usif::TAuthenticity>(aNativeComponentInfo.iAuthenticity),
-										aNativeComponentInfo.iUserGrantableCaps,
-										aNativeComponentInfo.iMaxInstalledSize,
-										aNativeComponentInfo.iHasExe,
-										&children);
-	CleanupStack::Pop(node);
-	CleanupStack::Pop(&children);
-	children.Close();
-	return (node);
-	}
+    {
+    // Create the array to store the children nodes.
+    RPointerArray<Usif::CComponentInfo::CNode> children;
+    CleanupResetAndDestroyPushL(children);
+    
+    // If there is any child for the current node, call this method with that child object.
+    // Continue this (recursively) until we get the leaf node in the embedded tree (with no children)
+    // and add the resultant node as one of the children and pass it to create the parent node further.
+    TInt count = aNativeComponentInfo.iChildren.Count();
+    for (TInt i = 0; i < count; ++i)
+        {
+        Usif::CComponentInfo::CNode* node = MapToComponentInfoL(*aNativeComponentInfo.iChildren[i]);
+        CleanupStack::PushL(node);
+        children.AppendL(node);
+        CleanupStack::Pop(node);
+        }
+        
+    // Create the CNode object using the appropriate parameters.
+    // children for leaf nodes (bottom most nodes in the embedded tree) will be null.
+    Usif::CComponentInfo::CNode* node = Usif::CComponentInfo::CNode::NewLC(
+                                        Usif::KSoftwareTypeNative(),
+                                        *(aNativeComponentInfo.iComponentName), 
+                                        *(aNativeComponentInfo.iVersion),
+                                        *(aNativeComponentInfo.iVendor),
+                                        static_cast<Usif::TScomoState>(aNativeComponentInfo.iScomoState),
+                                        static_cast<Usif::TInstallStatus>(aNativeComponentInfo.iInstallStatus),
+                                        aNativeComponentInfo.iComponentId,
+                                        *(aNativeComponentInfo.iGlobalComponentId),
+                                        static_cast<Usif::TAuthenticity>(aNativeComponentInfo.iAuthenticity),
+                                        aNativeComponentInfo.iUserGrantableCaps,
+                                        aNativeComponentInfo.iMaxInstalledSize,
+                                        aNativeComponentInfo.iHasExe,
+                                        &children);
+    CleanupStack::Pop(node);
+    CleanupStack::Pop(&children);
+    children.Close();
+    return (node);
+    }
 #endif
+
+
+void LogSwiErrorsToFileL(TInt aErrorCode, const TDesC& aAppName)
+    {
+    _LIT(KErrorString, "%S : Failed with %d");
+    _LIT(KLogFile, "c:\\data\\swilog.log");
+    
+    //Format Output string
+    HBufC* outputString = HBufC::NewLC(aAppName.Length()+ 30);
+    outputString->Des().Format(KErrorString, &aAppName, aErrorCode);
+    
+	//Maximum number of log file entries.
+    const TUint KLogFileSize = 10;
+    
+    RFs fs;
+    User::LeaveIfError(fs.Connect());
+    CleanupClosePushL(fs);
+    
+    RFile logFile;
+    TInt err = logFile.Open(fs, KLogFile, EFileWrite);
+    if(err != KErrNone)
+        {
+		//Attempt to create the file.
+        err = logFile.Create(fs, KLogFile, EFileWrite);
+        User::LeaveIfError(err);
+        }
+    CleanupClosePushL(logFile);   
+    
+
+	//Read the entire log file.
+    RPointerArray<HBufC> linesArray;
+    CleanupResetAndDestroyPushL(linesArray);
+    
+    TFileText logFileManipulator;
+    logFileManipulator.Set(logFile);
+
+    TBuf<200>buffer;
+    err = logFileManipulator.Read(buffer);
+    TInt count(0);
+    while(err == KErrNone && ++count <= KLogFileSize)
+        {
+		HBufC* line = buffer.AllocLC();
+        linesArray.AppendL(line);
+		CleanupStack::Pop(line);
+        err = logFileManipulator.Read(buffer);   
+        }
+    
+	// If the log file contains less than KLogFileSize entries,
+	// write the new log entry.
+    if(count < KLogFileSize)
+        {
+        logFileManipulator.Seek(ESeekEnd);
+        logFileManipulator.Write(*outputString);
+        }
+    else
+        {
+		// Contains KLogFileSize entries. 
+		// Replicate the last KLogFileSize - 1 entries and add the
+		// new log at the end.
+        logFile.Close();
+        logFile.Replace(fs, KLogFile, EFileWrite);
+        logFileManipulator.Set(logFile);
+        for(TInt i = linesArray.Count()- KLogFileSize +1; i<linesArray.Count(); ++i )
+            {
+            logFileManipulator.Write(*linesArray[i]);
+            }
+
+		// New Entry.
+        logFileManipulator.Write(*outputString);   
+        }
+    logFile.Close();
+    CleanupStack::PopAndDestroy(4, outputString);    
+    }
 } // namespace Swi
--- a/installationservices/swi/source/sishelper/uissclienthandler.h	Tue Apr 27 16:46:15 2010 +0300
+++ b/installationservices/swi/source/sishelper/uissclienthandler.h	Tue May 11 16:20:28 2010 +0300
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2004-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"
@@ -166,6 +166,7 @@
 	MUiHandler& iUiHandler;        ///< UI implementation
 	MCancelHandler* iCancelHandler;///< Internal cancel handler
 	HBufC8* iBuf;                  ///< Command buffer
+	HBufC8* iBufLogger;            ///< Command buffer
 	TPtr8 iPtrIntoBuf;
 	RUissSession iUissSession;     ///< UISS session
 
--- a/installationservices/swi/source/sisregistry/client/sisregistryentry.cpp	Tue Apr 27 16:46:15 2010 +0300
+++ b/installationservices/swi/source/sisregistry/client/sisregistryentry.cpp	Tue May 11 16:20:28 2010 +0300
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2004-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"
@@ -315,6 +315,9 @@
 
 EXPORT_C void RSisRegistryEntry::AugmentationsL(RPointerArray<HBufC>& aPackageNames, RPointerArray<HBufC>& aVendorNames)
 	{
+	CleanupResetAndDestroyPushL(aPackageNames);
+    CleanupResetAndDestroyPushL(aVendorNames);
+    
 	HBufC8* buffer = RSisRegistryEntry::SendReceiveBufferLC(EPackageAugmentations);
 	
 	// create a stream based on the buffer
@@ -340,6 +343,8 @@
 		CleanupStack::Pop(2, vendor);	//vendor package, 
 		}
 	CleanupStack::PopAndDestroy(3, buffer);// buffer, stream, packages
+	
+	CleanupStack::Pop(2, &aPackageNames);
 	}
 
 EXPORT_C void RSisRegistryEntry::AugmentationsL(RPointerArray<CSisRegistryPackage>& aPackages)
@@ -392,6 +397,7 @@
 
 EXPORT_C void RSisRegistryEntry::ControllersL(RPointerArray<HBufC8>& aControllers)
 	{
+	CleanupResetAndDestroyPushL(aControllers);
 	HBufC8* buffer = SendReceiveBufferLC(EControllers);
 	
 	// this call returns pure data, so we don't incur the overheads of the streamstore
@@ -413,6 +419,7 @@
 		}
 	
 	CleanupStack::PopAndDestroy(buffer);
+	CleanupStack::Pop(&aControllers);
 	}
 
 EXPORT_C TChar RSisRegistryEntry::SelectedDriveL()
--- a/installationservices/swi/source/sisregistry/client/sisregistrysession.cpp	Tue Apr 27 16:46:15 2010 +0300
+++ b/installationservices/swi/source/sisregistry/client/sisregistrysession.cpp	Tue May 11 16:20:28 2010 +0300
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2004-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"
@@ -35,7 +35,7 @@
 #include "hashcontainer.h"
 #include "dessisdataprovider.h"
 #include "siscontroller.h"
-
+#include "cleanuputils.h"
 
 using namespace Swi;
 
@@ -380,6 +380,7 @@
 	
 EXPORT_C void RSisRegistrySession::RetrieveLogFileL(RPointerArray<CLogEntry>& aLogEntry)
  	{
+    CleanupResetAndDestroyPushL(aLogEntry); 	
  	HBufC8* buffer = SendReceiveBufferLC(EloggingFile);
   
  	RDesReadStream stream(*buffer);
@@ -408,6 +409,7 @@
  		}
  	 	
  	CleanupStack::PopAndDestroy(2,buffer);	//buffer,stream
+ 	CleanupStack::Pop(&aLogEntry);
  	}
  
 HBufC8* RSisRegistrySession::SendReceiveBufferLC(TInt aMessage, TPtrC8 aInputBuffer, TInt aThirdArgument) 
--- a/installationservices/swi/source/sisregistry/common/sisregistryhelperclient.cpp	Tue Apr 27 16:46:15 2010 +0300
+++ b/installationservices/swi/source/sisregistry/common/sisregistryhelperclient.cpp	Tue May 11 16:20:28 2010 +0300
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2009-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"
@@ -42,6 +42,7 @@
 
 EXPORT_C void RSisRegistryHelper::GetEquivalentLanguagesL(TLanguage aLangId,RArray<TLanguage>& aEquivLangs)
 	{
+	CleanupClosePushL(aEquivLangs);
 	// calculate the likely size of the data transfer buffer
 	const TInt KMaxBufSize=
 		sizeof(TInt)+                 // number of entries
@@ -69,4 +70,5 @@
 		}
 	// cleanup
 	CleanupStack::PopAndDestroy(2, buf); // buf
+	CleanupStack::Pop(&aEquivLangs);
 	}
--- a/installationservices/swi/source/sisregistry/server_legacy/sisregistrycache.cpp	Tue Apr 27 16:46:15 2010 +0300
+++ b/installationservices/swi/source/sisregistry/server_legacy/sisregistrycache.cpp	Tue May 11 16:20:28 2010 +0300
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2004-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"
@@ -183,13 +183,16 @@
 
 void CSisRegistryCache::PackageListL(RPointerArray<CSisRegistryPackage>& aPackages) const
 	{
+	CleanupResetAndDestroyPushL(aPackages);
 	aPackages.ResetAndDestroy();
+	
 	for (TInt i = 0; i < iTokens.Count(); i++)
 		{
 		CSisRegistryPackage *package = CSisRegistryPackage::NewLC(*iTokens[i]);
 		aPackages.AppendL(package);
 		CleanupStack::Pop(package);
 		}
+	CleanupStack::Pop(&aPackages);
 	}
 	
 RFs& CSisRegistryCache::RFsHandle()
@@ -715,19 +718,22 @@
 
 void CSisRegistryCache::SidToPackageL(const TUid aSid, RArray<CSisRegistryPackage>& aListMatchingPackages) const
 	{
-		for (TInt i = 0; i < iTokens.Count(); i++)
+	CleanupClosePushL(aListMatchingPackages);
+	for (TInt i = 0; i < iTokens.Count(); i++)
+	{
+	if (iTokens[i]->SidPresent(aSid))
 		{
-		if (iTokens[i]->SidPresent(aSid))
-			{
-			aListMatchingPackages.AppendL(*iTokens[i]); 
-			}
+		aListMatchingPackages.AppendL(*iTokens[i]); 
 		}
+	}
 	
 	DEBUG_PRINTF2(_L("SidToPackageL ListMatchingPackages->Count = %d"), aListMatchingPackages.Count());
 	if(aListMatchingPackages.Count() == 0  )
 		{
 		User::Leave(KErrNotFound);
 		}
+	
+	CleanupStack::Pop(&aListMatchingPackages);
 	}
 	
 TBool CSisRegistryCache::ModifiableL(const TDesC& aFileName)
@@ -835,6 +841,7 @@
 
 void CSisRegistryCache::PackageAugmentationsL(const TUid aUid, RPointerArray<CSisRegistryPackage>& aPackages) const
 	{
+	CleanupResetAndDestroyPushL(aPackages);
 	for (TInt i = 0; i < iTokens.Count(); i++)
 		{
 		if ((iTokens[i]->Uid() == aUid) && (iTokens[i]->Index() != CSisRegistryPackage::PrimaryIndex))
@@ -844,6 +851,7 @@
 			CleanupStack::Pop(tmp);
 			}
 		}
+	CleanupStack::Pop(&aPackages);
 	}
 	
 TInt CSisRegistryCache::PackageAugmentationsNumber(const TUid aUid) const
@@ -1006,11 +1014,13 @@
 							   RPointerArray<CSisRegistryPackage>& aDependents
 							   )
 	{
+	CleanupResetAndDestroyPushL(aDependents);
 	aDependents.ResetAndDestroy();
 	// if it is an augmentation - nothing depends on it
 	if (aObject.InstallType() == Sis::EInstAugmentation || 
 		aObject.InstallType() == Sis::EInstPreInstalledPatch)
 		{
+		CleanupStack::Pop(&aDependents);
 		return;
 		}	
 		
@@ -1062,11 +1072,13 @@
 			CleanupStack::PopAndDestroy(2, &stream);// &stream, tmpObject
 			}
 		}
+	CleanupStack::Pop(&aDependents);
 	}
 
 void CSisRegistryCache::EmbeddingPackagesL(const CSisRegistryObject& aObject,
 									   RPointerArray<CSisRegistryPackage>& aEmbeddingPackages)
 	{
+	CleanupResetAndDestroyPushL(aEmbeddingPackages);
 	aEmbeddingPackages.ResetAndDestroy();
 	
 	TUid matchingUid = aObject.Uid();
@@ -1091,12 +1103,14 @@
 			}
 		// delete entry & stream 
 		CleanupStack::PopAndDestroy(2, &stream);// &stream, tmpObject
-		}	
+		}
+	CleanupStack::Pop(&aEmbeddingPackages);
 	}
 	
 void CSisRegistryCache::GenerateChainListL(const CSisRegistryObject& aObject, 
 											 RPointerArray<HBufC8>& aChainList)	
 	{
+	CleanupResetAndDestroyPushL(aChainList);
 	aChainList.ResetAndDestroy();
 	// read the controller for every member of the list	
 	for (TInt i = 0; i < aObject.ControllerInfo().Count(); i++)
@@ -1118,6 +1132,7 @@
 		// release the data	
 		CleanupStack::PopAndDestroy(3, name); // fileProvider, controller
 		}	
+	CleanupStack::Pop(&aChainList);
 	}
 
 HBufC8* CSisRegistryCache::LoadControllerLC(const CSisRegistryObject& aObject, TUint aIndex)
@@ -1147,6 +1162,7 @@
 void CSisRegistryCache::GenerateControllersArrayL(const CSisRegistryObject& aObject, 
 												RPointerArray<HBufC8>& aControllers)
 	{
+	CleanupResetAndDestroyPushL(aControllers);
 	aControllers.ResetAndDestroy();
 	
 	// read the controller for every member of the list	
@@ -1158,6 +1174,7 @@
 		aControllers.AppendL(buffer);
 		CleanupStack::Pop(buffer);
 		}
+	CleanupStack::Pop(&aControllers);
 	}	
 		
 void CSisRegistryCache::AddControllerL(const CSisRegistryObject& aObject, 
@@ -1392,6 +1409,7 @@
 void CSisRegistryCache::ControllerDriveListL(const CSisRegistryObject& aObject,
 										 RArray<TInt>& aDriveList)
 	{
+	CleanupClosePushL(aDriveList);
 	aDriveList.Reset();
 	// a copy of the controller is always kept on drive C
 	aDriveList.Append(iSystemDrive);
@@ -1402,21 +1420,22 @@
 	TUint fixedDrives = FixedDrives();
 	TUint remainingDrives = installationDrives & ~fixedDrives;
 
-		if (remainingDrives)
+	if (remainingDrives)
+		{
+		TInt index = 0;
+		// reuse the path but change drive letter
+		while (remainingDrives)
 			{
-			TInt index = 0;
-			// reuse the path but change drive letter
-			while (remainingDrives)
+			// compare a single drive digit
+			if (remainingDrives & 0x00000001)
 				{
-				// compare a single drive digit
-				if (remainingDrives & 0x00000001)
-					{
-					User::LeaveIfError(aDriveList.Append(index)); 
-					}
-				remainingDrives>>=1;
-				index++;
+				User::LeaveIfError(aDriveList.Append(index)); 
 				}
+			remainingDrives>>=1;
+			index++;
 			}
+		}
+	CleanupStack::Pop(&aDriveList);	
 	}
 
 	
@@ -2046,6 +2065,8 @@
 	CSisRegistryObject* obj = 0;
 	TUint id = 0;
 	
+	CleanupResetAndDestroyPushL(aPackages);
+
 	aPackages.ResetAndDestroy();
 	for (TInt i = 0; i < iTokens.Count(); i++)
 		{
@@ -2062,6 +2083,7 @@
 
 		CloseReadHandleL(id);
 		}	
+	CleanupStack::Pop(&aPackages);
 	}
 	
 void CSisRegistryCache::RecoverL()
--- a/installationservices/swi/source/swis/server/adornedutilities.cpp	Tue Apr 27 16:46:15 2010 +0300
+++ b/installationservices/swi/source/swis/server/adornedutilities.cpp	Tue May 11 16:20:28 2010 +0300
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2008-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"
@@ -23,6 +23,7 @@
 
 #include "adornedutilities.h"
 #include "log.h"
+#include "cleanuputils.h"
 
 _LIT(KAdornedWildCharString, "{????????}");
 const TInt Swi::FileNameUnadornedPartLength = 10;
@@ -75,6 +76,7 @@
 
 void Swi::FindAllAdornedVariantsL(RFs& aFs, const TDesC& aSearchNameWild, const TDesC& aSearchPath, RPointerArray<HBufC>& aAdornedFileNamesFound)
 	{
+	CleanupResetAndDestroyPushL(aAdornedFileNamesFound);
 	TFindFile finder(aFs);
 	CDir* dirList=0;
 	TBool matchFound = (finder.FindWildByDir( aSearchNameWild, aSearchPath, *&dirList) == KErrNone);
@@ -104,6 +106,7 @@
 		CleanupStack::PushL(dirList);
 		}
 	CleanupStack::PopAndDestroy(dirList);
+	CleanupStack::Pop(&aAdornedFileNamesFound);
 	}
 
 void Swi::GenerateSearchNameWildL(const TDesC& aFileName, TDes& aSearchNameWild)
--- a/installationservices/swi/source/swis/server/planner.cpp	Tue Apr 27 16:46:15 2010 +0300
+++ b/installationservices/swi/source/swis/server/planner.cpp	Tue May 11 16:20:28 2010 +0300
@@ -231,6 +231,11 @@
 	// tree.
 	RPointerArray<CSisRegistryPackage> plannedPackages;
 	CleanupResetAndDestroy<RPointerArray<CSisRegistryPackage> >::PushL(plannedPackages);
+
+	// Add the root node in the planned packages, so that it is not added again (as a node in the tree)
+	// in case of a cyclic dependency.	
+	CSisRegistryPackage* rootPackage = CSisRegistryPackage::NewL(currentNode->PackageL());
+	plannedPackages.AppendL(rootPackage);
 	
 	while(ETrue)
 		{
@@ -350,6 +355,7 @@
 	{
 	// We are removing items from array (aProcessPackages)and thus require index 
 	// adjustment. But if loop run in reverse order there is no need to adjust the index
+	CleanupResetAndDestroyPushL(aPlannedPackages);
 	for (TInt i = aProcessPackages.Count() - 1; i >= 0; --i)
 		{
 		// Ignore already added package
@@ -392,6 +398,7 @@
 		aProcessPackages.Remove(i);
 		CleanupStack::PopAndDestroy(&registryEntry);
 		}
+	CleanupStack::Pop(&aPlannedPackages);
 	}
 
 /**
@@ -514,6 +521,7 @@
             User::Leave(err);
 		    }
 		}
+
 	CleanupStack::Pop(rootApplication);
 	
 	return rootApplication;
@@ -528,13 +536,14 @@
  */
 void CPlanner::ConfirmForUninstallL(CUninstallationNode& aNode, RPointerArray<CSisRegistryPackage>& aPlannedPackages)
 	{
+	CleanupResetAndDestroyPushL(aPlannedPackages);
 	aNode.SetIsPlanned(ETrue);
 
 	// aNode owns package therefore to transfer the ownership
 	// a copy of CSisRegistryPackage is made.
 	CSisRegistryPackage* package = CSisRegistryPackage::NewLC(aNode.PackageL());
 	aPlannedPackages.AppendL(package);
-	CleanupStack::Pop(package);
+	CleanupStack::Pop(2, &aPlannedPackages);
 	}
 
 /**
--- a/installationservices/swi/source/swis/server/sidcache.cpp	Tue Apr 27 16:46:15 2010 +0300
+++ b/installationservices/swi/source/swis/server/sidcache.cpp	Tue May 11 16:20:28 2010 +0300
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2005-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"
@@ -170,7 +170,7 @@
 		{								
 		// Count() will increase if a subdirectory is encountered so don't 'optimise'
 		// the loop invariant !				
-
+		CleanupResetAndDestroyPushL(aSearchDirs);
 		for (TInt i = 0; i < aSearchDirs.Count(); ++i) 
 			{
 			CDir* entries(0);
@@ -197,6 +197,7 @@
 				}
 			CleanupStack::PopAndDestroy(subDirs);
 			}
+		CleanupStack::Pop(&aSearchDirs);
 		}
 		
 	void CSidCache::ScanFileSystemL(RFs& aFs)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/installationservices/swi/test/testexes/embed/cyclic_dependency_base.pkg	Tue May 11 16:20:28 2010 +0300
@@ -0,0 +1,13 @@
+; This test file tests embedded cyclic dependencies.
+
+;Languages
+&EN
+
+;Header
+#{"cyclic_dependency_base"}, (0x811118FD), 1, 2, 3,TYPE=SA
+
+%{"Vendor"}
+:"Unique Vendor Name"
+
+@"cyclic_dependency_embedded.sis",(0x811111E0)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/installationservices/swi/test/testexes/packages/cyclic_dependency_embedded.pkg	Tue May 11 16:20:28 2010 +0300
@@ -0,0 +1,15 @@
+; This test file tests cyclic dependencies.
+
+;Languages
+&EN
+
+;Header
+#{"cyclic_dependency_embedded"}, (0x811111E0), 1, 2, 3,TYPE=SA
+
+%{"Vendor"}
+:"Unique Vendor Name"
+
+(0x811118FD), 1, 2, 3, {"cyclic_dependency_base"}
+
+
+
--- a/installationservices/swi/test/tuiscriptadaptors/scripts/tuiscriptadaptors.ini	Tue Apr 27 16:46:15 2010 +0300
+++ b/installationservices/swi/test/tuiscriptadaptors/scripts/tuiscriptadaptors.ini	Tue May 11 16:20:28 2010 +0300
@@ -1382,4 +1382,19 @@
 
 [u_smlsyncagent]
 uid=10009f46
-script=z:\tswi\tuiscriptadaptors\scripts\uninstall.xml
\ No newline at end of file
+script=z:\tswi\tuiscriptadaptors\scripts\uninstall.xml
+
+[cyclicDependency_A]
+sis=z:\tswi\tsis\data\cyclic_dependency_base.sis
+script=z:\tswi\tuiscriptadaptors\scripts\simple.xml
+
+[cyclicDependency_B]
+sis=z:\tswi\tsis\data\cyclic_dependency_embedded.sis
+script=z:\tswi\tuiscriptadaptors\scripts\simple.xml
+
+[cyclicDependency_U_B]
+uid=811111E0
+script=z:\tswi\tuiscriptadaptors\scripts\uninstall.xml
+
+[cyclicDependency_Uid]
+packageUid=811118FD
--- a/installationservices/swi/test/tuiscriptadaptors/scripts/tuiscriptadaptors.script	Tue Apr 27 16:46:15 2010 +0300
+++ b/installationservices/swi/test/tuiscriptadaptors/scripts/tuiscriptadaptors.script	Tue May 11 16:20:28 2010 +0300
@@ -1326,6 +1326,20 @@
 
 END_TESTCASE API-SEC-SWIREG-Hidden-0004
 
+//! @SYMTestCaseID SEC-cyclicDependency-def145326
+//! @SYMTestCaseDesc User installs a package(A) with dependency on package (B), then installs package B with dependency on A, then unistalls pkg B
+//! @SYMDEF  INC
+//! @SYMTestPriority High
+//! @SYMTestActions  Install SA pkg and then Install another SA package, Uninstall second SA
+//! @SYMTestExpectedResults The SIS gets installed and uninstalled successfully
+
+
+START_TESTCASE cyclicDependency
+RUN_TEST_STEP 100 tuiscriptadaptors InstallStep z:\tswi\tuiscriptadaptors\scripts\tuiscriptadaptors.ini cyclicDependency_A
+RUN_TEST_STEP 100 tuiscriptadaptors InstallStep z:\tswi\tuiscriptadaptors\scripts\tuiscriptadaptors.ini cyclicDependency_B
+RUN_TEST_STEP 100 tuiscriptadaptors RemoveWithLastDependent z:\tswi\tuiscriptadaptors\scripts\tuiscriptadaptors.ini cyclicDependency_Uid
+RUN_TEST_STEP 100 tuiscriptadaptors UninstallStep z:\tswi\tuiscriptadaptors\scripts\tuiscriptadaptors.ini cyclicDependency_U_B
+END_TESTCASE cyclicDependency
 
 // Ensure that SWIS shuts down after the above tests to make sure heap checks run
 RUN_TEST_STEP 5 tuiscriptadaptors SwisNotRunning
--- a/installationservices/swi/test/tuiscriptadaptors/tswisserver.cpp	Tue Apr 27 16:46:15 2010 +0300
+++ b/installationservices/swi/test/tuiscriptadaptors/tswisserver.cpp	Tue May 11 16:20:28 2010 +0300
@@ -234,7 +234,9 @@
 	else if (aStepName == KSwisGetPackageDetails)	// Get Package Details
 		testStep = new CSwisUninstallPkgsStep(CSwisUninstallPkgsStep::EPkgDetails);
 	else if (aStepName == KSwisGetPublishedUidArrayStep)  // Get Published Package Uid's Array
-	        testStep = new CSwisCheckPublishUidStep();
+	    testStep = new CSwisCheckPublishUidStep();
+	else if (aStepName == KSwisRemoveWithLastDependent)  // Set RemoveWithLastDependent
+		testStep = new CSwisSetRemoveWithLastDependent();
 	#ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK
 	else if (aStepName == KCheckSCRFieldStep)	// Check the SCR components' 'Origin Verified', 'Known Revoked', 'DRM Ptotected' field values.
 		testStep = new CCheckScrFieldStep();
--- a/installationservices/swi/test/tuiscriptadaptors/tswisstep.cpp	Tue Apr 27 16:46:15 2010 +0300
+++ b/installationservices/swi/test/tuiscriptadaptors/tswisstep.cpp	Tue May 11 16:20:28 2010 +0300
@@ -2973,4 +2973,40 @@
 	return reinterpret_cast<CAppSidChecker*>(ptr);
 	}
 #endif
+
+/////
+//Step to Set RemoveWithLastDependent property
+/////
+
+CSwisSetRemoveWithLastDependent::CSwisSetRemoveWithLastDependent()
+    {
+    }
+
+CSwisSetRemoveWithLastDependent::~CSwisSetRemoveWithLastDependent()
+    {
+    }
+
+TVerdict CSwisSetRemoveWithLastDependent::doTestStepL()
+    {
+    RSisRegistrySession registrySession;
+    User::LeaveIfError(registrySession.Connect());
+    CleanupClosePushL(registrySession);
+    
+    TInt packageUid = 0;
+    GetHexFromConfig(ConfigSection(),_L("packageUid"),packageUid);    
+    TUid expectedPkgUid = TUid::Uid(packageUid);
+    RSisRegistryEntry regEntry;
+    CleanupClosePushL(regEntry);
+    User::LeaveIfError(regEntry.Open(registrySession, expectedPkgUid));
+    TRAPD(err, regEntry.SetRemoveWithLastDependentL(expectedPkgUid));
+    if(KErrNone == err)
+        SetTestStepResult(EPass);
+    else
+        SetTestStepResult(EFail);
+
+    CleanupStack::PopAndDestroy(2, &registrySession);
+    return TestStepResult();
+    
+    }
+
 // End of file
--- a/installationservices/swi/test/tuiscriptadaptors/tswisstep.h	Tue Apr 27 16:46:15 2010 +0300
+++ b/installationservices/swi/test/tuiscriptadaptors/tswisstep.h	Tue May 11 16:20:28 2010 +0300
@@ -370,6 +370,7 @@
 _LIT(KSwisRemoveUninstallPkgsStep, "RemoveUninstallPkgsStep");
 _LIT(KSwisGetPackageDetails, "GetPackageDetails");
 _LIT(KSwisGetPublishedUidArrayStep, "GetPublishedUidArrayStep");
+_LIT(KSwisRemoveWithLastDependent, "RemoveWithLastDependent");
 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK
 _LIT(KCheckSCRFieldStep, "CheckSCRFieldStep");
 _LIT(KCheckSCRCompPropertyStep, "CheckSCRCompPropertyStep");
@@ -513,4 +514,12 @@
 TBool iJustDefineProperty;
 	};
 
+class CSwisSetRemoveWithLastDependent : public CSwisTestStep
+    {
+public:    
+    CSwisSetRemoveWithLastDependent();
+    ~CSwisSetRemoveWithLastDependent();
+    virtual TVerdict doTestStepL();
+    };
+
 #endif // __TSWISSTEP_H__
--- a/installationservices/swidevicetools/source/swicertstoretool/CSWICertStoreTool.cpp	Tue Apr 27 16:46:15 2010 +0300
+++ b/installationservices/swidevicetools/source/swicertstoretool/CSWICertStoreTool.cpp	Tue May 11 16:20:28 2010 +0300
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2006-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"
@@ -400,6 +400,7 @@
 
 void CSWICertStoreTool::ParseApplicationsL(const CTestConfigSection& aSection, RArray<TUid>& aApplications)
 	{
+	CleanupClosePushL(aApplications);
 	for (TInt index = 0 ; ; ++index)
 		{
 		const CTestConfigItem* item = aSection.Item(KItemApplication, index);
@@ -424,6 +425,7 @@
 		LogL(KLogNoApplications);
 		User::Leave(KErrArgument);
 		}
+	CleanupStack::Pop(&aApplications);
 	}
 
 void CSWICertStoreTool::OpenInputFileL(const TDesC& aInputFile)
--- a/secureswitools/swisistools/source/interpretsislib/expressionevaluator.cpp	Tue Apr 27 16:46:15 2010 +0300
+++ b/secureswitools/swisistools/source/interpretsislib/expressionevaluator.cpp	Tue May 11 16:20:28 2010 +0300
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2006-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"
@@ -95,14 +95,14 @@
     }
 
 
-ExpressionResult ExpressionEvaluator::Evaluate(const CSISExpression* aExpression)
+ExpressionResult ExpressionEvaluator::Evaluate(const CSISExpression* aExpression, bool aLogInfo )
     {
 	Require(aExpression);
-	return Evaluate(*aExpression);
+	return Evaluate(*aExpression, aLogInfo);
     }
 
 
-ExpressionResult ExpressionEvaluator::Evaluate(const CSISExpression& aExpression)
+ExpressionResult ExpressionEvaluator::Evaluate(const CSISExpression& aExpression, bool aLogInfo)
     {
 	if (++iExpressionDepth > KMaxExpressionDepth)
 	    {
@@ -122,8 +122,8 @@
 	case CSISExpression::EBinOpGreaterThanOrEqual:
 	case CSISExpression::EBinOpLessThanOrEqual:
         {
-		const ExpressionResult resultLeft = Evaluate( aExpression.LHS() );
-		const ExpressionResult resultRight = Evaluate( aExpression.RHS() );
+		const ExpressionResult resultLeft = Evaluate( aExpression.LHS(), aLogInfo );
+		const ExpressionResult resultRight = Evaluate( aExpression.RHS(), aLogInfo  );
         //
 	    switch (aExpression.Operator())
 	        {
@@ -152,41 +152,41 @@
     
     case CSISExpression::ELogOpAnd:
 		{
-		ExpressionResult tmp1 = Evaluate(aExpression.LHS());
-		ExpressionResult tmp2 = Evaluate(aExpression.RHS());
+		ExpressionResult tmp1 = Evaluate(aExpression.LHS(), aLogInfo );
+		ExpressionResult tmp2 = Evaluate(aExpression.RHS(), aLogInfo );
 		iTempResult = ExpressionResult(tmp1.BoolValue() && tmp2.BoolValue());
 		break;
 		}
 
 	case CSISExpression::ELogOpOr:
 		{
-		ExpressionResult tmp1 = Evaluate(aExpression.LHS());
+		ExpressionResult tmp1 = Evaluate(aExpression.LHS(), aLogInfo );
 		if (tmp1.BoolValue())
     		{
 			iTempResult = ExpressionResult(true);
 	    	}
 		else
 		    {
-			iTempResult = ExpressionResult(Evaluate(aExpression.RHS())).BoolValue();
+			iTempResult = ExpressionResult(Evaluate(aExpression.RHS(), aLogInfo)).BoolValue();
 		    }
 		break;
 		}
 
 	case CSISExpression::EUnaryOpNot:
-		iTempResult=!Evaluate(aExpression.RHS());
+		iTempResult=!Evaluate(aExpression.RHS(), aLogInfo );
 		break;
 
 	case CSISExpression::EFuncAppProperties:
         {
-        const TUint32 resultLeft = Evaluate( aExpression.LHS() ).IntegerValue();
-        const TUint32 resultRight = Evaluate( aExpression.RHS() ).IntegerValue();
+        const TUint32 resultLeft = Evaluate( aExpression.LHS(), aLogInfo  ).IntegerValue();
+        const TUint32 resultRight = Evaluate( aExpression.RHS(), aLogInfo  ).IntegerValue();
         //
 		iTempResult = iExpEnv.ApplicationProperty( resultLeft, resultRight );
 		break;
         }
 
 	case CSISExpression::EFuncDevProperties:
-		iTempResult = ExpressionResult(iExpEnv.Package(Evaluate(aExpression.RHS()).IntegerValue()));
+		iTempResult = ExpressionResult(iExpEnv.Package(Evaluate(aExpression.RHS(), aLogInfo ).IntegerValue()));
 		break;
 
 	case CSISExpression::EFuncExists:
@@ -218,7 +218,7 @@
 			}
 		else
 			{
-			iTempResult = ExpressionResult(iExpEnv.FindFile(pS.GetString()));
+			iTempResult = ExpressionResult(iExpEnv.FindFile(pS.GetString(), aLogInfo));
 			}
 		}
 		break;
@@ -238,7 +238,7 @@
 	case CSISExpression::EPrimTypeVariable:
 		{
         const int variableId = aExpression.IntValue();
-        const int variableValue = iExpEnv.Variable( variableId );
+        const int variableValue = iExpEnv.Variable( variableId, aLogInfo);
         //
 		iTempResult = ExpressionResult( variableValue );
 		break;
@@ -292,7 +292,7 @@
     }
 
 
-bool ExpressionEnvironment::FindFile( const std::wstring& aFileName )
+bool ExpressionEnvironment::FindFile( const std::wstring& aFileName, bool aLogInfo )
     {
     bool fileExists = false;
 
@@ -308,7 +308,10 @@
     if ( fileName.length() >= 1 && fileName[ 0 ] == L'\\' )
         {
         // Bad file name?
-  		LWARN(L"\tAssuming file path \'" << aFileName << L"\' refers to Z:" );
+		if( aLogInfo )
+			{
+			LWARN(L"\tAssuming file path \'" << aFileName << L"\' refers to Z:" );
+			}  		
         fileName = L"Z:" + fileName;
         }
 
@@ -355,11 +358,14 @@
 		throw InvalidSis( "", error, INVALID_SIS );
         }
     //
-    std::ostringstream stream;
-    stream << "\tIF EXISTS(\'" << narrowFileName << "\') => " << fileExists;
-    std::string msg = stream.str();
-    std::wstring finalMessage = Utf8ToUcs2( msg );
-    LINFO( finalMessage );
+	if(aLogInfo)
+		{
+		std::ostringstream stream;
+		stream << "\tIF EXISTS(\'" << narrowFileName << "\') => " << fileExists;
+		std::string msg = stream.str();
+		std::wstring finalMessage = Utf8ToUcs2( msg );
+		LINFO( finalMessage );
+		}
     //
     return fileExists;
     }
@@ -396,7 +402,7 @@
     }
 
 
-int ExpressionEnvironment::Variable( int aVariableId )
+int ExpressionEnvironment::Variable( int aVariableId, bool aLogInfo )
     {
     int result = 0;
 
@@ -417,23 +423,32 @@
 			if (!iSisFile.IsSupportedLanguage((TUint32)result))
 				{
 				int firstLanguage = iSisFile.GetLanguage(); // get the first language
-				std::ostringstream stream;
-				stream << "Input language " << result << " is not supported by SIS file. Using first language " <<firstLanguage;
-				std::string msg = stream.str();
-				std::wstring finalMessage = Utf8ToUcs2( msg );
-				LWARN( finalMessage );	
+				if(aLogInfo)
+					{
+					std::ostringstream stream;
+					stream << "Input language " << result << " is not supported by SIS file. Using first language " <<firstLanguage;
+					std::string msg = stream.str();
+					std::wstring finalMessage = Utf8ToUcs2( msg );
+					LWARN( finalMessage );	
+					}
 				result = firstLanguage;
 				}
 			}
-        std::ostringstream stream;
-        stream << "\tIF " << attributeName << " ... where [" << attributeName << " = " << result << "]";
-        std::string msg = stream.str();
-        std::wstring finalMessage = Utf8ToUcs2( msg );
-        LINFO( finalMessage );
+        if(aLogInfo)
+			{
+			std::ostringstream stream;
+			stream << "\tIF " << attributeName << " ... where [" << attributeName << " = " << result << "]";
+			std::string msg = stream.str();
+			std::wstring finalMessage = Utf8ToUcs2( msg );
+			LINFO( finalMessage );
+			}
         }
 	else if ( aVariableId == KVariableLanguage )
     	{
-		LWARN(L"Disregarding language selection. Using ELangEnglish");
+		if(aLogInfo)
+			{
+			LWARN(L"Disregarding language selection. Using ELangEnglish");
+			}
 		result = 1;
     	}
     else
--- a/secureswitools/swisistools/source/interpretsislib/expressionevaluator.h	Tue Apr 27 16:46:15 2010 +0300
+++ b/secureswitools/swisistools/source/interpretsislib/expressionevaluator.h	Tue May 11 16:20:28 2010 +0300
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2006-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"
@@ -50,7 +50,7 @@
 	 * Check whether a file exists, corresponds to EXISTS() function in package
 	 * format.
 	 */
-	bool FindFile(const std::wstring& aFileName);
+	bool FindFile(const std::wstring& aFileName, bool aLogInfo = true);
 
 	/**
 	 * Queries an application property, which is a key,value pair associated 
@@ -64,7 +64,7 @@
 	 */
 	bool Package(TUint32 aKey);
 
-	int Variable( int aVariableId );
+	int Variable( int aVariableId, bool aLogInfo = true );
 
 	const std::wstring GetPackageName();
 
@@ -258,8 +258,8 @@
 	void SetFile(const SisFile& aSisFile);
 	void SetRegistry(const SisRegistry& aSisRegistry);
 	
-	ExpressionResult Evaluate(const CSISExpression& aExpression);
-	ExpressionResult Evaluate(const CSISExpression* aExpression);
+	ExpressionResult Evaluate(const CSISExpression& aExpression, bool aLogInfo = true);
+	ExpressionResult Evaluate(const CSISExpression* aExpression, bool aLogInfo = true);
 
 private:
 	void Require(const void *aPointer) const;
--- a/secureswitools/swisistools/source/interpretsislib/installer.cpp	Tue Apr 27 16:46:15 2010 +0300
+++ b/secureswitools/swisistools/source/interpretsislib/installer.cpp	Tue May 11 16:20:28 2010 +0300
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2006-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"
@@ -252,6 +252,56 @@
 	}
 }
 
+void Installer::ProcessConditionalBlockWarnings(const CSISInstallBlock& aInstallBlock, 
+											  ExpressionEvaluator& aEvaluator,
+											  const SisFile& aFile
+											  ) 
+	{
+	const CSISArray<CSISIf, CSISFieldRoot::ESISIf>& ifs = aInstallBlock.Ifs();
+	for (int i = 0; i < ifs.size(); ++i)
+		{
+		const CSISIf& ifBlock = ifs[i];
+
+		if (ifBlock.WasteOfSpace())
+			{
+			return;
+			}
+
+		// Main expression
+		if ( aEvaluator.Evaluate(ifBlock.Expression(),false).BoolValue() )
+			{
+			ProcessInstallBlockWarnings(ifBlock.InstallBlock(), aFile);
+			ProcessConditionalBlockWarnings(ifBlock.InstallBlock(), aEvaluator, aFile);
+			continue;
+			}
+		
+		int elseCount = ifBlock.ElseIfCount();
+		for (int i = 0; i < elseCount; ++i)
+			{
+			const CSISElseIf& elseIfBlock = ifBlock.ElseIf(i) ;
+			if ( aEvaluator.Evaluate(elseIfBlock.Expression(),false).BoolValue())
+				{
+				ProcessInstallBlockWarnings(elseIfBlock.InstallBlock(), aFile);
+				ProcessConditionalBlockWarnings(elseIfBlock.InstallBlock(), aEvaluator, aFile);
+				break;	// Stop processing else if blocks
+				}
+			}
+		} 
+	}
+
+void Installer::ProcessInstallBlockWarnings(const CSISInstallBlock& aInstallBlock, const SisFile& aFile)
+	{
+	aFile.ProcessEmbeddedFileWarning(aInstallBlock);
+	
+	std::string error;
+	bool result = aFile.ProcessInstallOptionsWarning(aInstallBlock,error);	
+	if(result == false)
+		{
+		std::string x;
+		throw InvalidSis(Ucs2ToUtf8(aFile.GetPackageName(),x),
+			error, SIS_NOT_SUPPORTED);
+		}
+	}
 
 TInt Installer::Install(const InstallSISFile& aInstallSISFile)
 {
@@ -270,6 +320,9 @@
 	// check file is acceptable
 	file.CheckValid();
 
+	const CSISController& ctrl = file.GetController();	
+	ProcessConditionalBlockWarnings(ctrl.InstallBlock(), *iExpressionEvaluator, file);
+	
 	if (!DependenciesOk(file))
 	{
 		return MISSING_DEPENDENCY;
--- a/secureswitools/swisistools/source/interpretsislib/installer.h	Tue Apr 27 16:46:15 2010 +0300
+++ b/secureswitools/swisistools/source/interpretsislib/installer.h	Tue May 11 16:20:28 2010 +0300
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2006-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"
@@ -115,6 +115,12 @@
 	void FilterNonBlockingFilesOfFilename(const SisFile& aFile, const std::wstring& target);
 	void WarnEclipseOverWrite(const SisFile& aFile);
 
+	void ProcessConditionalBlockWarnings(const CSISInstallBlock& aInstallBlock, 
+												  ExpressionEvaluator& aEvaluator,
+												  const SisFile& aFile
+												  ); 
+	void ProcessInstallBlockWarnings(const CSISInstallBlock& aInstallBlock, const SisFile& aFile);
+
 	// Adorned methods
 	void AdornedProcessingOfFile(const std::wstring& aTarget, std::wstring& aUnadornedName, 
 										std::list<std::wstring>& aAdornedFileNamesFound);
--- a/secureswitools/swisistools/source/interpretsislib/sisfile.cpp	Tue Apr 27 16:46:15 2010 +0300
+++ b/secureswitools/swisistools/source/interpretsislib/sisfile.cpp	Tue May 11 16:20:28 2010 +0300
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2006-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"
@@ -169,7 +169,7 @@
 }
 
 void SisFile::CheckValid() const
-	{
+{
 	std::string error;
 
 	CSISInfo::TSISInstallationType installType = iContents.Controller().SISInfo().InstallationType();
@@ -198,11 +198,26 @@
 	failed = failed || !success;
 
 	const CSISInstallBlock& blk = iContents.Controller().InstallBlock();
+	success = ProcessInstallOptionsWarning( blk, error);
 
-	int fileCount = blk.FileCount();
+	failed = failed || !success;
+
+	if (failed)
+		{
+		std::string x;
+		throw InvalidSis(Ucs2ToUtf8(this->GetPackageName(),x),
+			error, SIS_NOT_SUPPORTED);
+		}
+	}
+
+bool SisFile::ProcessInstallOptionsWarning(const CSISInstallBlock& aInstallBlock, std::string& aError)
+	{
+	bool success = true;
+
+	int fileCount = aInstallBlock.FileCount();
 	for(int i = 0; i < fileCount; ++i)
 		{
-		const CSISFileDescription& fD = blk.FileDescription(i);
+		const CSISFileDescription& fD = aInstallBlock.FileDescription(i);
         const CSISFileDescription::TSISFileOperation operation = fD.Operation();
 		std::wstring target(fD.Target().GetString());
         //
@@ -257,19 +272,12 @@
 		//
         if (!success)
     		{
-			error += "SIS File contains install options : "+operation;
+			aError += "SIS File contains install options : "+operation;
 			break;
 	    	}
 		}
-	failed = failed || !success;
+	}
 
-	if (failed)
-		{
-		std::string x;
-		throw InvalidSis(Ucs2ToUtf8(this->GetPackageName(),x),
-			error, SIS_NOT_SUPPORTED);
-		}
-	}
 
 std::wstring SisFile::GetVendorName() const
 	{
@@ -458,6 +466,18 @@
 	return pkgs;
 }
 
+void SisFile::ProcessEmbeddedFileWarning(const CSISInstallBlock& aInstallBlock) const
+	{
+	TControllerMap embeddedCtls;
+	aInstallBlock.GetEmbeddedControllers(embeddedCtls, false);
+	for (TControllerMapConstIter iter = embeddedCtls.begin(); iter != embeddedCtls.end(); ++iter)
+		{
+		const CSISController* ctrl = iter->second;
+		const CSISInfo& info = ctrl->SISInfo();			
+		LWARN(L" Embedded Package not installed: UID " << std::hex << info.UID1() );
+		}
+	}
+
 bool SisFile::IsSupportedLanguage(TUint32 aLanguage) const
 {
 	bool result = false;
--- a/secureswitools/swisistools/source/interpretsislib/sisfile.h	Tue Apr 27 16:46:15 2010 +0300
+++ b/secureswitools/swisistools/source/interpretsislib/sisfile.h	Tue May 11 16:20:28 2010 +0300
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2006-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"
@@ -96,6 +96,10 @@
 	void MakeSISStub(std::wstring& aFileName);
 	
 	const CSISController& GetController(); 
+	
+	void ProcessEmbeddedFileWarning(const CSISInstallBlock& aInstallBlock) const;
+
+	bool ProcessInstallOptionsWarning(const CSISInstallBlock& aInstallBlock, std::string& aError);
 
 private:
 	void GetInstallableFiles(	InstallableFiles& aFiles,