Catchup to latest Symbian^4 GCC_SURGE
authorWilliam Roberts <williamr@symbian.org>
Thu, 22 Jul 2010 16:35:22 +0100
branchGCC_SURGE
changeset 52 6cd49ffea600
parent 41 ced935b952ef (current diff)
parent 49 76883296a0d5 (diff)
Catchup to latest Symbian^4
commonappservices/alarmserver/Documentation/AlarmStateTransitionAndAlarmAlertCom.xls
commonappservices/appservicesdocs/app-services_documentation.history.xml
commonappservices/appservicesdocs/app-services_documentation.mrp
commonappservices/appservicesdocs/architecturaldescription.eap
contenthandling/webrecognisers/Documentation/Uid.txt
coreapplicationuis/Rfs/Plugins/GSRFSPlugin/data/10275117.rss
coreapplicationuis/Rfs/Plugins/GSRFSPlugin/data/GSRFSPluginRsc.rss
coreapplicationuis/Rfs/Plugins/GSRFSPlugin/group/GSRFSPlugin.mmp
coreapplicationuis/Rfs/Plugins/GSRFSPlugin/group/GSRFSPluginIcons.mk
coreapplicationuis/Rfs/Plugins/GSRFSPlugin/group/bld.inf
coreapplicationuis/Rfs/Plugins/GSRFSPlugin/inc/GSRFSPlugin.h
coreapplicationuis/Rfs/Plugins/GSRFSPlugin/inc/GSRFSPluginContainer.h
coreapplicationuis/Rfs/Plugins/GSRFSPlugin/inc/GSRFSPluginTraces.h
coreapplicationuis/Rfs/Plugins/GSRFSPlugin/inc/gscommonresources.rss
coreapplicationuis/Rfs/Plugins/GSRFSPlugin/inc/gsrfsplugin.hrh
coreapplicationuis/Rfs/Plugins/GSRFSPlugin/loc/gsrfsplugin.loc
coreapplicationuis/Rfs/Plugins/GSRFSPlugin/src/GSRFSPlugin.cpp
coreapplicationuis/Rfs/Plugins/GSRFSPlugin/src/GSRFSPluginContainer.cpp
coreapplicationuis/Rfs/Plugins/GSRFSPlugin/src/GSRFSPluginImplementationTable.cpp
sysdef_1_4_0.dtd
sysresmonitoring/oommonitor/tsrc/public/basic/BWINS/MT_OomMonitorU.DEF
sysresmonitoring/oommonitor/tsrc/public/basic/EABI/MT_OomMonitorU.DEF
sysresmonitoring/oommonitor/tsrc/public/basic/MT_OomMonitor/MT_COomMonitorPlugin.cpp
sysresmonitoring/oommonitor/tsrc/public/basic/MT_OomMonitor/MT_COomMonitorPlugin.h
sysresmonitoring/oommonitor/tsrc/public/basic/MT_OomMonitor/MT_OomMonitor.cpp
sysresmonitoring/oommonitor/tsrc/public/basic/MT_OomMonitor/MT_OomMonitor.h
sysresmonitoring/oommonitor/tsrc/public/basic/MT_OomMonitor/MT_OomMonitor_DllMain.cpp
sysresmonitoring/oommonitor/tsrc/public/basic/MT_OomMonitor/stub_MemoryMonitor.cpp
sysresmonitoring/oommonitor/tsrc/public/basic/group/MT_OomMonitor.mmp
sysresmonitoring/oommonitor/tsrc/public/basic/group/bld.inf
sysresmonitoring/oommonitor/tsrc/public/basic/test.xml
--- a/appfw/apparchitecture/apgrfx/APGWGNAM.CPP	Tue Jun 15 16:07:48 2010 +0100
+++ b/appfw/apparchitecture/apgrfx/APGWGNAM.CPP	Thu Jul 22 16:35:22 2010 +0100
@@ -1,4 +1,4 @@
-// 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 "Eclipse Public License v1.0"
@@ -9,6 +9,7 @@
 // Nokia Corporation - initial contribution.
 //
 // Contributors:
+// NTT DOCOMO, INC. -- Fix CApaWindowGroupName::AppUid() cannot handle UID with 0 prefix
 //
 // Description:
 //
@@ -513,7 +514,7 @@
 		{
 		start++;
 		TInt end=FindDelimiter(EEndUid);
-		if ((end-start) == KUidBufLength)
+		if (0<end && (end-start)<=KUidBufLength)
 			{
 			TBuf<KUidBufLength> uidBuf=iBuf->Mid(start, end-start);
 			TLex lex(uidBuf);
--- a/appfw/apparchitecture/apgrfx/apgrecog.cpp	Tue Jun 15 16:07:48 2010 +0100
+++ b/appfw/apparchitecture/apgrfx/apgrecog.cpp	Thu Jul 22 16:35:22 2010 +0100
@@ -1,4 +1,4 @@
-// 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 "Eclipse Public License v1.0"
@@ -403,11 +403,15 @@
 
 /** Gets the data (MIME) type of data passed by buffer.
 
-@param aBuffer A buffer containing data 
+@param aBuffer A buffer containing data; Provide preferred size of buffer. 
+If MIME type could not be recognized using this buffer, provide a buffer of 
+larger size.
 @param aDataType On return, contains the result of the attempt to recognize 
 data. 
 @return KErrNone, if successful; otherwise one of the other system-wide error 
 codes. 
+
+@see RApaLsSession::GetPreferredBufSize()
 */
 EXPORT_C TInt RApaLsSession::RecognizeData(const TDesC8& aBuffer, TDataRecognitionResult& aDataType) const
     {
@@ -417,12 +421,15 @@
 /** Gets the data (MIME) type for data taken from a file with a specified name.
 
 @param aName The full filename, including drive and path, of the file containing the data.
-@param aBuffer A buffer containing data taken from the specified file; typically 
-the data is read from the beginning of the file.
+@param aBuffer A buffer containing data taken from the specified file; Provide preferred size of buffer 
+from beginning of the file. If MIME type could not be recognized using this buffer, provide a buffer of 
+larger size.
 @param aDataType On return, contains the result of the attempt to recognize 
 data. 
 @return KErrNone, if successful; otherwise one of the other system-wide error 
 codes. 
+
+@see RApaLsSession::GetPreferredBufSize()
 */
 EXPORT_C TInt RApaLsSession::RecognizeData(const TDesC& aName, const TDesC8& aBuffer, TDataRecognitionResult& aDataType) const
 	{
@@ -456,12 +463,15 @@
 data (MIME) type.
 
 @param aName The name of the file containing the data.
-@param aBuffer A buffer containing data taken from the specified file; typically 
-the data is read from the beginning of the file.
+@param aBuffer A buffer containing data taken from the specified file; Provide preferred size of buffer 
+from beginning of the file. If MIME type could not be recognized using this buffer, provide a buffer of 
+larger size.
 @param aDataType The data (MIME) type.
 @param aResult On return, contains the result of the test.
 @return KErrNone, if successful; otherwise one of the other system-wide error 
 codes. 
+
+@see RApaLsSession::GetPreferredBufSize()
 */
 EXPORT_C TInt RApaLsSession::RecognizeSpecificData(const TDesC& aName, const TDesC8& aBuffer, const TDataType& aDataType, TBool& aResult) const
 	{
--- a/appfw/apparchitecture/aplist/aplappinforeader.cpp	Tue Jun 15 16:07:48 2010 +0100
+++ b/appfw/apparchitecture/aplist/aplappinforeader.cpp	Thu Jul 22 16:35:22 2010 +0100
@@ -233,13 +233,13 @@
     {
     ReadAppRegistrationInfoL();
     ReadLocalisationInfoL();  
-#ifdef _DEBUG    
+#ifdef APPARC_SHOW_TRACE    
     DisplayAppInfo();
 #endif
     return ETrue;
     }
 
-#ifdef _DEBUG
+#ifdef APPARC_SHOW_TRACE
 void CApaAppInfoReader::DisplayAppInfo()
     { 
     RDebug::Print(_L("[Apparc] Application UID: %X"), iAppUid.iUid);
--- a/appfw/apparchitecture/aplist/aplappinforeader.h	Tue Jun 15 16:07:48 2010 +0100
+++ b/appfw/apparchitecture/aplist/aplappinforeader.h	Thu Jul 22 16:35:22 2010 +0100
@@ -172,7 +172,7 @@
     void ReadMimeTypesSupportedL(const RPointerArray<Usif::CDataType>& dataTypes, CArrayFixFlat<TDataTypeWithPriority>& aMimeTypesSupported);    
     void ReadLocalisationInfoL();
     void ReadViewInfoL(const RPointerArray<Usif::CAppViewData>& aViewData);    
-#ifdef _DEBUG   
+#ifdef APPARC_SHOW_TRACE   
     void DisplayAppInfo();
 #endif
     
--- a/appfw/apparchitecture/aplist/aplapplist.cpp	Tue Jun 15 16:07:48 2010 +0100
+++ b/appfw/apparchitecture/aplist/aplapplist.cpp	Thu Jul 22 16:35:22 2010 +0100
@@ -830,7 +830,7 @@
 @param aObserver Observer to be notified when the update has finished. */
 	{
     
-#if _DEBUG    
+#ifdef APPARC_SHOW_TRACE    
     RDebug::Printf("[Apparc] *****************START CREATING APPLIST ****************************");
 #endif    
     
@@ -1225,7 +1225,7 @@
             iAppData=appData->iNext;
             }
 
-#if _DEBUG  
+#ifdef APPARC_SHOW_TRACE  
         if(appData)
             {
             RDebug::Print(_L("[Apparc] Application with UID: %X is deleted from applist"), appData->iUidType[2]);
@@ -1547,7 +1547,7 @@
 	aAppData->iNext=iAppData;
 	iAppData=aAppData;
 	
-#if _DEBUG	
+#ifdef APPARC_SHOW_TRACE	
     RDebug::Print(_L("[Apparc] Application with UID: %X is added to applist"), aAppData->iUidType[2]);
 #endif
     
@@ -1809,7 +1809,7 @@
 	iScrAppInfo=NULL;
     iScr.Close();
 #endif
-#if _DEBUG    
+#ifdef APPARC_SHOW_TRACE    
     RDebug::Printf("[Apparc] *****************END CREATING APPLIST ****************************");
 #endif    
 	}
--- a/appfw/apparchitecture/aplist/aplappregfinder.cpp	Tue Jun 15 16:07:48 2010 +0100
+++ b/appfw/apparchitecture/aplist/aplappregfinder.cpp	Thu Jul 22 16:35:22 2010 +0100
@@ -1,4 +1,4 @@
-// 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 "Eclipse Public License v1.0"
@@ -187,8 +187,13 @@
 			const TDriveName driveName = currentDrive.iUnit.Name();
 			regFileNameParser.Set(entry.iName, &appFolderOnDrive, &driveName);
 
-			// If the appliation is located on a removable drive...
-			if (currentDrive.iAttribs&KDriveAttRemovable)
+			// Apparc will call sidchecker to verify if an application is a valid registered application. 
+			// Apparc will call sidchecker in the following conditions
+			// 1. If the current drive is a removable drive
+			// 2. If the current drive is not 
+			//		a) an internal read-only drive
+			// 		b) the system drive
+			if(currentDrive.iAttribs&KDriveAttRemovable || ((currentDrive.iUnit != iFs.GetSystemDrive()) && (currentDrive.iAttribs&KDriveAttInternal) && !(currentDrive.iAttribs&KDriveAttRom)))
 				{
 				// ...then verify that there is a valid Secure ID (SID) for the appliation
 				// to protect against untrusted applications.
--- a/appfw/apparchitecture/apserv/APSSES.CPP	Tue Jun 15 16:07:48 2010 +0100
+++ b/appfw/apparchitecture/apserv/APSSES.CPP	Thu Jul 22 16:35:22 2010 +0100
@@ -421,7 +421,7 @@
 
 void CApaAppArcServSession::ServiceL(const RMessage2& aMessage)
 	{
-#ifdef _DEBUG    
+#ifdef APPARC_SHOW_TRACE    
     TFullName* name = new(ELeave) TFullName();
     RThread client;
     if ( aMessage.Client( client ) == KErrNone )
@@ -624,13 +624,13 @@
 		break;
 	default:
 		iAppListSession->DoServiceL(aMessage);
-#ifdef _DEBUG   
+#ifdef APPARC_SHOW_TRACE   
 		RDebug::Print( _L("[Apparc] CApaAppListServSession::ServiceL(0x%08x) - END - op code: %04d, completeMessage: %d"), this, aMessage.Function(), completeMessage );
 #endif		
 		return;
 		}
 	
-#ifdef _DEBUG 	
+#ifdef APPARC_SHOW_TRACE 	
     RDebug::Print( _L("[Apparc] CApaAppListServSession::ServiceL(0x%08x) - END - op code: %04d, completeMessage: %d"), this, aMessage.Function(), completeMessage );
 #endif	
 	if (completeMessage && !aMessage.IsNull())
@@ -1456,30 +1456,59 @@
 	aInfo.iShortCaption = app->ShortCaption();
 	}
 	
-void CApaAppArcServSession::DoRecognizeUnpackLC(HBufC*& aName, HBufC8*& aBuffer, const RMessage2& aMessage)
-	{
-	ASSERT(aName==NULL);
-	ASSERT(aBuffer==NULL);
-	aName=HBufC::NewLC(User::LeaveIfError(aMessage.GetDesLength(1)));
-	TPtr name(aName->Des());
-	aMessage.ReadL(1, name);
-	aBuffer=HBufC8::NewLC(User::LeaveIfError(aMessage.GetDesLength(2)));
-	TPtr8 buffer(aBuffer->Des());
-	aMessage.ReadL(2, buffer);
-	}
+TPtrC8 CApaAppArcServSession::DoRecognizeUnpackLC(HBufC*& aName, RChunk& aLocalChunk, const RMessage2& aMessage)
+    {
+    ASSERT(aName==NULL);
+    
+    aName=HBufC::NewLC(User::LeaveIfError(aMessage.GetDesLength(1)));
+    TPtr name(aName->Des());
+    aMessage.ReadL(1, name);
+    
+    HBufC8* buffer=NULL;
+    TInt error=KErrNone;
+    TInt bufferSize= aMessage.GetDesLength(2);
+    User::LeaveIfError(bufferSize);
+    //Allocate memory in apparc's process heap.
+    TRAP(error, buffer=HBufC8::NewL(bufferSize));
+
+    if(error==KErrNone)
+        {
+        CleanupStack::PushL(buffer);
+        TPtr8 bufPtr(buffer->Des());
+        aMessage.ReadL(2, bufPtr);   
+        return bufPtr;
+        }
+    else if(error==KErrNoMemory)
+        {
+        //If memory is not available in apparc's process heap, then allocate in kernel heap
+        User::LeaveIfError(aLocalChunk.CreateLocal(bufferSize,bufferSize));
+        CleanupClosePushL(aLocalChunk);
+        TPtr8 bufPtr(aLocalChunk.Base(), bufferSize);
+        aMessage.ReadL(2, bufPtr); 
+        return bufPtr;        
+        }
+    else
+        {
+        User::Leave(error);
+        }
+    
+    TPtrC8 bufPtr(NULL,0); //Never executed. To make compiler happy
+    return bufPtr;
+    }
 
 void CApaAppArcServSession::RecognizeDataL(const RMessage2& aMessage)
 // Recognize the data type of an object
-	{
-	HBufC* name=NULL;
-	HBufC8* buffer=NULL;
-	DoRecognizeUnpackLC(name,buffer,aMessage);
+    {
+    HBufC* name=NULL;
+    RChunk localChunk;
+    
+    TPtrC8 bufPtr=DoRecognizeUnpackLC(name, localChunk, aMessage);
 
-	const TDataRecognitionResult result = iServ.RecognizeDataL(*name, *buffer);
+    const TDataRecognitionResult result = iServ.RecognizeDataL(*name, bufPtr);
 
-	CleanupStack::PopAndDestroy(2); // name & buffer
-	aMessage.WriteL(0,TPckgC<TDataRecognitionResult>(result));
-	}
+    CleanupStack::PopAndDestroy(2); // name & buffer or localChunk
+    aMessage.WriteL(0,TPckgC<TDataRecognitionResult>(result));
+    }
 
 
 void CApaAppArcServSession::RecognizeFilesL(const RMessage2& aMessage)
@@ -1754,16 +1783,17 @@
 	
 void CApaAppArcServSession::RecognizeSpecificDataL(const RMessage2& aMessage)
 // Determine whether an object is of a specific data type
-	{
-	HBufC* name=NULL;
-	HBufC8* buffer=NULL;
-	DoRecognizeUnpackLC(name,buffer,aMessage);
-	TDataType dataType;
-	{TPckg<TDataType> dataType_asDescriptor(dataType);
-	aMessage.ReadL(0, dataType_asDescriptor);}
-	aMessage.Complete(iServ.RecognizeDataL(*name,*buffer,dataType));
-	CleanupStack::PopAndDestroy(2); // name & buffer
-	}
+    {
+    HBufC* name=NULL;
+    RChunk localChunk;
+    
+    TPtrC8 bufPtr=DoRecognizeUnpackLC(name, localChunk, aMessage);
+    TDataType dataType;
+    {TPckg<TDataType> dataType_asDescriptor(dataType);
+    aMessage.ReadL(0, dataType_asDescriptor);}
+    aMessage.Complete(iServ.RecognizeDataL(*name,bufPtr,dataType));
+    CleanupStack::PopAndDestroy(2); // name & buffer or localChunk
+    }
 
 void CApaAppArcServSession::RecognizeSpecificDataPassedByFileHandleL(const RMessage2& aMessage)
 	{
--- a/appfw/apparchitecture/apserv/APSSES.H	Tue Jun 15 16:07:48 2010 +0100
+++ b/appfw/apparchitecture/apserv/APSSES.H	Thu Jul 22 16:35:22 2010 +0100
@@ -178,7 +178,7 @@
 	void RecognizeDataPassedByFileHandleL(const RMessage2& aMessage);
 	void RecognizeSpecificDataL(const RMessage2& aMessage);
 	void RecognizeSpecificDataPassedByFileHandleL(const RMessage2& aMessage);
-	static void DoRecognizeUnpackLC(HBufC*& aName, HBufC8*& aBuffer, const RMessage2& aMessage);
+    static TPtrC8 DoRecognizeUnpackLC(HBufC*& aName, RChunk& aLocalChunk, const RMessage2& aMessage);
 
 	void AppForDataTypeL(const RMessage2& aMessage);
 	TUid AppForDataTypeL(const TDataType& aDataType, const TUid* aServiceUid);
--- a/appfw/apparchitecture/group/BLD.INF	Tue Jun 15 16:07:48 2010 +0100
+++ b/appfw/apparchitecture/group/BLD.INF	Thu Jul 22 16:35:22 2010 +0100
@@ -29,7 +29,7 @@
 // specify the source file followed by its destination here
 // copy will be used to copy the source file to its destination
 // If there's no destination then the source file will be copied
-// to the same name in \epoc32\include
+// to the same name in /epoc32/include
 
 // Files from aincc.prj
 ../inc/APACLN.H SYMBIAN_MW_LAYER_PLATFORM_EXPORT_PATH(apacln.h)
@@ -95,7 +95,7 @@
 
 ../group/apparc.iby /epoc32/rom/include/apparc.iby
 
-// File from ..\inc (which is relocated from app-framework\aiftool\inc)
+// File from ../inc (which is relocated from app-framework/aiftool/inc)
 ../inc/AIFTOOL.RH /epoc32/include/aiftool.rh
 
 //Backup and restore exports
@@ -199,13 +199,13 @@
 
 // testupdregappuninstallation is used in t_serviceregistry test. If any changes done to
 // this application, uncomment testupdregappuninstallation.mmp file and build it.
-// Then comment it and copy the testupdregappuninstallation_reg.rsc file to ..\tdata folder.
+// Then comment it and copy the testupdregappuninstallation_reg.rsc file to ../tdata folder.
 // Delete any testupdregappuninstallation* files from epoc32 directory.
 //../tef/testapp/testupdregappuninstallation/testupdregappuninstallation.mmp
 
 // testupgradeupdregappuninstallation is used in t_serviceregistry test. If any changes done to
 // this application, uncomment testupdregappuninstallation.mmp file and build it.
-// Then comment it and copy the testupgradeupdregappuninstallation_reg.rsc file to ..\tdata folder.
+// Then comment it and copy the testupgradeupdregappuninstallation_reg.rsc file to ../tdata folder.
 // Delete any testupdregappuninstallation* files from epoc32 directory.
 //../tef/testapp/testupgradeupdregappuninstallation/testupgradeupdregappuninstallation.mmp
 
@@ -245,7 +245,7 @@
 
 //*****************************************************************************************************************************************************************************************************
 //recupgrade_1 plug-in is used to upgrade the mime type recognizer during runtime in T_RecUpgrade test.  
-//              It is build for armv5 and rename to recupgrade_armv5_rel.dll and copied to apparc\Tdata before actual code builds.  If you are making any change in recupgrade_1.cpp then uncomment 
+//              It is build for armv5 and rename to recupgrade_armv5_rel.dll and copied to apparc/Tdata before actual code builds.  If you are making any change in recupgrade_1.cpp then uncomment 
 //              “recupgrade_1.MMP” , build , rename (.dll) and copy as mentioned above .
 //*****************************************************************************************************************************************************************************************************
 //../tef/TRecUpgrade_1/recupgrade_1.MMP
@@ -253,7 +253,7 @@
 
 // ***************************************************************************************************************************************************************************************************
 // recupgrade_2 plug-in is used to upgrade the mime type recognizer during runtime in T_RecUpgrade test.  
-//              It is build for armv5 and rename to recupgrade2_armv5_rel.dll and copied to apparc\Tdata before actual code builds.  If you are making any change in recupgrade_2.cpp then uncomment 
+//              It is build for armv5 and rename to recupgrade2_armv5_rel.dll and copied to apparc/Tdata before actual code builds.  If you are making any change in recupgrade_2.cpp then uncomment 
 //              “recupgrade_2.MMP” , build , rename (.dll) and copy as mentioned above .
 // ***************************************************************************************************************************************************************************************************
 //../tef/TRecUpgrade_2/recupgrade_2.MMP
@@ -378,7 +378,7 @@
 
 ../tef/tupgradeiconapp/tupgradeiconapp.mbm					/epoc32/release/winscw/udeb/z/apparctestregfiles/tupgradeiconapp.mbm
 
-// epoc32\data
+// epoc32/data
 
 // export certificates for creating sis files
 ../tef/testpkg/Nokia_RnDCert_02.der							/epoc32/tools/Nokia_RnDCert_02.der
--- a/appfw/apparchitecture/group/app-framework_apparc.mrp	Tue Jun 15 16:07:48 2010 +0100
+++ b/appfw/apparchitecture/group/app-framework_apparc.mrp	Thu Jul 22 16:35:22 2010 +0100
@@ -1,19 +1,3 @@
-#
-# Copyright (c) 2009 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"
-# which accompanies this distribution, and is available
-# at the URL "http://www.eclipse.org/legal/epl-v10.html".
-#
-# Initial Contributors:
-# Nokia Corporation - initial contribution.
-#
-# Contributors:
-#
-# Description: 
-#
-
 component	app-framework_apparc
 source	\sf\mw\appsupport\appfw\apparchitecture
 binary	\sf\mw\appsupport\appfw\apparchitecture\group	all
--- a/appfw/apparchitecture/group/apparc.iby	Tue Jun 15 16:07:48 2010 +0100
+++ b/appfw/apparchitecture/group/apparc.iby	Thu Jul 22 16:35:22 2010 +0100
@@ -17,6 +17,37 @@
 #ifndef __APPARC_IBY__
 #define __APPARC_IBY__
 
+#ifdef __TEXTSHELL_OBY__
+
+#include <openenv.iby>
+#include <scr.iby>
+#include <sts.iby>
+file=ABI_DIR\BUILD_DIR\sisregistryclient.dll		sys\bin\sisregistryclient.dll
+file=ABI_DIR\BUILD_DIR\sisregistryserver.exe		sys\bin\sisregistryserver.exe
+file=ABI_DIR\BUILD_DIR\plan.dll				sys\bin\plan.dll
+file=ABI_DIR\BUILD_DIR\siscontroller.dll		sys\bin\siscontroller.dll
+file=ABI_DIR\BUILD_DIR\apprscparser.dll			sys\bin\apprscparser.dll
+file=ABI_DIR\BUILD_DIR\swtypereginfo.dll		sys\bin\swtypereginfo.dll
+file=ABI_DIR\BUILD_DIR\swidataprovider.dll		sys\bin\swidataprovider.dll
+file=ABI_DIR\BUILD_DIR\securitymanager.dll		sys\bin\securitymanager.dll
+file=ABI_DIR\BUILD_DIR\sislauncherclient.dll		sys\bin\sislauncherclient.dll
+file=ABI_DIR\BUILD_DIR\sislauncherserver.exe		sys\bin\sislauncherserver.exe
+file=ABI_DIR\BUILD_DIR\swiobserverclient.dll		sys\bin\swiobserverclient.dll
+file=ABI_DIR\BUILD_DIR\uissclient.dll			sys\bin\uissclient.dll
+#include <asnpkcs.iby>
+#include <filetokens.iby>
+#include <certman.iby>
+#include <ocsp.iby>
+file=ABI_DIR\BUILD_DIR\devinfosupportclient.dll		sys\bin\devinfosupportclient.dll
+file=ABI_DIR\BUILD_DIR\devinfosupportcommon.dll		sys\bin\devinfosupportcommon.dll
+file=ABI_DIR\BUILD_DIR\ocspsupportclient.dll		sys\bin\ocspsupportclient.dll
+file=ABI_DIR\BUILD_DIR\ocspsupport.exe			sys\bin\ocspsupport.exe
+file=ABI_DIR\BUILD_DIR\swiobserver.exe			sys\bin\swiobserver.exe
+file=ABI_DIR\BUILD_DIR\Http.dll             		System\Libs\Http.dll
+file=ABI_DIR\BUILD_DIR\httputils.dll           		System\Libs\httputils.dll
+
+#endif
+
 REM Application Architecture
 
 file=ABI_DIR\BUILD_DIR\apparc.dll			System\Libs\apparc.dll
--- a/appfw/apparchitecture/inc/apaapp.h	Tue Jun 15 16:07:48 2010 +0100
+++ b/appfw/apparchitecture/inc/apaapp.h	Thu Jul 22 16:35:22 2010 +0100
@@ -1,4 +1,4 @@
-// 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 "Eclipse Public License v1.0"
@@ -19,11 +19,6 @@
 #ifndef __APAAPP_H__
 #define __APAAPP_H__
 
-#ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
-#if !defined(__APAID_PARTNER_H__)
-#include "apaidpartner.h"
-#endif
-#endif //SYMBIAN_ENABLE_SPLIT_HEADERS
 #include <e32std.h>
 #include <e32base.h>
 #include <apadef.h>
--- a/appfw/apparchitecture/tef/T_WgnamStep.CPP	Tue Jun 15 16:07:48 2010 +0100
+++ b/appfw/apparchitecture/tef/T_WgnamStep.CPP	Thu Jul 22 16:35:22 2010 +0100
@@ -1,4 +1,4 @@
-// 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 "Eclipse Public License v1.0"
@@ -201,6 +201,16 @@
 	TEST(apaWindowGroupName->AppUid()==uid);
 	INFO_PRINTF1(_L("\n"));
 	// User::After(2000000);
+	
+	// RDebug::Print(_L("Block 5a"));
+	INFO_PRINTF1(_L("Test setting appUid starting with 0"));
+	const TUid uid1={ 0x00000111 };
+	PrintWindowGroupName(apaWindowGroupName->WindowGroupName());
+	INFO_PRINTF2(_L("Setting app uid to %x\n"), uid1.iUid);
+	apaWindowGroupName->SetAppUid(uid1);
+	PrintWindowGroupName(apaWindowGroupName->WindowGroupName());
+	TEST(apaWindowGroupName->AppUid()==uid1);
+	INFO_PRINTF1(_L("\n"));
 
 	// test setting caption
 	// RDebug::Print(_L("Block 6"));
--- a/appfw/apparchitecture/tef/testapp/testforceregistrationapp1/testforceregistrationapp1.mmp	Tue Jun 15 16:07:48 2010 +0100
+++ b/appfw/apparchitecture/tef/testapp/testforceregistrationapp1/testforceregistrationapp1.mmp	Thu Jul 22 16:35:22 2010 +0100
@@ -1,4 +1,4 @@
-// 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 "Eclipse Public License v1.0"
@@ -14,22 +14,24 @@
 // testforceregistrationapp1.mmp
 //
 
+#include <platform_paths.hrh>
+
 target          testforceregistrationapp1.exe
 targettype      EXE
 UID             0x1000007a 0x102826E0
 
 
-systeminclude   /epoc32/include
+MW_LAYER_SYSTEMINCLUDE
 
 source	 ./testforceregistrationapp1.cpp
 
 
 START RESOURCE      testforceregistrationapp1_reg.rss
-    TARGETPATH      \apparctest
+    TARGETPATH      /apparctest
 END
 
 START RESOURCE      testforceregistrationapp1_loc.rss
-    TARGETPATH      \apparctest
+    TARGETPATH      /apparctest
 END
 
 library  euser.lib
--- a/appfw/apparchitecture/tef/tssaac/tssaac.mmp	Tue Jun 15 16:07:48 2010 +0100
+++ b/appfw/apparchitecture/tef/tssaac/tssaac.mmp	Thu Jul 22 16:35:22 2010 +0100
@@ -1,4 +1,4 @@
-// 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 "Eclipse Public License v1.0"
@@ -41,7 +41,7 @@
 #else
 // startup with tssaac application for hardware
 START RESOURCE	tssaac_hardware.rss
-TARGETPATH		\private\10205C44
+TARGETPATH		/private/10205C44
 END
 #endif
 
--- a/appfw/apparchitecture/tef/zerosizedicontestapp.mmp	Tue Jun 15 16:07:48 2010 +0100
+++ b/appfw/apparchitecture/tef/zerosizedicontestapp.mmp	Thu Jul 22 16:35:22 2010 +0100
@@ -14,6 +14,8 @@
 // zerosizedicontestapp.mmp
 //
 
+#include <platform_paths.hrh>
+
 target		zerosizedicontestapp.exe
 TARGETTYPE 	exe
 	
@@ -27,7 +29,7 @@
 MW_LAYER_SYSTEMINCLUDE_SYMBIAN
 APP_LAYER_SYSTEMINCLUDE_SYMBIAN
 USERINCLUDE   	.
-SYSTEMINCLUDE 	/epoc32/include
+MW_LAYER_SYSTEMINCLUDE
 SYSTEMINCLUDE 	/epoc32/include/techview
 
 // Application exe specific resource which is localised to the application
--- a/appfw/uiftestfw/group/app-framework_testframework.mrp	Tue Jun 15 16:07:48 2010 +0100
+++ b/appfw/uiftestfw/group/app-framework_testframework.mrp	Thu Jul 22 16:35:22 2010 +0100
@@ -1,19 +1,3 @@
-#
-# Copyright (c) 2009 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"
-# which accompanies this distribution, and is available
-# at the URL "http://www.eclipse.org/legal/epl-v10.html".
-#
-# Initial Contributors:
-# Nokia Corporation - initial contribution.
-#
-# Contributors:
-#
-# Description: 
-#
-
 component	app-framework_testframework
 source	\sf\mw\appsupport\appfw\uiftestfw
 
--- a/appfw/viewserver/group/app-framework_viewsrv.mrp	Tue Jun 15 16:07:48 2010 +0100
+++ b/appfw/viewserver/group/app-framework_viewsrv.mrp	Thu Jul 22 16:35:22 2010 +0100
@@ -1,19 +1,3 @@
-#
-# Copyright (c) 2009 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"
-# which accompanies this distribution, and is available
-# at the URL "http://www.eclipse.org/legal/epl-v10.html".
-#
-# Initial Contributors:
-# Nokia Corporation - initial contribution.
-#
-# Contributors:
-#
-# Description: 
-#
-
 component	app-framework_viewsrv
 source	\sf\mw\appsupport\appfw\viewserver
 binary	\sf\mw\appsupport\appfw\viewserver\group	all
--- a/appfw/viewserver/server/VWSERVER.CPP	Tue Jun 15 16:07:48 2010 +0100
+++ b/appfw/viewserver/server/VWSERVER.CPP	Thu Jul 22 16:35:22 2010 +0100
@@ -1,4 +1,4 @@
-// Copyright (c) 1999-2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 1999-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"
@@ -206,7 +206,8 @@
 		iEnableBoostAppPriorityBeforePanic = valueOfKVwsBoostAppPriorityBeforePanic;
 		}
 #endif
-	
+	LOG3(CVwsLog::EQuiet,_L("CVwsServer::IsPriorityBoostBeforePanicEnabled(): iEnableBoostAppPriorityBeforePanic = [%d] "),iEnableBoostAppPriorityBeforePanic);
+		
 	if (iEnableBoostAppPriorityBeforePanic)
 		{
 		CVwsStartupAware* startupAware = new(ELeave)CVwsStartupAware(*this);
@@ -837,7 +838,7 @@
 		{
 		return;
 		}
-		
+	
 	if (starved.ProcessPriority() < EPriorityForeground)
 		{
 		RProcess owningProcess;
--- a/appfw/viewserver/server/VWSEVENT.CPP	Tue Jun 15 16:07:48 2010 +0100
+++ b/appfw/viewserver/server/VWSEVENT.CPP	Thu Jul 22 16:35:22 2010 +0100
@@ -1,4 +1,4 @@
-// Copyright (c) 1999-2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 1999-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"
@@ -127,6 +127,7 @@
 		firstDelay=iServerEventTimeOut;
 		}
 
+	LOG3(CVwsLog::EQuiet,_L("CVwsEventTimer::Start : firstDelay [%d] "),firstDelay.Int());
 	TTimeIntervalMicroSeconds32 delay(firstDelay);
 	iPeriodic->Start(delay,delay,TCallBack(TimerCallBack,this));	
 	iScreenDeviceChangeEvent = aScreenDeviceChangeEvent;
@@ -167,7 +168,7 @@
 			else
 				{
 				//Delay of KTimeoutValueForPreemptedProcess is given after boosting priority of an application
-				TUint8 patchableConst = KTimeoutValueForPreemptedProcess;
+				TInt patchableConst = KTimeoutValueForPreemptedProcess;
 				#ifdef __WINS__
 				// For the emulator allow the constant to be patched via epoc.ini
 				UserSvr::HalFunction(EHalGroupEmulator, EEmulatorHalIntProperty,
@@ -175,8 +176,9 @@
 				#endif
 				delay = patchableConst;
 				iTimeOutState = EServerEventTimeOut;
+                LOG2(CVwsLog::ELoud,_L("CVwsEventTimer::DoTimerCallBack : iTimeOutState == EIntermediateEventTimeOut"));
 				}
-			
+            LOG3(CVwsLog::EQuiet,_L("CVwsEventTimer::DoTimerCallBack : delay = [%d] "),delay.Int());
             iPeriodic->Start(delay,delay,TCallBack(TimerCallBack,this));
 			}
 		}
--- a/appfw/viewserver/server/vwspatchdata.cpp	Tue Jun 15 16:07:48 2010 +0100
+++ b/appfw/viewserver/server/vwspatchdata.cpp	Thu Jul 22 16:35:22 2010 +0100
@@ -1,4 +1,4 @@
-// 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"
@@ -15,6 +15,6 @@
 
 #include <e32std.h>
 
-EXPORT_C extern const TInt KVwsBoostAppPriorityBeforePanic = 0;
+EXPORT_C extern const TInt KVwsBoostAppPriorityBeforePanic = 1;
 
 EXPORT_C extern const TInt KTimeoutValueForPreemptedProcess = 4*1000*1000; //4 seconds
--- a/applaunchservices/aftermarketappstarter/group/app-framework_amastart.mrp	Tue Jun 15 16:07:48 2010 +0100
+++ b/applaunchservices/aftermarketappstarter/group/app-framework_amastart.mrp	Thu Jul 22 16:35:22 2010 +0100
@@ -1,19 +1,3 @@
-#
-# Copyright (c) 2009 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"
-# which accompanies this distribution, and is available
-# at the URL "http://www.eclipse.org/legal/epl-v10.html".
-#
-# Initial Contributors:
-# Nokia Corporation - initial contribution.
-#
-# Contributors:
-#
-# Description: 
-#
-
 component	app-framework_amastart
 source	\sf\mw\appsupport\applaunchservices\aftermarketappstarter
 binary	\sf\mw\appsupport\applaunchservices\aftermarketappstarter\group	all
--- a/applaunchservices/applaunchplugins/group/app-framework_aplp.mrp	Tue Jun 15 16:07:48 2010 +0100
+++ b/applaunchservices/applaunchplugins/group/app-framework_aplp.mrp	Thu Jul 22 16:35:22 2010 +0100
@@ -1,19 +1,3 @@
-#
-# Copyright (c) 2009 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"
-# which accompanies this distribution, and is available
-# at the URL "http://www.eclipse.org/legal/epl-v10.html".
-#
-# Initial Contributors:
-# Nokia Corporation - initial contribution.
-#
-# Contributors:
-#
-# Description: 
-#
-
 component	app-framework_aplp
 source	\sf\mw\appsupport\applaunchservices\applaunchplugins
 binary	\sf\mw\appsupport\applaunchservices\applaunchplugins\group	all
--- a/applaunchservices/applaunchplugins/test/tapstart/group/apstarttest_apstart.iby	Tue Jun 15 16:07:48 2010 +0100
+++ b/applaunchservices/applaunchplugins/test/tapstart/group/apstarttest_apstart.iby	Thu Jul 22 16:35:22 2010 +0100
@@ -21,9 +21,9 @@
 
 data=ABI_DIR\BUILD_DIR\tapstart_server.exe					sys\bin\tapstart_server.exe
 
-data=DATAZ_\apstarttest\apstarttest_apstart_run.bat		\apstarttest_apstart_run.bat
+//data=DATAZ_\apstarttest\apstarttest_apstart_run.bat		\apstarttest_apstart_run.bat
 
-data=DATAZ_\apstarttest\apstarttest_apstart.script		\apstarttest\apstarttest_apstart.script
+//data=DATAZ_\apstarttest\apstarttest_apstart.script		\apstarttest\apstarttest_apstart.script
 
 
 #endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/applaunchservices/applaunchplugins/test/tapstart/group/apstarttest_apstart.pkg	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,29 @@
+;
+; Copyright (c) 2009 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"
+; which accompanies this distribution, and is available
+; at the URL "http://www.eclipse.org/legal/epl-v10.html".
+;
+; Initial Contributors:
+; Nokia Corporation - initial contribution.
+;
+; Contributors:
+;
+; Description:
+;
+
+;Languages
+&EN
+
+
+;Localised Vendor name
+%{"apstarttest_apstart.pkg EN"}
+
+; Vendor name
+: "apstarttest_apstart"
+
+
+"\epoc32\data\z\apstarttest\apstarttest_apstart_run.bat"-"c:\apstarttest_apstart_run.bat"
+"\epoc32\data\z\apstarttest\apstarttest_apstart.script"-"c:\apstarttest\apstarttest_apstart.script"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/appsupport.pro	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,26 @@
+#
+# Copyright (c) 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"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+#
+# Contributors:
+# 
+# Description: Project file for building phonesrv components
+#
+#
+
+TEMPLATE = subdirs
+CONFIG += ordered
+
+symbian: {
+:BLD_INF_RULES.prj_mmpfiles += $$LITERAL_HASH"include \"group/bld.inf\""
+SUBDIRS += coreapplicationuis\devicepowermenuplugin
+SUBDIRS += systemsettings\accindicatorplugin
+SUBDIRS += systemsettings\accindicatorplugin\accindicatorsettings
+}
--- a/appsupport_info/appsupport_metadata/appsupport_metadata.mrp	Tue Jun 15 16:07:48 2010 +0100
+++ b/appsupport_info/appsupport_metadata/appsupport_metadata.mrp	Thu Jul 22 16:35:22 2010 +0100
@@ -1,19 +1,3 @@
-#
-# Copyright (c) 2009 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"
-# which accompanies this distribution, and is available
-# at the URL "http://www.eclipse.org/legal/epl-v10.html".
-#
-# Initial Contributors:
-# Nokia Corporation - initial contribution.
-#
-# Contributors:
-#
-# Description: 
-#
-
 component           appsupport_metadata
 source   \sf\mw\appsupport\appsupport_info\appsupport_metadata 
 source   \sf\mw\appsupport\package_definition.xml
--- a/appsupport_plat/oom_monitor_api/inc/oommonitor.h	Tue Jun 15 16:07:48 2010 +0100
+++ b/appsupport_plat/oom_monitor_api/inc/oommonitor.h	Thu Jul 22 16:35:22 2010 +0100
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2006 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 "Eclipse Public License v1.0"
@@ -16,11 +16,10 @@
 */
 
 
-#include <e32hashtab.h>
-#include <f32file.h>
+#ifndef OOMMONITOR_H
+#define OOMMONITOR_H
+
 #include <w32std.h>
-#include <apgtask.h>
-#include <e32property.h>
 
 /**
  * Creates thread for OOM watchers.
@@ -28,248 +27,4 @@
  */
 IMPORT_C void CreateOOMWatcherThreadL();
 
-// ---------------------------------------------------------
-// CMemoryMonitor
-// ---------------------------------------------------------
-//
-class COutOfMemoryWatcher;
-class CSubscribeHelper;
-class COomMonitorPlugin;
-class COomPlugins;
-class CAppCloseTimer;
-class CAppCloseWatcher;
-class CMemoryMonitorServer;
-class CWservEventReceiver;
-class RResourceFile;
-class CApaWindowGroupName;
-
-NONSHARABLE_CLASS(CMemoryMonitor) : public CBase
-    {
-public:
-    static CMemoryMonitor* NewL();
-    ~CMemoryMonitor();
-
-public: // event handlers
-    void FreeMemThresholdCrossedL();
-    void CloseAppEvent();
-    void AppNotExiting(TInt aWgId);
-    void StartFreeSomeRamL(TInt aTargetFree);
-    void HandleFocusedWgChangeL();
-    
-private:
-    CMemoryMonitor();
-    void ConstructL();
-    void CloseAppsFinished(TBool aMemoryGood);
-    static TInt WatchdogStatusStatusChanged(TAny* aPtr);
-    void HandleWatchdogStatusCallBackL();
-    void ColapseWindowGroupTree();
-    void SetPluginMemoryGood(TBool aSetToGood);
-    void GetWgsToCloseL();
-    TBool FreeMemoryAboveThreshold();
-    void CancelAppCloseWatchers();
-    TInt AppCloseOrder(TInt aWgIndex, TInt aWgId);
-    void CloseNextApp();
-    void ReadAppResourceArrayL(RResourceFile& aResFile, TInt aResId, TInt aOrderBase, TInt aOrderInc);
-	void RestartAppCloser();
-	
-public:
-	// All members are owned
-    // generally useful sessions
-    RFs iFs;
-    RWsSession iWs;
-
-private:
-	// All members are owned, except where stated
-    // parameters for OOM watcher.
-    TInt iLowThreshold;
-    TInt iGoodThreshold;
-    TInt iMaxExitTime; // Time we wait for application exit gracefully, after this we'll try to shut next application down.
-    TInt iRamPluginRunTime; // Time we wait for plugins to free RAM before we start to shut apps.
-
-    // parameters for app close order
-    enum TAppCloseOrderConstants
-        {
-        ECloseFirst = -1000000,        // apps to close first are given an order around negative one million
-        ECloseNormal = 0,            // apps to close normally are given an order around zero
-        ECloseLast = 1000000,        // apps to close last are given an order around one million
-        ENeverClose = 1000000000    // one billion signals apps that should never be closed
-        };
-    typedef RHashMap<TInt, TInt> RAppCloseOrderMap;    // maps app UID to close order
-    RAppCloseOrderMap iAppCloseOrderMap;
-
-    // internal
-    CApaWindowGroupName* iWgName;
-    HBufC* iWgNameBuf;              // owned by iWgName
-
-    // app closer state
-    TBool iAppCloserRunning;
-    TInt iCurrentTarget;
-    TApaTask iCurrentTask;
-    RArray<RWsSession::TWindowGroupChainInfo> iWgIds;
-    TInt iNextAppToClose;
-    TBool iMemoryAboveThreshold;
-    
-    // event receivers
-    CAppCloseTimer* iAppCloseTimer;
-    CAppCloseWatcher* iAppCloseWatcher;
-    COutOfMemoryWatcher* iOOMWatcher;
-    CWservEventReceiver* iWservEventReceiver;
-
-    // parameters for P&S watcher.
-    RProperty iWatchdogStatusProperty;
-    CSubscribeHelper* iWatchdogStatusSubscriber;
-
-    // Plugin support
-    COomPlugins* iPlugins;
-    TBool iPluginMemoryGood;
-    
-    // Server
-    CMemoryMonitorServer* iServer;
-    };
-
-
-
-NONSHARABLE_CLASS(COutOfMemoryWatcher) : public CActive
-    {
-public:
-    static COutOfMemoryWatcher* NewL(CMemoryMonitor& aLafShutdown, TInt aLowThreshold, TInt aGoodThreshold);
-    ~COutOfMemoryWatcher();
-    void Start();
-private:
-    COutOfMemoryWatcher(CMemoryMonitor& aLafShutdown);
-    void ConstructL(TInt aLowThreshold, TInt aGoodThreshold);
-private: // from CActive
-    void DoCancel();
-    void RunL();
-private: // data
-    RChangeNotifier iChangeNotifier;
-    CMemoryMonitor& iLafShutdown;
-    };
-
-NONSHARABLE_CLASS(CSubscribeHelper) : public CActive
-    {
-public:
-    CSubscribeHelper(TCallBack aCallBack, RProperty& aProperty);
-    ~CSubscribeHelper();
-
-public: // New functions
-    void SubscribeL();
-    void StopSubscribe();
-
-private: // from CActive
-    void RunL();
-    void DoCancel();
-
-private:
-    TCallBack   iCallBack;
-    RProperty&  iProperty;
-    };
-
-
-NONSHARABLE_CLASS(COomPlugins) : public CBase
-    {
-public:
-    COomPlugins();
-    ~COomPlugins();
-    void ConstructL();
-    
-public:
-    void FreeRam();
-    void MemoryGood();
-    
-private:
-    struct TPlugin
-        {
-        TPlugin();
-        COomMonitorPlugin* iImpl;
-        TUid iDtorUid;
-        };
-
-private:
-    RArray<TPlugin> iPlugins;
-    };
-
-
-NONSHARABLE_CLASS(CAppCloseTimer) : public CTimer
-    {
-public:
-    static CAppCloseTimer* NewL(CMemoryMonitor& aMonitor);
-private:
-    CAppCloseTimer(CMemoryMonitor& aMonitor);
-    void RunL();
-private:
-    CMemoryMonitor& iMonitor;
-    };
-
-
-NONSHARABLE_CLASS(CAppCloseWatcher) : public CActive
-    {
-public:
-    CAppCloseWatcher(CMemoryMonitor& aMonitor);
-    ~CAppCloseWatcher();
-    void Start(const TApaTask& aTask);
-private:
-    void DoCancel();
-    void RunL();
-private:
-    CMemoryMonitor& iMonitor;
-    RThread iThread;
-    TProcessPriority iOriginalProcessPriority;
-    };
-
-
-NONSHARABLE_CLASS(CWservEventReceiver) : public CActive
-    {
-public:
-    CWservEventReceiver(CMemoryMonitor& aMonitor, RWsSession& aWs);
-    ~CWservEventReceiver();
-    void ConstructL();
-private:
-    void Queue();
-    void DoCancel();
-    void RunL();
-private:
-    CMemoryMonitor& iMonitor;
-    RWsSession& iWs;
-    RWindowGroup iWg;
-    };
-
-
-NONSHARABLE_CLASS(CMemoryMonitorServer) : public CServer2
-    {
-public:
-    static CMemoryMonitorServer* NewL(CMemoryMonitor& aMonitor);
-    ~CMemoryMonitorServer();
-
-    CMemoryMonitor& Monitor();
-    void CloseAppsFinished(TBool aMemoryGood);
-
-private:
-    CMemoryMonitorServer(CMemoryMonitor& aMonitor);
-    void ConstructL();
-    CSession2* NewSessionL(const TVersion& aVersion,const RMessage2& aMessage) const;
-    TInt RunError(TInt aError);
-
-private:
-    CMemoryMonitor& iMonitor;
-    };
-
-
-NONSHARABLE_CLASS(CMemoryMonitorSession) : public CSession2
-    {
-public:
-    CMemoryMonitorSession();
-    void CreateL();
-    void CloseAppsFinished(TBool aMemoryGood);
-
-private:
-    ~CMemoryMonitorSession();
-    CMemoryMonitorServer& Server();
-    CMemoryMonitor& Monitor();
-    void ServiceL(const RMessage2& aMessage);
-
-private:
-    RMessagePtr2 iRequestFreeRam;
-    };
-
-
+#endif // OOMMONITOR_H
--- a/appsupport_plat/oom_monitor_api/inc/oommonitorsession.h	Tue Jun 15 16:07:48 2010 +0100
+++ b/appsupport_plat/oom_monitor_api/inc/oommonitorsession.h	Thu Jul 22 16:35:22 2010 +0100
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2006 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 "Eclipse Public License v1.0"
@@ -21,50 +21,125 @@
 
 #include <e32std.h>
 
+const TInt KOomMaxAllocationWithoutPermission = 1048576;
+const TUid KOomMemoryMonitorStatusPropertyCategory = {0x10207218};
+const TUint32 KOomMemoryMonitorStatusPropertyKey = 0;
+enum TMemoryMonitorStatusPropertyValues
+    {
+    // Above Treshhold: Free Ram is above good treshhold point and memory monitor isn't freeing any memory
+    EAboveTreshHold,
+    
+    // Freeing Memory: Memory monitor is in the middle of freeing memory
+    EFreeingMemory,
+    
+    // Below Treshhold: Memory monitor has tried to free some RAM but total memory is still below treshhold and memory monitor has given up freeing more memory.
+    EBelowTreshHold
+    };
 class ROomMonitorSession : public RSessionBase
-	{
+    {
+public:
+
+    /**  Defines the application priorities of OOM monitor. */
+    enum TOomPriority
+        {
+        /**
+        * Application can be closed if needed.
+        */
+        EOomPriorityNormal = 0,
+
+        /**
+        * Application should not be closed if possible.
+        */
+        EOomPriorityHigh,
+
+        /**
+        * Application is busy and should not be closed.
+        */
+        EOomPriorityBusy
+        };
+
 public:
-	/**
-	* Connects a new session.
-	* Sessions must be connected before any other APIs can be used.
-	* When the client has finished using a session, Close() must be called.
-	* @return KErrNone if successful, error code otherwise.
-	*/
-	IMPORT_C TInt Connect();
-	/**
-	* Request that the OOM monitor attempts to free some memory.
-	* This function may take several seconds to execute, depending on
-	* the memory state. It will not return until the attempt to recover
-	* memory has completed.
-	* @param aBytesRequested The number of bytes of free memory that the client requests.
-	* @return KErrNone if the request memory is free. KErrNoMemory if that
-	*         amount of memory could not be recovered. Other error codes may
-	*         also be returned.
-	*/
-	IMPORT_C TInt RequestFreeMemory(TInt aBytesRequested);
-	/**
-	* Request that the OOM monitor attempts to free some memory.
-	* This is an asynchronous version of the request for free memory.
-	* @param aBytesRequested The number of bytes of free memory that the client requests.
-	* @param aStatus will be completed when the attempt to recover memory
-	*        has finished. This may take several seconds, depending on
-	*        the memory state. On completion, aStatus will be set to 
-	*        KErrNone if the request memory is free. KErrNoMemory if that
-	*        amount of memory could not be recovered. Other error codes may
-	*        also be set.
-	*/
-	IMPORT_C void RequestFreeMemory(TInt aBytesRequested, TRequestStatus& aStatus);
-	/**
-	* Cancels the asynchronous request for free memory.
-	*/
-	IMPORT_C void CancelRequestFreeMemory();
-	/**
-	* Notifiy the OOM monitor that this application is not responding
-	* to the EEikCmdExit request to exit the application.
-	* This function is used by the Avkon framework's app shutter.
-	* @param aWgId the window group identifier of the app that is not exiting.
-	*/
-	IMPORT_C void ThisAppIsNotExiting(TInt aWgId);
-	};
+    /**
+    * Connects a new session.
+    * Sessions must be connected before any other APIs can be used.
+    * When the client has finished using a session, Close() must be called.
+    * @return KErrNone if successful, error code otherwise.
+    */
+    IMPORT_C TInt Connect();
+
+    /**
+    * Request that the OOM monitor attempts to free some paged memory.
+    * This function may take several seconds to execute, depending on
+    * the memory state. It will not return until the attempt to recover
+    * memory has completed.
+    * @param aBytesRequested The number of bytes of free memory that the client requests.
+    * @return KErrNone if the request memory is free. KErrNoMemory if that
+    *         amount of memory could not be recovered. Other error codes may
+    *         also be returned.
+    */
+    IMPORT_C TInt RequestFreeMemory(TInt aBytesRequested);
+
+    /**
+    * Request that the OOM monitor attempts to free some paged memory.
+    * This is an asynchronous version of the request for free paged memory.
+    * @param aBytesRequested The number of bytes of free memory that the client requests.
+    * @param aStatus will be completed when the attempt to recover memory
+    *        has finished. This may take several seconds, depending on
+    *        the memory state. On completion, aStatus will be set to 
+    *        KErrNone if the request memory is free. KErrNoMemory if that
+    *        amount of memory could not be recovered. Other error codes may
+    *        also be set.
+    */
+    IMPORT_C void RequestFreeMemory(TInt aBytesRequested, TRequestStatus& aStatus);
+    
+    /**
+    * Request that the OOM monitor attempts to free some memory for an optional allocation.
+    * The passed in plugin ID is used to determine the priority for this allocation.
+    * Lower priority OOM actions may be executed to free enough RAM for this allocation.
+    * This function may take several seconds to execute, depending on
+    * the memory state. It will not return until the attempt to recover
+    * memory has completed.
+    * @param aBytesRequested The number of bytes of free memory that the client requests.
+    * @param aPluginId The ID of the plugin that may delete the allocation in event of low memory.
+    * @return KErrNone if the request memory is free. KErrNoMemory if that
+    *         amount of memory could not be recovered. Other error codes may
+    *         also be returned.
+    */
+    IMPORT_C TInt RequestOptionalRam(TInt aBytesRequested, TInt aMinimumBytesNeeded, TInt aPluginId, TInt& aBytesAvailable);
+    
+    /**
+    * Request that the OOM monitor attempts to free some memory for an optional allocation.
+    * The passed in plugin ID is used to determine the priority for this allocation.
+    * Lower priority OOM actions may be executed to free enough RAM for this allocation.
+    * This function may take several seconds to execute, depending on
+    * the memory state. It will not return until the attempt to recover
+    * memory has completed.
+    * @param aBytesRequested The number of bytes of free memory that the client requests.
+    * @param aPluginId The ID of the plugin that may delete the allocation in event of low memory.
+    * @param aStatus The TRequestStatus (completes with the number of bytes freed (aStatus >= 0) or an error (aStatus <= 0))
+    * @return None
+    */
+    IMPORT_C void RequestOptionalRam(TInt aBytesRequested, TInt aMinimumBytesNeeded, TInt aPluginId, TRequestStatus& aStatus);
+
+    /**
+    * Cancels the asynchronous request for free memory.
+    */
+    IMPORT_C void CancelRequestFreeMemory();
+
+    /**
+    * Notify the OOM monitor that this application is not responding
+    * to the EEikCmdExit request to exit the application.
+    * This function is used by the Avkon framework's app shutter.
+    * @param aWgId the window group identifier of the app that is not exiting.
+    */
+    IMPORT_C void ThisAppIsNotExiting(TInt aWgId);
+
+    /**
+    * Notify the OOM monitor that this application has the specified priority
+    * @param aPriority the priority of the application
+    */
+    IMPORT_C void SetOomPriority(TOomPriority aPriority);
+    
+    };
 
 #endif // R_OOMMONITORSESSION_H
--- a/appsupport_plat/oom_monitor_plugin_api/inc/oommonitorplugin.h	Tue Jun 15 16:07:48 2010 +0100
+++ b/appsupport_plat/oom_monitor_plugin_api/inc/oommonitorplugin.h	Thu Jul 22 16:35:22 2010 +0100
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2006 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 "Eclipse Public License v1.0"
@@ -99,6 +99,44 @@
 	};
 
 
+class COomMonitorPluginV2 : public COomMonitorPlugin
+	{
+public:	// From COomMonitorPlugin
+	/**
+	* FreeRam is called when the system RAM level becomes
+	* low. This plugin is requested to help free some RAM.
+	* 
+	* Note that OomMonitorV2 will not call this version of the function so it does not need to be implemented.
+	*/
+	IMPORT_C virtual void FreeRam();
+
+	/**
+	* MemoryGood is called when the system RAM level becomes
+	* good after being low.The plugin may take this opportunity
+	* to start using RAM again.
+	* Nb It is assumed that the plugin will not immediately
+	* cause a large increase in memory use, but that memory may be
+	* used over time, otherwise the plugin may cause oscillation
+	* between low and good memory states.
+	*/
+	virtual void MemoryGood() = 0;
+
+public:	
+	/**
+	* FreeRam is called when the system RAM level becomes
+	* low. This plugin is requested to help free some RAM.
+	* Note that it is desirable to delete all memory associated with this plugin if
+	* not using a disconnected chunk. The reason for this is that by only releasing a small amount
+	* of the memory you reduce the chances of that memory being at the end of the chunk and therefore
+	* reduce the likelihood of it being released to the system.
+	* @param aBytesToFree The minimum number of bytes of free memory that the plugin should try to free.
+	*/
+	virtual void FreeRam(TInt aBytesToFree) = 0;
+
+	};
+
+
+
 /**
 * CAppOomMonitorPlugin is a specialised OOM monitor plugin
 * that sends messages to applications when the memory state
--- a/appsupport_plat/oom_monitor_plugin_api/inc/oommonitorplugin.hrh	Tue Jun 15 16:07:48 2010 +0100
+++ b/appsupport_plat/oom_monitor_plugin_api/inc/oommonitorplugin.hrh	Thu Jul 22 16:35:22 2010 +0100
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2006 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 "Eclipse Public License v1.0"
@@ -22,4 +22,6 @@
 #define KOomPluginInterfaceUidValue 0x10281eea
 #define KOomPluginInterfaceUid (TUid::Uid(KOomPluginInterfaceUidValue))
 
+#define KOomPluginInterfaceV2UidValue 0x10286A80
+#define KOomPluginInterfaceV2Uid (TUid::Uid(KOomPluginInterfaceV2UidValue))
 #endif // OOMMONITORPLUGIN_HRH
--- a/appsupport_plat/secondary_display_accfw_api/group/bld.inf	Tue Jun 15 16:07:48 2010 +0100
+++ b/appsupport_plat/secondary_display_accfw_api/group/bld.inf	Thu Jul 22 16:35:22 2010 +0100
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2006 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 "Eclipse Public License v1.0"
@@ -24,4 +24,4 @@
 
 PRJ_EXPORTS
 
-../inc/secondarydisplay/SecondaryDisplayAccFwAPI.h     MW_LAYER_PLATFORM_EXPORT_PATH(secondarydisplay/SecondaryDisplayAccFwAPI.h)
+../inc/secondarydisplay/SecondaryDisplayAccFwAPI.h     MW_LAYER_PLATFORM_EXPORT_PATH(SecondaryDisplay/SecondaryDisplayAccFwAPI.h)
--- a/appsupport_plat/secondary_display_sysap_api/group/bld.inf	Tue Jun 15 16:07:48 2010 +0100
+++ b/appsupport_plat/secondary_display_sysap_api/group/bld.inf	Thu Jul 22 16:35:22 2010 +0100
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2006 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 "Eclipse Public License v1.0"
@@ -24,4 +24,4 @@
 
 PRJ_EXPORTS
 
-../inc/secondarydisplay/SecondaryDisplaySysApAPI.h     MW_LAYER_PLATFORM_EXPORT_PATH(secondarydisplay/SecondaryDisplaySysApAPI.h)
+../inc/secondarydisplay/SecondaryDisplaySysApAPI.h     MW_LAYER_PLATFORM_EXPORT_PATH(SecondaryDisplay/SecondaryDisplaySysApAPI.h)
--- a/appsupport_plat/startup_configuration_api/inc/startupdomaincrkeys.h	Tue Jun 15 16:07:48 2010 +0100
+++ b/appsupport_plat/startup_configuration_api/inc/startupdomaincrkeys.h	Thu Jul 22 16:35:22 2010 +0100
@@ -263,6 +263,13 @@
 */
 const TUint32 KStartupDefaultTime = 0x00000016;
 
+/**
+ * Enables or disables the FTU StartupSequence. This key is modified by ftu when user accepts the eterms
+ * Possible values true or false
+ */
+const TUint32 KFtuStartupEnabled = 0x0000001A;
+
+
 #endif // STARTUPDOMAINCRKEYS_H
 
 // End of File
--- a/appsupport_plat/system_application_notification_api/inc/coreapplicationuisdomainpskeys.h	Tue Jun 15 16:07:48 2010 +0100
+++ b/appsupport_plat/system_application_notification_api/inc/coreapplicationuisdomainpskeys.h	Thu Jul 22 16:35:22 2010 +0100
@@ -215,6 +215,17 @@
      ECoreAppUIsVideoSharingIndicatorOff,
      ECoreAppUIsVideoSharingIndicatorOn
      };
+     
+/**
+* Used for notifying SysAp for releasing memory of power menu custom dialog
+*/
+const TUint32 KCoreAppUIsPowerMenuCustomDialogStatus= 0x00000207;
+enum TCoreAppUIsPowerMenuCustomDialog
+     {
+     ECoreAppUIsPowerMenuCustomDialogUninitialized = 0,
+     ECoreAppUIsPowerMenuCustomDialogOff,
+     ECoreAppUIsPowerMenuCustomDialogOn
+     };
 
 // =============================================================================
 // Contacts Database Recovery Status API
--- a/commonappservices/alarmserver/Client/Source/ASCliSession.cpp	Tue Jun 15 16:07:48 2010 +0100
+++ b/commonappservices/alarmserver/Client/Source/ASCliSession.cpp	Thu Jul 22 16:35:22 2010 +0100
@@ -1,4 +1,4 @@
-// Copyright (c) 1999-2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 1999-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"
@@ -742,6 +742,7 @@
 */
 EXPORT_C void RASCliSession::GetAvailableCategoryListL(RArray<TAlarmCategory>& aCategories) const
 	{
+	CleanupClosePushL(aCategories);
 	// First step is to build the transfer buffer in the server
 	// and get the size (in bytes) so that we know
 	// how big to make the client-side (corresponding) temporary one.
@@ -768,6 +769,8 @@
 	//
 	stream.Close();
 	CleanupStack::PopAndDestroy(2, buffer);
+  // relieve the ownership of the array to the caller
+  CleanupStack::Pop(&aCategories);
 	}
 
 
@@ -1328,6 +1331,7 @@
 */
 void RASCliSession::FetchAlarmIdsFromBufferL(RArray<TAlarmId>& aAlarmIds, TInt aBufferSize) const
 	{
+	CleanupClosePushL(aAlarmIds);
 	CBufBase* buffer = FetchTransferBufferLC(aBufferSize);
 
 	// The buffer just contains serialized TAlarmId's so we need to
@@ -1344,6 +1348,8 @@
 		}
 	//
 	CleanupStack::PopAndDestroy(2, buffer);
+	// relieve the ownership of the array to the caller
+	CleanupStack::Pop(&aAlarmIds); 
 	}
 
 /** 
--- a/commonappservices/alarmserver/ConsoleAlarmAlertServer/app-services_consolealarmalertserver.mrp	Tue Jun 15 16:07:48 2010 +0100
+++ b/commonappservices/alarmserver/ConsoleAlarmAlertServer/app-services_consolealarmalertserver.mrp	Thu Jul 22 16:35:22 2010 +0100
@@ -1,19 +1,3 @@
-#
-# Copyright (c) 2009 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"
-# which accompanies this distribution, and is available
-# at the URL "http://www.eclipse.org/legal/epl-v10.html".
-#
-# Initial Contributors:
-# Nokia Corporation - initial contribution.
-#
-# Contributors:
-#
-# Description: 
-#
-
 component	app-services_consolealarmalertserver
 
 
Binary file commonappservices/alarmserver/Documentation/AlarmStateTransitionAndAlarmAlertCom.xls has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commonappservices/alarmserver/Group/TEF_AlarmServerCIT.pkg	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,28 @@
+;
+; Copyright (c) 2009 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"
+; which accompanies this distribution, and is available
+; at the URL "http://www.eclipse.org/legal/epl-v10.html".
+;
+; Initial Contributors:
+; Nokia Corporation - initial contribution.
+;
+; Contributors:
+;
+; Description:
+;
+
+;Languages
+&EN
+
+
+;Localised Vendor name
+%{"TEF_AlarmServerCIT.pkg EN"}
+
+; Vendor name
+: "TEF_AlarmServerCIT"
+
+
+"\epoc32\data\C\CITAlarmServer\scripts\TestCITAlarmServer.script"-"c:\CITAlarmServer\scripts\TestCITAlarmServer.script"
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commonappservices/alarmserver/Group/alarmserverunittestserver.pkg	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,39 @@
+;
+; Copyright (c) 2009 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"
+; which accompanies this distribution, and is available
+; at the URL "http://www.eclipse.org/legal/epl-v10.html".
+;
+; Initial Contributors:
+; Nokia Corporation - initial contribution.
+;
+; Contributors:
+;
+; Description:
+;
+
+;Languages
+&EN
+
+
+;Localised Vendor name
+%{"alarmserverunittestserver.pkg EN"}
+
+; Vendor name
+: "alarmserverunittestserver"
+
+"\epoc32\data\z\testdata\scripts\TEAlarmServer.script"-"c:\testdata\scripts\TEAlarmServer.script"
+"\epoc32\data\z\testdata\scripts\TEAlarmServer_apc_loop.script"-"c:\testdata\scripts\TEAlarmServer_apc.script"
+"\epoc32\data\z\testdata\scripts\TEAlarmServer_man.script"-"c:\testdata\scripts\TEAlarmServer_man.script"
+"\epoc32\data\z\testdata\scripts\TEAlarmServer_man_TC3.script"-"c:\testdata\scripts\TEAlarmServer_man_TC3.script"
+"\epoc32\data\z\testdata\scripts\TEAlarmServer_man_exceptTC3.script"-"c:\testdata\scripts\TEAlarmServer_man_exceptTC3.script"
+"\epoc32\data\z\testdata\scripts\TEAlarmServer_apc_repeat.script"-"c:\testdata\scripts\TEAlarmServer_apc.script"
+"\epoc32\data\z\testdata\scripts\TEAlarmServer_apc_stop.script"-"c:\testdata\scripts\TEAlarmServer_apc.script"
+"\epoc32\data\z\testdata\scripts\TEAlarmServer_apc_disabled.script"-"c:\testdata\scripts\TEAlarmServer_apc.script"
+"\epoc32\data\z\testdata\scripts\TEAlarmServer_apc_disordered.script"-"c:\testdata\scripts\TEAlarmServer_apc.script"
+"\epoc32\data\z\testdata\scripts\TEAlarmServer_apc_ini.script"-"c:\testdata\scripts\TEAlarmServer_apc.script"
+"\epoc32\data\z\testdata\scripts\TEAlarmServer_apc_invalid.script"-"c:\testdata\scripts\TEAlarmServer_apc.script"
+"\epoc32\data\z\testdata\scripts\TEAlarmServer_apc_norsc.script"-"c:\testdata\scripts\TEAlarmServer_apc.script"
+"\epoc32\data\z\testdata\scripts\TEAlarmServer_man_exceptTC3.script"-"c:\testdata\scripts\TEAlarmServer_man.script"
\ No newline at end of file
--- a/commonappservices/alarmserver/Group/app-services_alarmserver.mrp	Tue Jun 15 16:07:48 2010 +0100
+++ b/commonappservices/alarmserver/Group/app-services_alarmserver.mrp	Thu Jul 22 16:35:22 2010 +0100
@@ -1,19 +1,3 @@
-#
-# Copyright (c) 2009 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"
-# which accompanies this distribution, and is available
-# at the URL "http://www.eclipse.org/legal/epl-v10.html".
-#
-# Initial Contributors:
-# Nokia Corporation - initial contribution.
-#
-# Contributors:
-#
-# Description: 
-#
-
 component	app-services_alarmserver
 source	\sf\mw\appsupport\commonappservices\alarmserver
 binary	\sf\mw\appsupport\commonappservices\alarmserver\Group	all
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commonappservices/alarmserver/Test/Integration/TestCITAlarmServer/group/TEF_AlarmServerCIT.pkg	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,28 @@
+;
+; Copyright (c) 2009 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"
+; which accompanies this distribution, and is available
+; at the URL "http://www.eclipse.org/legal/epl-v10.html".
+;
+; Initial Contributors:
+; Nokia Corporation - initial contribution.
+;
+; Contributors:
+;
+; Description:
+;
+
+;Languages
+&EN
+
+
+;Localised Vendor name
+%{"TEF_AlarmServerCIT.pkg EN"}
+
+; Vendor name
+: "TEF_AlarmServerCIT"
+
+
+"\epoc32\data\C\CITAlarmServer\scripts\TestCITAlarmServer.script"-"c:\CITAlarmServer\scripts\TestCITAlarmServer.script"
\ No newline at end of file
Binary file commonappservices/alarmserver/doc_pub/AlarmStateTransitionAndAlarmAlertCom.xls has changed
Binary file commonappservices/alarmserver/doc_pub/SGL.GT0257.207_Rev1.1_Alarm_Server_Configuration_how_to.doc has changed
--- a/commonappservices/alarmservertest/TestAlarmSrv/app-services_testalarmsrv.mrp	Tue Jun 15 16:07:48 2010 +0100
+++ b/commonappservices/alarmservertest/TestAlarmSrv/app-services_testalarmsrv.mrp	Thu Jul 22 16:35:22 2010 +0100
@@ -1,19 +1,3 @@
-#
-# Copyright (c) 2009 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"
-# which accompanies this distribution, and is available
-# at the URL "http://www.eclipse.org/legal/epl-v10.html".
-#
-# Initial Contributors:
-# Nokia Corporation - initial contribution.
-#
-# Contributors:
-#
-# Description: 
-#
-
 component	app-services_testalarmsrv
 source	\sf\mw\appsupport\commonappservices\alarmservertest
 binary	\sf\mw\appsupport\commonappservices\alarmservertest\TestAlarmSrv	all
--- a/commonappservices/appservicesdocs/app-services_documentation.history.xml	Tue Jun 15 16:07:48 2010 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,5 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<relnotes name="DEVELOPERLIBRARY">
-  <purpose>
-  </purpose>
-</relnotes>
--- a/commonappservices/appservicesdocs/app-services_documentation.mrp	Tue Jun 15 16:07:48 2010 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,25 +0,0 @@
-#
-# Copyright (c) 2009 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"
-# which accompanies this distribution, and is available
-# at the URL "http://www.eclipse.org/legal/epl-v10.html".
-#
-# Initial Contributors:
-# Nokia Corporation - initial contribution.
-#
-# Contributors:
-#
-# Description: 
-#
-
-component	app-services_documentation
-
-source	\sf\mw\appsupport\commonappservices\appservicesdocs\
-
-notes_source	\component_defs\release.src
-
-
-ipr E 
-
Binary file commonappservices/appservicesdocs/architecturaldescription.eap has changed
--- a/commonappservices/backuprestorenotification/group/app-services_BackupRestoreNotification.mrp	Tue Jun 15 16:07:48 2010 +0100
+++ b/commonappservices/backuprestorenotification/group/app-services_BackupRestoreNotification.mrp	Thu Jul 22 16:35:22 2010 +0100
@@ -1,19 +1,3 @@
-#
-# Copyright (c) 2009 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"
-# which accompanies this distribution, and is available
-# at the URL "http://www.eclipse.org/legal/epl-v10.html".
-#
-# Initial Contributors:
-# Nokia Corporation - initial contribution.
-#
-# Contributors:
-#
-# Description: 
-#
-
 component	app-services_BackupRestoreNotification
 source	\sf\mw\appsupport\commonappservices\backuprestorenotification
 binary	\sf\mw\appsupport\commonappservices\backuprestorenotification\group	all
--- a/commonappservices/coreappstest/Group/app-services_CoreAppsTest.mrp	Tue Jun 15 16:07:48 2010 +0100
+++ b/commonappservices/coreappstest/Group/app-services_CoreAppsTest.mrp	Thu Jul 22 16:35:22 2010 +0100
@@ -1,19 +1,3 @@
-#
-# Copyright (c) 2009 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"
-# which accompanies this distribution, and is available
-# at the URL "http://www.eclipse.org/legal/epl-v10.html".
-#
-# Initial Contributors:
-# Nokia Corporation - initial contribution.
-#
-# Contributors:
-#
-# Description: 
-#
-
 component app-services_coreappstest
 source	\sf\mw\appsupport\commonappservices\coreappstest
 binary	\sf\mw\appsupport\commonappservices\coreappstest\Group	all
Binary file commonappservices/doc_pub/App-Services_Architectural_Description.doc has changed
Binary file commonappservices/doc_pub/App-Services_Functional_Specification.doc has changed
Binary file commonappservices/doc_pub/PIMTestCodeOrganisationHowTo.doc has changed
Binary file commonappservices/doc_pub/SGL.GT0109.110_Rev1.2_AppServices_Subsystem_Release_Note.doc has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commonappservices/doc_pub/app-services_documentation.history.xml	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<relnotes name="DEVELOPERLIBRARY">
+  <purpose>
+  </purpose>
+</relnotes>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commonappservices/doc_pub/app-services_documentation.mrp	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,9 @@
+component	app-services_documentation
+
+source	\sf\mw\appsupport\commonappservices\doc_pub\
+
+notes_source	\component_defs\release.src
+
+
+ipr E 
+
Binary file commonappservices/doc_pub/architecturaldescription.eap has changed
--- a/contenthandling/webrecognisers/Documentation/Uid.txt	Tue Jun 15 16:07:48 2010 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,14 +0,0 @@
-UIDs Allocated for Application-Protocol Recognisers
-
-KUidAppProtRecognisers
-
-101FD8D0	KUidRecogTestEcomInterface	ECom Interface for recogniser test plugins
-101FD8D1	KUidWebUrlRecogTestDll		Web URL recogniser test plugin DLL UID
-101FD8D2	KUidWebUrlRecogTest		Web URL recogniser ECom implementation UID
-101FD8D3	KUidEBookmarkRecogTestDll	EBookmark recogniser test plugin DLL UID
-101FD8D4	KUidEBookmarkRecogTest		EBookmark recogniser ECom implementation UID
-101FD8D5	KUidRecWebRecogTestDll		Web (html/xml) recogniser test plugin DLL UID
-101FD8D6	KUidRecWebRecogTest		Web (html/xml) recogniser ECom implementation UID
-101FD8D7
-101FD8D8
-101FD8D9
\ No newline at end of file
--- a/contenthandling/webrecognisers/Test/Group/t_ebookmark.mmp	Tue Jun 15 16:07:48 2010 +0100
+++ b/contenthandling/webrecognisers/Test/Group/t_ebookmark.mmp	Thu Jul 22 16:35:22 2010 +0100
@@ -1,4 +1,4 @@
-// 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"
@@ -13,6 +13,8 @@
 // Description:
 //
 
+#include <platform_paths.hrh>
+
 TARGET t_ebookmark.dll
 TARGETTYPE plugin
 CAPABILITY protserv
@@ -27,14 +29,13 @@
 
 USERINCLUDE		. ../t_recogtest
 #ifdef SYMBIAN_OLD_EXPORT_LOCATION
-SYSTEMINCLUDE	/epoc32/include
+MW_LAYER_SYSTEMINCLUDE 
 SYSTEMINCLUDE	/epoc32/include/ecom
 #else
 OS_LAYER_SYSTEMINCLUDE_SYMBIAN
 SYSTEMINCLUDE	/epoc32/include/ecom
 SYSTEMINCLUDE	/epoc32/include/platform/ecom
-SYSTEMINCLUDE	/epoc32/include/mw
-SYSTEMINCLUDE	/epoc32/include/platform/mw
+MW_LAYER_SYSTEMINCLUDE 
 #endif
 
 
--- a/contenthandling/webrecognisers/Test/Group/t_recogtest.mmp	Tue Jun 15 16:07:48 2010 +0100
+++ b/contenthandling/webrecognisers/Test/Group/t_recogtest.mmp	Thu Jul 22 16:35:22 2010 +0100
@@ -1,4 +1,4 @@
-// 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"
@@ -13,6 +13,8 @@
 // Description:
 //
 
+#include <platform_paths.hrh>
+
 TARGET			t_recogtest.exe
 TARGETTYPE		exe
 CAPABILITY 		ProtServ
@@ -23,14 +25,13 @@
 
 USERINCLUDE		.
 #ifdef SYMBIAN_OLD_EXPORT_LOCATION
-SYSTEMINCLUDE	/epoc32/include
+MW_LAYER_SYSTEMINCLUDE
 SYSTEMINCLUDE	/epoc32/include/ecom
 #else
 OS_LAYER_SYSTEMINCLUDE_SYMBIAN
 SYSTEMINCLUDE	/epoc32/include/ecom
 SYSTEMINCLUDE	/epoc32/include/platform/ecom
-SYSTEMINCLUDE	/epoc32/include/mw
-SYSTEMINCLUDE	/epoc32/include/platform/mw
+MW_LAYER_SYSTEMINCLUDE
 #endif
 
 LIBRARY			euser.lib ecom.lib
--- a/contenthandling/webrecognisers/Test/Group/t_recwap.mmp	Tue Jun 15 16:07:48 2010 +0100
+++ b/contenthandling/webrecognisers/Test/Group/t_recwap.mmp	Thu Jul 22 16:35:22 2010 +0100
@@ -1,4 +1,4 @@
-// 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 "Eclipse Public License v1.0"
@@ -13,6 +13,8 @@
 // Description:
 //
 
+#include <platform_paths.hrh>
+
 TARGET t_recwap.dll
 TARGETTYPE plugin
 CAPABILITY protserv
@@ -27,14 +29,13 @@
 
 USERINCLUDE		. ../t_recogtest
 #ifdef SYMBIAN_OLD_EXPORT_LOCATION
-SYSTEMINCLUDE	/epoc32/include
+MW_LAYER_SYSTEMINCLUDE
 SYSTEMINCLUDE	/epoc32/include/ecom
 #else
 OS_LAYER_SYSTEMINCLUDE_SYMBIAN
 SYSTEMINCLUDE	/epoc32/include/ecom
 SYSTEMINCLUDE	/epoc32/include/platform/ecom
-SYSTEMINCLUDE	/epoc32/include/mw
-SYSTEMINCLUDE	/epoc32/include/platform/mw
+MW_LAYER_SYSTEMINCLUDE
 #endif
 
 
--- a/contenthandling/webrecognisers/Test/Group/t_recweb.mmp	Tue Jun 15 16:07:48 2010 +0100
+++ b/contenthandling/webrecognisers/Test/Group/t_recweb.mmp	Thu Jul 22 16:35:22 2010 +0100
@@ -1,4 +1,4 @@
-// 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"
@@ -13,6 +13,8 @@
 // Description:
 //
 
+#include <platform_paths.hrh>
+
 TARGET t_recweb.dll
 TARGETTYPE plugin
 CAPABILITY protserv
@@ -27,14 +29,13 @@
 
 USERINCLUDE		. ../t_recogtest
 #ifdef SYMBIAN_OLD_EXPORT_LOCATION
-SYSTEMINCLUDE	/epoc32/include
+MW_LAYER_SYSTEMINCLUDE
 SYSTEMINCLUDE	/epoc32/include/ecom
 #else
 OS_LAYER_SYSTEMINCLUDE_SYMBIAN
 SYSTEMINCLUDE	/epoc32/include/ecom
 SYSTEMINCLUDE	/epoc32/include/platform/ecom
-SYSTEMINCLUDE	/epoc32/include/mw
-SYSTEMINCLUDE	/epoc32/include/platform/mw
+MW_LAYER_SYSTEMINCLUDE
 #endif
 
 
--- a/contenthandling/webrecognisers/Test/Group/t_weburlrec.mmp	Tue Jun 15 16:07:48 2010 +0100
+++ b/contenthandling/webrecognisers/Test/Group/t_weburlrec.mmp	Thu Jul 22 16:35:22 2010 +0100
@@ -1,4 +1,4 @@
-// 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"
@@ -13,6 +13,8 @@
 // Description:
 //
 
+#include <platform_paths.hrh>
+
 TARGET t_weburlrec.dll
 TARGETTYPE plugin
 CAPABILITY protserv
@@ -27,14 +29,13 @@
 
 USERINCLUDE		. ../t_recogtest
 #ifdef SYMBIAN_OLD_EXPORT_LOCATION
-SYSTEMINCLUDE	/epoc32/include
+MW_LAYER_SYSTEMINCLUDE
 SYSTEMINCLUDE	/epoc32/include/ecom
 #else
 OS_LAYER_SYSTEMINCLUDE_SYMBIAN
 SYSTEMINCLUDE	/epoc32/include/ecom
 SYSTEMINCLUDE	/epoc32/include/platform/ecom
-SYSTEMINCLUDE	/epoc32/include/mw
-SYSTEMINCLUDE	/epoc32/include/platform/mw
+MW_LAYER_SYSTEMINCLUDE
 #endif
 
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/contenthandling/webrecognisers/doc_pub/Uid.txt	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,30 @@
+// Copyright (c) 1999-2009 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"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+
+UIDs Allocated for Application-Protocol Recognisers
+
+KUidAppProtRecognisers
+
+101FD8D0	KUidRecogTestEcomInterface	ECom Interface for recogniser test plugins
+101FD8D1	KUidWebUrlRecogTestDll		Web URL recogniser test plugin DLL UID
+101FD8D2	KUidWebUrlRecogTest		Web URL recogniser ECom implementation UID
+101FD8D3	KUidEBookmarkRecogTestDll	EBookmark recogniser test plugin DLL UID
+101FD8D4	KUidEBookmarkRecogTest		EBookmark recogniser ECom implementation UID
+101FD8D5	KUidRecWebRecogTestDll		Web (html/xml) recogniser test plugin DLL UID
+101FD8D6	KUidRecWebRecogTest		Web (html/xml) recogniser ECom implementation UID
+101FD8D7
+101FD8D8
+101FD8D9
\ No newline at end of file
--- a/contenthandling/webrecognisers/group/application-protocols_recognisers.mrp	Tue Jun 15 16:07:48 2010 +0100
+++ b/contenthandling/webrecognisers/group/application-protocols_recognisers.mrp	Thu Jul 22 16:35:22 2010 +0100
@@ -1,19 +1,3 @@
-#
-# Copyright (c) 2009 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"
-# which accompanies this distribution, and is available
-# at the URL "http://www.eclipse.org/legal/epl-v10.html".
-#
-# Initial Contributors:
-# Nokia Corporation - initial contribution.
-#
-# Contributors:
-#
-# Description: 
-#
-
 component	application-protocols_recognisers
 source	\sf\mw\appsupport\contenthandling\webrecognisers
 binary	\sf\mw\appsupport\contenthandling\webrecognisers\group	all
Binary file contextframework/cfw/conf/contextframework.confml has changed
Binary file contextframework/cfw/conf/contextframework_10282BCD.crml has changed
--- a/contextframework/cfwplugins/ApplicationStateSourcePlugIn/group/bld.inf	Tue Jun 15 16:07:48 2010 +0100
+++ b/contextframework/cfwplugins/ApplicationStateSourcePlugIn/group/bld.inf	Thu Jul 22 16:35:22 2010 +0100
@@ -10,13 +10,17 @@
 * Nokia Corporation - initial contribution.
 *
 * Contributors:
-* NTT DOCOMO, INC - BUG 2365
+* 
 *
 * Description:
 *
 */
 
 
+/*
+*NTT DOCOMO, INC - BUG 2365
+*/
+
 #include <platform_paths.hrh>
 
 PRJ_PLATFORMS
--- a/contextframework/cfwplugins/PSStateSourcePlugIn/group/bld.inf	Tue Jun 15 16:07:48 2010 +0100
+++ b/contextframework/cfwplugins/PSStateSourcePlugIn/group/bld.inf	Thu Jul 22 16:35:22 2010 +0100
@@ -10,13 +10,17 @@
 * Nokia Corporation - initial contribution.
 *
 * Contributors:
-* NTT DOCOMO, INC - BUG 2365
+* 
 * 
 * Description:  Build information file for project PSStateSourcePlugIn
 *
 */
 
 
+/*
+*NTT DOCOMO, INC - BUG 2365
+*/
+
 #include <platform_paths.hrh>
 
 PRJ_PLATFORMS
--- a/contextframework/cfwplugins/sensorsourceplugin/group/bld.inf	Tue Jun 15 16:07:48 2010 +0100
+++ b/contextframework/cfwplugins/sensorsourceplugin/group/bld.inf	Thu Jul 22 16:35:22 2010 +0100
@@ -10,12 +10,15 @@
 * Nokia Corporation - initial contribution.
 *
 * Contributors:
-* NTT DOCOMO, INC - BUG 2365
+* 
 *
 * Description:  Build information file for project SensorSourcePlugin
 *
 */
 
+/*
+*NTT DOCOMO, INC - BUG 2365
+*/
 
 #include <platform_paths.hrh>
 
--- a/coreapplicationuis/ATCmdPlugin/sis/atcmdplugin.pkg	Tue Jun 15 16:07:48 2010 +0100
+++ b/coreapplicationuis/ATCmdPlugin/sis/atcmdplugin.pkg	Thu Jul 22 16:35:22 2010 +0100
@@ -11,8 +11,9 @@
 ;
 ; Contributors:
 ;
-; Description: 
+; Description:  ?Description
 ;
+
 ; ExtAtCmdHandler.pkg
 ;
 ;Language - standard language definitions
--- a/coreapplicationuis/Rfs/Plugins/GSRFSPlugin/data/10275117.rss	Tue Jun 15 16:07:48 2010 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,43 +0,0 @@
-/*
-* Copyright (c) 2009 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"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:  ECOM plugin resource file for GS RFS plugin.
-*
-*/
-
-
-#include <ecom/registryinfo.rh>
-
-RESOURCE REGISTRY_INFO theInfo
-	{
-	dll_uid     = 0x10275117; // Plugin dll UID
-	interfaces  = 
-		{
-		INTERFACE_INFO
-			{
-			interface_uid   = 0x10207236; // UID for CGSPluginInterface - do not change.
-			implementations = 
-				{
-				IMPLEMENTATION_INFO
-					{
-					implementation_uid  = 0x10275118; // Plugin UID
-					version_no          = 1;
-					display_name        = "GS RFS Plugin"; // Plugin debug name
-					default_data        = "0x10283317"; // Parent UID
-					opaque_data         = "40"; // Order number
-					}
-				};
-			}
-		};
-	}
-
--- a/coreapplicationuis/Rfs/Plugins/GSRFSPlugin/data/GSRFSPluginRsc.rss	Tue Jun 15 16:07:48 2010 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,154 +0,0 @@
-/*
-* Copyright (c) 2005-2009 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"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description: 
-*        Resource file for GSRFSPlugin
-*
-*/
-
-
-//  RESOURCE IDENTIFIER
-NAME    GRFS // 4 letter ID
-
-//  INCLUDES
-
-#include <avkon.rsg>
-#include <avkon.mbg>
-#include <EIKCORE.rsg>
-#include <eikon.rsg>
-#include <avkon.loc>
-#include "gsrfsplugin.hrh"
-#include "gsrfsplugin.loc"
-#include <uikon.rh>
-
-
-// CONSTANTS
-
-//  RESOURCE DEFINITIONS 
-
-//----------------------------------------------------
-//   
-//    
-//    Needed or loading the resource fails!
-//
-//----------------------------------------------------
-//
-RESOURCE RSS_SIGNATURE
-    {
-    }
-
-#include "gscommonresources.rss"
-RESOURCE TBUF
-    {
-    buf="GRFS";
-    }
-
-//----------------------------------------------------
-//
-//    EIK_APP_INFO
-//    It contains application information.
-//
-//----------------------------------------------------
-//
-RESOURCE EIK_APP_INFO
-    {
-    }
-
-//----------------------------------------------------
-//  r_rfs_factory_settings
-// 
-//  Orig. factory settings caption for plugin
-//----------------------------------------------------
-//
-RESOURCE TBUF r_rfs_factory_settings
-    {
-    buf = qtn_set_folder_original_settings;
-    }
-
-//----------------------------------------------------
-//  r_rfs_factory_settings_title
-//
-//  Factory settings view title.
-//----------------------------------------------------
-//
-RESOURCE TITLE_PANE r_rfs_factory_settings_title
-    {
-    txt = qtn_set_folder_original_settings;
-    }
-
-
-//----------------------------------------------------
-//  r_rfs_factory_settings_view
-//  
-//  Factory settings view.
-//----------------------------------------------------
-//
-RESOURCE MENU_BAR r_gs_menubar_exit_help
-    {
-    titles =
-        {
-        MENU_TITLE
-            {
-            menu_pane = r_gs_menu_item_exit;
-            },
-        MENU_TITLE
-            {
-            menu_pane = r_gs_menu_item_help;
-            }
-        };
-    }
-
-
-RESOURCE CBA r_gs_rfs_softkeys_options_back__exit
-    {
-    buttons =
-        {
-        CBA_BUTTON {id=EAknSoftkeyOptions; txt = text_softkey_option;},
-        CBA_BUTTON {id=EAknSoftkeyBack; txt = text_softkey_back; }
-        };
-    }
-
-RESOURCE AVKON_VIEW r_rfs_factory_settings_view
-    {
-    menubar = r_gs_menubar_exit_help; 
-    cba = r_gs_rfs_softkeys_options_back__exit;
-    }
-
-
-
-//----------------------------------------------------
-//  r_rfs_factory_settings_lbx
-//
-//  Factory settings view's listbox.
-//----------------------------------------------------
-
-//
-RESOURCE GS_FEATURE_ARRAY r_rfs_factory_settings_lbx
-    {
-    items =
-        {
-        GS_FEATURE
-            {
-            txt = " \t"qtn_rfs_orig_settings"\t\t";
-            item = EGSSettIdOptNormalRfs;
-
-            },
-        GS_FEATURE
-            {
-            txt = " \t"qtn_rfs_erase_all_data"\t\t";
-            item = EGSSettIdOptDeepRfs;
-            }
-        };
-    }
-
-//End of File
--- a/coreapplicationuis/Rfs/Plugins/GSRFSPlugin/group/GSRFSPlugin.mmp	Tue Jun 15 16:07:48 2010 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,83 +0,0 @@
-/*
-* Copyright (c) 2005-2009 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"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:  Project specification file.
-*
-*/
-
-
-#include  <data_caging_paths.hrh>    // For RESOURCE_FILES_DIR
-#include <platform_paths.hrh>
-
-CAPABILITY          CAP_ECOM_PLUGIN
-TARGET              gsrfsplugin.dll
-TARGETTYPE          PLUGIN
-UID                 0x10009D8D 0x10275117
-VENDORID            VID_DEFAULT
-
-
-SOURCEPATH  ../src
-SOURCE      GSRFSPluginImplementationTable.cpp
-SOURCE      GSRFSPlugin.cpp
-SOURCE      GSRFSPluginContainer.cpp
-
-//User include paths
-USERINCLUDE     ../inc
-USERINCLUDE     ../data         	// For *.rh
-USERINCLUDE     ../../../inc 		// for gsrfsplugin.loc
- 
-
-//System include paths
-APP_LAYER_SYSTEMINCLUDE   /epoc32/include/ecom
-APP_LAYER_SYSTEMINCLUDE   /epoc32/include/cshelp
-
-//System include paths
-MW_LAYER_SYSTEMINCLUDE
-
-SOURCEPATH      ../data
-
-START RESOURCE  10275117.rss
-TARGET          gsrfsplugin.rsc
-END
-
-START RESOURCE  GSRFSPluginRsc.rss
-TARGETPATH      RESOURCE_FILES_DIR
-HEADER
-LANGUAGE_IDS
-END
-
-LIBRARY   euser.lib
-LIBRARY   ecom.lib
-LIBRARY   efsrv.lib
-LIBRARY   avkon.lib
-LIBRARY   bafl.lib 
-LIBRARY   cone.lib 
-LIBRARY   eikcoctl.lib 
-LIBRARY   eikcore.lib 
-LIBRARY   egul.lib
-LIBRARY   ws32.lib
-LIBRARY   rfs.lib
-LIBRARY   gsecomplugin.lib
-LIBRARY   commonengine.lib
-LIBRARY   fbscli.lib
-LIBRARY   aknicon.lib
-LIBRARY   aknskins.lib
-
-LIBRARY   hlplch.lib
-LIBRARY   gsframework.lib
-LIBRARY   gslistbox.lib
-
-
-DOCUMENT            10275117.rss
-
-// End of File
\ No newline at end of file
--- a/coreapplicationuis/Rfs/Plugins/GSRFSPlugin/group/GSRFSPluginIcons.mk	Tue Jun 15 16:07:48 2010 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,71 +0,0 @@
-#
-# Copyright (c) 2007 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"
-# which accompanies this distribution, and is available
-# at the URL "http://www.eclipse.org/legal/epl-v10.html".
-#
-# Initial Contributors:
-# Nokia Corporation - initial contribution.
-#
-# Contributors:
-#
-# Description: 
-#
-
-
-ifeq (WINS,$(findstring WINS, $(PLATFORM)))
-ZDIR=\epoc32\release\$(PLATFORM)\$(CFG)\Z
-else
-ZDIR=\epoc32\data\z
-endif
-
-# ----------------------------------------------------------------------------
-# Configure these
-# ----------------------------------------------------------------------------
-
-TARGETDIR=$(ZDIR)\resource\apps
-HEADERDIR=\epoc32\include
-ICONTARGETFILENAME=$(TARGETDIR)\GSRFSPlugin.mif
-HEADERFILENAME=$(HEADERDIR)\GSRFSPlugin.mbg
-
-do_nothing :
-	@rem do_nothing
-
-MAKMAKE : do_nothing
-
-BLD : do_nothing
-
-CLEAN : do_nothing
-
-LIB : do_nothing
-
-CLEANLIB : do_nothing
-
-# ----------------------------------------------------------------------------
-# Configure these.
-#
-# NOTE 1: DO NOT DEFINE MASK FILE NAMES! They are included automatiNetworky by
-# MifConv if the mask detph is defined.
-#
-# NOTE 2: Usually, source paths should not be included in the bitmap
-# definitions. MifConv searches for the icons in all icon directories in a
-# predefined order, which is currently \s60\icons, \s60\bitmaps2, \s60\bitmaps.
-# The directory \s60\icons is included in the search only if the feature flag
-# __SCALABLE_ICONS is defined.
-# ----------------------------------------------------------------------------
-
-RESOURCE :
-	mifconv $(ICONTARGETFILENAME) /h$(HEADERFILENAME) \
-		/c8,8 qgn_prop_set_gene_phone.bmp
-
-FREEZE : do_nothing
-
-SAVESPACE : do_nothing
-
-RELEASABLES :
-	@echo $(HEADERFILENAME)&& \
-	@echo $(ICONTARGETFILENAME)
-
-FINAL : do_nothing
--- a/coreapplicationuis/Rfs/Plugins/GSRFSPlugin/group/bld.inf	Tue Jun 15 16:07:48 2010 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,39 +0,0 @@
-/*
-* Copyright (c) 2005 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"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:  This file provides the information required for building
-*                GS RFS Plugin.
-*
-*/
-
-#include <platform_paths.hrh>
-
-PRJ_PLATFORMS
-DEFAULT
-
-PRJ_EXPORTS
-../loc/gsrfsplugin.loc             MW_LAYER_LOC_EXPORT_PATH(gsrfsplugin.loc)
-
-PRJ_EXTENSIONS
-START EXTENSION s60/mifconv
-  OPTION TARGETFILE GSRFSPlugin.mif
-  OPTION HEADERFILE GSRFSPlugin.mbg
-  OPTION SOURCES -c8,8 qgn_prop_set_gene_phone
-END
-
-
-PRJ_MMPFILES
-//gnumakefile GSRFSPluginIcons.mk
-GSRFSPlugin.mmp
-
-//  End of File
--- a/coreapplicationuis/Rfs/Plugins/GSRFSPlugin/inc/GSRFSPlugin.h	Tue Jun 15 16:07:48 2010 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,133 +0,0 @@
-/*
-* Copyright (c) 2005-2009 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"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:  GS Restore Factory Settings plugin
-*
-*/
-
-
-#ifndef GSRFSPLUGIN_H
-#define GSRFSPLUGIN_H
-
-// Includes
-#include <aknsettingpage.h>
-#include <gsbaseview.h>
-#include <ConeResLoader.h>
-#include <gsplugininterface.h>
-
-// Classes referenced
-class CRfsHandler;
-class CGSRFSPluginContainer;
-class CAknViewAppUi;
-
-// Constants
-const TUid KGSRFSPluginUid = { 0x10275117 };
-  
-
-// Class Declaration
-/**
- *
- * @since Series60_3.1
- */
-class CGSRFSPlugin : public CGSBaseView
-    {
-public: // Constructors and destructor
-        
-    /**
-     * Symbian OS two-phased constructor
-     * @return 
-     */
-    static CGSRFSPlugin* NewL( TAny* aInitParams );
-    
-    /**
-     * Destructor.
-     */
-     ~CGSRFSPlugin();
-
-public: // From CAknView
-                
-     /**
-      * See base class.
-      *
-      * This function is used also for identifying the plugin so be sure to
-      * return correct UID.
-      */
-     TUid Id() const;
-        
-     /**
-      * See base class.
-      */
-     void HandleClientRectChange();
-        
-     /**
-      * See base class.
-      */
-     void DoActivateL( const TVwsViewId& aPrevViewId, TUid aCustomMessageId, const TDesC8& aCustomMessage );
-        
-     /**
-      * See base class.
-      */
-     void DoDeactivate();
-        
-     /**
-      * See base class.
-      */
-     void HandleCommandL( TInt aCommand );
-        
-
-public: // From CGSPluginInterface
-       
-     /**
-      * See base class.
-      */
-     void GetCaptionL( TDes& aCaption ) const;
-        
-     /**
-      * See base class.
-      */
-     TInt PluginProviderCategory() const;
-
-     /**
-      * See base class.
-      */
-     CGulIcon* CreateIconL( const TUid aIconType );
-        
-protected: // New
-
-     /**
-      * C++ default constructor.
-      */
-     CGSRFSPlugin();
-
-     /**
-      * Symbian OS default constructor.
-      */
-     void ConstructL();
-        
-     void DynInitMenuPaneL( TInt aResourceId, CEikMenuPane* aMenuPane );
-        
-private: // from CGSBaseView
-        
-     void NewContainerL();
-        
-     void HandleListBoxSelectionL();    
-        
-private: // Data
-
-     // Resource loader
-     RConeResourceLoader iResourceLoader;
-    };
-
-#endif // GSRFSPLUGIN_H
-
-// End of File
--- a/coreapplicationuis/Rfs/Plugins/GSRFSPlugin/inc/GSRFSPluginContainer.h	Tue Jun 15 16:07:48 2010 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,70 +0,0 @@
-/*
-* Copyright (c) 2007-2009 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"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:
-*
-*/
-
-#ifndef GSRFSPLUGINCONTAINER_H
-#define GSRFSPLUGINCONTAINER_H
-
-// INCLUDES
-#include <gsbasecontainer.h>
-#include "gssettingid.h"
-
-// CLASS DECLARATION
-class CGSRFSPlugin;
-class CGSListBoxItemTextArray;
-
-
-class CGSRFSPluginContainer : public CGSBaseContainer
-    {
-public: 
-        
-    /**
-     *  C++ default constructor.
-     */
-    CGSRFSPluginContainer( CGSRFSPlugin* aGSRFSPlugin );
-
-    /**
-     * By default Symbian OS constructor is private.
-     */
-    void ConstructL(const TRect& aRect);
-
-    /**
-     * Destructor.
-     */
-    ~CGSRFSPluginContainer();
-        
-public: // new methods
-        
-    TInt CurrentFeatureId() const;
-
-protected: // from CGSBaseContainer
-    
-    void ConstructListBoxL( TInt aResLbxId );
-    
-private: // from CCoeControl    
-        
-    void GetHelpContext( TCoeHelpContext& aContext ) const;
-
-private: // data
-
-    CGSRFSPlugin* iGSRFSPlugin;                 // not own    
-    CGSListBoxItemTextArray* iListboxItemArray;
-    };
-
-
-#endif  // GSRFSPLUGINCONTAINER_H
-
-// End of File
--- a/coreapplicationuis/Rfs/Plugins/GSRFSPlugin/inc/GSRFSPluginTraces.h	Tue Jun 15 16:07:48 2010 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,44 +0,0 @@
-/*
-* Copyright (c) 2002 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"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:  Includes some common defines used in the startup application
-*
-*/
-
-
-#ifndef STARTUPDEFINES_H
-#define STARTUPDEFINES_H
-
-//CONSTANTS
-_LIT( KAppName, "GSRFSPlugin" );           // The application name
-
-// MACROS
-
-#define PANIC(aPanic) User::Panic( KAppName, aPanic )
-
-#define TRACE_ADDPREFIX(aText) (TPtrC((const TText *)L"GSRFSPlugin: \"" L##aText L"\""))
-
-#ifdef _DEBUG
-#define TRACES(aMsg) RDebug::Print( TRACE_ADDPREFIX(aMsg) )
-#define TRACES1(aFormat,aP1) RDebug::Print( TRACE_ADDPREFIX(aFormat),(aP1) )
-#define TRACES2(aFormat,aP1,aP2) RDebug::Print( TRACE_ADDPREFIX(aFormat),(aP1),(aP2) )
-#define TRACES3(aFormat,aP1,aP2,aP3) RDebug::Print( TRACE_ADDPREFIX(aFormat),(aP1),(aP2),(aP3) )
-#else
-#define TRACES(aMsg)
-#define TRACES1(aFormat,aP1)
-#define TRACES2(aFormat,aP1,aP2)
-#define TRACES3(aFormat,aP1,aP2,aP3)
-#endif
-#endif      // STARTUPDEFINES_H
-            
-// End of File
--- a/coreapplicationuis/Rfs/Plugins/GSRFSPlugin/inc/gscommonresources.rss	Tue Jun 15 16:07:48 2010 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,187 +0,0 @@
-/*
-* Copyright (c) 2005-2009 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"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:  Common resources for internal GS plugins. This .rss is
-*                 included by other .rss files. This should not be compiled
-                  alone.
-*
-*/
-
-//  RESOURCE IDENTIFIER
-//NAME    GSCR // 4 letter ID
-
-//  INCLUDES
-#include    <gs.loc> // Common localized GS strings
-#include    <gscommon.rh> // Common GS resource structures
-
-#include    <bldvariant.hrh>
-#include    <eikon.rh>
-#include    <eikon.rsg>
-#include    <avkon.rh>
-#include    <avkon.loc>
-
-// CONSTANTS
-
-// -----------------------------------------------------------------------------
-//
-// r_gs_menubar_change_exit
-// GS menu with 'change' and 'exit' items.
-//
-// -----------------------------------------------------------------------------
-//
-RESOURCE MENU_BAR r_gs_menubar_change_exit
-    {
-    titles =
-        {
-        MENU_TITLE
-            {
-            menu_pane = r_gs_menu_item_exit;
-            },
-        MENU_TITLE
-            {
-            menu_pane = r_gs_menu_item_help;
-            },
-        MENU_TITLE
-            {
-            menu_pane = r_gs_menu_item_change;
-            }
-        };
-    }
-
-// -----------------------------------------------------------------------------
-//
-// r_gs_menubar_open_exit
-// GS menu with 'Open' and 'Exit' items.
-//
-// -----------------------------------------------------------------------------
-//
-RESOURCE MENU_BAR r_gs_menubar_open_exit
-    {
-    titles =
-        {
-        MENU_TITLE
-            {
-            menu_pane = r_gs_menu_item_exit;
-            },
-        MENU_TITLE
-            {
-            menu_pane = r_gs_menu_item_help;
-            },
-        MENU_TITLE
-            {
-            menu_pane = r_gs_menu_item_open;
-            }
-        };
-    }
-
-//----------------------------------------------------
-//
-// r_gs_menu_item_open
-// Open item.
-//
-//----------------------------------------------------
-
-RESOURCE MENU_PANE r_gs_menu_item_open
-    {
-    items =
-        {
-        MENU_ITEM
-            {
-            command = EAknSoftkeyOpen;
-            txt = qtn_set_options_open;
-            }
-        };
-    }
-
-
-// -----------------------------------------------------------------------------
-//
-// r_gs_menu_item_exit
-//
-// -----------------------------------------------------------------------------
-//
-RESOURCE MENU_PANE r_gs_menu_item_exit
-    {
-    items =
-        {
-        MENU_ITEM
-            {
-            command = EAknCmdExit;
-            txt = qtn_options_exit;
-            }
-        };
-    }
-
-
-// -----------------------------------------------------------------------------
-//
-// r_gs_menu_item_change
-// Change item.
-//
-// -----------------------------------------------------------------------------
-//
-RESOURCE MENU_PANE r_gs_menu_item_change
-    {
-    items =
-        {
-        MENU_ITEM
-            {
-            command = EGSCmdAppChange;
-            txt = qtn_set_options_change;
-            }
-        };
-    }
-
-// -----------------------------------------------------------------------------
-//
-// r_gs_menu_item_help
-// Change item.
-//
-// -----------------------------------------------------------------------------
-//
-RESOURCE MENU_PANE r_gs_menu_item_help
-    {
-    items =
-        {
-        MENU_ITEM
-            {
-            command = EAknCmdHelp;
-            txt = qtn_options_help;
-            }
-        };
-    }
-
-
-// -----------------------------------------------------------------------------
-//
-// r_setting_listbox
-// Common listbox editor resource for setting pages.
-//
-// -----------------------------------------------------------------------------
-//
-RESOURCE LISTBOX r_setting_listbox
-    {
-    flags = EEikListBoxMultipleSelection;
-    }
-
-
-// -----------------------------------------------------------------------------
-//
-// r_gs_cba_exit
-// Exit text for RSK
-//
-// -----------------------------------------------------------------------------
-//
-RESOURCE TBUF r_gs_cba_exit { buf = text_softkey_exit; }
-
-//End of File
--- a/coreapplicationuis/Rfs/Plugins/GSRFSPlugin/inc/gsrfsplugin.hrh	Tue Jun 15 16:07:48 2010 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,30 +0,0 @@
-/*
-* Copyright (c) 2009 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"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:  GS Restore Factory Settings plugin
-*
-*/
-
-
-#ifndef GSRFSPLUGIN_HRH
-#define GSRFSPLUGIN_HRH
-
-enum TSettingId
-    {
-    EGSSettIdOptNormalRfs,
-    EGSSettIdOptDeepRfs
-    };
-
-#endif //  GSRFSPLUGIN_HRH
-
-//End of File
--- a/coreapplicationuis/Rfs/Plugins/GSRFSPlugin/loc/gsrfsplugin.loc	Tue Jun 15 16:07:48 2010 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,44 +0,0 @@
-/*
-* Copyright (c) 2009 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"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description: 
-*	 Localization strings for Plugin
-*
-*/
-
-
-//  LOCALISATION STRINGS
-
-
-//d:Text of a list item in general setting list view's list
-//d:Item restores factory settings
-//l:list_setting_pane_t1
-#define qtn_set_folder_original_settings "Factory settings"
-
-
-//d:displays menu options for reset (full / partial)
-//l:title_pane_t2/opt9
-#define qtn_rfs_title_factory_conf "Factory settings"
-
-
-//d:restores factory settings (normal rfs)
-//l:list_setting_pane_t1 
-#define qtn_rfs_orig_settings "Restore"
-
-
-//d:erases all data (deep rfs)
-//l:list_setting_pane_t1 
-#define qtn_rfs_erase_all_data "Delete data and restore"
-
-
-// End of File
--- a/coreapplicationuis/Rfs/Plugins/GSRFSPlugin/src/GSRFSPlugin.cpp	Tue Jun 15 16:07:48 2010 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,244 +0,0 @@
-/*
-* Copyright (c) 2005-2009 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"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description: 
-*        GS RFS Plugin
-*
-*/
-
-
-// SYSTEM INCLUDES
-#include <aknViewAppUi.h>
-#include <bautils.h>
-#include <rfsHandler.h>
-#include <gsprivatepluginproviderids.h>
-#include <StringLoader.h>
-#include <GSRFSPluginRsc.rsg>
-#include <GSRFSPlugin.mbg>
-
-#include <hlplch.h>             
-#include <gscommon.hrh>
-#include <gsfwviewuids.h>
-#include "GSRFSPlugin.h"
-#include "GSRFSPluginTraces.h"
-#include "GSRFSPluginContainer.h"
-#include "gsrfsplugin.hrh"
-
-// Constants
-_LIT( KGSRFSPluginResourceFileName, "z:GSRFSPluginRsc.rsc" );
-
-
-// ---------------------------------------------------------------------------
-// CGSRFSPlugin::CGSRFSPlugin()
-// Constructor
-// ---------------------------------------------------------------------------
-CGSRFSPlugin::CGSRFSPlugin()
-    :iResourceLoader( *iCoeEnv )
-    {
-    TRACES("CGSRFSPlugin::CGSRFSPlugin()");
-    }
-
-// ---------------------------------------------------------------------------
-// CGSRFSPlugin::~CGSRFSPlugin()
-// Destructor
-// ---------------------------------------------------------------------------
-CGSRFSPlugin::~CGSRFSPlugin()
-    {
-    TRACES("CGSRFSPlugin::~CGSRFSPlugin()");
-	  iResourceLoader.Close();
-    TRACES("CGSRFSPlugin::~CGSRFSPlugin(): End");
-    }
-
-// ---------------------------------------------------------------------------
-// CGSRFSPlugin::ConstructL(const TRect& aRect)
-// Symbian OS two-phased constructor
-// ---------------------------------------------------------------------------
-void CGSRFSPlugin::ConstructL()
-    {
-    TRACES("CGSRFSPlugin::ConstructL()");
-    
-    // Find the resource file
-    TParse parse;
-    parse.Set( KGSRFSPluginResourceFileName, &KDC_RESOURCE_FILES_DIR, NULL );
-    TFileName fileName( parse.FullName() );
-    
-    // Get language of resource file
-    BaflUtils::NearestLanguageFile( iCoeEnv->FsSession(), fileName );
-
-    // Open resource file
-    iResourceLoader.OpenL( fileName );
-
-    BaseConstructL( R_RFS_FACTORY_SETTINGS_VIEW );
-
-    TRACES("CGSRFSPlugin::ConstructL(): End");
-    }
-
-// ---------------------------------------------------------------------------
-// CGSRFSPlugin::NewL()
-// Static constructor
-// ---------------------------------------------------------------------------
-CGSRFSPlugin* CGSRFSPlugin::NewL( TAny* /*aInitParams*/ )
-    {
-    TRACES("CGSRFSPlugin::NewL()");
-    CGSRFSPlugin* self = new( ELeave ) CGSRFSPlugin();
-    CleanupStack::PushL( self );
-    self->ConstructL();
-    CleanupStack::Pop( self );
-    TRACES("CGSRFSPlugin::NewL(): End");
-    return self;
-    }
-
-// ---------------------------------------------------------------------------
-// CGSRFSPlugin::Id()
-// ---------------------------------------------------------------------------
-TUid CGSRFSPlugin::Id() const
-    {
-    return KGSRFSPluginUid;
-    }
-
-// ---------------------------------------------------------------------------
-// CGSRFSPlugin::DoActivateL()
-// ---------------------------------------------------------------------------
-void CGSRFSPlugin::DoActivateL( const TVwsViewId& aPrevViewId, TUid aCustomMessageId, const TDesC8& aCustomMessage )
-    {
-    TRACES("CGSRFSPlugin::DoActivateL()");
-    CGSBaseView::DoActivateL( aPrevViewId, aCustomMessageId, aCustomMessage );
-    }
-    
-// ---------------------------------------------------------------------------
-// CGSRFSPlugin::DoDeactivate()
-// ---------------------------------------------------------------------------
-void CGSRFSPlugin::DoDeactivate()
-    {
-    TRACES("CGSRFSPlugin::DoDeactivate()");
-    CGSBaseView::DoDeactivate();
-    }
-
-// ---------------------------------------------------------------------------
-// CGSRFSPlugin::HandleCommandL()
-// ---------------------------------------------------------------------------
-void CGSRFSPlugin::HandleCommandL( TInt aCommand )
-    {
-    TRACES("CGSRFSPlugin::HandleCommandL()");
-    switch ( aCommand )
-        {
-        case EAknSoftkeyBack:
-            {
-            iAppUi->ActivateLocalViewL( KGSDeviceManagementPluginUid  );
-            break;
-            }
-        case EAknCmdHelp:
-            {
-            HlpLauncher::LaunchHelpApplicationL(iEikonEnv->WsSession(), iAppUi->AppHelpContextL() );
-            break;
-            }
-        default:
-            {
-            iAppUi->HandleCommandL( aCommand );
-            break;
-            }
-        }
-    }
-
-// ---------------------------------------------------------------------------
-// CGSRFSPlugin::GetCaptionL()
-// ---------------------------------------------------------------------------
-void CGSRFSPlugin::GetCaptionL( TDes& aCaption ) const
-    {
-    // the resource file is already opened
-    HBufC* result = StringLoader::LoadL( R_RFS_FACTORY_SETTINGS );    
-    aCaption.Copy( *result );
-    delete result;
-    }
-
-// ---------------------------------------------------------------------------
-// CGSRFSPlugin::PluginProviderCategory()
-// ---------------------------------------------------------------------------
-TInt CGSRFSPlugin::PluginProviderCategory() const
-    {
-    return KGSPluginProviderInternal;
-    }
-
-// -----------------------------------------------------------------------------
-// CGSNetworkPlugin::CreateIconL()
-// -----------------------------------------------------------------------------
-CGulIcon* CGSRFSPlugin::CreateIconL( const TUid aIconType )
-    {
-    CGulIcon* icon;
-    TParse* fp = new( ELeave ) TParse();
-    CleanupStack::PushL( fp );
-    _LIT( KGSRFSPluginIconDirAndName, "z:gsrfsplugin.mbm");
-    fp->Set( KGSRFSPluginIconDirAndName, &KDC_BITMAP_DIR, NULL );
-
-    if( aIconType == KGSIconTypeLbxItem )
-        {
-        icon = AknsUtils::CreateGulIconL( AknsUtils::SkinInstance(), KAknsIIDQgnPropSetGenePhone,
-                                          fp->FullName(),EMbmGsrfspluginQgn_prop_set_gene_phone,
-                                          EMbmGsrfspluginQgn_prop_set_gene_phone_mask );
-        }
-    else
-        {
-        icon = CGSPluginInterface::CreateIconL( aIconType );
-        }
-
-    CleanupStack::PopAndDestroy( fp );
-
-    return icon;
-    }
-
-// -----------------------------------------------------------------------------
-// CGSRFSPlugin::DynInitMenuPaneL()
-//
-// Dynamically handle help item if not supported
-// -----------------------------------------------------------------------------
-void CGSRFSPlugin::DynInitMenuPaneL( TInt aResourceId, CEikMenuPane* aMenuPane )
-    {
-    if( aResourceId == R_GS_MENU_ITEM_HELP )
-        {
-        User::LeaveIfNull( aMenuPane );
-        aMenuPane->SetItemDimmed( EAknCmdHelp, EFalse );
-        }
-    }
-
-// ---------------------------------------------------------------------------
-// CGSRFSPlugin::NewContainerL()
-//
-// Creates new iContainer.
-// ---------------------------------------------------------------------------
-void CGSRFSPlugin::NewContainerL()
-    {
-    iContainer = new( ELeave ) CGSRFSPluginContainer( this );
-    }
-
-// ---------------------------------------------------------------------------
-// CGSRFSPlugin::HandleListBoxSelectionL()
-// ---------------------------------------------------------------------------
-void CGSRFSPlugin::HandleListBoxSelectionL()
-    {    
-    CGSRFSPluginContainer *pluginContainer = static_cast<CGSRFSPluginContainer*>( iContainer );
-    const TInt currentFeatureId = pluginContainer->CurrentFeatureId();         
-    
-    CRfsHandler* iRfsHandler = new ( ELeave ) CRfsHandler;
-    CleanupStack :: PushL(iRfsHandler);
-    
-    TRfsType rfsType = ERfsNormal;
-    if ( currentFeatureId == EGSSettIdOptDeepRfs )
-        {
-        rfsType = ERfsDeep;
-        }
-    iRfsHandler->ActivateRfsL( rfsType );
-    
-    CleanupStack :: PopAndDestroy(iRfsHandler);
-    }
-
-// End of file
--- a/coreapplicationuis/Rfs/Plugins/GSRFSPlugin/src/GSRFSPluginContainer.cpp	Tue Jun 15 16:07:48 2010 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,108 +0,0 @@
-/*
-* Copyright (c) 2007-2009 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"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:  
-*
-*/
-
-
-//  INCLUDES
-#include <AknUtils.h>
-#include <AknsDrawUtils.h>
-#include <AknsFrameBackgroundControlContext.h>
-#include <bldvariant.hrh>
-#include <GSRFSPluginRsc.rsg>
-#include <aknlists.h>
-#include <StringLoader.h>
-#include <csxhelp/cp.hlp.hrh>
-#include <gsfwviewuids.h>
-#include <gslistbox.h>
-#include <settingsinternalcrkeys.h>
-#include "GSRFSPluginContainer.h"
-#include "GSRFSPluginTraces.h"
-#include "GSRFSPlugin.h"
-#include "gsrfsplugin.hrh"
-
-
-// ---------------------------------------------------------
-// CGSRFSPluginContainer::CGSRFSPluginContainer()
-// ---------------------------------------------------------
-CGSRFSPluginContainer::CGSRFSPluginContainer( CGSRFSPlugin* aGSRFSPlugin )
-    :iGSRFSPlugin( aGSRFSPlugin )
-    {
-    TRACES("CGSRFSPluginContainer::CGSRFSPluginContainer()");
-    }
-
-// -----------------------------------------------------------------------------
-// CGSRFSPluginContainer::ConstructL
-//
-// -----------------------------------------------------------------------------
-void CGSRFSPluginContainer::ConstructL(const TRect& aRect)
-    {
-    TRACES("CGSRFSPluginContainer::ConstructL()");
-    
-    iListBox = new( ELeave ) CAknSettingStyleListBox;
-    BaseConstructL( aRect, R_RFS_FACTORY_SETTINGS_TITLE, R_RFS_FACTORY_SETTINGS_LBX );
-    }
-
-// -----------------------------------------------------------------------------
-// CGSRFSPluginContainer::~CGSRFSPluginContainer
-//
-// -----------------------------------------------------------------------------
-CGSRFSPluginContainer::~CGSRFSPluginContainer()
-    {
-    TRACES("CGSRFSPluginContainer::~CGSRFSPluginContainer()");
-    delete iListboxItemArray;
-    TRACES("CGSRFSPluginContainer::~CGSRFSPluginContainer(): End");
-    }
-
-// ---------------------------------------------------------------------------
-// CGSRFSPluginContainer::CurrentFeatureId()
-//
-// Return the feature id of selected listitem  
-// ---------------------------------------------------------------------------
-TInt CGSRFSPluginContainer::CurrentFeatureId( ) const
-    {
-    return iListboxItemArray->CurrentFeature( );
-    }
-
-// ---------------------------------------------------------------------------
-// CGSRFSPluginContainer::ConstructListBoxL()
-// 
-// Construct the listbox from resource array.
-// ---------------------------------------------------------------------------
-void CGSRFSPluginContainer::ConstructListBoxL( TInt aResLbxId )
-    {
-    iListBox->ConstructL( this, EAknListBoxSelectionList );
-
-    iListboxItemArray = CGSListBoxItemTextArray::NewL( aResLbxId, *iListBox, *iCoeEnv );
-    
-    iListBox->Model()->SetItemTextArray( iListboxItemArray );
-    iListBox->Model()->SetOwnershipType( ELbmDoesNotOwnItemArray );
-    }
-
-// ---------------------------------------------------------------------------
-// CGSRFSPluginContainer::GetHelpContext() const
-//  
-// Gets help context 
-// ---------------------------------------------------------------------------
-void CGSRFSPluginContainer::GetHelpContext( TCoeHelpContext& aContext ) const
-    {
-    aContext.iMajor = KUidGS;
-    // TODO: The following statement should be un-commented and assigned with 
-    // the RFS helper text UID once available from concerned team
-    // aContext.iContext = KSET_HLP_WLAN_SETTINGS;
-    }
-
-// End of File  
-
--- a/coreapplicationuis/Rfs/Plugins/GSRFSPlugin/src/GSRFSPluginImplementationTable.cpp	Tue Jun 15 16:07:48 2010 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,51 +0,0 @@
-/*
-* Copyright (c) 2005 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"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description: 
-*        ECOM proxy table for this plugin
-*
-*/
-
-
-// System includes
-#include <e32std.h>
-#include <ecom/implementationproxy.h>
-#include "GSRFSPluginTraces.h"
-
-// User includes
-#include "GSRFSPlugin.h"
-
-// Constants
-const TImplementationProxy KGSRFSPluginImplementationTable[] = 
-	{
-	IMPLEMENTATION_PROXY_ENTRY( 0x10275118,	CGSRFSPlugin::NewL )
-	};
-
-
-// ---------------------------------------------------------------------------
-// ImplementationGroupProxy
-// Gate/factory function
-//
-// ---------------------------------------------------------------------------
-//
-EXPORT_C const TImplementationProxy* ImplementationGroupProxy( 
-    TInt& aTableCount )
-	{
-    TRACES("ImplementationGroupProxy()");
-	aTableCount = sizeof( KGSRFSPluginImplementationTable ) 
-        / sizeof( TImplementationProxy );
-    TRACES("ImplementationGroupProxy(): End");
-	return KGSRFSPluginImplementationTable;
-	}
-
-// End of File
--- a/coreapplicationuis/Rfs/group/bld.inf	Tue Jun 15 16:07:48 2010 +0100
+++ b/coreapplicationuis/Rfs/group/bld.inf	Thu Jul 22 16:35:22 2010 +0100
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies). 
+* Copyright (c) 2002-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"
@@ -23,7 +23,6 @@
 
 PRJ_EXPORTS
 ../loc/rfs.loc                              MW_LAYER_LOC_EXPORT_PATH(rfs.loc)
-../Plugins/GSRFSPlugin/loc/gsrfsplugin.loc  MW_LAYER_LOC_EXPORT_PATH(gsrfsplugin.loc)
 ../rom/rfs.iby                              CORE_MW_LAYER_IBY_EXPORT_PATH(rfs.iby)
 ../rom/rfsResources.iby                     LANGUAGE_MW_LAYER_IBY_EXPORT_PATH(rfsResources.iby)
 ../rom/rfs_variant.iby                      CUSTOMER_MW_LAYER_IBY_EXPORT_PATH(rfs_variant.iby)
@@ -32,12 +31,5 @@
 PRJ_MMPFILES
 rfs.mmp
 rfsMain.mmp
-../Plugins/GSRFSPlugin/group/GSRFSPlugin.mmp
 ../Plugins/rfscustcmd/group/rfscustcmd.mmp
 
-PRJ_EXTENSIONS
-START EXTENSION s60/mifconv
-  OPTION TARGETFILE GSRFSPlugin.mif
-  OPTION HEADERFILE GSRFSPlugin.mbg
-  OPTION SOURCES -c8,8 qgn_prop_set_gene_phone
-END
--- a/coreapplicationuis/Rfs/rom/rfs.iby	Tue Jun 15 16:07:48 2010 +0100
+++ b/coreapplicationuis/Rfs/rom/rfs.iby	Thu Jul 22 16:35:22 2010 +0100
@@ -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 "Eclipse Public License v1.0"
@@ -21,9 +21,6 @@
 file=ABI_DIR\BUILD_DIR\RFS.DLL                      SHARED_LIB_DIR\RFS.DLL
 file=ABI_DIR\BUILD_DIR\RfsServer.exe                PROGRAMS_DIR\RfsServer.exe
 
-ECOM_PLUGIN(GSRFSPlugin.dll,10275117.rsc)
-SCALABLE_IMAGE(APP_BITMAP_DIR,APP_BITMAP_DIR,GSRFSPlugin)
-
 file=ABI_DIR\BUILD_DIR\rfscustcmd.dll               SHARED_LIB_DIR\rfscustcmd.dll
 
 #endif
--- a/coreapplicationuis/Rfs/rom/rfsResources.iby	Tue Jun 15 16:07:48 2010 +0100
+++ b/coreapplicationuis/Rfs/rom/rfsResources.iby	Thu Jul 22 16:35:22 2010 +0100
@@ -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 "Eclipse Public License v1.0"
@@ -21,5 +21,4 @@
 
 //Resource file(s) for RFS
 data=DATAZ_\RESOURCE_FILES_DIR\Rfs.rsc                                  RESOURCE_FILES_DIR\Rfs.rsc
-data=DATAZ_\RESOURCE_FILES_DIR\GSRFSPluginRsc.RSC                       RESOURCE_FILES_DIR\GSRFSPluginRsc.RSC
 #endif
\ No newline at end of file
--- a/coreapplicationuis/SysAp/CenRep/CoreApplicationUIsPrivateCRKeys.h	Tue Jun 15 16:07:48 2010 +0100
+++ b/coreapplicationuis/SysAp/CenRep/CoreApplicationUIsPrivateCRKeys.h	Thu Jul 22 16:35:22 2010 +0100
@@ -21,7 +21,7 @@
 #define COREAPPLICATIONUISPRIVATECRKEYS_H
 
 // INCLUDES
-#include <coreapplicationuissdkcrkeys.h>
+#include <CoreApplicationUIsSDKCRKeys.h>
 
 // =============================================================================
 // CoreAppUIs Configuration API
--- a/coreapplicationuis/SysAp/Data/SysAp.rss	Tue Jun 15 16:07:48 2010 +0100
+++ b/coreapplicationuis/SysAp/Data/SysAp.rss	Thu Jul 22 16:35:22 2010 +0100
@@ -31,12 +31,18 @@
 
 RESOURCE RSS_SIGNATURE { }
 
-RESOURCE TBUF { buf=""; }
+RESOURCE TBUF { buf="sysap"; }
 
 RESOURCE EIK_APP_INFO
-{
-    status_pane=R_AVKON_STATUS_PANE_LAYOUT_EMPTY;
-}
+    {
+        status_pane = r_status_pane;
+    }
+
+RESOURCE STATUS_PANE_APP_MODEL r_status_pane
+    {
+        layout= R_AVKON_STATUS_PANE_LAYOUT_EMPTY;
+    }
+
 
 //   LOCALIZED STRINGS 
 
--- a/coreapplicationuis/SysAp/Group/SysAp.mmp	Tue Jun 15 16:07:48 2010 +0100
+++ b/coreapplicationuis/SysAp/Group/SysAp.mmp	Thu Jul 22 16:35:22 2010 +0100
@@ -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 "Eclipse Public License v1.0"
@@ -35,119 +35,46 @@
 MACRO SYSAP_USE_STARTUP_UI_PHASE
 #endif // RD_STARTUP_ANIMATION_CUSTOMIZATION 
 
+
 SOURCEPATH  ../Src
 SOURCE SysApApp.cpp
+SOURCE SysApDocument.cpp
+//SOURCE main.cpp
 SOURCE SysApAppUi.cpp
-SOURCE SysApDocument.cpp
-SOURCE sysapkeymanagement.cpp
+//SOURCE SysApWsClient.cpp
+SOURCE SysApFeatureManager.cpp
 SOURCE SysApLightsController.cpp
 SOURCE SysApTimer.cpp
-
-SOURCE SysApPubSubObserver.cpp
-SOURCE SysApProfileObserver.cpp
-SOURCE SysApEtelNetworkBarObserver.cpp
-SOURCE sysapetelnetworkbargetter.cpp
-
-//SOURCE CenRepObservers/sysapcenrepfmtxobserver.cpp
-SOURCE CenRepObservers/SysApCenRepLogsObserver.cpp
-SOURCE CenRepObservers/SysApCenRepBTObserver.cpp
-SOURCE CenRepObservers/SysApCenRepHacSettingObserver.cpp
-SOURCE CenRepObservers/sysapcenreplightsettingsobserver.cpp
-SOURCE CenRepObservers/sysapcenrepcallforwardingobserver.cpp
-SOURCE CenRepObservers/sysapcenrepmsgwaitingobserver.cpp
-SOURCE SysApCenRepController.cpp
-
-SOURCE SysApStartupController.cpp
-SOURCE SysApConnectionMonitorObserver.cpp
-SOURCE SysApPowerKeyMenuObserver.cpp
-SOURCE SysApSsSettingsObserver.cpp
+SOURCE sysaplightpluginhandler.cpp
+SOURCE SysApNspsHandler.cpp
+SOURCE SysApNspsAnim.cpp 
+SOURCE SysApPubSubObserver.cpp SysApSubscriber.cpp sysapremconobserver.cpp
+SOURCE sysapdefaultkeyhandler.cpp SysApStartupController.cpp
 SOURCE SysApShutdownImage.cpp
-SOURCE SysApShutdownAnimation.cpp
-#ifndef RD_STARTUP_ANIMATION_CUSTOMIZATION
-SOURCE SysApShutdownTone.cpp
-#endif // RD_STARTUP_ANIMATION_CUSTOMIZATION
-SOURCE SysApMsgSimMemLowQuery.cpp
-SOURCE SysApNspsAnim.cpp
-SOURCE SysApNspsHandler.cpp
-SOURCE SysApEtelNetworkStatusNspsObserver.cpp
-SOURCE SysApEtelSmsStoreObserver.cpp
-SOURCE SysApWaitNote.cpp
-SOURCE SysApConfirmationQuery.cpp
-SOURCE SysApFeatureManager.cpp
-SOURCE SysApSubscriber.cpp
-
-SOURCE SysApAnimKeySndControl.cpp
-SOURCE SysApKeySndAnim.cpp
-SOURCE SysApKeySndHandler.cpp
-
-SOURCE SysApSimChanged.cpp
-LIBRARY logcli.lib
-
-SOURCE SysApAccessoryObserver.cpp
-LIBRARY accclient.lib
-
-SOURCE SysApEtelConnector.cpp
+SOURCE hbdevicepowermenusymbian.cpp
 
 #ifdef __OFFLINE_MODE
 SOURCE OfflineModeController/SysApOfflineModeControllerImpl.cpp
-#else
-SOURCE OfflineModeController/SysApOfflineModeControllerStub.cpp
-#endif
-
-//Always use stub implementation of privacy framework, as it is no longer supported
-// Find out if/how a replacement must be done
-SOURCE PrivacyFramework/SysApLocationPrivacyIndicatorStub.cpp
-
-#ifdef __USB
-SOURCE Usb/SysApUsbIndicatorImpl.cpp
-LIBRARY     usbman.lib        // USB Manager
-#else
-SOURCE Usb/SysApUsbIndicatorStub.cpp
-#endif
-SOURCE Usb/sysapusbchargerdetector.cpp
-
-#ifdef __BT
-SOURCE Bt/SysApBtControllerImpl.cpp
-LIBRARY btengdevman.lib
-LIBRARY btengsettings.lib
-LIBRARY btmanclient.lib
-#else
-SOURCE Bt/SysApBtControllerStub.cpp
 #endif
 
-#ifdef __BT_SAP
-SOURCE BtSap/SysApBtSapControllerImpl.cpp
-LIBRARY btengconnman.lib
-LIBRARY btdevice.lib
-LIBRARY bluetooth.lib
-#else
-SOURCE BtSap/SysApBtSapControllerStub.cpp
-#endif
 
-SOURCE SysApMediatorObserver.cpp
-
-SOURCE sysapdefaultkeyhandler.cpp
-#ifdef RD_LIGHT_CONTROL_CHANGE
-SOURCE sysaplightpluginhandler.cpp
-#endif
+SYSTEMINCLUDE		/epoc32/include/mw/hb/hbwidgets
+SYSTEMINCLUDE		/epoc32/include/mw/hb/hbcore
+//SYSTEMINCLUDE		/epoc32/include/mw/QtCore
+SYSTEMINCLUDE      /epoc32/include/mw
 
-SOURCE sysapaudioroutingobserver.cpp
-SOURCE sysapeteldatabearerobserver.cpp
+USERINCLUDE        . 
+USERINCLUDE        ../Inc
+USERINCLUDE        ../Src/CenRepObservers 
+USERINCLUDE        ../Src/Usb 
+USERINCLUDE        ../Src/powersavemode
+USERINCLUDE        ../../inc // subsystem headers
+USERINCLUDE        ../../../inc // ado headers
+USERINCLUDE        ../CenRep
+USERINCLUDE        ../PubSub
 
-SOURCE memorycard/SysApMMCObserver.cpp
-#ifdef RD_MULTIPLE_DRIVE
-SOURCE memorycard/sysapdrivelist.cpp
-SOURCE memorycard/sysapdriveunlockhandler.cpp
-SOURCE memorycard/sysapdriveejecthandler.cpp
-#endif // RD_MULTIPLE_DRIVE
+MW_LAYER_SYSTEMINCLUDE 
 
-SOURCE sysapetelnetworkinfoobserver.cpp
-SOURCE sysapremconobserver.cpp
-SOURCE powersavemode/sysappsmcontroller.cpp
-SOURCE sysapbatteryinfocontroller.cpp
-
-SOURCE SysApSatObserver.cpp
-LIBRARY	    satclient.lib       // for sat refresh
 
 START RESOURCE ../Data/SysAp.rss
 HEADER
@@ -167,20 +94,6 @@
 TARGETPATH /private/10003a3f/apps
 END
 
-SOURCEPATH ../Data
-
-USERINCLUDE        . 
-USERINCLUDE        ../Inc
-USERINCLUDE        ../Src/CenRepObservers 
-USERINCLUDE        ../Src/memorycard 
-USERINCLUDE        ../Src/Usb 
-USERINCLUDE        ../Src/powersavemode
-USERINCLUDE        ../../inc // subsystem headers
-USERINCLUDE        ../../../inc // ado headers
-USERINCLUDE        ../CenRep
-USERINCLUDE        ../PubSub
-
-MW_LAYER_SYSTEMINCLUDE 
 
 LIBRARY euser.lib
 LIBRARY apparc.lib
@@ -188,67 +101,110 @@
 LIBRARY eikcore.lib
 LIBRARY apgrfx.lib
 LIBRARY ws32.lib
-LIBRARY avkon.lib
+
 LIBRARY bafl.lib
-LIBRARY aknnotify.lib
+
 LIBRARY eiksrvc.lib
 LIBRARY connmon.lib
 LIBRARY dsclient.lib
 LIBRARY profileeng.lib
 LIBRARY starterclient.lib
-LIBRARY centralrepository.lib
-LIBRARY cenrepnotifhandler.lib
-LIBRARY commonengine.lib
-LIBRARY activitymanager.lib
-LIBRARY akncapserverclient.lib
-LIBRARY secui.lib
-LIBRARY sssettings.lib
+
+
 LIBRARY fbscli.lib
 LIBRARY etel.lib
 LIBRARY etelmm.lib
-LIBRARY customapi.lib
+LIBRARY efsrv.lib
+
+LIBRARY esock.lib
+
+LIBRARY ecom.lib
+
+LIBRARY hbwidgets.lib
+//LIBRARY qtcore.lib
+
+//LIBRARY HbDeviceInputDialogWidget.lib
+
+//For CHbIndicatorSymbian and for CHbPowereMenusymbian
+LIBRARY hbcore.lib
+LIBRARY hwrmlightclient.lib
 LIBRARY featmgr.lib
-LIBRARY efsrv.lib
-LIBRARY aknmemorycardui.lib
-LIBRARY esock.lib
+LIBRARY activitymanager.lib
+LIBRARY	remconcoreapi.lib
+LIBRARY	remconinterfacebase.lib
+//LIBRARY hbpowermenuwidget.lib
+
+//  End of File
+
+
+#ifdef __USB
+SOURCEPATH ../Src/Usb
+SOURCE SysApUsbIndicatorImpl.cpp 
+LIBRARY     usbman.lib        // USB Manager
+#endif
+SOURCE sysapusbchargerdetector.cpp
+
+SOURCEPATH ../Src
+SOURCE SysApAccessoryObserver.cpp SysApCenRepController.cpp
+LIBRARY accclient.lib
+LIBRARY accpolicy.lib
+
+SOURCE CenRepObservers/SysApCenRepBTObserver.cpp
+SOURCE CenRepObservers/SysApCenRepHacSettingObserver.cpp
+SOURCE CenRepObservers/sysapcenreplightsettingsobserver.cpp
+SOURCE CenRepObservers/SysApCenRepLogsObserver.cpp
+SOURCE CenRepObservers/sysapcenrepofflinemodeobserver.cpp
+
+LIBRARY centralrepository.lib
+LIBRARY cenrepnotifhandler.lib
+
+SOURCE sysapaudioroutingobserver.cpp
+LIBRARY telephonyaudiorouting.lib
+
 #ifdef RD_STARTUP_ANIMATION_CUSTOMIZATION
 LIBRARY sanimctrl.lib
 #else // RD_STARTUP_ANIMATION_CUSTOMIZATION
 LIBRARY MediaClientAudio.lib
 #endif // RD_STARTUP_ANIMATION_CUSTOMIZATION
-LIBRARY hwrmlightclient.lib
-//LIBRARY hwrmfmtxclient.lib
-LIBRARY	remconcoreapi.lib
-LIBRARY	remconinterfacebase.lib
-LIBRARY aknicon.lib
-LIBRARY cdlengine.lib
 
-// POC launching
-LIBRARY servicehandler.lib
-
-LIBRARY ecom.lib
-
-
-LIBRARY mediatorclient.lib
 LIBRARY bmpanim.lib
 
-LIBRARY telephonyaudiorouting.lib
-LIBRARY etelpckt.lib
-
-#ifdef RD_MULTIPLE_DRIVE
-LIBRARY platformenv.lib
-LIBRARY disknotifyhandler.lib
-#endif // RD_MULTIPLE_DRIVE
-
+SOURCEPATH ../Src/powersavemode
+SOURCE sysappsmcontroller.cpp 
 LIBRARY psmclient.lib
 
-LIBRARY keylockpolicyapi.lib
+SOURCEPATH ../Src
+SOURCE sysapbatteryinfocontroller.cpp SysApSimChanged.cpp
 
+LIBRARY secui.lib
 LIBRARY bsutil.lib
-LIBRARY batterypopupcontrol.lib
+//LIBRARY batterypopupcontrol.lib
+//LIBRARY CommonEngine.lib
+SOURCEPATH ../Src/Bt
+SOURCE SysApBtControllerImpl.cpp
+SOURCEPATH ../Src/BtSap
+SOURCE SysApBtSapControllerImpl.cpp
 
-LIBRARY eikcoctl.lib
-//  End of File
+//LIBRARY eikcoctl.lib
+//LIBRARY etelpckt.lib
 
 
+LIBRARY btengconnman.lib
+LIBRARY btdevice.lib
+LIBRARY bluetooth.lib
 
+LIBRARY btengdevman.lib
+LIBRARY btengsettings.lib
+LIBRARY btmanclient.lib
+
+LIBRARY lockclient.lib
+
+SOURCEPATH ../Src
+SOURCE sysapkeymanagement.cpp SysApTaskList.cpp
+SOURCE SysApKeySndHandler.cpp SysApKeySndAnim.cpp SysApAnimKeySndControl.cpp
+
+//For Shutdown
+LIBRARY	    SVGEngine.lib
+LIBRARY	    gdi.lib
+
+LIBRARY avkon.lib
--- a/coreapplicationuis/SysAp/Group/bld.inf	Tue Jun 15 16:07:48 2010 +0100
+++ b/coreapplicationuis/SysAp/Group/bld.inf	Thu Jul 22 16:35:22 2010 +0100
@@ -22,11 +22,6 @@
 DEFAULT
 
 PRJ_EXTENSIONS
-START EXTENSION s60/mifconv
-  OPTION TARGETFILE sysap.mif
-  OPTION HEADERFILE sysap.mbg
-  OPTION SOURCES -c8 qgn_startup_screen
-END
 
 
 PRJ_EXPORTS
@@ -47,6 +42,9 @@
 
 ../PubSub/CoreApplicationUIsPrivatePSKeys.h |../../../inc/coreapplicationuisprivatepskeys.h // Illegal export for avoiding breaks
 
+/epoc32/s60/icons/qgn_startup_screen.svg          /epoc32/data/z/resource/apps/qgn_sysap_screen.svg
+/epoc32/s60/icons/qgn_startup_screen.svg          /epoc32/release/winscw/udeb/z/resource/apps/qgn_sysap_screen.svg
+/epoc32/s60/icons/qgn_startup_screen.svg          /epoc32/release/winscw/urel/z/resource/apps/qgn_sysap_screen.svg
 PRJ_MMPFILES
 //gnumakefile sysap_icons.mk 
 
--- a/coreapplicationuis/SysAp/Inc/SysApApp.h	Tue Jun 15 16:07:48 2010 +0100
+++ b/coreapplicationuis/SysAp/Inc/SysApApp.h	Thu Jul 22 16:35:22 2010 +0100
@@ -20,7 +20,8 @@
 #define SYSAPAPP_H
 
 // INCLUDES
-#include <aknapp.h>
+//#include <aknapp.h>
+#include <eikapp.h>
 
 // CONSTANTS
 const TUid KUidSysAp={0x100058F3};
@@ -33,7 +34,7 @@
 *  @since 1.0
 */
 
-class CSysApApp : public CAknApplication
+class CSysApApp : public CEikApplication 
     {
     private: // from CApaApplication
         /**
--- a/coreapplicationuis/SysAp/Inc/SysApAppUi.h	Tue Jun 15 16:07:48 2010 +0100
+++ b/coreapplicationuis/SysAp/Inc/SysApAppUi.h	Thu Jul 22 16:35:22 2010 +0100
@@ -1,116 +1,43 @@
 /*
-* Copyright (c) 2005-2009 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"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:  CSysApAppUi class definition. This class handles all user
-*                actions and also System Agent events.
-*
-*/
-
+ * 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 "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ *
+ */
 
 #ifndef SYSAPAPPUI_H
 #define SYSAPAPPUI_H
-
-// INCLUDES
+//#include <QObject>
+//#include <aknappui.h>
+//#include <hbmessagebox.h>
 #include <aknappui.h>
-#include <aknkeylock.h>
-#ifndef RD_MULTIPLE_DRIVE
- #include <aknmemorycarddialog.h>
-#endif // RD_MULTIPLE_DRIVE
-#include <starterclient.h>
-#include <starter.hrh>
-#include <babackup.h>
-#include <rmmcustomapi.h>
-
-#include <DosSvrServices.h>
 #include "SysAp.hrh"
-#include "SysApMMCObserver.h"
-#include "MSysApPropertyResponder.h"
-#include "SysApTimer.h"
+#include <f32file.h> 
+#include <W32STD.H>
+#include <coedef.h>
 #include <e32property.h>
-#include "coreapplicationuisprivatecrkeys.h"
 #include <sysapcallback.h>
-
+#include <starterclient.h>
+#include "SysApTimer.h"
+#include "SysApLightsController.h"
+#include "coreapplicationuisprivatecrkeys.h"
+#include "sysapusbchargerdetector.h"
 #include "SysApAccessoryObserver.h"
-#ifdef RD_MULTIPLE_DRIVE
-  #include "sysapdrivelist.h"
-#endif // RD_MULTIPLE_DRIVE
-
-#include "sysapusbchargerdetector.h"
-#include "sysappsmcontroller.h"
+#include <hbsymbianvariant.h>
+//For Powermenu--CHbDevicePowerMenuSymbian
+#include "hbdevicepowermenusymbian.h"
 
-// FORWARD DECLARATIONS
-class CAknSmallIndicator;
-class CAknSignalNotify;
-class CAknBatteryNotify;
-class CAknGlobalListQuery;
-class CAknGlobalNote;
-class CSystemLock;
-class CSysApLightsController;
-class CSysApPubSubObserver;
-class CSysApProfileObserver;
-class CSysApConnectionMonitorObserver;
-class CSysApCenRepLightSettingsObserver;
-class CSysApCenRepLogsObserver;
-class CSysApCenRepBtObserver;
-//class CSysApCenRepFmTxObserver;
-class CSysApCenRepController;
-class CSysApStartupController;
-class CSysApPowerKeyMenuObserver;
-class CSysApWaitNote;
-class CSysApSsSettingsObserver;
-class CSysApShutdownImage;
-class CSysApShutdownAnimation;
-class CSysApEtelConnector;
-class CSysApMsgSimMemLowQuery;
-class CSysApNspsHandler;
-class CSysApConfirmationQuery;
-class CSysApFeatureManager;
-class MSysApOfflineModeController;
-class MSysApBtController;
-class MSysApBtSapController;
-class MSysApUsbIndicator;
-class MSysApLocationPrivacyIndicator;
-class MProfileEngine;
-class MProfilesNamesArray;
-class CSysApKeySndHandler;
-class CSysApKeyManagement;  // KEF
-class CSysApMediatorObserver;
-class CAknAppUiBase;
-class CSysApCenRepHacSettingObserver;
-class CSysApAudioRoutingObserver;
-class CSysApCenRepCallForwardingObserver;
-class CSysApCenRepMsgWaitingObserver;
-
-// POC launching
-class CAiwServiceHandler;
-
-class CSysApDefaultKeyHandler;
-class CSysApDriveUnlockHandler;
-class CSysApDriveEjectHandler;
-
-class CSysApBatteryInfoController;
-
-//CONSTANTS
-const TInt KDummyReason( -1 );
-const TInt KBluetoothModulePowerModeOn ( 1 );
-const TInt KBluetoothModulePowerModeOff ( 0 );
-const TInt KGeneralProfileId ( 0 );
-const TInt KOfflineModeProfileId ( 5 );
-const TInt KApplicationScanningInterval( 1 ); // 1 second
-_LIT( KFSName, "Fat" );                 // MMC file system name
-const TDriveNumber KMMCDrive = EDriveE; // MMC drive number
-
-
+#include "sysappsmcontroller.h"
 
 //CLASS DECLARATION
 /**
@@ -121,18 +48,49 @@
 *  @lib   sysap
 *  @since 1.0
 */
+#include <eikappui.h>
 
-class CSysApAppUi :
-                    public CAknAppUi,
-#ifndef RD_MULTIPLE_DRIVE
-                    public MAknMemoryCardDialogObserver,
-#endif // RD_MULTIPLE_DRIVE
-                    public MSysApMemoryCardObserver,
+
+//class CAknAppUiBase;
+//class CSysApKeySndHandler;
+//class  CSysApWsClient;
+class CSysApFeatureManager;
+class CSysApNspsHandler;
+class CSysApPubSubObserver;
+class CSysApStartupController;
+class CSysApDefaultKeyHandler;
+class CSysApKeyManagement; 
+class MSysApOfflineModeController;
+class CHbDevicePowerMenuSymbian;
+class CSysApShutdownImage;
+class CSysApKeySndHandler;
+class CSysApCenRepController;
+class CSysApCenRepLightSettingsObserver;
+class CSysApCenRepBtObserver;
+class CSysApCenRepHacSettingObserver;
+class CSysApAudioRoutingObserver;
+class CSysApSsSettingsObserver;
+class CSystemLock;
+class CSysApCenRepCallForwardingObserver;
+class CSysApBatteryInfoController;
+class MSysApBtSapController;
+class MSysApBtController;
+class CSysApCenRepLogsObserver;
+class MSysApUsbIndicator;
+class CKeyguardAccessApi;
+
+
+const TInt KBluetoothModulePowerModeOn ( 1 );
+const TInt KDummyReason( -1 );
+
+//class HbMessageBox;
+
+class CSysApAppUi : public CAknAppUi,
                     public MSysApTimerResponder,
                     public MSysapCallback,
                     public MSysApPsmControllerNotifyCallback
-{
-    public:
+	{
+		public:
         /**
         * C++ default constructor.
         * @param None
@@ -146,7 +104,10 @@
         * @return void
         */
         virtual ~CSysApAppUi();
-
+        
+        // from CCoeAppUiBase
+        void PrepareToExit();
+        
     protected: // From MSysApTimerResponder
 
         /**
@@ -155,1057 +116,7 @@
         * @return void
         */
         void TimerExpiredL();
-
-    public:
-
-        /**
-        * Gets called when shutdown continues after shutdown animation
-        * @param None
-        * @return void
-        */
-        void ContinueShutdown();
-
-        /**
-        * Gets called when there is need to shutdown the device initiated by Symbian side
-        * @param None
-        * @return void
-        */
-        void DoShutdownL( const TBool aReset, const TInt aResetReason );
-
-        /**
-        * Gets called by CSysApSharedDataObserver if user has selected "No" in
-        * "Do you want to use the phone in Off-line mode?" query in startup.
-        * @param aDoProfileChange if ETrue, the last active profile is restored
-        * @return void
-        */
-        void GoOnlineL( TBool aDoProfileChange = ETrue );
-
-        /**
-        * Gets called by CSysApSharedDataObserver in Simless Offline Mode startup.
-        * @param None
-        * @return void
-        */
-        void GoOfflineL();
-
-        /**
-        * Calls CSysApOfflineModeController::SwitchFromOnlineToOfflineModeL()
-        * @param None
-        * @return void
-        */
-        void SwitchFromOnlineToOfflineModeL();
-
-        /**
-        * Called when offline mode change has been finished.
-        */
-        void OfflineModeChangedL();
-
-        /**
-        * Gets called after changing the SW state.
-        * @param aSwState The new state
-        * @return void
-        */
-        void DoStateChangedL( const RStarterSession::TGlobalState aSwState  );
-
-#ifdef SYSAP_USE_STARTUP_UI_PHASE        
-        /**
-        * Called when UI is ready after boot.
-        */
-        void HandleUiReadyAfterBootL();
-
-#endif // SYSAP_USE_STARTUP_UI_PHASE
         
-        /**
-        * Returns whether UI is ready after boot.
-        */
-        TBool UiReady() const;
-
-        /**
-        * Gets called when any case selection on powerkey menu is done.
-        * Does what is needed per selection.
-        * @param TInt aSelection
-        * @return void
-        */
-        void PowerKeyPopUpMenuSelectionDoneL( TInt aSelection );
-
-        /**
-        * Gets called when Alarm is being shown to user and lights need to be blinked.
-        * @param TBool aAlerting
-        * @return void
-        */
-        void AlertUiAlertingL( const TBool aAlerting );
-
-        /**
-        * Gets called when Alarm is being shown to user and keylock need to be turned off.
-        * @param TBool aKeyLockOff
-        * @return void
-        */
-        void AlertUiKeyLockOff( const TBool aKeyLockOff );
-
-        /**
-        * Notifies changes in KPSUidCoreApplicationUIs::KLightControl to light controller.
-        */
-        void HandleLightsRequireL() const;
-
-        /**
-        * Notifies changes in KPSUidCoreApplicationUIs::KCoreAppUIsLightsRawKeyEvent to light controller.
-        *
-        * @since S60 3.2
-        */
-        void HandleRawKeyEventLightsRequireL() const;
-
-        /**
-        * Gets called when Video Telephony requests to force/cancel lights on/
-        * @param const TInt aLightsParameter
-        * @return void
-        */
-        void HandleForcedLightsVTRequireL( const TInt aLightsParameter ) const;
-
-        /**
-        * Gets called when Screen Saver requests to force lights on/off
-        * @param const TInt aLightsParameter
-        * @return void
-        */
-        void HandleForcedLightsSSRequireL( const TInt aLightsParameter ) const;
-				
-				/**
-        * Gets called when AT Command requests to force lights on/off
-        * @param const TInt aLightsParameter
-        * @return void
-        */
-				void HandleForcedLightsATCRequireL( const TInt aLightsParameter ) const;
-        /**
-        * Calls SysApLightsController::SwitchLightsOnSoftRejectL
-        *
-        * @since S60 3.1
-        * @param None.
-        * @return None.
-        */
-        void SwitchLightsOnSoftRejectL();
-
-        /**
-        * Asks state of one property from PubSub
-        * @param const TUid&
-        * @param const TUint
-        * @return const TInt ( value of property or error code )
-         */
-        TInt StateOfProperty( const TUid& aCategory, const TUint aKey ) const;
-
-        /**
-        * Sets the indicator's aIndicator state to state aState.
-        * @param TInt aIndicator
-        * @param TInt aState
-        * @return void
-        */
-        void SetIndicatorStateL( const TInt aIndicator, const TInt aState ) const;
-
-        /**
-        * Returns the state of keylock
-        * @param none
-        * @return TBool the state of keylock
-        */
-        TBool KeyLockState() const;
-
-        /**
-        * Returns the state of devicelock
-        * @param none
-        * @return TBool the state of devicelock
-        */
-        TBool DeviceLockState() const;
-
-        /*
-        * @param None
-        * @return void
-        */
-        void SetIhfIndicatorL();
-
-        /*
-        * Handles actions needed when either SIM memory gets too full to receive any more SMS's.
-        * @param aSimStoreFull If true, SIM memory is full.
-        * @return void
-        */
-        void HandleSmsStorageNotificationL( TBool aSimStoreFull );
-
-        void HandleNspsRawKeyEventL();
-
-        void HandleNetworkNspsNotification( RMmCustomAPI::TNspsStatus aNspsStatus );
-
-        void HandleMessageTonePlayingQuitability( TInt aTonePlayingStatus );
-
-        /*
-        * Called by SysApLightsController when the lights are switced on/off
-        * @param aActivate If ETrue forwarding is activated, otherwise deactivated
-        * @return void
-        */
-        void ActivateKeyeventForwardingForLights(TBool aActivate);
-
-        /**
-        * Gets called when shutdown requested when sw state == ESWStateAlarm
-        * context active.
-        * @param None
-        * @return void
-        */
-        void StartShutDownTimerOnAlarmAndChargingStates();
-        static TInt DoShutdownOnAlarmStateAfterCallBack( TAny* aObject );
-
-#ifndef RD_STARTUP_ANIMATION_CUSTOMIZATION
-        /**
-        * Starts shutdown animation timing after shutdown tone sync is done
-        */
-        void StartAnimTiming();
-#endif // RD_STARTUP_ANIMATION_CUSTOMIZATION
-
-        /**
-        * Stops shutdown animation timing and continues shutdown.
-        */
-        static TInt DoStopAnimTiming( TAny* aObject );
-
-        /**
-        * Gets called when GPRS is suspended because of a phone call established while
-        * context active. Delay (KDelayBeforeShowingGprsSuspendedNote) required to ensure
-        * that the phone call was really established.
-        * @param None
-        * @return void
-        */
-        void StartGprsSuspendedTimer();
-        static TInt ShowGprsSuspendedNoteAfterCallBack( TAny* aObject );
-
-        /**
-        * Gets called when an accessory was connected to device. The indicator
-        * is shown and profile gets changed if needed.
-        * @param aAccessoryState Indicates the new accessory state
-        * @return void
-        */
-        void HandleAccessoryConnectedL( TAccMode aAccessoryState );
-
-        /**
-        * Gets called when headset/loopset was disconnected from device. The indicator
-        * is hidden and the original profile gets restored if needed.
-        * @param None
-        * @return void
-        */
-        void HandleAccessoryDisconnectedL();
-
-        /**
-        * Gets called when SysAp receives KSysApSatRefreshStart. All
-        * non-system UI applications are closed
-        * and an information note is shown to the user.
-        * @param None
-        * @return void
-        */
-        void HandleSatRefreshL();
-
-#ifndef RD_MULTIPLE_DRIVE
-        /**
-        * Mounts MMC drive
-        * @param None
-        * @return TInt : error value from RFs::MountFileSystem()
-        */
-        TInt MountMMC();
-
-        /**
-        * Dismounts MMC drive
-        * @param None
-        * @return TInt : error value from RFs::MountFileSystem()
-        */
-        TInt DismountMMC();
-#endif // RD_MULTIPLE_DRIVE
-
-        /**
-        * MMC Hot Swap Ejection from powerkey menu
-        * @param None
-        * @return void
-        */
-        void EjectMMCL();
-
-        /**
-        * Disconnect BtSap from powerkey meny
-        * @param None
-        * @return void
-        */
-        void DisconnectBtSap();
-
-         /**
-         * Enable or disable FM transmission 
-         */
-//         void ChangeFmTxStateL( TBool aEnable );
-
-#ifndef RD_MULTIPLE_DRIVE
-    public: // from MAknMemoryCardDialogObserver
-
-        /**
-        * To be notified when unlock completed
-        * @param TInt aResult
-        * @return void
-        */
-        void UnlockComplete( TInt aResult );
-#endif // RD_MULTIPLE_DRIVE
-
-    public:
-
-        /**
-        * Plays the sound EAvkonSIDInformationTone
-        * @param None
-        * @return void
-        */
-        void Beep();
-
-#ifndef RD_MULTIPLE_DRIVE
-        /**
-        * Unlocks MMC
-        * @param None
-        * @return void
-        */
-        void RunUnlockNotifierL( TSysApMemoryCardStatus aMemoryCardStatus = ESysApMemoryCardStatusNotKnown );
-
-        /**
-        * From MSysApMemoryCardObserver.
-        * Gets called by CSysApMMCObserver when an MMC is inserted/removed
-        * @return void
-        */
-        void MMCStatusChangedL();
-
-        /**
-        * Shows "MMC removed..." dialogs
-        * @param None
-        * @return void
-        */
-        void ShowMMCDismountedDialogL();
-#else // RD_MULTIPLE_DRIVE
-
-        /**
-        * Updates PS key during boot
-        * @return void
-        */
-        void MMCInsertedL();
-
-        /**
-        * Unlocks MMC
-        * @param None
-        * @return void
-        */
-        void RunUnlockNotifierL();
-
-        /**
-        * From MSysApMemoryCardObserver.
-        * Gets called by CSysApMMCObserver when an MMC is inserted/removed
-        * @param aDrive Changed drive
-        * @return void
-        */
-        void MMCStatusChangedL( TInt aDrive );
-
-        /**
-        * Shows "MMC removed..." dialogs
-        * @param aDrive Drive to dismount
-        * @param aEjectType Eject type used for the drive
-        * @return void
-        */
-        TBool ShowMMCDismountedDialogL(
-            TInt aDrive, CSysApDriveList::TDriveEjectType aEjectType );
-#endif // RD_MULTIPLE_DRIVE
-
-        /**
-        * Called after confirming dialog "MMC removed..."
-        * @param None
-        * @return void
-        */
-        void MMCDismountedDialogConfirmed();
-
-        /**
-        * Gets called by CSysApSharedDataObserver when "Eject" is started
-        * or finished in File Manager application.
-        * @param None
-        * @return void
-        */
-        void EjectStarted( TBool ejectStarted );
-
-    private:
-        /**
-        * EPOC default constructor.
-        * @param None
-        * @return void
-        */
-        void ConstructL();
-
-    private:
-
-#ifndef RD_MULTIPLE_DRIVE
-
-        /**
-        * Resolves process UID based on its thread id
-        *
-        * @since S60 3.1
-        * @param aThreadId id of the thread
-        * @return TInt32 process UID
-        */
-        TInt32 ResolveUidFromThread( TUint aThreadId ) const;
-
-        /**
-        * Called recursively when shutting down apps in Hot Swap
-        * @param None
-        * @return void
-        */
-        void CloseUIAppsInHotSwapL();
-
-        /**
-        * Called by CloseUIApplicationsHotSwapL when completing
-        * shutting apps
-        * @param None
-        * @return void
-        */
-        void CompleteAppsShuttingInHotSwapL();
-#endif // RD_MULTIPLE_DRIVE
-
-     public:
-
-        /**
-        * Initializes parameters used in shutting down apps in BT SAP
-        * @param None
-        * @return void
-        */
-        void InitCloseSimApplicationsL();
-
-      private:
-
-        /**
-        * Called recursively when shutting down apps in BT SAP
-        * @param None
-        * @return void
-        */
-        void CloseSimApplicationsL();
-
-        /**
-        * Called to re-envoke CloseSimApplicationsL()
-        * @param None
-        * @return void
-        */
-        static TInt DoCloseSimApplicationsAfterCallBack( TAny* aObject );
-
-    private:
-        /**
-        * Takes care of command handling.
-        * @param aCommand command to be handled
-        * @return void
-        */
-        void HandleCommandL( TInt aCommand);
-
-        /**
-        * handles key events
-        * @param TKeyEvent& aKeyEvent
-        * @param TEventCode aType
-        * @return TKeyResponse
-        */
-        TKeyResponse HandleKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType );
-
-    private:
-        // By default, prohibit copy constructor
-        CSysApAppUi( const CSysApAppUi& );
-
-        // Prohibit assigment operator
-        CSysApAppUi& operator= ( const CSysApAppUi& );
-
-    private:
-        void HandleApplicationSpecificEventL(TInt aType,const TWsEvent& aEvent);
-        /**
-        * Gets called by ConstructL function to set initial states to indicators etc
-        * Needed state information is got from Shared Data and status pane's components
-        * are set to the correct states.
-        * @param None
-        * @return void
-        */
-        void InitializeStatusPaneAreaL();
-
-        /**
-        * Gets called by HandleKeyEventL after detecting a long press of powerkey.
-        * According to current state of the device desides if it is time to either
-        * shutdown or make startup (from charging state ) to normal state
-        * @param None
-        * @return void
-        */
-        void HandleLongPowerKeyPressedL();
-
-        /**
-        * Gets called by HandleKeyEventL after a short press of powerkey.
-        * According to current state of the device desides if it is time to
-        * either switch lights on and show mode selection dialog(normal state)
-        * or to shutdown the phone (in alarm state).
-        * @param None
-        * @return void
-        */
-        void HandleShortPowerKeyPressedL();
-
-        /**
-        * Frees SysAp's reserved memory, closes connections to servers etc.
-        * @param None
-        * @return void
-        */
-        void FreeResources();
-
-    public:
-
-        /**
-        * Displays a UI query.
-        * @param TSysApConfirmationQueryIds
-        * @param aValue query related value
-        * @return void
-        */
-        void ShowQueryL( const TSysApConfirmationQueryIds aQueryId,
-            const TDesC& aValue = KNullDesC );
-
-        /**
-        * Displays a UI note.
-        * @param TSysApNoteIds aSysApNoteIds
-        * @return void
-        */
-        void ShowUiNoteL( const TSysApNoteIds aNote ) const;
-
-        /**
-        * Displays a "Charger connected" note.
-        * @param None
-        * @return void
-        */
-        void ShowChargingNoteL();
-
-        /**
-        * Handles charger related notes
-        * @param TInt : KPSUidChargerCStatusValue
-        * @return void
-        */
-        void HandleChargerNotesL( const TInt aValue );
-
-        /**
-        * Displays a "Selected profile" note.
-        * @param None
-        * @return void
-        */
-        void ShowProfileNoteL();
-
-        /**
-        * Cancels a UI wait note.
-        * @param None
-        * @return void
-        */
-        void CancelWaitNote();
-
-        /**
-        * Cancels the global list query
-        * @param None
-        * @return void
-        */
-        void CancelGlobalListQuery();
-
-        /**
-        * Updates signal bars to the value cached by Etel connector.
-        * @return void
-        */
-        void UpdateSignalBarsL();
-
-        /**
-        * Updates signal bars to specified state.
-        * @param TInt aState Number of bars or KAknSignalOffLineMode
-        * @return void
-        */
-        void UpdateSignalBarsL( const TInt aState );
-
-        /**
-        * Gets called by HandleSystemAgentEventL to singal availability indicator
-        * ie. Gprs state icon or common signal icon.
-        * @param None
-        * @return void
-        */
-        void SetSignalIndicatorL();
-
-        /**
-        * Gets called by SetSignalIndicatorL() when in GSM network
-        * @param None
-        * @return void
-        */
-        void SetSignalIndicatorGsmL();
-
-        /**
-        * Gets called by SetSignalIndicatorL() when in Wcdma network
-        * @param None
-        * @return void
-        */
-        void SetSignalIndicatorWcdmaL();
-
-        /**
-        * Handles GPRS suspend/resume notes if feature supported.
-        * ie. Gprs state icon or common signal icon.
-        * @param None
-        * @return void
-        */
-        void HandleGprsNotesL();
-
-        /**
-        * Returns the current bluetooth power mode setting using CSysApSharedDataObserver
-        * @param None
-        * @return TInt
-        */
-        TInt BluetoothPowerMode() const;
-
-        /**
-        * Activates the profile given as a parameter
-        * @param TInt aProfileId
-        * @return void
-        */
-        void ActivateProfileL( const TInt aProfileId ) const;
-
-        /**
-        * Activates the profile saved in iProfileToBeActivated.
-        * @param None
-        * @return void
-        */
-        void ActivateOnlineProfileL() const;
-
-        /**
-        * Checks whether Offline Mode is activated
-        * @param TBool
-        * @return void
-        */
-        TBool OfflineModeActive();
-
-        /**
-        * Tolds Offline Mode controller not to activate BT
-        * when next going online.
-        * @param None
-        * @return void
-        */
-        void DoNotActivateBt();
-
-        /**
-        * Switches BT module on/off using BT Engine
-        * @param TBool: ETrue = on, EFalse = off
-        * @return void
-        */
-        TInt SetBtPowerState( TBool aBtState );
-
-        /**
-        * Sets iKeyLockOnBeforeCall = EFalse.
-        * @param None
-        * @return void
-        */
-        void DoNotEnableKeylock();
-
-#ifdef RD_MULTIPLE_DRIVE
-        /*
-        * Starts wait note for eject
-        */
-        void ShowEjectWaitNoteL(  TInt aDriveToEject );
-
-        /*
-        * Checks is eject query visible
-        */
-        TBool IsEjectQueryVisible();
-#endif // RD_MULTIPLE_DRIVE
-
-        /**
-        * Gets called by CSysApSharedDataObserver when "Eject" is selected
-        * in File Manager application.
-        * @param aDrive Drive to eject
-        * @return void
-        */
-        void EjectUsed( TInt aDrive );
-
-        /**
-        * MMC Hot Swap Ejection from powerkey menu was canceled
-        * @param None
-        * @return void
-        */
-        void EjectMMCCanceled();
-
-    private:
-
-        /**
-        * Gets currently active profile's name.
-        * @param TPtr aProfileName
-        * @return void
-        */
-        void ActiveProfileNameL( TPtr aProfileName );
-
-    public:
-
-        /**
-        * Gets called by HandleSystemAgentEventL to update battery bars.
-        * @param TInt aState
-        * @return void
-        */
-        void UpdateBatteryBarsL( const TInt aState );
-
-        /**
-        * Gets called by HandleSystemAgentEventL when profile was changed.
-        * Profile selected Global Note is shown.
-        * @param TInt aValue
-        * @return void
-        */
-        void HandleProfileChangedL( const TInt aValue );
-
-        /**
-        * Checks if the active profile is silent and updates CSysApLightsController
-        * if needed.
-        * @param None
-        * @return void
-        */
-        void CheckSilentModeL();
-
-        /**
-        * Gets called by CSysApOfflineModeController when activation/deactivation
-        * of Offline Mode fails
-        * @param TBool aOffline
-        * @return void
-        */
-        void RestoreProfileL( const TBool aOffline );
-
-        /**
-        * Returns the id of the active profile.
-        * @param None
-        * @return Int
-        */
-        TInt ActiveProfileId();
-
-        /**
-        * Gets called when the value of the SD key KGSDisplayLightsTimeout
-        * changes
-        * @param TInt : lights timeout in seconds
-        * @return void
-        */
-        void DoLightsTimeoutChangedL( const TInt aTimeout );
-
-    private:
-
-        /**
-        * Checks whether it is necessary to change profiles in case an accessory
-        * was connected/disconnected while the device was powered down.
-        *
-        * @param TInt aValue
-        * @return void
-        */
-        void HandleAccessoryProfileInStartupL( );
-
-    public:
-        /**
-        * Gets called by HandleSystemAgentEventL to Disable keylock when devicelock is activated.
-        * This is done already when device lock is activated because this
-        * @param None
-        * @return void
-        */
-        void SetDeviceLockEnabledL( const TBool aLockEnabled );
-
-    private:
-
-        /**
-        * Gets called by HandleShortPowerKeyPressedL to display the power key popup menu
-        * @param None
-        * @return void
-        */
-        void ShowPowerKeyPopUpMenuL();
-
-        /**
-        * Does what is needed to do inside SysAp before actually doing
-        * other shutdown related things. This is used when shutdown image is enabled.
-        * @param None
-        * @return void
-        */
-        void PrepareForShutdownImage();
-
-        /**
-        * Does what is needed to do inside SysAp before actually doing
-        * other shutdown related things. This is used when shutdown animation is enabled.
-        * @param None
-        * @return void
-        */
-        void PrepareForShutdownAnimation();
-
-        /**
-        * Show shutdown animation
-        *
-        * @param
-        * @return ETrue if animation is enabled
-        */
-    #ifdef RD_STARTUP_ANIMATION_CUSTOMIZATION
-        void
-    #else // RD_STARTUP_ANIMATION_CUSTOMIZATION
-        TBool
-    #endif // RD_STARTUP_ANIMATION_CUSTOMIZATION
-        ShowAnimationL();
-
-        /**
-        * Makes Status pane visible/invisible when needed and changes it's layout between Charging/Alarm
-        * @param None
-        * @return void
-        */
-        void SetStatusPaneLayoutL( const TSysApPhoneState aState );
-
-        /**
-        * Checks from current Symbian swstate if it is ok to initiate shutdown
-        * @param None
-        * @return const TBool
-        */
-        TBool OkToInitiateShutdown();
-
-        /**
-        * Shows shutdown animation or shutdown image
-        * @param None
-        * @return void
-        */
-        void PrepareForCompleteShutdown();
-
-        /**
-        * Makes the end part of shutdown sequence.
-        * @param None
-        * @return void
-        */
-        void CompleteShutdown( const TBool aReset = EFalse, const TInt aResetReason = KDummyReason );
-
-        /**
-        * Sets calls forwarding indicators on/off accrding to aCallsForwardingState
-        * @param TInt aCallsForwardingState
-        * @return void
-        */
-        void DoSwStateNormalConstructionL();
-
-    public:
-
-        /**
-        * Starts an application or brings an already running application
-        * to foreground.
-        * @param TUid: UID of the application that is activated
-        * @return void
-        */
-        void ActivateApplicationL( const TUid aUid );
-
-        void HandleCurrentCallStateChangeL( TInt aCurrentCallState );
-
-        void DoSimChangedFromPreviousBootL();
-
-        /**
-        * Gets called in SysAp construction or when SysAp gets a SA/P&S notification
-        * @param const TInt: indicator status
-        * @return void
-        */
-        void HandleLocationPrivacyIndicatorL( const TInt aState );
-
-        /**
-        * Return value of the__SIMCARD feature
-        * @param None
-        * @return TBool
-        */
-        TBool SimSupported();
-
-        /**
-        * Notify CSysApLightController of the empty battery.
-        * @param None
-        * @return void
-        */
-        void BatteryEmptyL();
-
-        /**
-        * Prompt starter to change mode
-        * @param aState The new state
-        * @return KErrArgument if the state change is illegal (from current state
-        * it is not possible to change to the requested state), KErrNone if the
-        * global state change has been successfully initiated.
-        */
-        TInt SetStarterState( const RStarterSession::TGlobalState aState );
-
-        /**
-        * Creates the device name string for BT Sap disconnect prompt.
-        * @return device name string.
-        */
-        HBufC* GetBtSapDeviceNameL();
-
-        /**
-        * Handle alarm indicator
-        * @param aShowIndicator If ETrue, indicator is show, otherwise it is hidden.
-        */
-        void ShowAlarmIndicatorL( TBool aShowIndicator );
-
-        /**
-        * Informs lights controller that flip has been opened/close
-        * @param aFlipOpen ETrue if flip is open, EFalse otherwise
-        */
-        void SetFlipOpenL( TBool aFlipOpen );
-
-        /**
-        * Creates a virtual flip key event that is passed to the key management
-        * of SysAp.
-        *
-        * @since S60 3.2
-        * @param aFlipOpen ETrue if flip is open, EFalse otherwise
-        * @return None
-        */
-        void SimulateFlipKeyEventL( TBool aFlipOpen );
-
-        /**
-        * Informs lights controller that grip has been opened/close
-        * @param aGripOpen ETrue if grip is open, EFalse otherwise
-        */
-        void SetGripOpenL( TBool aGripOpen );
-
-        /**
-        * Sets the status of the Central Repository key
-        * KCRUidCoreApplicationUIs / KCoreAppUIsNetworkConnectionAllowed
-        * @param TInt
-        * @return void
-        */
-        void SetNetworkConnectionAllowed( TCoreAppUIsNetworkConnectionAllowed aNetworkConnectionAllowed );
-
-        /**
-        * Get pointer to RTelServer
-        *
-        * @return pointer to RTelServer if iSysApEtelConnector is initialized. Otherwise return NULL.
-        */
-        RTelServer* GetTelServer();
-
-        /**
-        * Show WLan indicator
-        *
-        * @param aValue The value of KPSWlanIndicator PS key.
-        */
-        void HandleWlanIndicatorL( TInt aValue );
-
-        /**
-        * Show TARM indicator
-        *
-        * @param aValue The value of KCoreAppUIsTarmIndicator PS key
-        */
-        void HandleTarmIndicatorL( TInt aValue );
-
-#ifndef RD_STARTUP_ANIMATION_CUSTOMIZATION
-        /**
-        * Continue shutdown animation showing after sync request
-        */
-        void ShutdownAnimationSyncOK();
-#endif RD_STARTUP_ANIMATION_CUSTOMIZATION
-
-        /**
-        * Skip shutdown animation (i.e. stop showing it). Initiated by CoverUI.
-        */
-        void SkipShutdownAnimation();
-
-        /**
-        * Notifies CoverUI about skipping shutdown animation.
-        */
-        void NotifyShutdownAnimationSkip();
-
-        /**
-        * Check cover display support
-        *
-        * @return ETrue if cover display is supported, EFalse otherwise
-        */
-        TBool CoverDisplaySupported();
-
-        /**
-        * Returns reference to RStarterSession
-        * RStarterSession is connected when this method is called
-        * for the first time.
-        *
-        * Always (except when freeing resources) access the starter session via this method,
-        * don't use the member variable directly.
-        *
-        * @return reference to RStarterSession
-        */
-        RStarterSession& StarterSession();
-
-        /**
-        * Returns reference to SysAp's CenRep controller
-        *
-        * @since S60 3.1
-        * @param None
-        * @return reference to CSysApCenRepController
-        */
-        CSysApCenRepController& CenRepController();
-
-        /**
-        * Ignore zero network bars signal notifies.
-        * This is needed in BT SAP mode.
-        *
-        * @param aIgnore If ETrue, ignore any future zero network bars notifications.
-        */
-        void IgnoreZeroNetworkBarNotifications(TBool aIgnore);
-
-        /**
-        * Check if BT SAP is enabled
-        *
-        * @return ETrue if BT SAP is enabled, EFalse otherwise
-        */
-        TBool BtSapEnabled();
-
-        /**
-        * Deactivate BT when changing to normal mode.
-        * Can only be used during startup, has no effect after that.
-        */
-        void DeactivateBT();
-
-    private:
-        /**
-        * Returns reference to SysAp's keylock session
-        * RAknKeylock2 session is connected when this method is called
-        * for the first time.
-        *
-        * Always (except when freeing resources) access the keylock session via this method,
-        * don't use the member variable directly.
-        *
-        * @since S60 3.1
-        * @param None
-        * @return reference to RAknKeylock2
-        */
-        RAknKeylock2& KeyLock();
-
-
-
-#ifdef __SYSAP_MODULE_TEST
-
-        /**
-        * Can be used for showing a CAknGlobalNote in module tests
-        * @param noteText : text to be shown in the note
-        * @return void
-        */
-        void ModuleTestShowUiNoteL( const TDesC& noteText ) const;
-#endif
-
-        /**
-        * shows power down note before displaying shutdown image
-        * @param: none
-        * @return void
-        */
-        void ShowShutdownNoteL();
-
-        /** Return ETrue if the global system state is one of the 'normal'
-        * states: ESwStateNormalRfOn, ESwStateNormalRfOff or
-        * ESwStateNormalBTSap.
-        */
-        TBool IsStateNormal() const;
-
-        /**
-        * Returns max of three integers
-        * @param: TInt
-        * @return void
-        */
-        TInt Max( const TInt aA, const TInt aB, const TInt aC );
-
-        /**
-        * Displays shutdown image.
-        * This method is just a nonleaving implementation,
-        * calls ShowShutdownImageL for performing the task.
-        *
-        * @since S60 3.1
-        * @param aBitmapId  bitmap identifier
-        * @return TInt an error value
-        * @see CSysApAppUi::ShowShutdownImageL
-        */
-        TInt ShowShutdownImage( TInt aBitmapId );
-
-        /**
-        * Displays shutdown image. If a CSysApShutdownImage instance
-        * does not exist, it will be created.
-        *
-        * @since S60 3.1
-        * @param aBitmapId  bitmap identifier
-        * @return None
-        * @leave Symbian error code
-        */
-        void ShowShutdownImageL( TInt aBitmapId );
-
     private: // from MSysapCallback
         /**
         * Executes a command in SysAp.
@@ -1258,19 +169,60 @@
         * @see MSysapCallback::TSysapQuery
         */
         void ExecQueryL( TSysapQuery aQuery, TDes8& aReturn, const TDesC8& aParam );
-
-    public:
+        
+//    private:
+        /**
+        * EPOC default constructor.
+        * @param None
+        * @return void
+        */
+    public: 
+        void ConstructL();
+        
+    private: // from CEikAppUi
+        /**
+        * Handles a change to the application's resources which are shared across the environment.
+        *
+        * @since S60 3.1
+        * @param aType The type of resources that have changed.
+        * @return None.
+        */
+//        void HandleResourceChangeL(TInt aType);
+        
+    private:
         /**
-        * Sets HAC (Hearing Aid Compatibility) indicator according to its CenRep-setting
-        * state.
-        * HAC indicator is not displayed if an accessory is connected.
-        *
-        * @param None
-        * @return None
+        * Takes care of command handling.
+        * @param aCommand command to be handled
+        * @return void
+        */
+        void HandleCommandL( TInt aCommand);
+
+        /**
+        * handles key events
+        * @param TKeyEvent& aKeyEvent
+        * @param TEventCode aType
+        * @return TKeyResponse
         */
-        void SetHacIndicatorL();
+        TKeyResponse HandleKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType );
+      
+     public:
+     	//	void CallFromMain();
+     		
+     		 /**
+        * Returns the state of keylock
+        * @param none
+        * @return TBool the state of keylock
+        */
+        TBool KeyLockState() const;
 
         /**
+        * Returns the state of devicelock
+        * @param none
+        * @return TBool the state of devicelock
+        */
+        TBool DeviceLockState() const;
+        
+        /**
         * Returns reference to SysAp's internal feature manager.
         *
         * @since S60 3.1
@@ -1278,387 +230,198 @@
         */
         CSysApFeatureManager& SysApFeatureManager();
         
-        /**
-        * Handles response to power save activation query.
-        *
-        * @param aEnable If ETrue, the user has accepted the query.
-        */
-        void HandleActivatePsmQueryResponse( TBool aEnable );
-
-        /**
-        * Handles response to power save deactivation query.
-        *
-        * @param aDisable If ETrue, the user has accepted the query.
-        */
-        void HandleDeactivatePsmQueryResponse( TBool aDisable );
-
-    private: // from CAknAppUi
-        /**
-        * Handles a change to the application's resources which are shared across the environment.
-        *
-        * @since S60 3.1
-        * @param aType The type of resources that have changed.
-        * @return None.
-        */
-        void HandleResourceChangeL(TInt aType);
-
-    private:
-        /**
-        * Shows and hides the memory card indicator depending on whether the memory card is inserted or not.
-        *
-        * @since S60 3.1
-        * @param None.
-        * @return None.
-        */
-        void SetMemoryCardIndicatorL();
-
-        /**
-        * Returns whether IHF has been enabled.
-        * Creates audio routing observer if it does not exist..
-        *
-        * @since S60 3.2
-        * @return TBool ETrue if IHF is enabled
+                /*
+        * Called by SysApLightsController when the lights are switced on/off
+        * @param aActivate If ETrue forwarding is activated, otherwise deactivated
+        * @return void
         */
-        TBool IhfEnabledL();
-
-#ifdef RD_MULTIPLE_DRIVE
-        void UpdateInsertedMemoryCardsL();
-#endif // RD_MULTIPLE_DRIVE
-
-    	/**
-    	* Handles setup of USB charger from given charging status.
-    	*
-    	* @since S60 3.2
-    	* @param aValue Given charging status
-    	*/
-        void HandleUsbCharger( const TInt aValue );
-
-    public:
-        /**
-        * Sets USB connection attach status.
-        * This prevents double beep when USB file transfer gets activated.
-        *
-        * @since S60 3.2
-        * @param aUsbConnected ETrue if USB cable has just been attached, otherwise EFalse
-        */
+        void ActivateKeyeventForwardingForLights(TBool aActivate);
+        
+        TBool IsEncryptionOperationOngoingL() const;
+//        void ConnectToFileServerL();
+//        void ConnectToWindowServerL();
+        void ShowExampleUiNoteL ( const TDesC& noteText )const;
+        void ShowNotificationDialog(const TDesC& noteText)const;
+        void PopupNote();
+//        void CreateWindowGroup();
+        TBool ResourcesFreed() const;
+        void ShowUiNoteL( const TSysApNoteIds aNote ) const;        
+        TInt StateOfProperty( const TUid& aCategory, const TUint aKey ) const;
+        TBool OfflineModeActive();
+        void GoOnlineL( TBool aDoProfileChange = ETrue );
+        void GoOfflineL();
+        void SwitchFromOnlineToOfflineModeL();
+        
+        void DoStateChangedL( const RStarterSession::TGlobalState aSwState  );
+        TInt SetStarterState( const RStarterSession::TGlobalState aState );
+        TInt BluetoothPowerMode() const;
+        void SetNetworkConnectionAllowed( TCoreAppUIsNetworkConnectionAllowed aNetworkConnectionAllowed );
+        RStarterSession& StarterSession();
+        TInt SetBtPowerState( TBool aBtState );
+        TBool SimSupported();
+        TBool BtSapEnabled();
+        void OfflineModeChangedL();
+        TBool UiReady() const;
+        void DoShutdownL( const TBool aReset, const TInt aResetReason );
+        TBool IsDeviceModeKey( const TKeyEvent& aKeyEvent ) const;
         void SetUsbAttachStatus( const TBool aUsbAttached );
-
-        /**
-    	* Returns whether the key event is considered to be a device mode key event,
-    	* which usually causes a transition in the device mode (e.g. grip, flip or twist).
-    	*
-    	* @since S60 3.2
-    	* @param aKeyEvent key event
-    	* @return TBool ETrue key event is considered to be a device mode key
-    	*               EFalse not a device moed key
-    	*/
-    	TBool IsDeviceModeKey( const TKeyEvent& aKeyEvent ) const;
-
-    	/**
-    	* Returns whether resources (objects, server connections) owned by this
-    	* class has been freed.
-    	*
-    	* @since S60 3.2
-    	* @return TBool ETrue if resource deallocation has been performed.
-    	*/
-    	TBool ResourcesFreed() const;
-
-    	/**
-    	* Returns pointer to CSysApEtelConnector.
-    	*
-    	* @since S60 3.2
-    	* @return pointer to CSysApEtelConnector instance owned by this class.
-    	*         NULL if the object creation has failed.
-    	*/
-    	CSysApEtelConnector* EtelConnector() const;
-    	
-    	/**
-    	* Returns reference to USB charger detector, TSysApUsbChargerDetector.
-    	*
-    	* @since S60 3.2
-    	* @return Reference to USB charger detector.
-    	*/
         TSysApUsbChargerDetector& UsbChargerDetector();
-
-    	/**
-    	* Sets envelope indicator according to current messaging status.
-    	*
-    	* @since S60 3.2
-    	*/
-        void SetEnvelopeIndicatorL();
-
-    	/**
-    	* Handles value changes of the key KHWRMBatteryStatus.
-    	*
-    	* @since S60 3.2
-    	* @param aValue the updated key value
-    	*/
-    	void HandleBatteryStatusL( const TInt aValue );
         
-        /**
-    	* Handles value changes of the key KHWRMChargingStatus.
-    	*
-    	* @since S60 3.2
-    	* @param aValue the updated key value
-    	*/
-        void HandleChargingStatusL( const TInt aValue );
-        
-        /**
-        * Cancel the specified query if it is active.
-        *
-        * @param aQueryId ID of the query that must be cancelled.
-        *                 If ESysApNoQuery is given, the active query is cancelled.
-        *                 without checking its ID.
-        */
-        void CancelQuery( TSysApConfirmationQueryIds aQueryId );
-    
-    private:
-        // from MSysApPsmControllerNotifyCallback
-        void NotifyPowerSaveModeL( TSysApPsmStatus aStatus );
-
-    private:
-        /**
-        * Get the logs observer. Created if does not exist.
-        * 
-        * @since S60 3.2
-        * @return reference to CSysApCenRepLogsObserver object
-        */
-        CSysApCenRepLogsObserver& CSysApAppUi::LogsObserverL();
-
-    private: //Data members
+        void HandleAccessoryConnectedL( TAccMode aAccessoryState );
 
-        /*****************************************************
-         * Series 60 Customer / DOS
-         * Series 60 Domestic OS API
-         *****************************************************/
-
-        CSysApLightsController*         iSysApLightsController;
-
-        CSysApPubSubObserver*           iSysApPubSubObserver;
-        CSysApProfileObserver*          iSysApProfileObserver;
+        void HandleAccessoryDisconnectedL();
+        void DoLightsTimeoutChangedL( const TInt aTimeout );
+        void SetHacIndicatorL();
+        void DoNotActivateBt();
+        void SetIhfIndicatorL();
+		void HandleLongPowerKeyPressedL();
+        void IgnoreZeroNetworkBarNotifications(TBool aIgnore);
+        void InitCloseSimApplicationsL();
+        void CloseSimApplicationsL();
+        void DoSimChangedFromPreviousBootL();
+        void ShowAlarmIndicatorL( TBool aShowIndicator );
+        void AlertUiAlertingL( const TBool aAlerting );
+        void HandleForcedLightsVTRequireL( const TInt aLightsParameter ) const;
+        void HandleForcedLightsSSRequireL( const TInt aLightsParameter ) const;
+        void HandleForcedLightsATCRequireL( const TInt aLightsParameter ) const;
+        void HandleLightsRequireL() const;
+        void AlertUiKeyLockOff( const TBool aKeyLockOff );
+        void DoNotEnableKeylock();
+        void SwitchLightsOnSoftRejectL();
+        void SetDeviceLockEnabledL( const TBool aLockEnabled );
+        void HandleBatteryStatusL( const TInt aValue );
+        void BatteryEmptyL();
+        void ShowQueryL( const TSysApConfirmationQueryIds aQueryId,
+            const TDesC& aValue = KNullDesC );
+        void HandleChargingStatusL( const TInt aValue );
+        void HandleChargerNotesL( const TInt aValue );
+        void UpdateBatteryBarsL( const TInt aState );
+        void ShowChargingNoteL();
+        void HandleCurrentCallStateChangeL( TInt aCurrentCallState );
+        TBool IsEmergencyCall();
+        CSysApCenRepController& CenRepController();
+        void HandleWlanIndicatorL( TInt aValue );
 
-        CSysApCenRepLightSettingsObserver*  iSysApCenRepLightSettingsObserver;
-        CSysApCenRepLogsObserver*                iSysApCenRepLogsObserver;
-        CSysApCenRepBtObserver*                  iSysApCenRepBtObserver;
-        CSysApCenRepHacSettingObserver* iSysApCenRepHacSettingObserver;
-//        CSysApCenRepFmTxObserver*      iSysApCenRepFmTxObserver;
-        CSysApCenRepController*                  iSysApCenRepController;
-        CSysApStartupController*        iSysApStartupController;
-        CSysApConnectionMonitorObserver*	iSysApConnectionMonitorObserver;
-        CSysApPowerKeyMenuObserver*     iSysApPowerKeyMenuObserver;
-        CSysApSsSettingsObserver*       iSysApSsSettingsObserver;
-        CSysApShutdownImage*            iSysApShutdownImage;
-        CSysApShutdownAnimation*        iSysApShutdownAnimation;
-        CSysApEtelConnector*            iSysApEtelConnector;
-        CSysApAccessoryObserver*        iSysApAccessoryObserver;
-        CSysApMsgSimMemLowQuery*        iSysApMsgSimMemLowQuery;
-        CSysApWaitNote*                 iSysApWaitNote;
-        CSysApConfirmationQuery*        iSysApConfirmationQuery;
-        CSysApConfirmationQuery*        iSysApConfirmationQueryForRestart;
-        CSysApFeatureManager*           iSysApFeatureManager;
-        MSysApOfflineModeController*    iSysApOfflineModeController;
-        CSysApMMCObserver*              iSysApMMCObserver;
-        CSysApNspsHandler*              iSysApNspsHandler;
-        MSysApUsbIndicator*             iSysApUsbIndicatorController;
-        MSysApBtController*             iSysApBtController;
-        MSysApBtSapController*          iSysApBtSapController;
-        MSysApLocationPrivacyIndicator* iSysApLocationPrivacyIndicator;
-        CAknBatteryNotify*              iBatteryNotify;
-        CAknSignalNotify*               iSignalNotify;
-        CAknGlobalListQuery*            iGlobalListQuery;
+        void SetKeyLockEnabledL();
+        void SetKeyLockDisabledL();
+        void SetLightsOnUnlockNoteL();
+        void SetLightsOnEcsQueryL();
+        void SetLightsOnSecurityQueryL();  
+        TBool CheckLongPowerKeyPressed();
+        TBool ReleasePowerMenuCustomDialogMemory();
+        
+#ifdef SYSAP_USE_STARTUP_UI_PHASE        
+        /**
+        * Called when UI is ready after boot.
+        */
+        void HandleUiReadyAfterBootL();
 
-        CSystemLock*                    iSysApSystemLock;
-        MProfileEngine*                 iProfileEngine;
-        MProfilesNamesArray*            iProfileNamesArray;
-        RStarterSession                 iStarterSession;
-        RAknKeylock2                    iKeyLock;
-#ifndef RD_MULTIPLE_DRIVE
-        CAknMemoryCardDialog*           iMemoryCardDialog;
-#endif // RD_MULTIPLE_DRIVE
-        TInt                            iCapturedEKeyPowerOff;
-        TInt                            iCapturedEKeyPowerOffUpAndDowns;
-        TInt                            iCapturedAppskey;
-        TInt                            iCapturedAppskeyUpAndDowns;
+#endif // SYSAP_USE_STARTUP_UI_PHASE
+
+     
+     private:
+         /**
+         * Frees SysAp's reserved memory, closes connections to servers etc.
+         * @param None
+         * @return void
+         */
+         void FreeResources();
+         TBool OkToInitiateShutdown();
 
 
-        TInt                            iNumberOfProfileNamesInPowerKeyMenu;
-
-        TBool                           iPowerkeyMenuLockKeypadShown;
-        TBool                           iPowerkeyMenuExitSapShown;
-        TBool                           iPowerkeyMenuLockSystemShown;
-        TBool                           iPowerkeyMenuEjectShown;
-
-        TInt                            iPowerkeyMenuLockKeypadSelection;
-        TInt                            iPowerkeyMenuExitSapSelection;
-        TInt                            iPowerkeyMenuLockSystemSelection;
-#ifndef RD_MULTIPLE_DRIVE
-        TInt                            iPowerkeyMenuEjectSelection;
-#endif // RD_MULTIPLE_DRIVE
+         void CompleteShutdown( const TBool aReset = EFalse, const TInt aResetReason = KDummyReason );
+         void PrepareForShutdownImage();
+         TInt ShowShutdownImage( TInt aBitmapId );
+         void ShowShutdownImageL( TInt aBitmapId );
+         TBool IhfEnabledL();
+         void DoSwStateNormalConstructionL();
+         static TInt DoCloseSimApplicationsAfterCallBack( TAny* aObject );
+         
+         // from MSysApPsmControllerNotifyCallback
+         void NotifyPowerSaveModeL( TSysApPsmStatus aStatus );
+         
+         void HandleUsbCharger( const TInt aValue );
+         TBool IsStateNormal() const;
+         void HandleAccessoryProfileInStartupL( );
+         
+         CSysApCenRepLogsObserver& CSysApAppUi::LogsObserverL();
 
-        TInt                            iProfileToBeActivated;
-        TInt                            iActiveProfileBeforeOfflineMode;
-
-        TInt                            iApplicationScanningRoundNumberInBtSap;
-        TBool                           iTimeToKillInBtSap;
+        
+     private:
+//          CSysApWsClient*                 iSysApWsClient;
+          CSysApLightsController*         iSysApLightsController;
+          CSysApFeatureManager*           iSysApFeatureManager;
+          CSysApNspsHandler*              iSysApNspsHandler;
+          CSysApPubSubObserver*           iSysApPubSubObserver;
+    
+          CSysApDefaultKeyHandler*          iSysApDefaultKeyHandler;
+//          RWindowGroup                      groupWin;
+          CSysApStartupController*        iSysApStartupController;
+          MSysApOfflineModeController*    iSysApOfflineModeController;
+          RStarterSession                 iStarterSession;
+          TSysApUsbChargerDetector        iSysApUsbChargerDetector;
+          CSysApAccessoryObserver*        iSysApAccessoryObserver;
+          CSysApShutdownImage*            iSysApShutdownImage;
+          CSysApKeySndHandler*            iSysApKeySndHandler;
+          CSysApCenRepController*                  iSysApCenRepController;
+          CSysApCenRepLightSettingsObserver*  iSysApCenRepLightSettingsObserver;
+          CSysApCenRepBtObserver*                  iSysApCenRepBtObserver;
+          CSysApCenRepHacSettingObserver* iSysApCenRepHacSettingObserver;
+          
+          CSysApAudioRoutingObserver* iSysApAudioRoutingObserver;
+          CSysApPsmController* iSysApPsmController;
+		  CHbSymbianVariant* iVariantAccState ;
+          CSysApSsSettingsObserver*       iSysApSsSettingsObserver;
+          CSystemLock*                    iSysApSystemLock;
+          CSysApCenRepCallForwardingObserver* iSysApCenRepCallForwardingObserver;
+          CSysApBatteryInfoController* iSysApBatteryInfoController;
+          MSysApBtSapController*          iSysApBtSapController;
+          CPeriodic*                      iSapTimer;
+          MSysApBtController*             iSysApBtController;
+          CSysApCenRepLogsObserver*                iSysApCenRepLogsObserver;
+		  MSysApUsbIndicator*             iSysApUsbIndicatorController;
+		  CKeyguardAccessApi*             iKeyguardController;
+		  CHbDevicePowerMenuSymbian*            iPowerMenuDialog;
+	      CSysApKeyManagement*            iSysApKeyManagement;
+		  
+//	      CSysApDriveList* iSysApDriveList;
 
-        CAknGlobalNote*                 iProfileNote;
-        TInt                            iProfileNoteId;
-
-        TBool                           iLastPowerKeyWasShort;
-        TBool                           iIgnoreNextPowerKeyUpEvent;
-        TBool                           iIgnoreNextPowerKeyRepeats;
-        TBool                           iPowerKeyPopupMenuActive;
-        TBool                           iDisablePowerkeyMenu;
-        TBool                           iPowerkeyMenuPowerOffShown;
-
+     private:         
+        TBool                           iPowerKeyPopupMenuActive;   
         TBool                           iDeviceLockEnabled;
         TBool                           iKeyLockEnabled;
         TBool                           iKeyLockOnBeforeCall;
         TBool                           iKeyLockOnBeforeAlarm;
         TBool                           iKeyLockOnBeforeCradle;
-        TBool                           iShowkeypadActivatedNoteAfterSoftReject;
-
-        TBool                           iEmergencyCallActive;
+        TBool                           iResourcesFreed;        
+        TInt                            iCapturedEKeyPowerOff;
+        TInt                            iCapturedEKeyPowerOffUpAndDowns;
+        TBool                           iOfflineModeActive;
+        TBool                           iShutdownStarted;
+        
+        TBool                           iIgnoreNextPowerKeyUpEvent;  // need to be added this flag in maliks client side apis.
+        TBool                           iLastPowerKeyWasShort;
+        TBool                           iPowerKeyPopupMenuDismissed; // need to be added this flag in malik implementation.
+        TInt                            iKeyBoardRepeatCount;
+        TBool                           iIgnoreNextPowerKeyRepeats;
+        TInt                            iActiveProfileBeforeOfflineMode;
+        
         TBool                           iSimChangedDone;
-        TBool                           iResourcesFreed;
-        TBool                           iNsps;
-#ifndef RD_MULTIPLE_DRIVE
-        TBool                           iHideFirstBeep;
-#endif // RD_MULTIPLE_DRIVE
-        TBool                           iShutdownStarted;
-        TBool                           iAlarmOrChargingStateShutdownStarted;
+        TBool                           iIgnoreZeroNetworkBarNotifications;
+        TInt                            iApplicationScanningRoundNumberInBtSap;
+        TBool                           iTimeToKillInBtSap;
+        TBool                           iShowkeypadActivatedNoteAfterSoftReject;
+        TBool                           iCharging;  // Indicates if charging is currently on
+        TBool                           iEmergencyCallActive;
+        TBool                           iCallActivated; // used    in defining whether to show GPRS suspended note
 
-        TBool                           iIgnoreAccessorySpecificProfileChanges;
-        TBool                           iAccessoryJustConnected;
-
-        TBool                           iHandleNextProfileEvent;
         TBool                           iActivateBt;
         TBool                           iDeactivateBt;
-#ifndef RD_MULTIPLE_DRIVE
-        TBool                           iTimeToKill;                     // MMC Hot Swap
-        TInt                            iApplicationScanningRoundNumber; // MMC Hot Swap
-#endif // RD_MULTIPLE_DRIVE
-        TBool                           iGprsActivated; // used    in defining whether to show GPRS suspended note
-        TBool                           iGprsSuspended; // used    in defining whether to show GPRS suspended note
-        TBool                           iCallActivated; // used    in defining whether to show GPRS suspended note
-        TBool                           iGprsSuspendedNoteShown;
-
-        TBool                           iMMCEjectUsed;
-#ifndef RD_MULTIPLE_DRIVE
-        TBool                           iMMCPowerMenuEjectUsed;
-        TBool                           iMMCInserted;
-#endif // RD_MULTIPLE_DRIVE
-
-        CPeriodic*                      iTimer;
-        CPeriodic*                      iSapTimer;
-#ifndef RD_STARTUP_ANIMATION_CUSTOMIZATION
-        CPeriodic*                      iAnimTimer;
-#endif // RD_STARTUP_ANIMATION_CUSTOMIZATION
-        CSysApTimer*                    iSysApTimer;
-
-#ifndef RD_STARTUP_ANIMATION_CUSTOMIZATION
-        TInt                            iAnimationShowingTime;
-#endif // RD_STARTUP_ANIMATION_CUSTOMIZATION
-
-        CSysApKeySndHandler*            iSysApKeySndHandler;
-
-        TBool                           iIgnoreZeroNetworkBarNotifications;
-
-        TBool                           iCharging;  // Indicates if charging is currently on
-        CSysApKeyManagement* 			iSysApKeyManagement;
-
-        CSysApMediatorObserver*         iSysApMediatorObserver;
-        TBool                           iShutdownContinued;
-
-        /**
-        * The default key handler.
-        * Own.
-        */
-        CSysApDefaultKeyHandler* iSysApDefaultKeyHandler;
-
-        TBool iPowerKeyPopupMenuDismissed; // Indicates if the popup menu has been dismissed
-
-#ifndef RD_MULTIPLE_DRIVE
-        TBool iHideNextBeep; // Prevents double beep when USB file transfer gets activated
-        TBool iFileManagerCloseDisabled; // Prevents File Manager to close on hotswap
-#endif // RD_MULTIPLE_DRIVE
-
-        CSysApAudioRoutingObserver* iSysApAudioRoutingObserver;
-
-        /**
-        * Call forwarding status CenRep key observer.
-        * Own.
-        */
-        CSysApCenRepCallForwardingObserver* iSysApCenRepCallForwardingObserver;
-
-        /**
-        * Message waiting status CenRep key observer.
-        * Own.
-        */
-        CSysApCenRepMsgWaitingObserver* iSysApCenRepMsgWaitingObserver;
-
-#ifdef RD_MULTIPLE_DRIVE
-        // First power menu index used for eject
-        TInt iPowerkeyMenuEjectSelectionBase;
-
-        /**
-        * Drive list container
-        * Own.
-        */
-        CSysApDriveList* iSysApDriveList;
-
-        /**
-        * Drive unlock handler.
-        * Own.
-        */
-        CSysApDriveUnlockHandler* iSysApDriveUnlockHandler;
-
-        /**
-        * Drive eject handler.
-        * Own.
-        */
-        CSysApDriveEjectHandler* iSysApDriveEjectHandler;
-
-        /**
-        * Array for storing inserted memory cards.
-        * Own.
-        */
-        RArray< CSysApDriveList::TMemoryCardEntry > iInsertedMemoryCards;
-
-        // Stores drive for dismount query
-        TInt iDriveToDismount;
-
-        // Stores drive for eject query
-        TInt iDriveToEject;
-#endif // RD_MULTIPLE_DRIVE
-
-        /**
-        * For USB charger detection.
-        */
-        TSysApUsbChargerDetector iSysApUsbChargerDetector;
-
-        /**
-        * SysAp power save mode controller.
-        * Own.
-        */
-        CSysApPsmController* iSysApPsmController;
+        
+        TBool                           iIgnoreAccessorySpecificProfileChanges;
+        TBool                           iCheckLongPowerKeyEvent;
         
-        /**
-        * SysAp battery info controller.
-        * Own.
-        */
-        CSysApBatteryInfoController* iSysApBatteryInfoController;
-
-		        /**
-         * Returns whether a de/encrypting operation is ongoing
-         *
-     	* @since S60 3.1
-     	* @return TBool ETrue if a de/encrypting operation is in progress
-     	*/
-         TBool IsEncryptionOperationOngoingL() const;
-		 TInt iKeyBoardRepeatCount;
-		     };
-
-#endif      // SYSAPAPPUI_H
-
-// End of File
+//        friend class CSysApWsClient;
+	};
+	
+#endif
--- a/coreapplicationuis/SysAp/Inc/SysApDocument.h	Tue Jun 15 16:07:48 2010 +0100
+++ b/coreapplicationuis/SysAp/Inc/SysApDocument.h	Thu Jul 22 16:35:22 2010 +0100
@@ -20,7 +20,8 @@
 #define SYSAPDOCUMENT_H
 
 // INCLUDES
-#include <AknDoc.h>
+//#include <AknDoc.h>
+#include <eikdoc.h>
 
 // FORWARD DECLARATIONS
 class  CEikAppUi;
@@ -32,7 +33,7 @@
 *  @since 1.0
 */
 
-class CSysApDocument : public CAknDocument
+class CSysApDocument : public CEikDocument
     {
     public:
         /**
@@ -40,7 +41,12 @@
         * @param CEikApplication& aApp
         * @return void
         */
-        CSysApDocument(CEikApplication& aApp): CAknDocument(aApp) { }
+        CSysApDocument(CEikApplication& aApp): CEikDocument(aApp) { }
+        
+        /**
+        *   Two-phased constructor.
+        */
+//        static CSysApDocument* NewL(CEikApplication& aApp);
 
         /**
         * Destructor.
@@ -50,6 +56,12 @@
         virtual ~CSysApDocument();
 
     private:
+        
+        /**
+        *   EPOC default constructor.
+        */
+//        void ConstructL();
+        
         /**
         * C++ default constructor.
         * @param None
--- a/coreapplicationuis/SysAp/Inc/SysApFeatureManager.h	Tue Jun 15 16:07:48 2010 +0100
+++ b/coreapplicationuis/SysAp/Inc/SysApFeatureManager.h	Thu Jul 22 16:35:22 2010 +0100
@@ -209,7 +209,7 @@
     * @since S60 3.2
     * @return ETrue if feature is supported
     */ 
-//    TBool FmTxSupported() const;
+    // TBool FmTxSupported() const;
 
     /**
     * Returns whether pen is enabled.
@@ -244,7 +244,7 @@
     * @since S60 5.1
     * @return ETrue if feature is supported
     */
-//    TBool FmTxRdsTextSupported() const;
+    // TBool FmTxRdsTextSupported() const;
 
 private:
 
@@ -339,7 +339,7 @@
     /**
     * FM TX supported status
     */
-//    TBool iFmTxSupported;
+    // TBool iFmTxSupported;
     
     /**
     * Pen enabled status.
@@ -359,7 +359,7 @@
     /**
     * FM TX RDS Text support status.
     */
-//    TBool iFmTxRdsTextSupported;
+    // TBool iFmTxRdsTextSupported;
 };
 
 #endif // SYSAPFEATUREMANAGER_H
--- a/coreapplicationuis/SysAp/Inc/SysApPubSubObserver.h	Tue Jun 15 16:07:48 2010 +0100
+++ b/coreapplicationuis/SysAp/Inc/SysApPubSubObserver.h	Thu Jul 22 16:35:22 2010 +0100
@@ -38,6 +38,15 @@
 *  @since 2.X 
 */
 
+enum TSecurityUIsLights
+    {
+    ESecurityUIsLightsUninitialized = 0,
+    ESecurityUIsLightsLockOnRequest,
+    ESecurityUIsLightsQueryOnRequest,
+    ESecurityUIsLightsLockOffRequest,
+    ESecurityUIsLightsLastValue
+    };
+
 class CSysApPubSubObserver : 
               public CBase, 
               public MSysApPropertyResponder
@@ -99,7 +108,7 @@
     /**
     * Handle keys under category KPSUidHWRMFmTx
     */
-//    void HandleHwrmFmTxCategoryL( const TUint aKey, const TInt aValue );
+    // void HandleHwrmFmTxCategoryL( const TUint aKey, const TInt aValue );
     
     /**
     * Handle keys under category KPSUidDataSynchronizationInternalKeys
@@ -134,6 +143,9 @@
     */         
     CSysApPubSubObserver( CSysApAppUi& aSysApAppUi );
     void ConstructL();
+    
+    void HandleLKeylockEventL( const TUint aKey, const TInt aValue  );
+    void HandleLightsOnRequestL( const TUint aKey, const TInt aValue  );
 
 protected: // From MSysApPropertyResponder
 
@@ -151,8 +163,8 @@
     CSysApSubscriber*   iInboxStatusSubscriber;              // KUidInboxStatusValue
     CSysApSubscriber*   iOutboxStatusSubscriber;             // KUidOutboxStatus
     CSysApSubscriber*   iIrdaStatusSubscriber;               // KPSUidIrdaStatus
-    CSysApSubscriber*   iGprsStatusSubscriber;               // KPSUidGprsStatus
-    CSysApSubscriber*   iWcdmaStatusSubscriber;              // KPSUidWcdmaStatus
+//    CSysApSubscriber*   iGprsStatusSubscriber;               // KPSUidGprsStatus
+//    CSysApSubscriber*   iWcdmaStatusSubscriber;              // KPSUidWcdmaStatus
     CSysApSubscriber*   iLocationGlobalPrivacySubscriber;    // KPSUidLocationGlobalPrivacy
     CSysApSubscriber*   iRestoreBackupSubscriber;            // KUidBackupRestoreKey
 
@@ -160,11 +172,11 @@
     CSysApSubscriber*   iSimChangedSubscriber;               // KPSSimChanged
 
     // Category KHWRMFmTxStatus
-//    CSysApSubscriber*   iFmTxStatusSubscriber;   // KPSUidHWRMFmTx
+    // CSysApSubscriber*   iFmTxStatusSubscriber;   // KPSUidHWRMFmTx
     
-//    TInt iPreviousFmTxPSValue;
+    // TInt iPreviousFmTxPSValue;
     
-//    CSysApRemConObserver* iFmTxRemConObserver;
+    // CSysApRemConObserver* iFmTxRemConObserver;
     
     // Category KPSUidCoreApplicationUIs
 
@@ -238,6 +250,13 @@
     * Own.
     */
     CSysApSubscriber* iSmsPhoneStoreSubscriber;
+    
+    CSysApSubscriber* iKeylockEventSubscriber;
+    
+    CSysApSubscriber* iLightsOnRequestSubscriber;
+    
+    CSysApSubscriber* iPowerMenuCustomDialogSubscriber;
+    
 };
 
 #endif // SYSAPPUBSUBOBSERVER_H
--- a/coreapplicationuis/SysAp/Inc/SysApShutdownImage.h	Tue Jun 15 16:07:48 2010 +0100
+++ b/coreapplicationuis/SysAp/Inc/SysApShutdownImage.h	Thu Jul 22 16:35:22 2010 +0100
@@ -131,6 +131,7 @@
         */
         TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType);
 
+        CFbsBitmap* ReadSVGL (TFileName aFileName);
     private:    // Data
 
         //Used for showing user selected image
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/coreapplicationuis/SysAp/Inc/SysApTaskList.h	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,104 @@
+/*
+* Copyright (c) 2005 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*
+*/
+
+
+#ifndef SYSAPTASKLIST_H
+#define SYSAPTASKLIST_H
+
+// INCLUDES
+
+#include <w32std.h>
+#include <apgtask.h>
+
+// CLASS DECLARATION
+
+/**
+*  Class for finding out about running applications.
+*  This class specialises in locating and identifying root applications,
+*  those applications who do not have any parent window group.
+*  It can be used along-side TApaTaskList.
+*
+*  @since Series 60 3.0
+*/
+class CSysApTaskList : public CBase
+	{
+public:
+    /**
+    * Factory function
+    * @param aWsSession an open session to the window server, often from CEikonEnv::WsSession()
+    * @return a new fully constructed instance of CSysApTaskList
+    */
+	static CSysApTaskList* NewL(RWsSession& aWsSession);
+    /**
+    * Factory function
+    * @param aWsSession an open session to the window server, often from CEikonEnv::WsSession()
+    * @return a new fully constructed instance of CSysApTaskList, which is on the cleanup stack
+    */
+	static CSysApTaskList* NewLC(RWsSession& aWsSession);
+    /**
+    * Destructor.
+    */
+	~CSysApTaskList();
+	
+	/**
+	* Refresh the window group array
+	*/
+	void UpdateListL();
+	/**
+	* Accessor for the window group array
+	* @return an array containing the window groups of running applications.
+	*/
+	const RArray<RWsSession::TWindowGroupChainInfo>& WgArray() const;
+
+	/**
+	* Find an application with the requested UID 3, which is running as a root application
+	* @param aAppUid the UID 3 of the target application.
+	* @return a TApaTask which refers to the running instance of the application.
+	* if the application is not running, the TApaTask's Exists() function will return EFalse.
+	*/	
+	TApaTask FindRootApp(TUid aAppUid) const;
+	/**
+	* Query whether an application's window group is running as a root application.
+	* @param aWgId the window group identifier of the target application.
+	* @return ETrue if this window group is running as a root window group.
+	*/
+	TBool IsRootWindowGroup(TInt aWgId) const;
+	
+	/**
+	* Find the parent window group. If there is no parent, 0 is returned.
+	* @param aWgId the window group id that you want to find the parent of.
+	* @return The window group id of the parent, or 0 if there is no parent.
+	*/
+	TInt FindParentWgId(TInt aWgId) const;
+	/**
+	* Find the child window group. If there is no child, 0 is returned.
+	* @param aWgId the window group id that you want to find the child of.
+	* @return The window group id of the child, or 0 if there is no child.
+	*/
+	TInt FindChildWgId(TInt aWgId) const;
+	
+private:
+	CSysApTaskList(RWsSession& aWsSession);
+	void ConstructL();
+
+private:
+	RWsSession& iWs;
+	RArray<RWsSession::TWindowGroupChainInfo> iWgs;
+	};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/coreapplicationuis/SysAp/Inc/hbdevicepowermenusymbian.h	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 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"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ *
+ */
+
+#ifndef HBDEVICEPOWERMENUSYMBIAN_H
+#define HBDEVICEPOWERMENUSYMBIAN_H
+
+#if defined(__SYMBIAN32__) || defined(SYMBIAN) || defined(HB_DOXYGEN)
+
+#include <e32base.h>
+#include <centralrepository.h>
+#include <settingsinternalcrkeys.h>
+#include <ProfileEngineInternalCRKeys.h>
+#include <ProfileEngineSDKCRKeys.h>
+#include <MProfileEngineExtended2.h>
+#include "SysApAppUi.h"
+
+class CHbDevicePowerMenuPrivate;
+
+class CHbDevicePowerMenuSymbian : public CBase
+{
+public:
+
+	static CHbDevicePowerMenuSymbian* NewL(CSysApAppUi& aSysApServer );
+    virtual ~CHbDevicePowerMenuSymbian();
+    
+    //Displays Dialog
+    void ShowL();
+    //Getters and Setters
+    void SetVolume(TInt aVolume);
+    void SetSilenceMode(TBool aEnable);
+    void SetOfflineMode(TBool aChecked);
+    void SetVibrationEnabled(TBool aEnable);
+    void SetPowerOffEnabled(TBool aEnable);
+
+private:
+
+    CHbDevicePowerMenuSymbian(CSysApAppUi& aSysApServer);
+    void ConstructL();
+
+private:
+    friend class CHbDevicePowerMenuPrivate;
+    //Used to set master Volume/Vibrate/Silence Mode in Control Panel
+    MProfileEngineExtended2* 	iProfileEngine;
+    //Used to Set and Get OfflineMode to and from Control Panel
+    CRepository* 				iCenrepOffline;
+    //Used to Get Master Volume/Vibrate/Silence Mode in Control Panel
+    CRepository* 				iCenrepProfile;
+    //Used to handle ShutDown
+    CSysApAppUi& 				iSysApServer;
+    CHbDevicePowerMenuPrivate* 	iPowerMenuPrivate;
+};
+
+#endif // defined(__SYMBIAN32__) || defined(SYMBIAN) || defined(HB_DOXYGEN)
+
+#endif // HBDEVICEPOWERMENUSYMBIAN_H
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/coreapplicationuis/SysAp/Inc/sysapaudioroutingobserver.h	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,127 @@
+/*
+* Copyright (c) 2007 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Observes audio output routing changes
+*
+*/
+
+
+#ifndef SYSAPAUDIOROUTINGONBSERVER_H
+#define SYSAPAUDIOROUTINGONBSERVER_H
+
+#include <MTelephonyAudioRoutingObserver.h>
+class CSysApAppUi;
+
+/**
+ *  ?one_line_short_description
+ *
+ *  ?more_complete_description
+ *
+ *  @lib ?library
+ *  @since S60 ?S60_version *** for example, S60 v3.0
+ */
+class CSysApAudioRoutingObserver : public CBase,
+                                   public MTelephonyAudioRoutingObserver
+    {
+
+public:
+
+    /**
+    * Symbian two-phased constructor.
+    * 
+    * @param aSysApAppUi    reference to System Application's application UI class
+    */
+    static CSysApAudioRoutingObserver* NewL( CSysApAppUi& aSysApAppUi );
+    
+    /**
+    * Destructor.
+    */
+    virtual ~CSysApAudioRoutingObserver();
+    
+    /**
+    * Returns whether audio output is routed to IHF.
+    * 
+    * @since S60 3.2
+    * @return   TBool   ETrue audios routed to IHF
+    *                   EFalse audios not routed to IHF.
+    */
+    TBool IhfEnabled() const;
+
+private: // from MTelephonyAudioRoutingObserver
+    /**
+    * Signals that available audio outputs have changed.
+    *
+    * @since S60 3.2
+    * @param CTelephonyAudioRouting& aTelephonyAudioRouting reference.
+    * @see MTelephonyAudioRoutingObserver::AvailableOutputsChanged
+    */
+    virtual void AvailableOutputsChanged( CTelephonyAudioRouting& aTelephonyAudioRouting);
+
+    /**
+    * Signals that current output has changed. 
+    *
+    * @since 60 3.2
+    * @param CTelephonyAudioRouting& aTelephonyAudioRouting reference.
+    * @see MTelephonyAudioRoutingObserver::OutputChanged
+    */
+    virtual void OutputChanged( CTelephonyAudioRouting& aTelephonyAudioRouting);
+
+    /**
+    * Signals that CTelephonyAudioRouting::SetOutputL request issued by this
+    * application (on CTelephonyAudioRouting instance) was serviced by the
+    * Adaptation.
+    *
+    * @since S60 3.2
+    * @param CTelephonyAudioRouting& aTelephonyAudioRouting reference.
+    * @param aError KErrNone if output requested by application is set, else
+    *        system-wide error code.
+    * @see MTelephonyAudioRoutingObserver::SetOutputComplete
+    */
+    virtual void SetOutputComplete( CTelephonyAudioRouting& aTelephonyAudioRouting, TInt aError);
+
+private:
+
+    /**
+    * C++ default constructor.
+    */
+    CSysApAudioRoutingObserver();
+
+    /**
+    * Constructor.
+    * 
+    * @param aSysApAppUi    reference to System Application's application UI class
+    */
+    CSysApAudioRoutingObserver( CSysApAppUi& aSysApAppUi );
+    
+    /**
+    * Symbian 2nd-phase constructor.
+    */
+    void ConstructL();
+
+private: // data
+
+    /**
+    * Telephony audio routing instance.
+    * Own.
+    */
+    CTelephonyAudioRouting* iTelephonyAudioRouting;
+
+    /**
+    * System Application application UI class.
+    */
+    CSysApAppUi& iSysApAppUi;
+
+    };
+
+
+#endif // SYSAPAUDIOROUTINGONBSERVER_H
--- a/coreapplicationuis/SysAp/Inc/sysapbatteryinfocontroller.h	Tue Jun 15 16:07:48 2010 +0100
+++ b/coreapplicationuis/SysAp/Inc/sysapbatteryinfocontroller.h	Thu Jul 22 16:35:22 2010 +0100
@@ -22,7 +22,7 @@
 #include <e32base.h>
 
 class CBSUtil;
-class CBatteryPopupControl;
+// class CBatteryPopupControl;
 
 /**
  *  Controller for enhanced battery information.
@@ -151,7 +151,7 @@
     * Battery popup control.
     * Own.
     */
-    CBatteryPopupControl* iBatteryPopup;
+    // CBatteryPopupControl* iBatteryPopup;
     };
 
 
--- a/coreapplicationuis/SysAp/Inc/sysapdefaultkeyhandler.h	Tue Jun 15 16:07:48 2010 +0100
+++ b/coreapplicationuis/SysAp/Inc/sysapdefaultkeyhandler.h	Thu Jul 22 16:35:22 2010 +0100
@@ -21,10 +21,13 @@
 
 #include <e32base.h>
 #include <coedef.h>
-#include <AknCapServerClient.h>
+//#include <AknCapServerClient.h>
 
+class RWindowGroup;
 class MSysapCallback;
-class RAknKeylock2;
+
+//class RAknKeylock2;
+//class CSysApAppUi;
 
 
 /**
@@ -49,7 +52,7 @@
         * @param aCallback reference to System Application callback interface.
         * @return pointer to a new instance of CSysApDefaultKeyHandler.
         */
-        static CSysApDefaultKeyHandler* NewL( MSysapCallback& callback );
+        static CSysApDefaultKeyHandler* NewL(MSysapCallback& callback);
 
         /**
         * Destructor.
@@ -85,7 +88,7 @@
         *
         * @param aCallback reference to System Application callback interface.
         */
-        CSysApDefaultKeyHandler( MSysapCallback& callback );
+        CSysApDefaultKeyHandler(MSysapCallback& callback );
 
     private:
     
@@ -162,7 +165,10 @@
         TBool DoShowKeysLockedNote();
         
     private: // data
-
+        
+        // Our window group from SysappUi
+ //       RWindowGroup& iRootWindowGroup;
+        
         /**
         * Reference to callback object.
         */
@@ -182,7 +188,7 @@
         * Pointer to sysap-owned RAknKeylock2*
         * Not own.
         */
-        RAknKeylock2* iKeylock;
+//        RAknKeylock2* iKeylock;
         
         /**
         * Handle of the captured camera key event.
@@ -222,7 +228,7 @@
         /**
         * Avkon UI Server
         */
-        RAknUiServer iAknUiServer;
+//        RAknUiServer iAknUiServer;
         
     };
 
--- a/coreapplicationuis/SysAp/Inc/sysapkeymanagement.h	Tue Jun 15 16:07:48 2010 +0100
+++ b/coreapplicationuis/SysAp/Inc/sysapkeymanagement.h	Thu Jul 22 16:35:22 2010 +0100
@@ -88,6 +88,7 @@
                 */
                 RArray<TInt32> iUpAndDownKeyHandles; //Handles of keys when capturing them
                 
+                RArray<TInt32> iLongKeyPressHandle ; //Handles long key when capturing them
                 /**
                  * Tells if the plugin is a key provider plugin (plugin version 2)
                  */
--- a/coreapplicationuis/SysAp/Src/BtSap/SysApBtSapControllerImpl.cpp	Tue Jun 15 16:07:48 2010 +0100
+++ b/coreapplicationuis/SysAp/Src/BtSap/SysApBtSapControllerImpl.cpp	Thu Jul 22 16:35:22 2010 +0100
@@ -26,7 +26,7 @@
 #include <btengconnman.h>
 #include <StringLoader.h>
 #include <coemain.h>
-#include <SysAp.rsg>
+//#include <SysAp.rsg>
 
 
 MSysApBtSapController* CreateSysApBtSapControllerL( CSysApAppUi& aSysApAppUi )
@@ -162,7 +162,7 @@
         
         // No RF available so signal bars should be same as in offline mode.
         iSysApAppUi.IgnoreZeroNetworkBarNotifications(ETrue);
-        TRAP( err, iSysApAppUi.UpdateSignalBarsL( KAknSignalOffLineMode ) );
+//        TRAP( err, iSysApAppUi.UpdateSignalBarsL( KAknSignalOffLineMode ) );
 
         iSysApAppUi.SetNetworkConnectionAllowed( ECoreAppUIsNetworkConnectionNotAllowed );
 
@@ -183,7 +183,8 @@
     iFinalizeDisconnectNeeded = EFalse;
     iSysApAppUi.IgnoreZeroNetworkBarNotifications(EFalse);
 
-    if ( iSysApAppUi.ActiveProfileId() == KOfflineModeProfileId )
+//    if ( iSysApAppUi.ActiveProfileId() == KOfflineModeProfileId )
+      if(0)
         {
         if ( iSwitchingToOffline )
             {
--- a/coreapplicationuis/SysAp/Src/CenRepObservers/SysApCenRepLogsObserver.cpp	Tue Jun 15 16:07:48 2010 +0100
+++ b/coreapplicationuis/SysAp/Src/CenRepObservers/SysApCenRepLogsObserver.cpp	Thu Jul 22 16:35:22 2010 +0100
@@ -154,9 +154,9 @@
     
     if ( iSimChangedCheckDone && iUiReady )
         {
-        TInt newState( iMissedCallsValue > 0 ? EAknIndicatorStateOn : EAknIndicatorStateOff );
+//        TInt newState( iMissedCallsValue > 0 ? EAknIndicatorStateOn : EAknIndicatorStateOff );
         
-        iSysApAppUi.SetIndicatorStateL( EAknIndicatorMissedCalls, newState );
+//        iSysApAppUi.SetIndicatorStateL( EAknIndicatorMissedCalls, newState );
         }
     }
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/coreapplicationuis/SysAp/Src/CenRepObservers/sysapcenrepofflinemodeobserver.cpp	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,149 @@
+/*
+ * 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 "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ * CSysApCenRepOfflineModeObserver is a an observer for the Offline Mode central Repository key.
+ * This class handles the changes to the offline mode changes done from Power Menu or Control Panel 
+ *
+ */
+
+#include "sysapcenrepofflinemodeobserver.h"
+#include "CoreApplicationUIsSDKCRKeys.h"
+#include "SysAp.hrh"
+
+#ifdef _DEBUG
+#include <e32debug.h>
+#endif
+
+// ----------------------------------------------------------------------------
+// CSysApCenRepOfflineModeObserver::NewL( MSysApOfflineModeController& )
+// Creates an instance of CSysApCenRepOfflineModeObserver and returns
+// ----------------------------------------------------------------------------
+
+CSysApCenRepOfflineModeObserver* CSysApCenRepOfflineModeObserver::NewL( 
+                    MSysApOfflineModeController& aSysApOfflineModeController )
+    {
+    TRACES( RDebug::Printf("CSysApCenRepOfflineModeObserver::NewL") );
+    CSysApCenRepOfflineModeObserver* self = 
+    new (ELeave) CSysApCenRepOfflineModeObserver(aSysApOfflineModeController);
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop(); //self
+    return self;
+    }
+
+
+// ----------------------------------------------------------------------------
+// CSysApCenRepOfflineModeObserver::CSysApCenRepOfflineModeObserver( MSysApOfflineModeController& )
+// ----------------------------------------------------------------------------
+
+CSysApCenRepOfflineModeObserver::CSysApCenRepOfflineModeObserver( 
+                MSysApOfflineModeController& aSysApOfflineModeController  )
+            : iSysApOfflineModeController( aSysApOfflineModeController )
+    {
+    TRACES( RDebug::Printf("CSysApCenRepOfflineModeObserver::CSysApCenRepOfflineModeObserver" ) );
+    }
+
+// ----------------------------------------------------------------------------
+// CSysApCenRepOfflineModeObserver::~CSysApCenRepOfflineModeObserver()
+// ----------------------------------------------------------------------------
+
+CSysApCenRepOfflineModeObserver::~CSysApCenRepOfflineModeObserver()
+    {
+    TRACES( RDebug::Printf("~CSysApCenRepOfflineModeObserver" ) );
+    if( iOfflineModeHandler )
+    {
+    iOfflineModeHandler->StopListening();
+    }
+    delete iOfflineModeHandler;
+    delete iOfflineCenRep;
+    }
+
+// ----------------------------------------------------------------------------
+// CSysApCenRepOfflineModeObserver::ConstructL()
+// ----------------------------------------------------------------------------
+
+void CSysApCenRepOfflineModeObserver::ConstructL()
+    {
+    TRACES(RDebug::Printf("CSysApCenRepOfflineModeObserver::ConstructL: trying CRepository::NewL(KCRUidCoreApplicationUIs)"));
+    
+    iOfflineCenRep = CRepository::NewL( KCRUidCoreApplicationUIs );
+    
+    iOfflineModeHandler =
+    CCenRepNotifyHandler::NewL( *this,
+    *iOfflineCenRep,
+    CCenRepNotifyHandler::EIntKey,
+    KCoreAppUIsNetworkConnectionAllowed );
+    iOfflineModeHandler->StartListeningL();    
+    }
+
+// ----------------------------------------------------------------------------
+// CSysApCenRepOfflineModeObserver::HandleNotifyInt()
+// Handles the changes to offline mode state
+// ----------------------------------------------------------------------------
+
+void CSysApCenRepOfflineModeObserver::HandleNotifyInt( TUint32 aId, TInt aNewValue  )
+    {
+    TRACES(RDebug::Printf("CSysApCenRepOfflineModeObserver::HandleNotifyInt(), aId=0x%x, aNewValue=%d", aId, aNewValue));    
+    if ( aId == KCoreAppUIsNetworkConnectionAllowed )
+    {
+        if( aNewValue == ECoreAppUIsNetworkConnectionNotAllowed )
+        {
+        // Offline mode enabled. Go Offline
+        TRACES( RDebug::Printf("CSysApCenRepOfflineModeObserver::HandleNotifyInt() Offline mode Enabled"));
+        // Ignore any leave because it will have already been handled by showing an 
+        // error notification to the user
+        TRAP_IGNORE(iSysApOfflineModeController.SwitchFromOnlineToOfflineModeL());
+        }
+    else if( aNewValue == ECoreAppUIsNetworkConnectionAllowed )
+    {
+        // Offline mode disabled. Go Online
+        TRACES( RDebug::Printf("CSysApCenRepOfflineModeObserver::HandleNotifyInt() Offline mode Disabled"));
+        // Ignore any leave because it will have already been handled by showing an 
+        // error notification to the user
+        TRAP_IGNORE(iSysApOfflineModeController.GoOnlineIfOkL());
+    }
+    else
+    {		
+        // Any other value is invalid	
+        TRACES(RDebug::Printf("CSysApCenRepOfflineModeObserver::HandleNotifyInt() Invalid Value %d", aNewValue));
+    }
+    }
+    }
+
+// ----------------------------------------------------------------------------
+// CSysApCenRepOfflineModeObserver::HandleNotifyError()
+// ----------------------------------------------------------------------------
+
+void CSysApCenRepOfflineModeObserver::HandleNotifyError( TUint32, TInt, CCenRepNotifyHandler* )
+    {
+    TRACES(RDebug::Printf("CSysApCenRepOfflineModeObserver::HandleNotifyError()"));
+    // Nothing to do if start listening leaves
+    TRAP_IGNORE(iOfflineModeHandler->StartListeningL());    
+    }
+
+
+
+// ----------------------------------------------------------------------------
+// CSysApCenRepOfflineModeObserver::IsOffline()
+// Fetches the Cen Rep for Offline mode and 
+// Return true if Offline mode is enabled, false otherwise
+// ----------------------------------------------------------------------------
+TBool CSysApCenRepOfflineModeObserver::IsOffline() const
+    {
+    TRACES(RDebug::Printf("CSysApCenRepOfflineModeObserver::IsOffline"));
+    TBool nwConnAllowed = ETrue;
+    iOfflineCenRep->Get(KCoreAppUIsNetworkConnectionAllowed, nwConnAllowed);
+    TRACES(RDebug::Printf("CSysApCenRepOfflineModeObserver::IsOffline returns %d",!nwConnAllowed));
+    return !nwConnAllowed;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/coreapplicationuis/SysAp/Src/CenRepObservers/sysapcenrepofflinemodeobserver.h	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,102 @@
+/*
+ * Copyright (c) 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"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ * CSysApCenRepOfflineModeObserver is a an observer for the Offline Mode central Repository key.
+ * This class handles the changes to the offline mode changes done from Power Menu or Control Panel 
+ *
+ */
+
+
+#ifndef SYSAPCENREPOFFLINEMODEOBSERVER_H
+#define SYSAPCENREPOFFLINEMODEOBSERVER_H
+
+// INCLUDES
+#include <e32base.h>
+#include <centralrepository.h>
+#include <cenrepnotifyhandler.h>
+
+#include "MSysApOfflineModeController.h"
+
+NONSHARABLE_CLASS(CSysApCenRepOfflineModeObserver) : public CBase, 
+                                                     public MCenRepNotifyHandlerCallback
+    {
+public: // Constructors and destructor
+    /**
+    * Default constructor
+    */
+    static CSysApCenRepOfflineModeObserver* NewL( 
+            MSysApOfflineModeController& aSysApOfflineModeController );
+    
+    /**
+    * Destructor.
+    */
+    ~CSysApCenRepOfflineModeObserver();
+    
+private:    
+    /**
+    * Two phase ConstructL
+    */
+    void ConstructL( );
+    
+    /**
+    * Constructor 
+    * @param aSysApOfflineModeController is the instance of Offline mode controller
+    */
+    CSysApCenRepOfflineModeObserver( MSysApOfflineModeController& aSysApOfflineModeController );
+    
+    /**
+    * default constructor.
+    */
+    CSysApCenRepOfflineModeObserver();
+    
+public: // From MCenRepNotifyHandlerCallback
+    /**
+    * Handles the changes to offline mode state
+    * @param aId is the cen rep key which was changed
+    * @param aNewValue is the new value		
+    */
+    void HandleNotifyInt( TUint32 aId, TInt aNewValue );
+    
+    /**
+    * Handles the error in changing offline mode state
+    * @param aId is the cen rep key which was changed
+    * @param aError is the error id		
+    * @param aHandler is Offline cep rep handler same as iOfflineModeHandler		
+    */
+    void HandleNotifyError( TUint32 aId, TInt aError, CCenRepNotifyHandler* aHandler );
+    
+    /**
+    * Returns whether Offline mode is currently active or not
+    * @return ETrue if Offline mode is active, else EFalse
+    */		
+    TBool IsOffline() const;
+    
+private:
+    /**
+    * Instance of Offline mode controller. Used for enabling or disabling offline mode
+    */	
+    MSysApOfflineModeController& iSysApOfflineModeController;
+    
+    /**
+    * Central Repository for gettting the Offline Mode
+    */	
+    CRepository*          iOfflineCenRep;
+    
+    /**
+    * Handler to the cen rep for listening to the offline changes
+    */
+    CCenRepNotifyHandler* iOfflineModeHandler;
+    };
+
+#endif      // SYSAPCENREPBTOBSERVER_H
--- a/coreapplicationuis/SysAp/Src/OfflineModeController/SysApOfflineModeControllerImpl.cpp	Tue Jun 15 16:07:48 2010 +0100
+++ b/coreapplicationuis/SysAp/Src/OfflineModeController/SysApOfflineModeControllerImpl.cpp	Thu Jul 22 16:35:22 2010 +0100
@@ -1,19 +1,22 @@
 /*
-* Copyright (c) 2005-2008 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"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:  CSysApOfflineModeController implementation
+ * 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 "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
  *
-*/
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ * CSysApOfflineModeController controls the offline mode.
+ * It turns OFF RF, BT and WLAN when offline mode is enabled and turns them ON when
+ * Offline mode is disabled
+ *
+ */
 
 
 // INCLUDES
@@ -23,8 +26,10 @@
 #include "SysAp.hrh"
 #include "DosSvrServices.h"
 #include "SysApCenRepController.h"
+#include "sysapcenrepofflinemodeobserver.h"
 #include <startupdomainpskeys.h>
 #include <PSVariables.h>
+#include <wlandevicesettingsinternalcrkeys.h> // For Turning ON/OFF WLAN
 
 
 MSysApOfflineModeController* CreateSysApOfflineModeControllerL( CSysApAppUi& aSysApAppUi )
@@ -53,22 +58,18 @@
 void CSysApOfflineModeController::ConstructL()
     {
     TRACES( RDebug::Print( _L("CSysApOfflineModeController::ConstructL") ) ); 
-    // Check the active profile
-    TInt activeProfile( iSysApAppUi.ActiveProfileId() );
-    activeProfile = iSysApAppUi.ActiveProfileId();
-    if ( activeProfile == KOfflineModeProfileId )
-        {
-        iOfflineModeActive = ETrue;
-        }
+    
+    // create an observer for Offline Mode
+    TRACES( RDebug::Print( _L("CSysApOfflineModeController::ConstructL: trying CSysApCenRepOfflineModeObserver::NewL") ) );
+    iSysApCenRepOfflineModeObserver = CSysApCenRepOfflineModeObserver::NewL(*this );         
+    iOfflineModeActive = iSysApCenRepOfflineModeObserver->IsOffline();
     }
 
 // ----------------------------------------------------------------------------
 // CSysApOfflineModeController::CSysApOfflineModeController() 
 // ----------------------------------------------------------------------------
 CSysApOfflineModeController::CSysApOfflineModeController( CSysApAppUi& aSysApAppUi ) :
-  iSysApAppUi( aSysApAppUi ),
-  iOfflineModeActive( EFalse ),
-  iDoNotActivateRF( EFalse )
+  iSysApAppUi( aSysApAppUi )
     {
 
     }
@@ -79,6 +80,7 @@
 
 CSysApOfflineModeController::~CSysApOfflineModeController()
     {
+    delete iSysApCenRepOfflineModeObserver;
     }
 
 // ----------------------------------------------------------------------------
@@ -87,6 +89,7 @@
 
 TBool CSysApOfflineModeController::OfflineModeActive()
     {
+    TRACES( RDebug::Print( _L("CSysApOfflineModeController::OfflineModeActive returns %d"), iOfflineModeActive ) );
     return iOfflineModeActive;
     }
 
@@ -97,6 +100,7 @@
 void CSysApOfflineModeController::SwitchFromOnlineToOfflineModeL()
     {
     TRACES( RDebug::Print( _L("CSysApOfflineModeController::SwitchFromOnlineToOfflineModeL") ) ); 
+        
     TInt err ( 0 );
 
     // Set state to starter. Note that if state is same as the current state, then nothing happens.
@@ -104,7 +108,6 @@
 
     if ( err )
         {
-        iSysApAppUi.RestoreProfileL( EFalse );
         iSysApAppUi.ShowUiNoteL( ECannotActivateOfflineModeNote );
         }
     else
@@ -119,8 +122,22 @@
             SetBtActiveBeforeOfflineMode( ETrue );       // Update "BT active" setting
             TRACES( RDebug::Print( _L("CSysApOfflineModeController SetBtPowerStateL returned %d"), err ) );
             }
-        
-        iSysApAppUi.OfflineModeChangedL();
+        /* Turn OFF WLAN */        
+        TInt err( KErrNone );
+        CRepository* repository = CRepository::NewL( KCRUidWlanDeviceSettingsRegistryId );
+        err = repository->Set(KWlanOnOff, 0);
+        delete repository;
+        if(err) 
+		{
+           TRACES( RDebug::Printf("CSysApOfflineModeController::SwitchFromOnlineToOfflineModeL Could not disable WLAN") );
+		    User::Leave(err);
+        }
+        else 
+		{
+            TRACES( RDebug::Printf("CSysApOfflineModeController::SwitchFromOnlineToOfflineModeL WLAN Disabled" ) );
+        }
+		
+		iSysApAppUi.OfflineModeChangedL();
         }
     }
 
@@ -144,7 +161,6 @@
         
     if ( err )
         {
-        iSysApAppUi.RestoreProfileL( ETrue );
         iSysApAppUi.ShowUiNoteL( ECannotDeactivateOfflineModeNote );
         }
     else
@@ -159,11 +175,25 @@
             TRACES( RDebug::Print( _L("CSysApOfflineModeController SetBtPowerStateL returned %d"), err ) );
             }
         
-        iSysApAppUi.OfflineModeChangedL();
+		        /* Turn ON WLAN */    
+           TInt err( KErrNone );
+           CRepository* repository = CRepository::NewL( KCRUidWlanDeviceSettingsRegistryId );
+           err = repository->Set(KWlanOnOff, 1);
+           delete repository;
+           if(err)
+		   {
+               TRACES( RDebug::Printf("CSysApOfflineModeController::SwitchFromOfflineToOnlineModeL Could not enable WLAN") );
+		       User::Leave(err);
+           }
+           else
+		   {
+               TRACES( RDebug::Printf("CSysApOfflineModeController::SwitchFromOfflineToOnlineModeL WLAN Enabled") );
+           }
 
-        iSysApAppUi.SetNetworkConnectionAllowed( ECoreAppUIsNetworkConnectionAllowed );
-        }
-    }
+        iSysApAppUi.OfflineModeChangedL();
+		iSysApAppUi.SetNetworkConnectionAllowed( ECoreAppUIsNetworkConnectionAllowed );
+		}
+	}
 
 // ----------------------------------------------------------------------------
 // CSysApOfflineModeController::CheckOfflineModeInitialStatusesL()
@@ -204,10 +234,12 @@
          ( iSysApAppUi.BtSapEnabled() && simStatus != ESimNotPresent ) ||     
          simStatus == ESimUsable )
         {
-        iSysApAppUi.ShowQueryL( ESysApLeaveOfflineModeQuery );
+        TRACES( RDebug::Printf("CSysApOfflineModeController::GoOnlineIfOkL SIM check PASSED") );
+        SwitchFromOfflineToOnlineModeL();
         }
     else    
         {
+        TRACES( RDebug::Printf("CSysApOfflineModeController::GoOnlineIfOkL SIM check FALIED" ) );
         iSysApAppUi.ShowUiNoteL( EInsertSimNote );
         }
     }
@@ -233,6 +265,7 @@
     TInt btToBeActivated = iSysApAppUi.CenRepController().GetInt( KCRUidCoreApplicationUIsSysAp,
                                                                   KSysApBtStatusBeforeOfflineMode,
                                                                   &err );
+
     if ( err )
         {
         TRACES( RDebug::Print( _L("CSysApOfflineModeController::BtActiveBeforeOfflineMode: ERROR: %d" ), err ) );
@@ -241,6 +274,7 @@
     else
         {
         return ( TBool ) btToBeActivated;
+        //return ETrue;
         }
 
     }
@@ -253,6 +287,7 @@
     return BtActiveBeforeOfflineMode();
     }
 
+
 // End of File
 
 
--- a/coreapplicationuis/SysAp/Src/OfflineModeController/SysApOfflineModeControllerImpl.h	Tue Jun 15 16:07:48 2010 +0100
+++ b/coreapplicationuis/SysAp/Src/OfflineModeController/SysApOfflineModeControllerImpl.h	Thu Jul 22 16:35:22 2010 +0100
@@ -1,19 +1,22 @@
 /*
-* Copyright (c) 2005 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"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:  The stub implementation of MSysApOfflineModeController.
-*
-*/
+ * 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 "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ * CSysApOfflineModeController controls the offline mode.
+ * It turns OFF RF, BT and WLAN when offline mode is enabled and turns them ON when
+ * Offline mode is disabled
+ *
+ */
 
 
 #ifndef SYSAPOFFLINEMODECONTROLLERIMPL_H
@@ -27,6 +30,7 @@
 // FORWARD DECLARATIONS
 
 class CSysApAppUi;
+class CSysApCenRepOfflineModeObserver;
 
 // CLASS DECLARATION
 /**
@@ -160,6 +164,11 @@
 private:
 
     CSysApAppUi&        iSysApAppUi;
+	
+    /**
+    * Instance of the Offline mode observer. Listens to offline mode changes
+	*/	
+    CSysApCenRepOfflineModeObserver*         iSysApCenRepOfflineModeObserver;
 
     TBool               iOfflineModeActive;
     TBool               iDoNotActivateRF;
--- a/coreapplicationuis/SysAp/Src/SysApApp.cpp	Tue Jun 15 16:07:48 2010 +0100
+++ b/coreapplicationuis/SysAp/Src/SysApApp.cpp	Thu Jul 22 16:35:22 2010 +0100
@@ -40,6 +40,8 @@
 CApaDocument* CSysApApp::CreateDocumentL()
     {
     return new( ELeave ) CSysApDocument( *this );
+    
+    // return CSysApDocument::NewL(*this);
     }
 
 // ===================== OTHER EXPORTED FUNCTIONS ============================
--- a/coreapplicationuis/SysAp/Src/SysApAppUi.cpp	Tue Jun 15 16:07:48 2010 +0100
+++ b/coreapplicationuis/SysAp/Src/SysApAppUi.cpp	Thu Jul 22 16:35:22 2010 +0100
@@ -14,178 +14,72 @@
 * Description:  CSysApAppUi implementation.
 *
 */
-
-
 // INCLUDES
 
-#include <avkon.hrh>
-#include <avkon.rsg>
-#include <eikon.hrh>
-#include <apgwgnam.h>
-#include <eiksrv.h>
-#include <eikdll.h>
-#include <AknSmallIndicator.h>
-#include <AknBatteryNotify.h>
-#include <AknSignalNotify.h>
-#include <AknGlobalNote.h>
-#include <AknGlobalListQuery.h>
-#include <aknsoundsystem.h>
-#include <apgcli.h>
-
+#include <startupdomainpskeys.h>
+#include "sysapappui.h"
+#include "coreapplicationuisprivatepskeys.h"
+#include <HbDeviceMessageBoxSymbian.h>
+//#include <hbdevicepowermenusymbian.h>
+#include <sacls.h>
+#include <featmgr.h>
+#include <DevEncProtectedPSKey.h>
+#include <ctsydomainpskeys.h>
+#include <secuisystemlock.h>
+#include <apgtask.h>
 #include <hwrmpowerstatesdkpskeys.h>
-#include <hwrmdomainpskeys.h>
-
-#include <PSVariables.h>
-#include "coreapplicationuisprivatepskeys.h"
-#include <ctsydomainpskeys.h>
-#include <startupdomainpskeys.h>
-#include <startupdomaincrkeys.h>
+#include <wlaninternalpskeys.h> 
+#include <HbDeviceNotificationDialogSymbian.h>
+//#include <HbDeviceInputDialogSymbian.h>
+#include <hbsymbianvariant.h>
+//#include <hbtextresolversymbian.h>
+#include <UikonInternalPSKeys.h>
 
-#ifndef SYMBIAN_ENABLE_SPLIT_HEADERS
-  #include <ASShdAlarm.h>
-#else
-  #include <asshddefs.h>
-  #include <ASShdAlarmCal.h>
-  #include <asshdalarm.h>
-#endif //SYMBIAN_ENABLE_SPLIT_HEADERS
-
-#include <MProfileEngine.h>
-#include <MProfileName.h>
-#include <MProfilesNamesArray.h>
-#include <MProfile.h>
-#include <StringLoader.h>
-#include <secuisystemlock.h>
-#include <secui.h>
-#include <settingsinternalcrkeys.h>
-
-#include <AknNotifierController.h>
-#include <eikappui.h>
-#include <es_enum.h>
-#include <data_caging_path_literals.hrh>
-#include <eikon.hrh>
-
-#include "SysApSimChanged.h"
-
-#include <SysAp.rsg>
-#include "SysApLightsController.h"
-
+//#include "SysApWsClient.h"
+#include "SysApFeatureManager.h"
+#include "SysApNspsHandler.h"
 #include "SysApPubSubObserver.h"
-#include "SysApProfileObserver.h"
-
+#include "sysapdefaultkeyhandler.h"
+#include "SysApStartupController.h"
+#include "MSysApOfflineModeController.h"
+#include "SysApCenRepController.h"
 #include "sysapcenreplightsettingsobserver.h"
 #include "SysApCenRepLogsObserver.h"
 #include "SysApCenRepBTObserver.h"
 #include "SysApCenRepHacSettingObserver.h"
-#include "SysApCenRepController.h"
-#include "coreapplicationuisprivatecrkeys.h"
-#include "coreapplicationuisprivatepskeys.h"
-#include <UikonInternalPSKeys.h>
-
-#include "SysApStartupController.h"
-#include "SysApConnectionMonitorObserver.h"
-#include "SysApPowerKeyMenuObserver.h"
-#include "SysApSsSettingsObserver.h"
-#include "SysApAppUi.h"
+#include "sysapaudioroutingobserver.h"
+#include "sysapbatteryinfocontroller.h"
+#include "SysApSimChanged.h"
+#include "MSysApBtSapController.h"
+#include "MSysApBtController.h"
+#include "MSysApUsbIndicator.h"
+//#include <hbindicatorsymbian.h>
+//#include <psmclient.h>
+//#include <psmsettings.h>
+#include "sysapkeymanagement.h"
 #include "SysApShutdownImage.h"
-#include "SysApEtelConnector.h"
-
-#include "SysApApp.h"
-#include "SysApMsgSimMemLowQuery.h"
-#include "SysApNspsHandler.h"
-#include "SysApWaitNote.h"
-#include "SysApConfirmationQuery.h"
-#include "SysApFeatureManager.h"
-#include "SysApSubscriber.h"
-#include "MSysApOfflineModeController.h"
-#include "MSysApBtController.h"
-#include "MSysApBtSapController.h"
-#include "MSysApLocationPrivacyIndicator.h"
-#include "MSysApUsbIndicator.h"
-
-#include <sysap.mbg>
-
-#include "SysApShutdownAnimation.h"
-
-//#include <hwrmfmtx.h>
-//#include <hwrmfmtxdomainpskeys.h>
-//#include <hwrmfmtxdomaincrkeys.h>
-//#include "sysapcenrepfmtxobserver.h"
-
 #include "SysApKeySndHandler.h"
 
-#include <ir_sock.h> // KIrdaPropertyCategory // KIrdaStatus
-
-#include <networkhandlingdomainpskeys.h>
-
-// POC launching
-#include <AiwServiceHandler.h>
-#include <AiwPoCParameters.h>
-
-#include <sacls.h>  // KUidPhonePwr
-
-#include <wlaninternalpskeys.h>  // WLan indicator
-
-#include <ecom/ecom.h>
-#include "sysapkeymanagement.h"
-
-#include "SysApMediatorObserver.h"
-
-#include <SecondaryDisplay/SecondaryDisplaySysApAPI.h>
-#include "aknSDData.h"
-
-#include <AknTaskList.h>
-#include <layoutmetadata.cdl.h>
-
-#include "sysapdefaultkeyhandler.h"
-#include "sysapaudioroutingobserver.h"
-#include "sysapcenrepcallforwardingobserver.h"
-#include "sysapcenrepmsgwaitingobserver.h"
-
-#ifdef RD_MULTIPLE_DRIVE
- #include "sysapdrivelist.h"
- #include "sysapdriveunlockhandler.h"
- #include "sysapdriveejecthandler.h"
-#endif // RD_MULTIPLE_DRIVE
+#include <settingsinternalcrkeys.h>
+#include <keyguardaccessapi.h>
+#include <eikdef.h>
+#include <eikenv.h>
 
-#include "sysappsmcontroller.h"
-#include "sysapbatteryinfocontroller.h"
-
-#include <keylockpolicyapi.h>
-
-#include <UsbWatcherInternalPSKeys.h> // USB transfer modes
-#include <usbpersonalityids.h>
-#include <smsuaddr.h>
-#include <featmgr.h>
-#include <DevEncProtectedPSKey.h>
-
-// CONSTANTS
-const TInt KPowerKeyMenuSelectionCancelled( -1 );
-const TInt KPowerKeyMenuSelectionSwitchOff( 0 );
+class CHbSymbianVariant;
 const TInt KModifierMask( 0 );
-const TInt KDelayBeforeShuttingDownInAlarmAndChargingStates( 500000 );
-const TInt KDelayBeforeShowingGprsSuspendedNote( 500000 );
-const TInt KDelayBeforeNextScanningRound( 1000000 );
-const TInt KActiveProfile( 0 ); //The value of ActiveProfile for accessory default profile selection in GS/SD.
-const TInt KProfileListInitialIndex( 0 );
-const TInt KMaxProfileNameLength( 64 );
-const TInt KTimeToShowShutdownNote( 2000000 ); //2 seconds time for Goodbye note to show before being shutdown
-#ifndef RD_STARTUP_ANIMATION_CUSTOMIZATION
-const TInt KCoefficientToMakeMicroToMilliSeconds = 1000;
-#endif // RD_STARTUP_ANIMATION_CUSTOMIZATION
-
-/* ENABLE ANIMATION: Add id of background image.
-   Example: const TInt KBackgroundImageID = EMbmSysapQgn_graf_startup_bg;
-   If there is no image defined, clear screen is used.*/
-const TInt KBackgroundImageID = 0;
-#ifndef RD_MULTIPLE_DRIVE
-const TInt32 KAutolockAppUid = 0x100059B5;
-const TInt KFileManagerAppUid = 0x101F84EB;
-#endif // RD_MULTIPLE_DRIVE
-const TInt KCoefficientKhzToMhz = 1000;
-const TInt KDecimalsInMhzFrequency = 2;
-
 _LIT_SECURITY_POLICY_PASS(KAlwaysPassPolicy);
 _LIT_SECURITY_POLICY_C1(KWriteDeviceDataPolicy, ECapabilityWriteDeviceData);
+const TInt KDelayBeforeNextScanningRound( 1000000 );
+/*
+_LIT(KPsmPlugin,"com.nokia.hb.powersavemodeplugin/1.0");
+_LIT(KPsm,"PSM");
+_LIT(KCharging,"Charging");
+_LIT(KPsmlocalisationfile, "powermanagement_");
+_LIT(KtsfilePath, "z:/resource/qt/translations/");
+_LIT(KlowbatteryIcon,"qtg_small_bt_low_battery.svg");
+_LIT(KbatteryFullIcon,"qtg_status_battery.svg");
+
+*/
 
 // ============================ MEMBER FUNCTIONS ==============================
 
@@ -193,61 +87,25 @@
 // CSysApAppUi::CSysApAppUi()
 // ----------------------------------------------------------------------------
 
-CSysApAppUi::CSysApAppUi() :
-    iSysApCenRepLogsObserver( NULL ),
-    iSysApCenRepHacSettingObserver( NULL ),
-    iSysApPowerKeyMenuObserver( NULL ),
-    iSysApShutdownImage( NULL ),
-    iSysApConfirmationQuery( NULL ),
-    iSysApConfirmationQueryForRestart( NULL ),
-    iSignalNotify( NULL ),
-#ifndef RD_MULTIPLE_DRIVE
-    iMemoryCardDialog( 0 ),
-#endif // RD_MULTIPLE_DRIVE
-    iProfileNote( NULL ),
-    iProfileNoteId( 0 ),
-    iPowerKeyPopupMenuActive( EFalse ),
-    iDisablePowerkeyMenu( EFalse ),
-    iDeviceLockEnabled( EFalse ),
-    iKeyLockEnabled( EFalse ),
-    iShowkeypadActivatedNoteAfterSoftReject( EFalse ),
-    iEmergencyCallActive( EFalse ),
-    iSimChangedDone( EFalse ),
-    iResourcesFreed( EFalse ),
-#ifndef RD_MULTIPLE_DRIVE
-    iHideFirstBeep( ETrue ),
-#endif // RD_MULTIPLE_DRIVE
-    iShutdownStarted( EFalse ),
-    iIgnoreAccessorySpecificProfileChanges( ETrue ),
-    iAccessoryJustConnected( EFalse ),
-    iHandleNextProfileEvent( ETrue ),
-    iActivateBt( EFalse ),
-    iDeactivateBt( EFalse ),
-    iGprsActivated( EFalse ),
-    iGprsSuspended( EFalse ),
-    iCallActivated( EFalse ),
-    iGprsSuspendedNoteShown( EFalse ),
-    iMMCEjectUsed( EFalse ),
-#ifndef RD_MULTIPLE_DRIVE
-    iMMCPowerMenuEjectUsed( EFalse ),
-    iMMCInserted( EFalse ),
-#endif // RD_MULTIPLE_DRIVE
-    iTimer( NULL ),
-    iSapTimer( NULL ),
-#ifndef RD_STARTUP_ANIMATION_CUSTOMIZATION
-    iAnimTimer( NULL ),
-#endif // RD_STARTUP_ANIMATION_CUSTOMIZATION
-    iSysApTimer( NULL ),
-#ifndef RD_STARTUP_ANIMATION_CUSTOMIZATION
-    iAnimationShowingTime( 0 ),
-#endif // RD_STARTUP_ANIMATION_CUSTOMIZATION
-    iShutdownContinued( EFalse ),
-    iSysApAudioRoutingObserver( NULL ),
-    iSysApCenRepCallForwardingObserver( NULL ),
-    iSysApCenRepMsgWaitingObserver( NULL ),
-	iKeyBoardRepeatCount(-1)
-    {
-    TRACES( RDebug::Print( _L("CSysApAppUi::CSysApAppUi()") ) );
+CSysApAppUi::CSysApAppUi()
+    :iSysApShutdownImage(NULL),
+     iPowerMenuDialog(NULL),
+     iDeviceLockEnabled(EFalse),
+     iKeyLockEnabled(EFalse),
+     iPowerKeyPopupMenuActive(EFalse),
+     iResourcesFreed (EFalse),
+     iShutdownStarted (EFalse),
+     iSysApAudioRoutingObserver (NULL),
+     iSysApBatteryInfoController (NULL),
+     iSysApPsmController(NULL),
+     iSapTimer (NULL),
+     iSysApCenRepLogsObserver (NULL),
+     iSysApUsbIndicatorController(NULL),
+     iKeyguardController (NULL),
+     iKeyLockOnBeforeCall (EFalse),
+     iCheckLongPowerKeyEvent (EFalse)
+	{
+	TRACES( RDebug::Print( _L("CSysApAppUi::CSysApAppUi()") ) );
     }
 
 // ----------------------------------------------------------------------------
@@ -257,61 +115,59 @@
 void CSysApAppUi::ConstructL()
     {
     TRACES( RDebug::Print( _L("CSysApAppUi::ConstructL: START") ) );
-    TRACES( RDebug::Print( _L("CSysApAppUi::ConstructL: trying BaseConstructL( EAknEnableSkin )") ) );
-    BaseConstructL( EAknEnableSkin );
+    TRACES( RDebug::Print( _L("CSysApAppUi::ConstructL: trying BaseConstructL()") ) );
+    BaseConstructL();
     TRACES( RDebug::Print( _L("CSysApAppUi::ConstructL: BaseConstructL() OK") ) );
-    
-   
 
-    /*SysAp is set as system application (Symbian terminology). This means some special privilege compared
-      to other applications. For example it does not get closed when system is asked to close applications
-    */
     iEikonEnv->SetSystem( ETrue );
 
     iEikonEnv->WsSession().ComputeMode( RWsSession::EPriorityControlDisabled );
-
-    static_cast<CAknAppUi*>(iEikonEnv->EikAppUi())->KeySounds()->PushContextL( R_AVKON_SILENT_SKEY_LIST );
-
+    
     RThread().SetProcessPriority( EPriorityForeground );
-
-    /*SysAp does not have any visible Status pane. An exception will be Charging state
-    where SysAp shows Status Pane as it is the only running application.
-    */
+    
     TInt mode;
     User::LeaveIfError( RProperty::Get( KPSUidStartup, KPSGlobalStartupMode, mode ) );
-
-    if( mode == EStartupModeCharging || mode == EStartupModeAlarm )
-        {
-        SetStatusPaneLayoutL(
-            mode == EStartupModeCharging ? ESysApCharging : ESysApAlarm );
-
-        SetKeyEventFlags(
-            CAknAppUiBase::EDisableSendKeyShort |
-            CAknAppUiBase::EDisableSendKeyLong );
-        }
-    else
-        {
-        SetStatusPaneLayoutL( ESysApNormal );
-        }
-
+    TRACES( RDebug::Print( _L("CSysApAppUi::ConstructL: KPSGlobalStartupMode = %d"), mode ) );
+    
+    //SysAp needs to capture PowerKey events because it handles all functionality related to that
+    TRACES( RDebug::Print( _L("CSysApAppUi::ConstructL: trying CEikApplication::RootWin()") ) );
+    RWindowGroup groupWin = iCoeEnv->RootWin();
+    User::LeaveIfError ( iCapturedEKeyPowerOff = groupWin.CaptureKey( EKeyPowerOff, KModifierMask, KModifierMask ) );
+    User::LeaveIfError ( iCapturedEKeyPowerOffUpAndDowns = groupWin.CaptureKeyUpAndDowns( EStdKeyDevice2, KModifierMask, KModifierMask ) );
+     
+    TRACES ( RDebug::Print( _L("CSysApAppUi::ConstructL: trying CSysApDefaultKeyHandler::NewL()") ) );
+    iSysApDefaultKeyHandler = CSysApDefaultKeyHandler::NewL(*this);
+    
+    // Define P&S keys "owned" by SysAp
+    RProperty::Define( KPSUidUikon, KUikMMCInserted, RProperty::EInt, KAlwaysPassPolicy, KWriteDeviceDataPolicy );
+    //initially assuming that the memory card is not inserted
+    RProperty::Set( KPSUidUikon, KUikMMCInserted, 0 );
+    TDriveInfo driveInfo;
+    TInt driveNumber; 
+    TInt err;    
+    RFs& fileServer = iEikonEnv->FsSession();  
+    for ( driveNumber = EDriveD; driveNumber < EDriveZ; driveNumber++ )
+         {
+      err = fileServer.Drive(driveInfo,driveNumber);
+          if(driveNumber == EDriveF && err == KErrNone && driveInfo.iType == EMediaHardDisk &&  driveInfo.iDriveAtt & KDriveAttRemovable)     
+            {     
+            TRACES( RDebug::Print( _L("CSysApAppUi::ConstructL: err = %d, driveInfo.iType = %d, driveInfo.iDriveAtt %d, KDriveAttRemovable = %d "),err,driveInfo.iType,driveInfo.iDriveAtt,KDriveAttRemovable) );     
+            RProperty::Set( KPSUidUikon, KUikMMCInserted, 1 );
+                break;  // Memory card drive found...     
+            }
+         }
+           
     TRACES( RDebug::Print( _L("CSysApAppUi::ConstructL: trying CSysApFeatureManager::NewL()") ) );
     iSysApFeatureManager = CSysApFeatureManager::NewL();
-
+    
     // Setup USB charging detector
-    iSysApUsbChargerDetector.EnableUsbCharging(
-        iSysApFeatureManager->Supported( KSysApFeatureIdChargerReminderNotes ) &&
-        iSysApFeatureManager->Supported( KSysApFeatureIdUsbChargingWithoutReminderNotes ) );
-
-    // Construct notifiers that are used frequently or in OOM situations.
-    TRACES( RDebug::Print( _L("CSysApAppUi::ConstructL: trying CAknBatteryNotify::NewL()") ) );
-    iBatteryNotify = CAknBatteryNotify::NewL();
-    TRACES( RDebug::Print( _L("CSysApAppUi::ConstructL: trying CAknSignalNotify::NewL()") ) );
-    iSignalNotify = CAknSignalNotify::NewL();
-    TRACES( RDebug::Print( _L("CSysApAppUi::ConstructL: trying new ( ELeave ) CSysApMsgSimMemLowQuery") ) );
-    iSysApMsgSimMemLowQuery = new( ELeave ) CSysApMsgSimMemLowQuery( iSysApFeatureManager->CoverDisplaySupported() );
-
+     iSysApUsbChargerDetector.EnableUsbCharging(
+         iSysApFeatureManager->Supported( KSysApFeatureIdChargerReminderNotes ) &&
+         iSysApFeatureManager->Supported( KSysApFeatureIdUsbChargingWithoutReminderNotes ) );
+    
     TRACES( RDebug::Print( _L("CSysApAppUi::ConstructL: trying CSysApPubSubObserver::NewL()") ) );
     iSysApPubSubObserver = CSysApPubSubObserver::NewL( *this );
+
     RProperty::Define( KPSUidCoreApplicationUIs, KCoreAppUIsPoCIndicator, RProperty::EInt, KAlwaysPassPolicy, KWriteDeviceDataPolicy );
     RProperty::Set( KPSUidCoreApplicationUIs, KCoreAppUIsPoCIndicator, ECoreAppUIsPocIndicatorUninitialized );
     RProperty::Define( KPSUidCoreApplicationUIs, KCoreAppUIsPoCMissedIndicator, RProperty::EInt, KAlwaysPassPolicy, KWriteDeviceDataPolicy );
@@ -324,43 +180,6 @@
     RProperty::Define( KPSUidCoreApplicationUIs, KCoreAppUIsVideoSharingIndicator, RProperty::EInt, KAlwaysPassPolicy, KWriteDeviceDataPolicy );
     RProperty::Set( KPSUidCoreApplicationUIs, KCoreAppUIsVideoSharingIndicator, ECoreAppUIsVideoSharingIndicatorUninitialized );
 
-    TRACES( RDebug::Print( _L("CSysApAppUi::ConstructL: trying CSysApAccessoryObserver::NewL()") ) );
-    iSysApAccessoryObserver = CSysApAccessoryObserver::NewL( *this );
-
-    TRACES( RDebug::Print( _L("CSysApAppUi::ConstructL: trying CSysApCenRepController::NewL()") ) );
-    iSysApCenRepController = CSysApCenRepController::NewL();
-
-    TRACES( RDebug::Print( _L("CSysApAppUi::ConstructL: trying CSysApCenRepLightSettingsObserver::NewL") ) );
-    iSysApCenRepLightSettingsObserver = CSysApCenRepLightSettingsObserver::NewL( *this );
-
-    TRACES( RDebug::Print( _L("CSysApAppUi::ConstructL: trying CSysApCenRepBtObserver::NewL") ) );
-    iSysApCenRepBtObserver = CSysApCenRepBtObserver::NewL( *this );
-
-/*    if ( iSysApFeatureManager->FmTxSupported() )
-        {
-        TRACES( RDebug::Print( _L("CSysApAppUi::ConstructL: trying CSysApCenRepFmTxObserver::NewL") ) );        
-        iSysApCenRepFmTxObserver = CSysApCenRepFmTxObserver::NewL( *this );    
-        }
-*/
-    // Define P&S keys "owned" by SysAp
-    RProperty::Define( KPSUidUikon, KUikMMCInserted, RProperty::EInt, KAlwaysPassPolicy, KWriteDeviceDataPolicy );
-    //initially assuming that the memory card is not inserted
-    RProperty::Set( KPSUidUikon, KUikMMCInserted, 0 );
-    TDriveInfo driveInfo;
-    TInt driveNumber; 
-    TInt err;    
-    RFs& fileServer = iEikonEnv->FsSession();  
-    for ( driveNumber = EDriveD; driveNumber < EDriveZ; driveNumber++ )
-         {
-	  err = fileServer.Drive(driveInfo,driveNumber);
-          if(driveNumber == EDriveF && err == KErrNone && driveInfo.iType == EMediaHardDisk &&  driveInfo.iDriveAtt & KDriveAttRemovable)     
-        	{     
-        	TRACES( RDebug::Print( _L("CSysApAppUi::ConstructL: err = %d, driveInfo.iType = %d, driveInfo.iDriveAtt %d, KDriveAttRemovable = %d "),err,driveInfo.iType,driveInfo.iDriveAtt,KDriveAttRemovable) );     
-        	RProperty::Set( KPSUidUikon, KUikMMCInserted, 1 );
-                break;  // Memory card drive found...     
-      		}
-         } 
-
     RProperty::Define( KPSUidCoreApplicationUIs, KCoreAppUIsHideAlarm, RProperty::EInt, KAlwaysPassPolicy, KWriteDeviceDataPolicy );
     RProperty::Define( KPSUidCoreApplicationUIs, KCoreAppUIsDisableKeyguard, RProperty::EInt, KAlwaysPassPolicy, KWriteDeviceDataPolicy );
     RProperty::Define( KPSUidCoreApplicationUIs, KCoreAppUIsSoftReject, RProperty::EInt, KAlwaysPassPolicy, KWriteDeviceDataPolicy );
@@ -381,717 +200,763 @@
 
     // Initialize P&S keys "owned" by SysAp
     RProperty::Set( KPSUidCoreApplicationUIs, KCoreAppUIsHideAlarm, ECoreAppUIsHideAlarmUninitialized );
-
+    
+    TRACES( RDebug::Print( _L("CSysApAppUi::ConstructL: trying CSysApAccessoryObserver::NewL()") ) );
+    iSysApAccessoryObserver = CSysApAccessoryObserver::NewL( *this );
+    
+    TRACES( RDebug::Print( _L("CSysApAppUi::ConstructL: trying CSysApCenRepController::NewL()") ) );
+    iSysApCenRepController = CSysApCenRepController::NewL();
+    
+    TRACES( RDebug::Print( _L("CSysApAppUi::ConstructL: trying CSysApCenRepLightSettingsObserver::NewL") ) );
+    iSysApCenRepLightSettingsObserver = CSysApCenRepLightSettingsObserver::NewL( *this );
+    
+    TRACES( RDebug::Print( _L("CSysApAppUi::ConstructL: trying CSysApCenRepBtObserver::NewL") ) );
+    iSysApCenRepBtObserver = CSysApCenRepBtObserver::NewL( *this );
+    
     TRACES( RDebug::Print( _L("CSysApAppUi::ConstructL: trying CSysApStartupController::NewL()") ) );
     iSysApStartupController = CSysApStartupController::NewL( *this, iSysApFeatureManager->OfflineModeSupported() );
 
+    iActiveProfileBeforeOfflineMode = iSysApCenRepController->GetInt( KCRUidCoreApplicationUIsSysAp, KSysApProfileBeforeOfflineMode );    
+           
+    iSysApFeatureManager->FeatureVariationCheckDone();        
+    // iHbIndicatorSymbian = CHbIndicatorSymbian::NewL();
+    
     TRACES( RDebug::Print( _L("CSysApAppUi::ConstructL: trying CSysApLightsController::NewL()") ) );
     iSysApLightsController = CSysApLightsController::NewL( *this,
                                                            iSysApCenRepLightSettingsObserver->GetLightsTimeout(),
                                                            iSysApFeatureManager->CoverDisplaySupported() );
-
-    TRACES( RDebug::Print( _L("CSysApAppUi::ConstructL: trying CSysApEtelConnector::NewL()") ) );
-    iSysApEtelConnector = CSysApEtelConnector::NewL( *this );
-
-    //SysAp needs to capture PowerKey events because it handles all functionality related to that
-    TRACES( RDebug::Print( _L("CSysApAppUi::ConstructL: trying CEikApplication::RootWin()") ) );
-    RWindowGroup groupWin = iCoeEnv->RootWin();
-    User::LeaveIfError ( iCapturedEKeyPowerOff = groupWin.CaptureKey( EKeyPowerOff, KModifierMask, KModifierMask ) );
-    User::LeaveIfError ( iCapturedEKeyPowerOffUpAndDowns = groupWin.CaptureKeyUpAndDowns( EStdKeyDevice2, KModifierMask, KModifierMask ) );
-
-    TRACES ( RDebug::Print( _L("CSysApAppUi::ConstructL: trying CSysApDefaultKeyHandler::NewL()") ) );
-    iSysApDefaultKeyHandler = CSysApDefaultKeyHandler::NewL( *this );
-
-
-    if ( iSysApFeatureManager->GripNotSupported() )
-        {
-        RProperty::Set( KPSUidHWRM, KHWRMGripStatus, EPSHWRMGripOpen );
-        }
-
-#ifndef RD_MULTIPLE_DRIVE
-    if ( iSysApFeatureManager->MmcSupported() )
-        {
-        iSysApMMCObserver = CSysApMMCObserver::NewL( this, &iEikonEnv->FsSession(), iSysApFeatureManager->MmcHotSwapSupported() );
-        }
-#else // RD_MULTIPLE_DRIVE
-    iSysApDriveList = CSysApDriveList::NewL( iEikonEnv->FsSession() );
-    if ( iSysApFeatureManager->MmcSupported() )
-        {
-        iSysApMMCObserver = CSysApMMCObserver::NewL(
-            iEikonEnv->FsSession(), *iSysApDriveList, *this, iSysApFeatureManager->MmcHotSwapSupported() );
-        iSysApDriveUnlockHandler = CSysApDriveUnlockHandler::NewL(
-            *iSysApDriveList, *this, iSysApFeatureManager->MemoryCardLockSupported() );
-        iSysApDriveEjectHandler = CSysApDriveEjectHandler::NewL(
-            *iSysApDriveList, *this, iEikonEnv->FsSession() );
-        }
-#endif // RD_MULTIPLE_DRIVE
-
+            
+    TRACES( RDebug::Print( _L("CSysApAppUi::ConstructL : trying CreateSysApOfflineModeControllerL()") ) );
+    iSysApOfflineModeController = CreateSysApOfflineModeControllerL( *this );
+    
+    TRACES( RDebug::Print( _L("CSysApAppUi::ConstructL : trying DoInitialSwStateCheckL()") ) );
+    iSysApStartupController->DoInitialSwStateCheckL();
+    
+    TRACES( RDebug::Print( _L("CCSysApAppUi::ConstructL  trying CSysApCenRepHacSettingObserver::NewL") ) );
+    iSysApCenRepHacSettingObserver = CSysApCenRepHacSettingObserver::NewL( *this ); 
+    
     //Instantiate the KEF plugin manager
-	//Trap constuction, since Sysap may live without iSysApKeyManagement
+    //Trap constuction, since Sysap may live without iSysApKeyManagement
     TRAPD(keyManagementErr, iSysApKeyManagement=CSysApKeyManagement::NewL(CCoeEnv::Static()->RootWin(), *this));
 
     if (keyManagementErr)
-    	{
-    	TRACES( RDebug::Print( _L("CSysApAppUi::ConstructL : CSysApKeyManagement::NewL returns error=%d"), keyManagementErr ) );
-    	}
-
-    iSysApFeatureManager->FeatureVariationCheckDone();
-
-    TRACES( RDebug::Print( _L("CSysApAppUi::ConstructL: trying CSysApProfileObserver::NewL()") ) );
-    iSysApProfileObserver = CSysApProfileObserver::NewL( *this );
-
-    TRACES( RDebug::Print( _L("CSysApAppUi::ConstructL : trying MProfileEngine* CreateProfileEngineL()") ) );
-    iProfileEngine = CreateProfileEngineL( &( iEikonEnv->FsSession() ) );
-
-    TRACES( RDebug::Print( _L("CSysApAppUi::ConstructL : trying CreateSysApOfflineModeControllerL()") ) );
-    iSysApOfflineModeController = CreateSysApOfflineModeControllerL( *this );
-
-    TRACES( RDebug::Print( _L("CSysApAppUi::ConstructL : trying DoInitialSwStateCheckL()") ) );
-    iSysApStartupController->DoInitialSwStateCheckL();
-
-    iActiveProfileBeforeOfflineMode = iSysApCenRepController->GetInt( KCRUidCoreApplicationUIsSysAp, KSysApProfileBeforeOfflineMode );
-
+        {
+        TRACES( RDebug::Print( _L("CSysApAppUi::ConstructL : CSysApKeyManagement::NewL returns error=%d"), keyManagementErr ) );
+        }
+    
     // Initialize animdll for handling side volume keys
     // (needed before normal mode in case emergency number is dialed from PIN query)
     iSysApKeySndHandler = CSysApKeySndHandler::NewL(iEikonEnv->WsSession());
-
-    // Initialize shutdown image (needed by nspshandler)
+    iKeyguardController = CKeyguardAccessApi::NewL();
     TRACES( RDebug::Print( _L("CSysApAppUi::ConstructL: trying CSysApShutdownImage::NewL()") ) );
-    iSysApShutdownImage = CSysApShutdownImage::NewL();
-
+    iSysApShutdownImage = CSysApShutdownImage::NewL();//NULL; //
+    
     // Initialize nsps handler. Needed for proper lights control during PIN query.
     TRACES( RDebug::Print( _L("CSysApAppUi::ConstructL: trying CSysApNspsHandler::NewL") ) );
     iSysApNspsHandler = CSysApNspsHandler::NewL( iEikonEnv->WsSession(), iSysApShutdownImage->ShutdownCoeControlWindow() );
 
-#ifdef RD_LIGHT_CONTROL_CHANGE
-    // NSPS Plugin has been loaded, inform lights controller that in can activate key event forwarding
-    iSysApLightsController->KeyEventForwardingReady();
-#endif // RD_LIGHT_CONTROL_CHANGE    
+    RProperty::Define( KPSUidCoreApplicationUIs,KCoreAppUIsPowerMenuCustomDialogStatus, RProperty::EInt, KAlwaysPassPolicy, KWriteDeviceDataPolicy );
+    RProperty::Set( KPSUidCoreApplicationUIs, KCoreAppUIsPowerMenuCustomDialogStatus, ECoreAppUIsPowerMenuCustomDialogUninitialized );
+    
+
+                    
+    // TBool result = HbTextResolverSymbian::Init(KPsmlocalisationfile, KtsfilePath);
+    
+    TRACES( RDebug::Print( _L("CSysApAppUi::ConstructL: END") ) );    
+    }
+
+// ----------------------------------------------------------------------------
+// CSysApAppUi::FreeResources()
+// ----------------------------------------------------------------------------
+
+void CSysApAppUi::FreeResources()
+    {
+    TRACES( RDebug::Print( _L("CSysApAppUi::FreeResources") ) );
+    delete iSysApBatteryInfoController;
+    delete iSysApPsmController;
+    //delete iVariantAccState; 
+
+    delete iSysApAudioRoutingObserver;
+
+    if ( iSapTimer )
+        {
+        iSapTimer->Cancel();
+        delete iSapTimer;
+        }
+    //Powermenu
+    if (iPowerMenuDialog!=NULL)
+        {
+        //PowerMenu already exist
+        delete iPowerMenuDialog;
+        iPowerMenuDialog = NULL;
+        }
+    
+    RWindowGroup groupWin = iCoeEnv->RootWin();
+    groupWin.CancelCaptureKey( iCapturedEKeyPowerOff );
+    groupWin.CancelCaptureKeyUpAndDowns( iCapturedEKeyPowerOffUpAndDowns );
+    
+    delete iSysApDefaultKeyHandler;
+    delete iSysApCenRepLightSettingsObserver;
+    delete iSysApCenRepBtObserver;
+    delete iSysApCenRepHacSettingObserver;
+    delete iSysApCenRepController;
 
-    // Create HAC setting observer now because telephony state may change before entering to normal state
-    TRACES( RDebug::Print( _L("CCSysApAppUi::ConstructL  trying CSysApCenRepHacSettingObserver::NewL") ) );
-    iSysApCenRepHacSettingObserver = CSysApCenRepHacSettingObserver::NewL( *this );
+    delete iSysApPubSubObserver;
+    
+    delete iSysApLightsController;
+    delete iSysApFeatureManager;
+    
+    delete iSysApCenRepLogsObserver;
+    delete iSysApOfflineModeController;
+    
+    delete iSysApUsbIndicatorController;
+    delete iKeyguardController;
+    // delete iHbIndicatorSymbian; 
+    delete iSysApKeyManagement;
+    iSysApKeyManagement = NULL;
+    
+    REComSession::FinalClose();
+    iResourcesFreed = ETrue;
+    TRACES( RDebug::Print( _L("CSysApAppUi::FreeResources:END") ) );
+    }
+
+// ---------------------------------------------------------------------------
+// CStartupAppUi::PrepareToExit()
+// ---------------------------------------------------------------------------
+void CSysApAppUi::PrepareToExit()
+    {
+    TRACES("CSysApAppUi::PrepareToExit()");
+    CEikAppUi::PrepareToExit();
+    }
+
 
-    TRACES( RDebug::Print( _L("CSysApAppUi::ConstructL: END") ) );
+// ----------------------------------------------------------------------------
+// CSysApAppUi::StateOfProperty()
+// ----------------------------------------------------------------------------
+TInt CSysApAppUi::StateOfProperty( const TUid& aCategory, const TUint aKey ) const
+    {
+    TInt err( KErrNone );
+    TInt value( 0 );
+    err = RProperty::Get( aCategory, aKey, value );
+    if ( err )
+        {
+        TRACES( RDebug::Print( _L("CSysApAppUi::StateOfProperty. RProperty::Get: err=%d"), err ) );
+        return err;
+        }
+    return value;
+    }
+
+// ----------------------------------------------------------------------------
+// CSysApAppUi::OfflineModeActive()
+// ----------------------------------------------------------------------------
+TBool CSysApAppUi::OfflineModeActive()
+    {
+    if(iSysApOfflineModeController)
+        {
+        return iSysApOfflineModeController->OfflineModeActive();
+        }
+    else
+        {
+        return EFalse;
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// CSysApAppUi::GoOnlineL()
+// ----------------------------------------------------------------------------
+
+void CSysApAppUi::GoOnlineL( TBool /* aDoProfileChange */ )
+    {
+    if ( iSysApFeatureManager->OfflineModeSupported() )
+        {
+//        TRACES( RDebug::Print( _L("CSysApAppUi::GoOnlineL: going from off-line into on-line: aDoProfileChange=%d" ), aDoProfileChange ) );
+        iActivateBt = iSysApOfflineModeController->MustBtBeActivated();
+        iSysApOfflineModeController->SwitchFromOfflineToOnlineModeL();
+        TRACES( RDebug::Print( _L("CSysApAppUi::GoOnlineL: iActivateBt = %d" ), iActivateBt ) );
+        }
     }
 
 // ----------------------------------------------------------------------------
-// CSysApAppUi::~CSysApAppUi()
+// CSysApAppUi::GoOfflineL()
+// ----------------------------------------------------------------------------
+
+void CSysApAppUi::GoOfflineL()
+    {
+    if ( iSysApFeatureManager->OfflineModeSupported() )
+        {
+        TRACES( RDebug::Print( _L("CSysApAppUi::GoOfflineL" ) ) );
+        iDeactivateBt = ETrue;
+        iSysApOfflineModeController->SwitchFromOnlineToOfflineModeL();
+        }
+    }
+
+#ifndef SYSAP_USE_STARTUP_UI_PHASE
+// need to configure the above macro.
+#else // SYSAP_USE_STARTUP_UI_PHASE
+
+// ----------------------------------------------------------------------------
+// CSysApAppUi::HandleUiReadyAfterBootL()
+// Called when startup UI activities has been finished
+// ----------------------------------------------------------------------------
+
+void CSysApAppUi::HandleUiReadyAfterBootL()
+    {
+    TRACES( RDebug::Print(_L("CSysApAppUi::HandleUiReadyAfterBootL" ) ) );    
+    TInt state( StateOfProperty( KPSUidHWRMPowerState, KHWRMBatteryLevel ) );
+
+    UpdateBatteryBarsL( state );   
+    DoSwStateNormalConstructionL();
+    HandleAccessoryProfileInStartupL();       
+   
+    if ( !iSysApPsmController ) // created here if first state change has not occurred yet
+       {
+       iSysApPsmController = CSysApPsmController::NewL( *this );        
+       }
+
+    if ( iSysApPsmController )
+       {
+        if ( iCharging ) // if charger is connected on boot PSM queries may need to be shown
+        {
+         HandleChargingStatusL( StateOfProperty( KPSUidHWRMPowerState, KHWRMChargingStatus ) );
+        }
+       }
+    
+    TInt batteryStatus = StateOfProperty( KPSUidHWRMPowerState, KHWRMBatteryStatus );
+    TRACES( RDebug::Print(_L("CSysApAppUi::HandleUiReadyAfterBootL: batteryStatus %d" ), batteryStatus ) );
+    if(  batteryStatus == EBatteryStatusLow || batteryStatus == EBatteryStatusEmpty )
+        {
+        // low and empty battery states are informed to the user in device startup
+        HandleBatteryStatusL( batteryStatus );
+        }
+    else if ( iSysApPsmController && !iCharging )
+        {
+            TRACES( RDebug::Print(_L("CSysApAppUi::HandleUiReadyAfterBootL: batteryStatus %d, iCharging %d -> disable partial psm" ), batteryStatus, iCharging ) );
+
+            iSysApPsmController->BatteryLow( EFalse );
+            iSysApPsmController->DoEnablePartialPsm( EFalse );
+        }
+    
+    if ( ! iSysApUsbIndicatorController )
+        {
+        TRAPD ( usbErr, iSysApUsbIndicatorController = CreateSysApUsbIndicatorL( *this ) );
+        if ( usbErr )
+            {
+            TRACES( RDebug::Print(_L("CSysApAppUi::HandleUiReadyAfterBootL: error in constructing USB ind. controller %d" ), usbErr ) );
+            }
+        }
+   }
+
+// ----------------------------------------------------------------------------
+// CSysApAppUi::DoStateChangedL(const RStarterSession::TGlobalState aSwState)
+// This method is not called after boot has finished.
 // ----------------------------------------------------------------------------
 
+void CSysApAppUi::DoStateChangedL(const RStarterSession::TGlobalState aSwState)
+    {
+    TRACES( RDebug::Print(_L("CSysApAppUi::DoStateChangedL: %d" ), aSwState ) );
+
+    TRAPD( simChangedErr, DoSimChangedFromPreviousBootL() );
+    TRACES( RDebug::Print( _L("CSysApAppUi::DoStateChangedL: simChangedErr = %d" ), simChangedErr ) );
+    simChangedErr = simChangedErr; // suppress 'variable not used' warning
+    LogsObserverL().HandleSimChangedCheckDoneL();
+
+    if ( iSysApFeatureManager->PowerSaveSupported() )
+        {
+        // create controller before checking battery state, so that power saving can be enabled during boot if needed
+        if ( !iSysApPsmController ) // created only in first state change
+            {
+            iSysApPsmController = CSysApPsmController::NewL( *this );        
+            }
+
+        // in charger boot explicitly disable  power save mode
+        if ( aSwState == RStarterSession::ECharging )
+            {
+            iSysApPsmController->ChargerConnected();
+            iSysApPsmController->DoEnablePartialPsm( EFalse ); // disable  power save now
+            }
+        }
+
+    if ( aSwState == RStarterSession::ECharging || aSwState == RStarterSession::EAlarm )
+        {
+        TInt state( StateOfProperty( KPSUidHWRMPowerState, KHWRMBatteryLevel ) );
+        //Also Charging status will be updated with the following function.
+        UpdateBatteryBarsL( state );    
+        }
+        
+    if( IsStateNormal() )
+        {
+        TRACES( RDebug::Print(_L("CSysApAppUi::DoStateChangedL to normal state.") ) );
+
+        iSysApBtController = CreateSysApBtControllerL( *this );
+        iSysApBtSapController = CreateSysApBtSapControllerL( *this );
+
+        if ( iActivateBt )
+            {
+            TRACES( RDebug::Print(_L("CSysApAppUi::DoStateChangedL Activating BT" ) ) );
+            SetBtPowerState( ETrue );
+            }
+
+        if ( iDeactivateBt )
+            {
+            TRACES( RDebug::Print(_L("CSysApAppUi::DoStateChangedL Deactivating BT" ) ) );
+            SetBtPowerState( EFalse );
+            }
+
+        if ( !StarterSession().Handle() )
+            {
+            User::Leave( KErrBadHandle );
+            }
+
+/*        if ( !KeyLock().Handle() )
+            {
+            User::Leave( KErrBadHandle );
+            }
+*/
+#ifdef __SYSAP_MODULE_TEST
+        ModuleTestShowUiNoteL( _L("SysAp: SW state normal!") );
+#endif
+        }
+
+    // Allow lights
+    iSysApLightsController->AllowLightsOn();
+    }
+
+#endif // SYSAP_USE_STARTUP_UI_PHASE
+
 CSysApAppUi::~CSysApAppUi()
     {
     TRACES( RDebug::Print( _L("~CSysApAppUi() started") ) );
     if( !iResourcesFreed )
-        {
+      {
         FreeResources();
-
-        iStarterSession.Close();
-
-        }
-
-    delete iSysApShutdownImage;
-
-#ifndef RD_STARTUP_ANIMATION_CUSTOMIZATION
-    if (iSysApShutdownAnimation)
-        {
-        RemoveFromStack( iSysApShutdownAnimation );
-#endif // RD_STARTUP_ANIMATION_CUSTOMIZATION
-        delete iSysApShutdownAnimation;
-#ifndef RD_STARTUP_ANIMATION_CUSTOMIZATION
-        }
-#endif // RD_STARTUP_ANIMATION_CUSTOMIZATION
-
-    delete iProfileNote;
-
-#ifndef RD_STARTUP_ANIMATION_CUSTOMIZATION
-    if( iAnimTimer )
-        {
-        iAnimTimer->Cancel();
-        }
-    delete iAnimTimer;
-#endif // RD_STARTUP_ANIMATION_CUSTOMIZATION
-
-    delete iSysApPowerKeyMenuObserver;
-
+      }
     delete iSysApStartupController;
-
-#ifdef RD_MULTIPLE_DRIVE
-    iInsertedMemoryCards.Close();
-    delete  iSysApDriveEjectHandler;
-    delete iSysApDriveUnlockHandler;
-    delete iSysApDriveList;
-#endif // RD_MULTIPLE_DRIVE
-
-    TRACES( RDebug::Print( _L("~CSysApAppUi() completed") ) );
+    }
+        
+TBool CSysApAppUi::ResourcesFreed() const
+    {
+    return iResourcesFreed;
     }
 
-
-// ----------------------------------------------------------------------------
-// CSysApAppUi::HandleLocationPrivacyIndicatorL()
-// ----------------------------------------------------------------------------
-
-void CSysApAppUi::HandleLocationPrivacyIndicatorL( const TInt aState )
-    {
-    TRACES( RDebug::Print( _L("CSysApAppUi::HandleLocationPrivacyIndicatorL() state=%d"), aState ) );
-    if ( iSysApFeatureManager->LocationPrivacySupported() )
-        {
-        // Phase 1. Set all Location Privacy indicators off
-        if ( iSysApLocationPrivacyIndicator->iIndicatorIdAcceptAll != KSysApNoIndicator )
-            {
-            SetIndicatorStateL( iSysApLocationPrivacyIndicator->iIndicatorIdRejectAll, EAknIndicatorStateOff );
-            }
-        if ( iSysApLocationPrivacyIndicator->iIndicatorIdRejectAll != KSysApNoIndicator )
-            {
-            SetIndicatorStateL( iSysApLocationPrivacyIndicator->iIndicatorIdRejectAll, EAknIndicatorStateOff );
-            }
-        if ( iSysApLocationPrivacyIndicator->iIndicatorIdAlwaysAsk != KSysApNoIndicator )
-            {
-            SetIndicatorStateL( iSysApLocationPrivacyIndicator->iIndicatorIdAlwaysAsk, EAknIndicatorStateOff );
-            }
-        if ( iSysApLocationPrivacyIndicator->iIndicatorIdIndividualPrivacy != KSysApNoIndicator )
-            {
-            SetIndicatorStateL( iSysApLocationPrivacyIndicator->iIndicatorIdIndividualPrivacy, EAknIndicatorStateOff );
-            }
-        // Phase 2. Set the required Location Privacy indicator on
-        switch ( aState )
-            {
-            case EPSLocPrivAcceptAll:
-                if ( iSysApLocationPrivacyIndicator->iIndicatorIdAcceptAll != KSysApNoIndicator )
-                    {
-                    SetIndicatorStateL( iSysApLocationPrivacyIndicator->iIndicatorIdAcceptAll, EAknIndicatorStateOn );
-                    }
-                break;
-            case EPSLocPrivRejectAll:
-                if ( iSysApLocationPrivacyIndicator->iIndicatorIdRejectAll != KSysApNoIndicator )
-                    {
-                    SetIndicatorStateL( iSysApLocationPrivacyIndicator->iIndicatorIdRejectAll, EAknIndicatorStateOn );
-                    }
-                break;
-            case EPSLocPrivAlwaysAsk:
-                if ( iSysApLocationPrivacyIndicator->iIndicatorIdAlwaysAsk != KSysApNoIndicator )
-                    {
-                    SetIndicatorStateL( iSysApLocationPrivacyIndicator->iIndicatorIdAlwaysAsk, EAknIndicatorStateOn );
-                    }
-                break;
-            case EPSLocPrivIndividualPrivacy:
-                if ( iSysApLocationPrivacyIndicator->iIndicatorIdIndividualPrivacy != KSysApNoIndicator )
-                    {
-                    SetIndicatorStateL( iSysApLocationPrivacyIndicator->iIndicatorIdIndividualPrivacy, EAknIndicatorStateOn );
-                    }
-                break;
-            default:
-                break;
-            }
-        }
+void CSysApAppUi::ShowExampleUiNoteL( const TDesC& noteText )const
+    {          
+    //   QString msg  = QString::fromUtf16(aStringPointer.Ptr(),aStringPointer.Length());
+ 	TRACES( RDebug::Print( _L("CSysApAppUi::ShowExampleUiNoteL:: constructing CHbDeviceMessageBoxSymbian:BeGIN") ) );    
+    CHbDeviceMessageBoxSymbian *note = CHbDeviceMessageBoxSymbian::NewL(CHbDeviceMessageBoxSymbian::EInformation);
+ 	CleanupStack::PushL(note);
+    TRACES( RDebug::Print( _L("CSysApAppUi::ShowExampleUiNoteL:: construction of CHbDeviceMessageBoxSymbian:END") ) ); 
+	//	HbMessageBox *note = new HbMessageBox (HbMessageBox ::MessageTypeInformation);
+    note->SetTextL(noteText);
+    //  note->SetTimeout(HbPopup::NoTimeout);
+	note->SetTimeout(5);
+ 	TRACES( RDebug::Print( _L("CSysApAppUi:: Display of  CHbDeviceMessageBoxSymbian::Begin") ) );    
+    note->ShowL();
+	TRACES( RDebug::Print( _L("CSysApAppUi:: Display of  CHbDeviceMessageBoxSymbian::End") ) );
+	CleanupStack::PopAndDestroy(note);
     }
 
 
-// ----------------------------------------------------------------------------
-// CSysApAppUi::HandleKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType )
-// ----------------------------------------------------------------------------
-
-TKeyResponse CSysApAppUi::HandleKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType )
+void CSysApAppUi::ExecQueryL( TSysapQuery aQuery, TDes8& aReturn )
     {
-    if ( ! iShutdownStarted )
-        {
-        TRACES( RDebug::Print( _L("CSysApAppUi::HandleKeyEventL: aKeyEvent.iCode:%d, aKeyEvent.iScanCode:%d, aType:%d, iIgnoreNextPowerKeyUpEvent:%d, iPowerKeyPopupMenuActive:%d, iLastPowerKeyWasShort:%d, iPowerKeyPopupMenuDismissed:%d"),
-                               aKeyEvent.iCode, aKeyEvent.iScanCode, aType, iIgnoreNextPowerKeyUpEvent, iPowerKeyPopupMenuActive, iLastPowerKeyWasShort, iPowerKeyPopupMenuDismissed ) );
-
-#ifdef _DEBUG
-        // camery latency measurement environment instrumentation, don't remove
-        if ( aType == EEventKey && aKeyEvent.iCode == EKeyCamera )
-            {
-            TRACES( RDebug::Print( _L("e_KEY_EVENT_SENDING 0") ) );
-            }
-#endif // _DEBUG
-
-        TKeyResponse response( EKeyWasNotConsumed );
-        if (iSysApKeyManagement && aKeyEvent.iCode != EKeyPowerOff && aKeyEvent.iCode != 'E')
-            {
-            response = iSysApKeyManagement->HandleKeyEventL(aKeyEvent, aType );
-            }
-        
-        if( aType == EEventKey )
-            {
-            switch ( aKeyEvent.iCode )
-                {
-#ifdef _DEBUG
-                case 'E': //For testing
-                    Exit();
-                    break;
-#endif
-                case EKeyPowerOff:
-                    //Short power key press
-                    iKeyBoardRepeatCount++;
-                    if( aKeyEvent.iRepeats == 0 )
-                        {
-                        TRACES( RDebug::Print(_L("CSysApAppUi::HandleKeyEventL, Short powerkey") ) );
-                        iLastPowerKeyWasShort = ETrue;
-                        HandleShortPowerKeyPressedL();
-                        iIgnoreNextPowerKeyRepeats = EFalse;
-                        }
-                    //Long power key press
-                    else if( aKeyEvent.iRepeats > 0 && iKeyBoardRepeatCount >= iSysApCenRepController->GetInt( KCRUidCoreApplicationUIsSysAp, KSysApPowerkeyRepeatcount ))
-                        {
-                        iKeyBoardRepeatCount = -1;
-                        TRACES( RDebug::Print(_L("CSysApAppUi::HandleKeyEventL, Long powerkey") ) );
-                        iLastPowerKeyWasShort = EFalse;
-                        HandleLongPowerKeyPressedL();
-                        }
-                    break;
-
-                default:
-                	{
-                	TKeyResponse response = EKeyWasNotConsumed;
-                	if (iSysApKeyManagement)
-                		{
-                		response = iSysApKeyManagement->HandleKeyEventL(aKeyEvent, aType );
-                		}
-
-                    if ( response == EKeyWasNotConsumed ) // none of the plugins consumed the key, offer it to default handling
-                        {
-                        iSysApDefaultKeyHandler->HandleKeyEventL( aKeyEvent, aType );
-                        }
-                	}
-                    break;
-                }
-            }
-        else if( aType == EEventKeyUp )
-            {
-            if( aKeyEvent.iScanCode == EStdKeyDevice2 )
-                {
-                if ( iIgnoreNextPowerKeyUpEvent )
-                    {
-                    if ( !iPowerKeyPopupMenuDismissed ) // If the popup menu has been dismissed, do nothing
-                        {
-                        iPowerKeyPopupMenuActive = ETrue;
-                        iIgnoreNextPowerKeyUpEvent = EFalse;
-                        }
-                    }
-                else if( iLastPowerKeyWasShort )
-                    {
-                    if ( iPowerKeyPopupMenuActive )
-                        {
-                        if ( iGlobalListQuery )
-                            {
-                            if ( iSysApFeatureManager->NoPowerKeySupported() )
-                                {
-                            	CancelGlobalListQuery();
-                                }
-                            else
-                                {
-                                iGlobalListQuery->MoveSelectionDown();	
-                                }                            
-                            }
-                        }
-                    }
-
-                }
-            }
-
-        TRACES( RDebug::Print( _L("CSysApAppUi::HandleKeyEventL:ended, aKeyEvent.iCode:%d, aKeyEvent.iScanCode:%d, aType:%d, iIgnoreNextPowerKeyUpEvent:%d, iPowerKeyPopupMenuActive:%d, iLastPowerKeyWasShort:%d, iPowerKeyPopupMenuDismissed:%d"),
-                               aKeyEvent.iCode, aKeyEvent.iScanCode, aType, iIgnoreNextPowerKeyUpEvent, iPowerKeyPopupMenuActive, iLastPowerKeyWasShort, iPowerKeyPopupMenuDismissed ) );
-        }
-    else // shutdown started
-        {
-        TRACES( RDebug::Print( _L("CSysApAppUi::HandleKeyEventL: aKeyEvent.iCode:%d, aKeyEvent.iScanCode:%d, aType:%d"),
-                               aKeyEvent.iCode, aKeyEvent.iScanCode, aType ) );
-
-        // When shutdown has been started, only device mode key events are passed to plug-in framework
-        // This for enabling plug-in activities during shutdown animation
-        if ( IsDeviceModeKey( aKeyEvent ) ) // Other key events are not passed, because they must cancel the shutdown animation as stated in UI spefication
-            {
-            if ( aType == EEventKey && iSysApKeyManagement )
-                {
-                iSysApKeyManagement->HandleKeyEventL( aKeyEvent, aType );
-                }
-            }
-    #ifdef RD_STARTUP_ANIMATION_CUSTOMIZATION
-        else if ( aType == EEventKey && iSysApShutdownAnimation && !iShutdownContinued )
-            {
-            if ( aKeyEvent.iCode != EKeyPowerOff || iLastPowerKeyWasShort )
-                {
-                iSysApShutdownAnimation->Cancel();
-                NotifyShutdownAnimationSkip();
-                }
-            }
-
-    #endif // RD_STARTUP_ANIMATION_CUSTOMIZATION
-
-        TRACES( RDebug::Print( _L("CSysApAppUi::HandleKeyEventL: ended") ) );
-        }
-    return EKeyWasConsumed;
+    ExecQueryL( aQuery, aReturn, KNullDesC8 );
     }
 
 // ----------------------------------------------------------------------------
-// CSysApAppUi::HandleCommandL( TInt aCommand)
+// CSysApAppUi::ExecQueryL
 // ----------------------------------------------------------------------------
-
-void CSysApAppUi::HandleCommandL( TInt aCommand )
+//
+void CSysApAppUi::ExecQueryL( TSysapQuery aQuery, TDes8& aReturn, const TDesC8& /*aParam*/ )
     {
-    TRACES( RDebug::Print( _L("CSysApAppUi::HandleCommandL aCommend: %d"), aCommand ) );
-    switch ( aCommand )
+    TRACES( RDebug::Print(_L("CSysApAppUi::ExecQueryL: aQuery=%d"), aQuery ) );
+
+    switch ( aQuery )
         {
-        case EEikCmdExit:   // EAknCmdExit
-            Exit();
+        case EGetHwrmLight: // get handle to HWRM client session. Returns CHWRMLight*.
+            {
+            THwrmLightBuf retBuf( iSysApLightsController->GetHwrmLight() );
+            aReturn.Copy( retBuf );
+            }
             break;
+
+        case EGetKeylock: // get handle to keylock client session. Returns RAknKeylock2*.
+            {
+            // do nothing
+            }
+            break;
+
+
         default:
+            __ASSERT_DEBUG( EFalse, User::Panic( _L("CSysApAppUi::ExecQueryL: Invalid query"), KErrArgument ) );
+            User::Leave( KErrArgument );
             break;
         }
     }
 
 // ----------------------------------------------------------------------------
-// CSysApAppUi::HandleApplicationSpecificEventL(TInt aType,const TWsEvent& aEvent)
+// CSysApAppUi::ExecCommandL
 // ----------------------------------------------------------------------------
-
-void CSysApAppUi::HandleApplicationSpecificEventL(TInt aType,const TWsEvent& aEvent)
+//
+void CSysApAppUi::ExecCommandL( TSysapCommand aCommand )
     {
-    TRACES( RDebug::Print( _L("CSysApAppUi::HandleApplicationSpecificEventL: aType:%d"), aType ) );
+    ExecCommandL( aCommand, KNullDesC8 );
+    }
 
-    CAknAppUi::HandleApplicationSpecificEventL(aType, aEvent);
-    
-    if ( ResourcesFreed() )
-        {
-        TRACES( RDebug::Print( _L("CSysApAppUi::HandleApplicationSpecificEventL: discarded, shutting down") ) );
-        return;
-        }
-    
-    switch( aType )
+// ----------------------------------------------------------------------------
+// CSysApAppUi::ExecCommandL
+// ----------------------------------------------------------------------------
+//
+void CSysApAppUi::ExecCommandL( TSysapCommand aCommand, const TDesC8&  /* aParam */ )
+    {
+    TRACES( RDebug::Print(_L("CSysApAppUi::ExecCommandL: aCommand=%d"), aCommand ) );
+
+    switch ( aCommand )
         {
-        case EEikKeyLockEnabled:
-            iKeyLockEnabled = ETrue;
-            iSysApCenRepController->SetInt( KCRUidCoreApplicationUIsSysAp, KSysApKeyguardActive, 1 );
-            SetIndicatorStateL( EAknIndicatorKeyguard, EAknIndicatorStateOn );
-            iSysApLightsController->KeylockStateChangedL( ETrue );
-            break;
-        case EEikKeyLockDisabled:
-            iKeyLockEnabled = EFalse;
-            iSysApCenRepController->SetInt( KCRUidCoreApplicationUIsSysAp, KSysApKeyguardActive, 0 );
-            SetIndicatorStateL( EAknIndicatorKeyguard, EAknIndicatorStateOff );
-            if (! iDeviceLockEnabled )
-                {
-                iSysApLightsController->KeylockStateChangedL( EFalse );
-                if ( iSysApFeatureManager->MmcHotSwapSupported() )
-                    {
-                    if ( StateOfProperty( KPSUidCtsyCallInformation, KCTsyCallState ) !=  EPSCTsyCallStateRinging && StateOfProperty( KPSUidCtsyCallInformation, KCTsyCallState ) !=  EPSCTsyCallStateAlerting )
-                        {
-                        RunUnlockNotifierL();
-                        }
-                    }
-                }
-            break;
-        case EEikKeyLockPowerKeyPressed: //sent when power key is captured by keylockserver
-            HandleShortPowerKeyPressedL();
-            break;
-
-        case EEikKeyLockLightsOnRequest:
-            iSysApLightsController->SetLightsOnUnlockNoteL();
-            break;
-
-        case EEikEcsQueryLights: // emergency note is shown
-            iSysApLightsController->SetLightsOnEcsQueryL();
-            break;
-
-        case EEikSecurityQueryLights: // for device lock security query
-            iSysApLightsController->SetLightsOnSecurityQueryL();
+        case EResetKeyguardState: // reset the internal keyguard flags of the SysAp, except for iKeyLockOnBeforeCradle
+            iKeyLockOnBeforeCall = EFalse;
+            iKeyLockOnBeforeAlarm = EFalse;
             break;
 
         default:
+            // do nothing in release builds since no harm is done
+            __ASSERT_DEBUG( EFalse, User::Panic( _L("CSysApAppUi::ExecCommandL: Invalid command"), KErrArgument ) );
             break;
+        }
+    }
+    
+// ----------------------------------------------------------------------------
+// CSysApAppUi::TimerExpiredL()
+// ----------------------------------------------------------------------------
+void CSysApAppUi::TimerExpiredL()
+    {
+/*
+ * Not suppported , will take care in wk25
+ * #ifndef RD_MULTIPLE_DRIVE 
+ * CloseUIAppsInHotSwapL();
+ * #endif // RD_MULTIPLE_DRIVE
+*/   
+   }
+
+
+  // ----------------------------------------------------------------------------
+// CSysApAppUi::KeyLockState() const
+// ----------------------------------------------------------------------------
+
+TBool CSysApAppUi::KeyLockState() const
+    {
+    return iKeyLockEnabled;
+    }
+
+// ----------------------------------------------------------------------------
+// CSysApAppUi::DeviceLockState() const
+// ----------------------------------------------------------------------------
+
+TBool CSysApAppUi::DeviceLockState() const
+    {
+    return iDeviceLockEnabled;
+    }
+    
+// ----------------------------------------------------------------------------
+// CSysApAppUi::SysApFeatureManager
+// ----------------------------------------------------------------------------
+
+CSysApFeatureManager& CSysApAppUi::SysApFeatureManager()
+    {
+    __ASSERT_DEBUG( iSysApFeatureManager, User::Panic( _L("iSysApFeatureManager == NULL"), KErrBadHandle ) );
+
+    return *iSysApFeatureManager;
+    }
+    
+// ----------------------------------------------------------------------------
+// CSysApAppUi::ActivateKeyeventForwardingForLights()
+// ----------------------------------------------------------------------------
+
+void CSysApAppUi::ActivateKeyeventForwardingForLights(TBool aActivate)
+    {
+    if( iSysApNspsHandler )
+        {
+        if ( aActivate )
+            {
+            iSysApNspsHandler->ActivateKeyeventForwardingForLights();
             }
+        else
+            {
+            iSysApNspsHandler->DeActivateKeyeventForwardingForLights();
+            }
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// CSysApAppUi::StarterSession()
+// ----------------------------------------------------------------------------
+
+RStarterSession& CSysApAppUi::StarterSession()
+    {
+    if ( !iStarterSession.Handle() )
+        {
+        // All server connections are tried to be made KTriesToConnectServer times because occasional
+        // fails on connections are possible at least on some servers
+        TRACES( RDebug::Print( _L("CSysApAppUi::StarterSession: trying RStarterSession::Connect()") ) );
+        TInt thisTry = 0;
+        TInt err;
+        while ( ( err = iStarterSession.Connect() ) != KErrNone && ( thisTry++ ) <= KTriesToConnectServer )
+            {
+            User::After( KTimeBeforeRetryingServerConnection );
+            }
+
+        if ( err != KErrNone )
+            {
+            // What do in error case?
+            TRACES( RDebug::Print( _L("CSysApAppUi::StarterSession: RStarterSession::Connect() failed with %d"), err ) );
+            }
+        }
+
+    return iStarterSession;
+    }
+
+// ----------------------------------------------------------------------------
+// CSysApAppUi::SetBtPowerState()
+// ----------------------------------------------------------------------------
+TInt CSysApAppUi::SetBtPowerState( TBool aBtState )
+    {
+    if ( iSysApBtController )
+        {
+        return iSysApBtController->SetPowerState( aBtState );
+        }
+    else
+        {
+        return KErrNotReady;
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// CSysApAppUi::SetStarterState()
+// ----------------------------------------------------------------------------
+
+TInt CSysApAppUi::SetStarterState( const RStarterSession::TGlobalState aState )
+    {
+    if ( iSysApStartupController->GlobalStateChangeAllowed( aState ) )
+        {
+        TRACES( RDebug::Print( _L("CSysApAppUi::SetStarterState: aState=%d" ), aState ) );
+        return StarterSession().SetState( aState );
+        }
+    else
+        {
+        TRACES( RDebug::Print( _L("CSysApAppUi::SetStarterState: aState=%d - not allowed" ), aState ) );
+        return KErrNone;
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// CSysApAppUi::SetNetworkConnectionAllowed()
+// ----------------------------------------------------------------------------
+
+void CSysApAppUi::SetNetworkConnectionAllowed( TCoreAppUIsNetworkConnectionAllowed aNetworkConnectionAllowed )
+    {
+    TRACES( RDebug::Print( _L("CSysApAppUi::SetNetworkConnectionAllowed: status: %d" ), aNetworkConnectionAllowed ) );
+
+    iSysApCenRepController->SetInt( KCRUidCoreApplicationUIs, KCoreAppUIsNetworkConnectionAllowed, (TInt) aNetworkConnectionAllowed );
+
+    // Also set the Symbian PS key used for the same purpose:
+    RProperty::Set(KUidSystemCategory, KUidPhonePwr.iUid, aNetworkConnectionAllowed ? ESAPhoneOn : ESAPhoneOff);
+    }
+
+// ----------------------------------------------------------------------------
+// CSysApAppUi::BluetoothPowerMode()
+// ----------------------------------------------------------------------------
+TInt CSysApAppUi::BluetoothPowerMode() const
+    {
+    return iSysApCenRepBtObserver->BluetoothPowerMode();
+    }
+
+// ----------------------------------------------------------------------------
+// CSysApAppUi::SimSupported()
+// ----------------------------------------------------------------------------
+TBool CSysApAppUi::SimSupported()
+    {
+    return iSysApFeatureManager->SimSupported();
+    }
+
+// ----------------------------------------------------------------------------
+// CSysApAppUi::BtSapEnabled()
+// ----------------------------------------------------------------------------
+
+TBool CSysApAppUi::BtSapEnabled()
+    {
+    if ( iSysApBtSapController )
+        {
+        return iSysApBtSapController->BtSapEnabled();    
+        }  
+    return EFalse;
     }
 
 
 // ----------------------------------------------------------------------------
-// CSysApAppUi::InitializeStatusPaneAreaL()
+// CSysApAppUi::OfflineModeChangedL()
+// ----------------------------------------------------------------------------
+void CSysApAppUi::OfflineModeChangedL()
+    {
+#ifdef SYSAP_USE_STARTUP_UI_PHASE    
+    // if UI is not ready, don't update indicators
+    if ( !UiReady() )
+        {
+        return;
+        }
+#endif // SYSAP_USE_STARTUP_UI_PHASE
+
+#if 0 // Not used as of now
+    SetHacIndicatorL();
+#endif //0	
+    }
+
+// ----------------------------------------------------------------------------
+// CSysApAppUi::UiReady()
+// 
 // ----------------------------------------------------------------------------
 
-void CSysApAppUi::InitializeStatusPaneAreaL()
+TBool CSysApAppUi::UiReady() const
     {
-    TRACES( RDebug::Print( _L("CSysApAppUi::InitializeStatusPaneAreaL(): START") ) );
-    TInt state( StateOfProperty( KPSUidHWRMPowerState, KHWRMBatteryLevel ) );
-
-    //Also Charging status will be updated with the following function.
-    UpdateBatteryBarsL( state );
+#ifdef SYSAP_USE_STARTUP_UI_PHASE    
+    return iSysApStartupController->UiReady(); 
+#else // SYSAP_USE_STARTUP_UI_PHASE
+    // if startup UI phase information is not used, global system state normal is handled as UI idle state
+    return IsStateNormal();
+#endif // SYSAP_USE_STARTUP_UI_PHASE        
+    }
 
-#ifdef SYSAP_USE_STARTUP_UI_PHASE
-    if ( OfflineModeActive() )
-        {
-        UpdateSignalBarsL( KAknSignalOffLineMode );
-        }
-    else
-        {
-        UpdateSignalBarsL();    
-        }          
-#else
-    UpdateSignalBarsL();
-#endif // SYSAP_USE_STARTUP_UI_PHASE
-    
-    SetSignalIndicatorL();
-    SetIhfIndicatorL();
-    SetHacIndicatorL();
-    LogsObserverL().HandleUiReadyL();
-
-    if ( iSysApEtelConnector )
-        {
-        iSysApEtelConnector->ReadSimSmsStoreStatusInStartup();
-        }
 
-    SetEnvelopeIndicatorL();
-
-    TRACES( RDebug::Print( _L("CSysApAppUi::InitializeStatusPaneAreaL(): accessories") ) );
-
-    TAccMode accessoryState(EAccModeHandPortable);
-    if ( iSysApAccessoryObserver )
-        {
-        accessoryState = iSysApAccessoryObserver->GetAccessoryMode();
-        }
+// ----------------------------------------------------------------------------
+// CSysApAppUi::CompleteShutdown()
+// ----------------------------------------------------------------------------
 
-    if( accessoryState == EAccModeWiredHeadset ||
-        accessoryState == EAccModeWirelessHeadset ||
-        accessoryState == EAccModeHeadphones )
-        {
-        SetIndicatorStateL( EAknIndicatorLoopset, EAknIndicatorStateOff );
-        SetIndicatorStateL( EAknIndicatorTTY,     EAknIndicatorStateOff );
-        SetIndicatorStateL( EAknIndicatorHeadset, EAknIndicatorStateOn );
-        SetIndicatorStateL( EAknIndicatorHeadsetUnavailable, EAknIndicatorStateOff );
-        SetIndicatorStateL( EAknIndicatorCarkit, EAknIndicatorStateOff );
-        SetIndicatorStateL( EAknIndicatorTvOut, EAknIndicatorStateOff );
-        SetIndicatorStateL(  EAknIndicatorHDMI, EAknIndicatorStateOff );
-        }
-    else if( accessoryState == EAccModeLoopset )
-        {
-        SetIndicatorStateL( EAknIndicatorHeadset, EAknIndicatorStateOff );
-        SetIndicatorStateL( EAknIndicatorTTY,     EAknIndicatorStateOff );
-        SetIndicatorStateL( EAknIndicatorLoopset, EAknIndicatorStateOn );
-        SetIndicatorStateL( EAknIndicatorHeadsetUnavailable, EAknIndicatorStateOff );
-        SetIndicatorStateL( EAknIndicatorCarkit, EAknIndicatorStateOff );
-        SetIndicatorStateL( EAknIndicatorTvOut, EAknIndicatorStateOff );
-        SetIndicatorStateL(  EAknIndicatorHDMI, EAknIndicatorStateOff );
-        }
-    else if( accessoryState == EAccModeTextDevice )
+void CSysApAppUi::CompleteShutdown( const TBool aReset, const TInt aResetReason )
+    {
+    TRACES( RDebug::Print(_L("CSysApAppUi::CompleteShutdown(): START" ) ) );
+    
+    iCheckLongPowerKeyEvent = ETrue;
+
+    PrepareForShutdownImage();//SysAp's internal preparation for ShutDown with image
+
+    FreeResources();
+
+    if ( aReset )
         {
-        SetIndicatorStateL( EAknIndicatorHeadset, EAknIndicatorStateOff );
-        SetIndicatorStateL( EAknIndicatorLoopset, EAknIndicatorStateOff );
-        SetIndicatorStateL( EAknIndicatorTTY,     EAknIndicatorStateOn );
-        SetIndicatorStateL( EAknIndicatorHeadsetUnavailable, EAknIndicatorStateOff );
-        SetIndicatorStateL( EAknIndicatorCarkit, EAknIndicatorStateOff );
-        SetIndicatorStateL( EAknIndicatorTvOut, EAknIndicatorStateOff );
-        SetIndicatorStateL(  EAknIndicatorHDMI, EAknIndicatorStateOff );
-        }
-    else if( accessoryState == EAccModeWiredCarKit || accessoryState == EAccModeWirelessCarKit )
-        {
-        SetIndicatorStateL( EAknIndicatorHeadset, EAknIndicatorStateOff );
-        SetIndicatorStateL( EAknIndicatorLoopset, EAknIndicatorStateOff );
-        SetIndicatorStateL( EAknIndicatorTTY,     EAknIndicatorStateOff );
-        SetIndicatorStateL( EAknIndicatorHeadsetUnavailable, EAknIndicatorStateOff );
-        SetIndicatorStateL( EAknIndicatorCarkit, EAknIndicatorStateOn );
-        SetIndicatorStateL( EAknIndicatorTvOut, EAknIndicatorStateOff );
-        SetIndicatorStateL(  EAknIndicatorHDMI, EAknIndicatorStateOff );
-        }
-    else if( accessoryState == EAccModeTVOut )
-        {
-        SetIndicatorStateL( EAknIndicatorHeadset, EAknIndicatorStateOff );
-        SetIndicatorStateL( EAknIndicatorLoopset, EAknIndicatorStateOff );
-        SetIndicatorStateL( EAknIndicatorTTY,     EAknIndicatorStateOff );
-        SetIndicatorStateL( EAknIndicatorHeadsetUnavailable, EAknIndicatorStateOff );
-        SetIndicatorStateL( EAknIndicatorCarkit, EAknIndicatorStateOff );
-        SetIndicatorStateL( EAknIndicatorTvOut, EAknIndicatorStateOn );
-        SetIndicatorStateL(  EAknIndicatorHDMI, EAknIndicatorStateOff );
-        }
-    else if (accessoryState == EAccModeHDMI )
-        {
-        SetIndicatorStateL( EAknIndicatorHeadset, EAknIndicatorStateOff );
-                SetIndicatorStateL( EAknIndicatorLoopset, EAknIndicatorStateOff );
-                SetIndicatorStateL( EAknIndicatorTTY,     EAknIndicatorStateOff );
-                SetIndicatorStateL( EAknIndicatorHeadsetUnavailable, EAknIndicatorStateOff );
-                SetIndicatorStateL( EAknIndicatorCarkit, EAknIndicatorStateOff );
-                SetIndicatorStateL( EAknIndicatorTvOut, EAknIndicatorStateOff);
-                SetIndicatorStateL(  EAknIndicatorHDMI, EAknIndicatorStateOn );
-        }
-    else // all indicators off
-        {
-        SetIndicatorStateL( EAknIndicatorHeadset, EAknIndicatorStateOff );
-        SetIndicatorStateL( EAknIndicatorLoopset, EAknIndicatorStateOff );
-        SetIndicatorStateL( EAknIndicatorTTY,     EAknIndicatorStateOff );
-        SetIndicatorStateL( EAknIndicatorHeadsetUnavailable, EAknIndicatorStateOff );
-        SetIndicatorStateL( EAknIndicatorCarkit, EAknIndicatorStateOff );
-        SetIndicatorStateL( EAknIndicatorTvOut, EAknIndicatorStateOff );
-        SetIndicatorStateL(  EAknIndicatorHDMI, EAknIndicatorStateOff );
-        }
-
-    TRACES( RDebug::Print( _L("CSysApAppUi::InitializeStatusPaneAreaL(): msg") ) );
-    state = StateOfProperty( KUidSystemCategory, KUidOutboxStatusValue );
-    if( state == ESADocumentsInOutbox )
-        {
-        SetIndicatorStateL( EAknIndicatorOutbox, EAknIndicatorStateOn );
-        }
-    else
-        {
-        SetIndicatorStateL( EAknIndicatorOutbox, EAknIndicatorStateOff );
-        }
-
-    state = StateOfProperty( KAlarmServerPubSubCategory, KWakeupAlarmPubSubKey );
-    
-    if( state == EActiveWakeupAlarmSet )
-        {
-        TRACES( RDebug::Print(_L("CSysApAppUi::InitializeStatusPaneAreaL called the SetIndicatorStateL with EActiveWakeupAlarmSet ")));
-        SetIndicatorStateL( EAknIndicatorAlarmClock, EAknIndicatorStateOn );
+        __ASSERT_DEBUG( aResetReason >= RStarterSession::ELanguageSwitchReset &&
+                        aResetReason <= RStarterSession::EDataRestoreReset,
+                        User::Invariant() );
+        StarterSession().Reset( static_cast<RStarterSession::TResetReason>( aResetReason ) );
         }
     else
         {
-        TRACES( RDebug::Print(_L("CSysApAppUi::InitializeStatusPaneAreaL called the SetIndicatorStateL with EActiveNoWakeupAlarmsSet ")));
-        SetIndicatorStateL( EAknIndicatorAlarmClock, EAknIndicatorStateOff );
+        StarterSession().Shutdown();
         }
 
-    state = StateOfProperty( KIrdaPropertyCategory, KIrdaStatus );
-    if( state == TIrdaStatusCodes::EIrLoaded || state == TIrdaStatusCodes::EIrDisconnected || state == TIrdaStatusCodes::EIrBlocked )
+    StarterSession().Close();
+
+    TRACES( RDebug::Print(_L("CSysApAppUi::CompleteShutdown(): END" ) ) );
+    }
+
+
+
+// ----------------------------------------------------------------------------
+// CSysApAppUi::DoShutdownL( const TBool aReset, const TSWStartupReason aSWStartupReason )
+// ----------------------------------------------------------------------------
+
+void CSysApAppUi::DoShutdownL( const TBool aReset, const TInt aResetReason )
+    {
+    TRACES( RDebug::Print(_L("CSysApAppUi::DoShutdownL: aResetReason:%d, aReset:%d" ),
+        aResetReason, aReset ) );
+#ifndef RD_STARTUP_ANIMATION_CUSTOMIZATION
+    TBool animationenabled( EFalse );
+#endif // RD_STARTUP_ANIMATION_CUSTOMIZATION
+
+    if( OkToInitiateShutdown() )
         {
-        SetIndicatorStateL( EAknIndicatorIrActive, EAknIndicatorStateAnimate );
-        }
-    else if( state == TIrdaStatusCodes::EIrConnected  )
-        {
-        SetIndicatorStateL( EAknIndicatorIrActive, EAknIndicatorStateOn );
+        TRACES( RDebug::Print(_L("CSysApAppUi::DoShutdownL: Was OkToToInitiateShutdown" ) ) );
+
+
+        if ( !aReset && iSysApFeatureManager->Supported(KSysApFeatureIdGoodbyeNote) )
+            {
+            // show shutdown note
+            }
+
+        if( !aReset )
+            {
+    #ifdef RD_STARTUP_ANIMATION_CUSTOMIZATION
+//            TRAPD( err, ShowAnimationL() );
+//            if ( err )
+                {
+     //           TRACES( RDebug::Print(_L("CSysApAppUi::DoShutdownL ShowAnimationL() leaved: %d" ), err ) );
+                CompleteShutdown(aReset, aResetReason);
+                }
+            }
+        else // aReset
+           {
+            CompleteShutdown(aReset, aResetReason);
+            }
+    #else // RD_STARTUP_ANIMATION_CUSTOMIZATION
+            TRAPD( err, animationenabled = ShowAnimationL() );
+            if ( err )
+                {
+                TRACES( RDebug::Print(_L("CSysApAppUi::DoShutdownL ShowAnimationL() leaved: %d" ), err ) );
+                }
+            }
+
+        if ( !animationenabled )
+            {
+            CompleteShutdown(aReset, aResetReason);
+            }
+    #endif // RD_STARTUP_ANIMATION_CUSTOMIZATION
         }
     else
         {
-        SetIndicatorStateL( EAknIndicatorIrActive, EAknIndicatorStateOff );
-        }
-
-    iSysApCenRepCallForwardingObserver->UpdateCallForwardingIndicatorsL();
-
-    iSysApCenRepMsgWaitingObserver->UpdateMessageWaitingIndicatorsL();
-
-    state = StateOfProperty( KPSUidNetworkInfo, KNWHomeZoneStatus );
-    if( state == ENWNone || state == ENWCityZone )
-        {
-        SetIndicatorStateL( EAknIndicatorHomeZone, EAknIndicatorStateOff );
-        }
-    else if( state == ENWHomeZone )
-        {
-        SetIndicatorStateL( EAknIndicatorHomeZone, EAknIndicatorStateOn );
+        TRACES( RDebug::Print(_L("CSysApAppUi::DoShutdownL: Was not OkToToInitiateShutdown" ) ) );
         }
-
-    // Initialize WLan state
-    state = StateOfProperty( KPSUidWlan, KPSWlanIndicator );
-    HandleWlanIndicatorL(state);
-
-    // Initialize Tarm state
-    state = StateOfProperty( KPSUidCoreApplicationUIs, KCoreAppUIsTarmIndicator );
-    HandleTarmIndicatorL(state);
-
-    TRACES( RDebug::Print( _L("CSysApAppUi::InitializeStatusPaneAreaL(): END") ) );
-    }
-
-// ----------------------------------------------------------------------------
-// CSysApAppUi::HandleWlanIndicator()
-// ----------------------------------------------------------------------------
-void CSysApAppUi::HandleWlanIndicatorL( TInt aValue )
-    {
-    if ( aValue == EPSWlanIndicatorAvailable )
-        {
-        SetIndicatorStateL( EAknIndicatorWlanActive,       EAknIndicatorStateOff );
-        SetIndicatorStateL( EAknIndicatorWlanActiveSecure, EAknIndicatorStateOff );
-        SetIndicatorStateL( EAknIndicatorWlanAvailable,    EAknIndicatorStateOn  );
-        }
-    else if ( aValue == EPSWlanIndicatorActive )
-        {
-        SetIndicatorStateL( EAknIndicatorWlanAvailable,    EAknIndicatorStateOff );
-        SetIndicatorStateL( EAknIndicatorWlanActiveSecure, EAknIndicatorStateOff );
-        SetIndicatorStateL( EAknIndicatorWlanActive,       EAknIndicatorStateOn  );
-        }
-    else if ( aValue == EPSWlanIndicatorActiveSecure )
-        {
-        SetIndicatorStateL( EAknIndicatorWlanAvailable,    EAknIndicatorStateOff );
-        SetIndicatorStateL( EAknIndicatorWlanActive,       EAknIndicatorStateOff );
-        SetIndicatorStateL( EAknIndicatorWlanActiveSecure, EAknIndicatorStateOn  );
-        }
-    else // No indication required
-        {
-        SetIndicatorStateL( EAknIndicatorWlanAvailable,    EAknIndicatorStateOff );
-        SetIndicatorStateL( EAknIndicatorWlanActive,       EAknIndicatorStateOff );
-        SetIndicatorStateL( EAknIndicatorWlanActiveSecure, EAknIndicatorStateOff );
-        }
+    TRACES( RDebug::Print(_L("CSysApAppUi::DoShutdownL: END" ) ) );
     }
 
-// ----------------------------------------------------------------------------
-// CSysApAppUi::HandleTarmIndicatorL()
-// ----------------------------------------------------------------------------
-
-void CSysApAppUi::HandleTarmIndicatorL( TInt aValue )
-    {
-    if ( aValue == ECoreAppUIsTarmTerminalSecurityOnIndicatorOn )
-        {
-        SetIndicatorStateL( EAknIndicatorTARM, EAknIndicatorStateOff );
-        SetIndicatorStateL( EAknIndicatorTARMModuleOn, EAknIndicatorStateOn );
-        }
-    else if ( aValue == ECoreAppUIsTarmMngActiveIndicatorOn )
-        {
-        SetIndicatorStateL( EAknIndicatorTARMModuleOn, EAknIndicatorStateOff );
-        SetIndicatorStateL( EAknIndicatorTARM, EAknIndicatorStateOn );
-        }
-    else
-        {
-        SetIndicatorStateL( EAknIndicatorTARM, EAknIndicatorStateOff );
-        SetIndicatorStateL( EAknIndicatorTARMModuleOn, EAknIndicatorStateOff );
-        }
-    }
-
-// ----------------------------------------------------------------------------
-// CSysApAppUi::HandleShortPowerKeyPressedL()
-// ----------------------------------------------------------------------------
-
-void CSysApAppUi::HandleShortPowerKeyPressedL()
-    {
-    TInt callState( StateOfProperty( KPSUidCtsyCallInformation, KCTsyCallState ) );
-
-    TRACES (
-        RDebug::Print(
-        _L("CSysApAppUi::HandleShortPowerKeyPressedL() callState:%d, iDeviceLockEnabled:%d" ),
-        callState,
-        iDeviceLockEnabled );
-    );
-    iSysApLightsController->PowerKeyPressedL();
-
-    RProperty::Set( KPSUidCoreApplicationUIs, KCoreAppUIsHideAlarm, ECoreAppUIsHideAlarm );
 
 
-    if( UiReady() && !iDeviceLockEnabled )
-        {
-        if ( iPowerKeyPopupMenuActive )
-            {
-            //Do nothing here. EEventKeyUp moves selection in the list!
-            }
-        else if ( !iKeyLockEnabled
-            && callState != EPSCTsyCallStateAlerting
-            && callState != EPSCTsyCallStateRinging
-            && callState != EPSCTsyCallStateDialling )
-            //Show power key menu
-            {
-            ShowPowerKeyPopUpMenuL();
-            }
-        }
-    else 
-        {
-        TInt swState( StateOfProperty( KPSUidStartup, KPSGlobalSystemState ) );
-        
-        if( swState == ESwStateAlarm )
-            //From Alarm state even a short press causes shutdown but charger state need to be checked
-            {
-            TInt chargerState( StateOfProperty( KPSUidHWRMPowerState, KHWRMChargingStatus ) );
-            if( chargerState == EChargingStatusNotConnected )
-                //shutdown
+/* 
+----------------------------------------------------------------------------
+CSysApAppUi::IsEncryptionOperationOngoingL()
+Introduced the code as a part of Sub : 405-3362 - Power Management SUB for ES 
+recapture functionalities in platform which support multidrive as well. 
+-------------------------------------------------------------------------------
+*/
+TBool CSysApAppUi::IsEncryptionOperationOngoingL() const
+    {
+        TBool deFeatureSupported(EFalse);
+        FeatureManager::InitializeLibL();
+        deFeatureSupported = FeatureManager::FeatureSupported( KFeatureIdFfDeviceEncryptionFeature);
+        FeatureManager::UnInitializeLib();
+
+        if(deFeatureSupported)
+            {         
+            /**
+             * Store the last memory status changed
+             * 0: Idle. It can be Encrypted or Decrypted
+             * 1: Encrypting
+             * 2: Decrypting
+             **/
+             
+            RProperty deProperty;
+            User::LeaveIfError(deProperty.Attach(KDevEncProtectedUid, KDevEncOperationKey,EOwnerThread));
+            TInt deValue = 0;
+            if((deProperty.Get(deValue)== KErrNone)&&( deValue == EOpEncrypting || deValue == EOpDecrypting))
                 {
-                StartShutDownTimerOnAlarmAndChargingStates();
+                deProperty.Close();
+                return ETrue;
                 }
             else
-                //to charging state
                 {
-                SetStarterState( RStarterSession::ECharging );
+                deProperty.Close();
+                return EFalse;
                 }
             }
-        }
+        else
+            {
+            return EFalse;
+            }
     }
 
 // ----------------------------------------------------------------------------
@@ -1104,8 +969,8 @@
 
     TInt swState;
     RProperty::Get( KPSUidStartup, KPSGlobalSystemState, swState );
-
-    iSysApLightsController->PowerKeyPressedL();
+    
+    iSysApLightsController->PowerKeyPressedL();  //need to handle later.
 
     if( swState == ESwStateStartingCriticalApps ||
         swState == ESwStateSelfTestOK ||
@@ -1121,10 +986,7 @@
             {
             if( iPowerKeyPopupMenuActive )
                 {
-                if ( iGlobalListQuery )
-                    {
-                    iGlobalListQuery->SelectItem();
-                    }
+                // do nothing
                 }
             else if( !iIgnoreNextPowerKeyRepeats )
                 {
@@ -1154,1101 +1016,356 @@
     }
 
 // ----------------------------------------------------------------------------
-// CSysApAppUi::FreeResources()
-// ----------------------------------------------------------------------------
-
-void CSysApAppUi::FreeResources()
-    {
-    TRACES( RDebug::Print( _L("CSysApAppUi::FreeResources") ) );
-
-    delete iSysApBatteryInfoController;
-    delete iSysApPsmController;
-
-    delete iSysApAudioRoutingObserver;
-
-    delete iProfileNamesArray;
-    iProfileNamesArray = NULL;
-
-    if ( iTimer )
-        {
-        iTimer->Cancel();
-        delete iTimer;
-        }
-
-    if ( iSapTimer )
-        {
-        iSapTimer->Cancel();
-        delete iSapTimer;
-        }
-
-    if ( iSysApTimer )
-        {
-        iSysApTimer->Cancel();
-        delete iSysApTimer;
-        }
-
-    delete iGlobalListQuery;
-
-    RWindowGroup groupWin = iCoeEnv->RootWin();
-    groupWin.CancelCaptureKey( iCapturedEKeyPowerOff );
-    groupWin.CancelCaptureKeyUpAndDowns( iCapturedEKeyPowerOffUpAndDowns );
-
-    delete iSysApDefaultKeyHandler;
-
-    if ( iProfileEngine )
-        {
-        iProfileEngine->Release();
-        }
-
-    delete iSysApSsSettingsObserver;
-    delete iSysApEtelConnector;
-
-    delete iSysApProfileObserver;
-    delete iSysApNspsHandler;
-    delete iSysApKeySndHandler;
-    delete iSysApCenRepMsgWaitingObserver;
-    delete iSysApCenRepCallForwardingObserver;
-    delete iSysApConnectionMonitorObserver;
-    delete iSysApCenRepLightSettingsObserver;
-    delete iSysApCenRepLogsObserver;
-    delete iSysApCenRepBtObserver;
-//    delete iSysApCenRepFmTxObserver;
-    delete iSysApCenRepHacSettingObserver;
-    delete iSysApCenRepController;
-
-    delete iSysApPubSubObserver;
-
-    delete iSysApMMCObserver;
-    delete iSysApMsgSimMemLowQuery;
-    delete iSysApWaitNote;
-    delete iSysApConfirmationQuery;
-    delete iSysApConfirmationQueryForRestart;
-    delete iSysApOfflineModeController;
-    delete iSysApUsbIndicatorController;
-    delete iSysApBtController;
-    delete iSysApBtSapController;
-    delete iSignalNotify;
-    delete iBatteryNotify;
-    delete iSysApSystemLock;
-    delete iSysApLocationPrivacyIndicator;
-    delete iSysApAccessoryObserver;
-    delete iSysApMediatorObserver;
-
-    delete iSysApKeyManagement;
-    iSysApKeyManagement = NULL;
-    delete iSysApLightsController;
-    iKeyLock.Close();
-    delete iSysApFeatureManager;
-
-    // Cleanup ECom, used by key management and light control
-    REComSession::FinalClose();
-
-    iResourcesFreed = ETrue;
-    TRACES( RDebug::Print( _L("CSysApAppUi::FreeResources:END") ) );
-    }
-
-// ----------------------------------------------------------------------------
-// CSysApAppUi::ShowUiNoteL( const TSysApNoteIds aNote ) const
+// CSysApAppUi::IsDeviceModeKey
 // ----------------------------------------------------------------------------
 
-void CSysApAppUi::ShowUiNoteL( const TSysApNoteIds aNote ) const
+TBool CSysApAppUi::IsDeviceModeKey( const TKeyEvent& aKeyEvent ) const
     {
-    TRACES( RDebug::Print( _L("CSysApAppUi::ShowUiNoteL aNote: %d"), aNote ) );
+    return CSysApDefaultKeyHandler::IsDeviceModeKey( aKeyEvent );
+    }
+
 
-    TInt tone( EAvkonSIDNoSound );
-    TAknGlobalNoteType noteType( EAknGlobalBatteryLowNote );
-    CAknGlobalNote* note = CAknGlobalNote::NewLC();
-    TInt secondaryDisplayId(SecondaryDisplay::ECmdNoNote);
+// ----------------------------------------------------------------------------
+// CSysApAppUi::ShowShutdownImage
+// ----------------------------------------------------------------------------
+//
+TInt CSysApAppUi::ShowShutdownImage( TInt aBitmapId )
+    {
+    TRACES( RDebug::Print(_L("CSysApAppUi::ShowShutdownImage") ) );
 
-    switch ( aNote )
+    TRAPD( err, ShowShutdownImageL( aBitmapId ) );
+
+    if ( err != KErrNone )
         {
-        case EBatteryLowNote:
-            noteType = EAknGlobalBatteryLowNote;
-            tone = EAvkonSIDBatteryLowTone;
-            break;
-        case EBatteryFullNote:
-            noteType = EAknGlobalBatteryFullNote;
-            tone = EAvkonSIDInformationTone;
-            break;
-        case ERechargeBatteryNote:
-            iSysApLightsController->BatteryEmptyL( ETrue );
-            noteType = EAknGlobalRechargeBatteryNote;
-            tone = EAvkonSIDRechargeBatteryTone;
-            break;
-        case ENotChargingNote:
-            noteType = EAknGlobalNotChargingNote;
-            tone = EAvkonSIDWrongCharger;
-            break;
-        case EInsertSimNote:
-            noteType = EAknGlobalInformationNote;
-            tone = EAvkonSIDInformationTone;
-            secondaryDisplayId = SecondaryDisplay::ECmdShowInsertSimNote;
-            break;
-        case EMemoryCardRemovedWithoutEjectNote:
-            noteType = EAknGlobalInformationNote;
-            tone = EAvkonSIDInformationTone;
-            secondaryDisplayId = SecondaryDisplay::ECmdShowMemoryCardRemovedWithoutEjectNote;
-            break;
-        case EGprsSuspendedNote:
-            noteType = EAknGlobalInformationNote;
-            tone = EAvkonSIDInformationTone;
-            secondaryDisplayId = SecondaryDisplay::ECmdShowGprsSuspendedNote;
-            break;
-        case EGprsResumedNote:
-            noteType = EAknGlobalInformationNote;
-            tone = EAvkonSIDInformationTone;
-            secondaryDisplayId = SecondaryDisplay::ECmdShowGprsResumedNote;
-            break;
-        case EShutdownNote:
-            noteType = EAknGlobalInformationNote;
-            tone = EAvkonSIDInformationTone;
-            secondaryDisplayId = SecondaryDisplay::ECmdShowShutdownNote;
-            break;
-        case ECannotActivateOfflineModeNote:
-            noteType = EAknGlobalErrorNote;
-            tone = EAvkonSIDErrorTone;
-            secondaryDisplayId = SecondaryDisplay::ECmdShowCannotActivateOfflineModeNote;
-            break;
-        case ECannotDeactivateOfflineModeNote:
-            noteType = EAknGlobalErrorNote;
-            tone = EAvkonSIDErrorTone;
-            secondaryDisplayId = SecondaryDisplay::ECmdShowCannotDeactivateOfflineModeNote;
-            break;
-        case EKeypadActiveNote:
-            noteType = EAknGlobalInformationNote;
-            tone = EAvkonSIDInformationTone;
-            secondaryDisplayId = SecondaryDisplay::ECmdShowKeypadActiveNote;
-            break;
-/*        case EFmTxAccessoryStandbyNote:
-            noteType = EAknGlobalInformationNote; 
-            tone = EAvkonSIDInformationTone;
-            secondaryDisplayId = SecondaryDisplay::ECmdShowFmTxStandbyInAccessoryConnectionNote;
-            break;
-        case EFmTxAccessoryForbidsNote:
-            noteType = EAknGlobalInformationNote; 
-            tone = EAvkonSIDInformationTone;
-            secondaryDisplayId = SecondaryDisplay::ECmdShowFmTxCannotEnableWhileAccessoryConnectedNote;
-            break;
-        case EFmTxVolumeDisabledNote:
-            noteType = EAknGlobalInformationNote; 
-            tone = EAvkonSIDInformationTone;
-            secondaryDisplayId = SecondaryDisplay::ECmdShowFmTxVolumeDisabledNote;
-            break;
-        case EFmTxOnNote:
-            noteType = EAknGlobalInformationNote; 
-            tone = EAvkonSIDInformationTone;
-            secondaryDisplayId = SecondaryDisplay::ECmdShowFmTxTuneRadioToFrequencyNote;
-            break;
-        case EFmTxOffNote:
-            noteType = EAknGlobalInformationNote; 
-            tone = EAvkonSIDInformationTone;
-            secondaryDisplayId = SecondaryDisplay::ECmdShowFmTxDisabledNote;
-            break;
-*/        case EBatteryFullUnplugChargerNote:
-            noteType = EAknGlobalBatteryFullUnplugNote;
-            tone = EAvkonSIDInformationTone;
-            break;
-        case EUnplugChargerNote:
-            noteType = EAknGlobalUnplugChargerNote;
-            tone = EAvkonSIDInformationTone;
-            break;
-        case EPowerSaveModeActivated:
-            noteType = EAknGlobalConfirmationNote;
-            tone = EAvkonSIDConfirmationTone;
-            secondaryDisplayId = SecondaryDisplay::ECmdShowPowerSavingActivatedNote;
-            break;
-        case EPowerSaveModeDeactivated:
-            noteType = EAknGlobalConfirmationNote;
-            tone = EAvkonSIDConfirmationTone;
-            secondaryDisplayId = SecondaryDisplay::ECmdShowPowerSavingDeactivatedNote;
-            break;
-        case ECannotActivatePowerSaveMode:
-            noteType = EAknGlobalWarningNote;
-            tone = EAvkonSIDWarningTone;
-            secondaryDisplayId = SecondaryDisplay::ECmdShowCannotActivatePowerSavingNote;
-            break;
-        case ECannotDeactivatePowerSaveMode:
-            noteType = EAknGlobalWarningNote;
-            tone = EAvkonSIDWarningTone;
-            secondaryDisplayId = SecondaryDisplay::ECmdShowCannotDeactivatePowerSavingNote;
-            break;
-        default:
-            break;
-
+        TRACES( RDebug::Print(_L("CSysApAppUi::ShowShutdownImageL failed, err=%d"), err ) );
         }
 
-    TInt swState( StateOfProperty( KPSUidStartup, KPSGlobalSystemState ) );
-
-    if( UiReady() || swState == ESwStateSecurityCheck)
-        {
-        HBufC* noteStringBuf = NULL;
-
-        switch ( aNote )
-            {
-            case EInsertSimNote:
-                noteStringBuf = StringLoader::LoadLC( R_QTN_SU_NOTE_INSERT_SIM, iEikonEnv );
-                break;
-            case EMemoryCardRemovedWithoutEjectNote:
-                noteStringBuf = StringLoader::LoadLC( R_QTN_MEMS_EJECT_ERROR, iEikonEnv );
-                note->SetSoftkeys( R_AVKON_SOFTKEYS_OK_EMPTY );
-                break;
-            case EGprsSuspendedNote:
-                noteStringBuf = StringLoader::LoadLC( R_QTN_GPRS_CONF_GPRS_SUSPENDED, iEikonEnv );
-                break;
-            case EGprsResumedNote:
-                noteStringBuf = StringLoader::LoadLC( R_QTN_GPRS_CONF_GPRS_RESUMED, iEikonEnv );
-                break;
-            case EShutdownNote:
-                noteStringBuf = StringLoader::LoadLC( R_QTN_PWRC_INFO_GOODBYE, iEikonEnv);
-                break;
-            case ECannotActivateOfflineModeNote:
-                noteStringBuf = StringLoader::LoadLC( R_QTN_ERR_OFFLINE_UNABLE, iEikonEnv );
-                break;
-            case ECannotDeactivateOfflineModeNote:
-                noteStringBuf = StringLoader::LoadLC( R_QTN_ERR_OFFLINE_UNABLE_PROFILE, iEikonEnv );
-                break;
-            case EKeypadActiveNote:
-                if ( iSysApFeatureManager->PenEnabled() )
-                    {
-                    noteStringBuf = StringLoader::LoadLC( R_QTN_KEYG_CONF_DISPLAY_KEYS_ACTIVE,
-                                                          iEikonEnv );
-                    }
-                else
-                    {
-                    noteStringBuf = StringLoader::LoadLC( R_QTN_KEYG_CONF_KEYPAD_ACTIVE,
-                                                          iEikonEnv );
-                    }
-                note->SetAnimation( R_QGN_NOTE_KEYGUARD_OPEN_ANIM );
-                break;
-/*            case EFmTxOnNote:
-                {
-                const TInt KFrequencyMaxLength(7);
-                // read frequency
-                TInt frequencykHz = iSysApCenRepFmTxObserver->Frequency();
-                TReal frequencyMHz = static_cast<TReal>( frequencykHz ) / KCoefficientKhzToMhz; // kHz to Mhz
-                TBuf<KFrequencyMaxLength> frequencyAsString;
-                frequencyAsString.AppendNum( frequencyMHz, TRealFormat( KFrequencyMaxLength, KDecimalsInMhzFrequency ) );
-                AknTextUtils::LanguageSpecificNumberConversion( frequencyAsString );
-                noteStringBuf 
-                      = StringLoader::LoadLC( R_QTN_FMTX_SYSAP_INFO_NOTE_CHANGE_FREQ, 
-                                              frequencyAsString,
-                                              iEikonEnv );
-                break;
-                }
-            case EFmTxAccessoryForbidsNote:
-                {
-                noteStringBuf = StringLoader::LoadLC( R_QTN_FMTX_SYSAP_INFO_NOTE_ACCESSORY_FORBIDS, 
-                                                       iEikonEnv );
-                break;
-                }
-            case EFmTxAccessoryStandbyNote:
-                {                                     
-                noteStringBuf = StringLoader::LoadLC( R_QTN_FMTX_SYSAP_INFO_NOTE_ACCESSORY_STANDBY, 
-                                                       iEikonEnv );
-                break;
-                }
-            case EFmTxVolumeDisabledNote:
-                {
-                noteStringBuf = StringLoader::LoadLC( R_QTN_FMTX_SYSAP_INFO_NOTE_VOLUME_DISABLED, 
-                                                       iEikonEnv );
-                break;
-                }
-            case EFmTxOffNote:
-                {
-                noteStringBuf = StringLoader::LoadLC( R_QTN_FMTX_SYSAP_INFO_NOTE_DISABLED, 
-                                                       iEikonEnv );
-                break;
-                }
-*/            case EPowerSaveModeActivated:
-                noteStringBuf = StringLoader::LoadLC( R_QTN_POWER_SAVING_ACTIVATED_CONF_NOTE, iEikonEnv );
-                break;
-            case EPowerSaveModeDeactivated:
-                noteStringBuf = StringLoader::LoadLC( R_QTN_POWER_SAVING_DEACTIVATED_CONF_NOTE, iEikonEnv );
-                break;
-            case ECannotActivatePowerSaveMode:
-                noteStringBuf = StringLoader::LoadLC( R_QTN_POWER_SAVING_FAILED_WARNING_NOTE, iEikonEnv );
-                break;
-            case ECannotDeactivatePowerSaveMode:
-                noteStringBuf = StringLoader::LoadLC( R_QTN_POWER_SAVING_DEACTIVATION_FAILED_WARNING_NOTE, iEikonEnv ); 
-                break;
-            default:
-                break;
-            }
-
-        note->SetTone( tone );
-
-        // Set secondary display data if necessary
-/*        if ( iSysApFeatureManager->CoverDisplaySupported() && secondaryDisplayId != SecondaryDisplay::ECmdNoNote)
-            {
-            TRACES( RDebug::Print( _L("CSysApAppUi::ShowUiNoteL - Notifying secondary display") ) );
-            CAknSDData* sd;
-            
-            if ( aNote == EFmTxOnNote ) // frequency information is passed to secondary display
-                {
-                SecondaryDisplay::TFmTxFrequencyInKhzPckg pckg( iSysApCenRepFmTxObserver->Frequency() );
-                sd = CAknSDData::NewL( SecondaryDisplay::KCatSysAp, secondaryDisplayId, pckg );
-                }
-            else
-                {
-                sd = CAknSDData::NewL(SecondaryDisplay::KCatSysAp, secondaryDisplayId, KNullDesC8);
-                }
-             
-            note->SetSecondaryDisplayData(sd); // ownership to notifier client
-            }
-*/
-        if ( noteStringBuf )
-            {
-            TPtr textBuffer = noteStringBuf->Des();
-            TRACES( RDebug::Print( _L("CSysApAppUi::ShowUiNoteL Next:note->ShowNoteL" ) ) );
-            note->ShowNoteL( noteType, textBuffer );
-            CleanupStack::PopAndDestroy( ); // noteStringbuf
-            }
-        else
-            {
-            TRACES( RDebug::Print( _L("CSysApAppUi::ShowUiNoteL Next:note->ShowNoteL" ) ) );
-            note->ShowNoteL( noteType, KNullDesC );
-            }
-        }
-    else if( swState == ESwStateAlarm || swState == ESwStateCharging )
-        {
-        if ( aNote != EUnplugChargerNote ) // don't play tone when charger is disconnected in charging state
-            {
-            static_cast<CAknAppUi*>(iEikonEnv->EikAppUi())->KeySounds()->PlaySound( tone );    
-            }
-        }
-
-    CleanupStack::PopAndDestroy(); // note
+    return err;
     }
 
-// ----------------------------------------------------------------------------
-// CSysApAppUi::ShowChargingNoteL()
-// ----------------------------------------------------------------------------
-
-void CSysApAppUi::ShowChargingNoteL()
-    {
-    TRACES( RDebug::Print( _L("CSysApAppUi::ShowChargingNoteL") ) );
-    TBool showNote( ETrue );
-
-    TInt swState( StateOfProperty( KPSUidStartup, KPSGlobalSystemState ) );
-    TRACES( RDebug::Print( _L("CSysApAppUi::ShowChargingNoteL: swState: %d"), swState ) );
-
-    if( UiReady() || swState == ESwStateSecurityCheck )
-        {
-        if ( StateOfProperty( KPSUidCtsyCallInformation, KCTsyCallState ) ==  EPSCTsyCallStateRinging )
-            {
-            showNote = EFalse;
-            }
-        TRACES( RDebug::Print( _L("CSysApAppUi::ShowChargingNoteL KCTsyCallState=%d"), StateOfProperty( KPSUidCtsyCallInformation, KCTsyCallState ) ) );
-        if ( showNote ) // Power Mgmt UI spec defines that no Charging note is shown while the phone is ringing/alerting
-            {
-            CAknGlobalNote* chargingNote = CAknGlobalNote::NewLC();
-            chargingNote->SetTone( EAvkonSIDChargingBatteryTone );
-            chargingNote->ShowNoteL( EAknGlobalChargingNote, KNullDesC );
-            CleanupStack::PopAndDestroy( chargingNote );
-            }
-        }
-    else if( swState == ESwStateAlarm || swState == ESwStateCharging )
-        {
-        TRACES( RDebug::Print( _L("CSysApAppUi::ShowChargingNoteL - Just play tone") ) );
-        static_cast<CAknAppUi*>(iEikonEnv->EikAppUi())->KeySounds()->PlaySound( EAvkonSIDChargingBatteryTone );
-        }
-    else
-        {
-        TRACES( RDebug::Print( _L("CSysApAppUi::ShowChargingNoteL - No note shown") ) );
-        }
-    }
 
 // ----------------------------------------------------------------------------
-// CSysApAppUi::HandleChargerNotesL()
+// CSysApAppUi::ShowShutdownImageL
 // ----------------------------------------------------------------------------
-void CSysApAppUi::HandleChargerNotesL( const TInt aValue )
+//
+void CSysApAppUi::ShowShutdownImageL( TInt aBitmapId )
     {
-    TBool showNote(StateOfProperty( KPSUidCtsyCallInformation, KCTsyCallState ) !=  EPSCTsyCallStateRinging);
-    if ( aValue == EChargingStatusCharging )
-        {
-        iSysApLightsController->BatteryEmptyL( EFalse );
-        TRACES( RDebug::Print( _L("SysAp: charger connected") ) );
-        iSysApLightsController->ChargerConnectedL( ETrue );
-        ShowChargingNoteL();
-        }
-    //Display Not Charging note
-    else if ( aValue == EChargingStatusError )
+    TRACES( RDebug::Print(_L("CSysApAppUi::ShowShutdownImageL") ) );
+    // do nothing
+    if ( !iSysApShutdownImage ) // Shutdown image may be shown without entering normal state (e.g. charging), so construct here
         {
-        if(showNote)
-            {
-            ShowUiNoteL( ENotChargingNote );
-            }
+        TRACES( RDebug::Print( _L("CSysApAppUi::ShowShutdownImageL: trying CSysApShutdownImage::NewL()") ) );
+        iSysApShutdownImage = CSysApShutdownImage::NewL();
         }
-    else if ( aValue == EChargingStatusChargingComplete )
+    TRACES( RDebug::Print( _L("CSysApAppUi::ShowShutdownImageL: trying CSysApShutdownImage::ShowShutdownImageL()") ) );
+    iSysApShutdownImage->ShowShutdownImageL( aBitmapId );
+   }
+   
+// ----------------------------------------------------------------------------
+// CSysApAppUi::PrepareForShutdownImage()
+// ----------------------------------------------------------------------------
+
+void CSysApAppUi::PrepareForShutdownImage()
+    {
+    TRACES( RDebug::Print( _L("CSysApAppUi::PrepareForShutdownImage() START" ) ) );
+ 
+    // If RD_STARTUP_ANIMATION_CUSTOMIZATION is enabled, the following actions are always taken in PrepareForShutdownAnimation
+#ifndef RD_STARTUP_ANIMATION_CUSTOMIZATION
+    if ( !iAnimationShowingTime ) // actions already taken in PrepareForShutdownAnimation
         {
-        iSysApLightsController->ChargingCompleteL();
+        static_cast<CAknAppUi*>(iEikonEnv->EikAppUi())->KeySounds()->PlaySound( EAvkonSIDPowerOffTone );
+        CancelGlobalListQuery();
         
-        TSysApNoteIds note( EBatteryFullNote );
-        
-        if ( !iSysApUsbChargerDetector.HostOnlyUsbChargingUsed() &&
-             iSysApFeatureManager->Supported( KSysApFeatureIdChargerReminderNotes ) )
-            {
-            note = EBatteryFullUnplugChargerNote;
-            }
-        iSysApUsbChargerDetector.Reset();
-        if(showNote)
+        if ( iSysApPowerKeyMenuObserver )
             {
-            ShowUiNoteL( note );
-            }
-        }
-    else if ( aValue == EChargingStatusNotConnected )
-        {
-        TRACES( RDebug::Print( _L("SysAp: charger removed") ) );
-        iSysApLightsController->ChargerConnectedL( EFalse );
-        
-        if ( !iSysApUsbChargerDetector.HostOnlyUsbChargingUsed() &&
-             iSysApFeatureManager->Supported( KSysApFeatureIdChargerReminderNotes ) )
-            {
-		if(showNote)
-                {
-                ShowUiNoteL( EUnplugChargerNote );
-                }
+            iSysApPowerKeyMenuObserver->Cancel();
             }
-        iSysApUsbChargerDetector.Reset();
-        }
-    else if ( aValue == EChargingStatusNotCharging )
-        {
-        TRACES( RDebug::Print( _L("SysAp: Not charging") ) );
+        
+        // deactivate notifiers before showing the shutdown image
+        AknNotifierController::CancelAllNotifications();
+        AknNotifierController::HideAllNotifications(ETrue);
+        RWindowGroup groupWin = iCoeEnv->RootWin();
+        iCapturedAppskey = groupWin.CaptureKey( EKeyApplication, KModifierMask, KModifierMask );
+        iCapturedAppskeyUpAndDowns = groupWin.CaptureKeyUpAndDowns( EStdKeyApplication0, KModifierMask, KModifierMask );
         }
-    else if ( aValue == EChargingStatusAlmostComplete )
-        {
-        TRACES( RDebug::Print( _L("SysAp: Charging almost complete") ) );
-        }
-    else if ( aValue == EChargingStatusChargingContinued )
-        {
-        //in this case we simply want to scroll the battery bars and not turn light on or show ui note
-        // set lights controller iBatteryEmpty to EFalse
-        iSysApLightsController->BatteryEmptyL( EFalse );
-        TRACES( RDebug::Print( _L("SysAp: charging continues") ) );
-        }
+#endif // RD_STARTUP_ANIMATION_CUSTOMIZATION
+
+#ifndef __SYSAP_MODULE_TEST //to make errors during shutdown sequence being seen more easily
+    iEikonEnv->RootWin().SetOrdinalPosition(0, ECoeWinPriorityAlwaysAtFront );
+    TRACES( RDebug::Print( _L("CSysApAppUi::PrepareForShutdownImage() Show Shutdown image" ) ) );
+    ShowShutdownImage( 1  );//EMbmSysapQgn_startup_screen
+#endif
+    TRACES( RDebug::Print( _L("CSysApAppUi::PrepareForShutdownImage() END" ) ) );
     }
 
 // ----------------------------------------------------------------------------
-// CSysApAppUi::ShowProfileNoteL()
-// ----------------------------------------------------------------------------
-
-void CSysApAppUi::ShowProfileNoteL()
-    {
-    TRACES( RDebug::Print( _L("CSysApAppUi::ShowProfileNoteL") ) );
-
-    if ( UiReady() )
-        {
-        if ( iProfileNote )
-            {
-            // when a call is coming in, there might be a pending "Selected profile"
-            // we don't want to show anymore
-            iProfileNote->CancelNoteL( iProfileNoteId );
-            }
-
-        TBufC<KMaxProfileNameLength> profileName;
-        HBufC* noteStringBuf = NULL;
-        ActiveProfileNameL( profileName.Des() );
-        noteStringBuf = StringLoader::LoadLC( R_TEXT_MODE_SELECTED, profileName, iEikonEnv );
-        TPtr textBuffer = noteStringBuf->Des();
-        AknTextUtils::DisplayTextLanguageSpecificNumberConversion( textBuffer );
-
-        // profile note is constructed when it is needed for the first time
-        if ( !iProfileNote )
-            {
-            iProfileNote = CAknGlobalNote::NewL();
-            iProfileNote->SetTone( EAvkonSIDConfirmationTone );
-            }
-
-        // Set secondary display data if necessary
-        if ( iSysApFeatureManager->CoverDisplaySupported() )
-            {
-            TRACES( RDebug::Print( _L("CSysApAppUi::ShowProfileNoteL - Notifying secondary display") ) );
-            SecondaryDisplay::TProfileName sdProfileName;
-            sdProfileName.Append(profileName.Left(SecondaryDisplay::KProfileNameMaxLen));
-            SecondaryDisplay::TProfileNotePckg pckg(sdProfileName);
-            CAknSDData* sd = CAknSDData::NewL(SecondaryDisplay::KCatSysAp, SecondaryDisplay::ECmdShowProfileNote, pckg);
-            iProfileNote->SetSecondaryDisplayData(sd); // ownership to notifier client
-            }
-
-        iProfileNoteId = iProfileNote->ShowNoteL( EAknGlobalConfirmationNote, textBuffer );
-
-        CleanupStack::PopAndDestroy( ); // noteStringbuf
-
-        iSysApLightsController->ProfileChangedL(); // All notes should always turn lights on.
-        }
-    }
-
-// ----------------------------------------------------------------------------
-// CSysApAppUi::ShowQueryL()
+// CSysApAppUi::OkToInitiateShutdown()
 // ----------------------------------------------------------------------------
 
-void CSysApAppUi::ShowQueryL( const TSysApConfirmationQueryIds aQueryId, const TDesC& aValue )
+TBool CSysApAppUi::OkToInitiateShutdown()
     {
-    CancelGlobalListQuery();
+    TInt swState;
+    RProperty::Get( KPSUidStartup, KPSGlobalSystemState, swState );
 
-    if ( aQueryId == ESysApRestartPhoneQuery )
-        {
-        iDisablePowerkeyMenu = ETrue;
-        // Cancel any other query that might be outstanding (i.e. ESysApRemoveMmcNote),
-        // to avoid multiple overlapping queries causing problems
-        if ( iSysApConfirmationQuery )
-            {
-            iSysApConfirmationQuery->Cancel();
-            }
-
-        if ( !iSysApConfirmationQueryForRestart )
-            {
-            TRACES( RDebug::Print( _L("CSysApAppUi::ShowQueryL: trying CSysApConfirmationQuery::NewL() for restart") ) );
-            iSysApConfirmationQueryForRestart = CSysApConfirmationQuery::NewL( *this );
-            }
-
-        iSysApConfirmationQueryForRestart->ShowQueryL( aQueryId, iEikonEnv );
-        }
-    else
+    if( !iShutdownStarted &&
+        swState == ESwStateStartingCriticalApps ||
+        swState == ESwStateSelfTestOK ||
+        swState == ESwStateSecurityCheck ||
+        swState == ESwStateCriticalPhaseOK ||
+        swState == ESwStateEmergencyCallsOnly ||
+        swState == ESwStateCharging ||
+        swState == ESwStateAlarm ||
+        swState == ESwStateNormalRfOn ||
+        swState == ESwStateNormalRfOff ||
+        swState == ESwStateNormalBTSap ||
+        swState == ESwStateFatalStartupError )
         {
-        if ( !iSysApConfirmationQuery )
-            {
-            TRACES( RDebug::Print( _L("CSysApAppUi::ShowQueryL: trying CSysApConfirmationQuery::NewL()") ) );
-            iSysApConfirmationQuery = CSysApConfirmationQuery::NewL( *this );
-            }
-
-        iSysApConfirmationQuery->ShowQueryL( aQueryId, aValue, iEikonEnv );
-        }
-    }
-
-// ----------------------------------------------------------------------------
-// CSysApAppUi::UpdateBatteryBarsL( const TInt aState )
-// ----------------------------------------------------------------------------
-
-void CSysApAppUi::UpdateBatteryBarsL( const TInt aState )
-    {
-    TInt state( StateOfProperty( KPSUidHWRMPowerState, KHWRMChargingStatus ) );
-    TRACES( RDebug::Print( _L("CSysApAppUi::UpdateBatteryBarsL aState: %d, chargerState:%d"), aState, state ) );
-    HandleUsbCharger( state );
-    if( state == EChargingStatusCharging ||
-        state == EChargingStatusChargingContinued ||
-        state == EChargingStatusAlmostComplete )
-        {
-        if ( !iCharging )
-            {
-            TRACES( RDebug::Print( _L("CSysApAppUi::UpdateBatteryBarsL: Starting Charging") ) );
-            iBatteryNotify->StartChargingL();
-            iCharging = ETrue;
-            }
-
-        // When Avkon supports battery state sending while charging,
-        // add setting battery level here also.
+        iShutdownStarted = ETrue;
+        return ETrue;
         }
     else
         {
-        if ( iCharging )
-            {
-            TRACES( RDebug::Print( _L("CSysApAppUi::UpdateBatteryBarsL: Stopping Charging") ) );
-            iBatteryNotify->StopChargingL();
-            iCharging = EFalse;
-            }
-
-        if( state == KErrUnknown || aState == KErrUnknown )
-            {
-            TRACES( RDebug::Print( _L("CSysApAppUi::UpdateBatteryBarsL: CAknBatteryNotify::SetBatteryLevelL(0)") ) );
-            iBatteryNotify->SetBatteryLevelL( 0 );
-            }
-        else
-            {
-            TRACES( RDebug::Print( _L("CSysApAppUi::UpdateBatteryBarsL: CAknBatteryNotify::SetBatteryLevelL(%d)"), aState - EBatteryLevelLevel0 ) );
-            iBatteryNotify->SetBatteryLevelL( aState - EBatteryLevelLevel0 );
-            }
-        }
-    
-    if ( !iSysApPsmController ) // created here if first state change has not occurred yet
-        {
-        iSysApPsmController = CSysApPsmController::NewL( *this );        
-        }
-
-    if ( iSysApPsmController )
-        {
-        if ( iSysApPsmController->FullPsmEnabled() )
-            {
-            iBatteryNotify->SetBatteryStateL( EAknBatteryIndicatorPowerSave );
-            }
-        else
-            {
-            iBatteryNotify->SetBatteryStateL( EAknBatteryIndicatorNormal );
-            }            
-        }
-        
-    if ( iSysApBatteryInfoController )        
-        {
-        iSysApBatteryInfoController->BatteryLevelUpdatedL();
-        }
-    }
-
-// ----------------------------------------------------------------------------
-// CSysApAppUi::UpdateSignalBarsL()
-// ----------------------------------------------------------------------------
-
-void CSysApAppUi::UpdateSignalBarsL()
-    {
-    UpdateSignalBarsL(iSysApEtelConnector->GetSignalBars());
-    }
-
-// ----------------------------------------------------------------------------
-// CSysApAppUi::UpdateSignalBarsL( const TInt aState )
-// ----------------------------------------------------------------------------
-
-void CSysApAppUi::UpdateSignalBarsL( const TInt aState )
-    {
-    TRACES( RDebug::Print( _L("CSysApAppUi::UpdateSignalBarsL aState: %d"), aState ) );
-
-    if( aState == KAknSignalOffLineMode || (iSysApOfflineModeController->OfflineModeActive() && !iEmergencyCallActive) )
-        {
-        iSignalNotify->SetSignalLevelL( KAknSignalOffLineMode );
-        }
-    else if( aState <= 0 )
-        {
-        // Do not update indicator show zero bars if we should be showing X over bars
-        // This is required for indicator to work correctly in BT SAP mode.
-        // Cannot use check for BT SAP enabled status, as zero bars notify comes before enabled status changes.
-        if ( !iIgnoreZeroNetworkBarNotifications )
-            {
-            iSignalNotify->SetSignalLevelL( 0 );
-            }
-        }
-    else
-        {
-        iSignalNotify->SetSignalLevelL( aState );
-        }
-    }
-
-// ----------------------------------------------------------------------------
-// CSysApAppUi::SetSignalIndicatorL()
-// ----------------------------------------------------------------------------
-
-void CSysApAppUi::SetSignalIndicatorL()
-    {
-    TSysApNetworkMode networkMode( ESysApGSM );
-
-    TInt networkModeFromNetworkInfo( StateOfProperty( KPSUidNetworkInfo, KNWTelephonyNetworkMode ) );
-    if ( networkModeFromNetworkInfo == ENWNetworkModeWcdma )
-        {
-        networkMode = ESysApWCDMA;
-        }
-    else
-        {
-        networkMode = ESysApGSM;
-        }
-
-    TRACES( RDebug::Print( _L("CSysApAppUi::SetSignalIndicatorL: networkMode = %d" ), networkMode ) );
-
-    if( iSysApOfflineModeController->OfflineModeActive() && !iEmergencyCallActive )
-        {
-        // The device is in Offline Mode
-        if ( iSysApFeatureManager->Supported( KSysApFeatureIdGprs_G_Icon ) )
-            {
-            iSignalNotify->SetGprsStateL( EAknSignalGprsIndicatorOff );
-            }
-        else
-            {
-            iSignalNotify->SetCommonPacketDataStateL( EAknSignalCommonPacketDataIndicatorOff );
-            }
-        iSignalNotify->SetWcdmaStateL( EAknSignalWcdmaIndicatorOff );
-        iSignalNotify->SetHsdpaStateL( EAknSignalHsdpaIndicatorOff);
-        }
-    else
-        {
-        // The device is in Online Mode
-        switch ( networkMode )
-            {
-            case ESysApGSM:
-                SetSignalIndicatorGsmL();
-                break;
-
-            case ESysApWCDMA:
-                SetSignalIndicatorWcdmaL();
-                break;
-
-            default:
-                break;
-            }
+        return EFalse;
         }
     }
 
-// ----------------------------------------------------------------------------
-// CSysApAppUi::SetSignalIndicatorGsmL()
-// ----------------------------------------------------------------------------
-void CSysApAppUi::SetSignalIndicatorGsmL()
+
+void CSysApAppUi::PopupNote()
     {
-    TInt signalGprsIndicatorState( 0 );
-    TInt signalIndicatorState( 0 );
-	TInt bearerValue = EBearerUnknown;
-
-	if(iSysApConnectionMonitorObserver)
-		{
-		bearerValue = iSysApConnectionMonitorObserver->GetBearerValue();
-		}
-
-	if(bearerValue == EBearerEdgeGPRS)
-		{
-		TInt egprsStatus = StateOfProperty( KUidSystemCategory, KPSUidGprsStatusValue );
-	    TRACES( RDebug::Print( _L("CSysApAppUi::SetSignalIndicatorGsmL gprsStatus: %d" ), egprsStatus ) );
-	    iSignalNotify->SetWcdmaStateL( EAknSignalWcdmaIndicatorOff );
-	    iSignalNotify->SetHsdpaStateL( EAknSignalHsdpaIndicatorOff );
-	    switch ( egprsStatus )
-	        {
-	        case EPSGprsContextActive:
-	            signalGprsIndicatorState = EAknSignalEdgeIndicatorContext;
-	            signalIndicatorState = EAknSignalCommonPacketDataIndicatorContext;
-	            iGprsActivated = ETrue;
-	            iGprsSuspended = EFalse;
-	            HandleGprsNotesL();
-	            break;
-
-	        case EPSGprsContextActivating:
-	            signalGprsIndicatorState = EAknSignalEdgeIndicatorEstablishingContext;
-	            signalIndicatorState = EAknSignalCommonPacketDataIndicatorEstablishingContext;
-	            iGprsActivated = EFalse;
-	            iGprsSuspended = EFalse;
-	            break;
-
-	        case EPSGprsSuspend:
-	            signalGprsIndicatorState = EAknSignalEdgeIndicatorSuspended;
-	            signalIndicatorState = EAknSignalCommonPacketDataIndicatorSuspended;
-	            iGprsSuspended = ETrue;
-	            HandleGprsNotesL();
-	            break;
-
-	        case EPSGprsAttach:
-	            signalGprsIndicatorState = EAknSignalEdgeIndicatorAttached;
-	            signalIndicatorState = EAknSignalCommonPacketDataIndicatorAttached;
-	            iGprsActivated = EFalse;
-	            iGprsSuspended = EFalse;
-	            break;
-
-	        case EPSGprsMultibleContextActive:
-	            signalGprsIndicatorState = EAknSignalEdgeIndicatorMultipdp;
-	            signalIndicatorState = EAknSignalCommonPacketDataIndicatorMultipdp;
-	            iGprsActivated = ETrue;
-	            iGprsSuspended = EFalse;
-	            HandleGprsNotesL();
-	            break;
-
-	        case EPSGprsUnattached:
-	        default:
-	            signalGprsIndicatorState = EAknSignalEdgeIndicatorOff;
-	            signalIndicatorState = EAknSignalCommonPacketDataIndicatorOff;
-	            iGprsSuspendedNoteShown = EFalse;
-	            iGprsActivated = EFalse;
-	            iGprsSuspended = EFalse;
-	            iCallActivated = EFalse;
-	            break;
-	        }
-        }
-	else
-		{
-
-		TInt gprsStatus = StateOfProperty( KUidSystemCategory, KPSUidGprsStatusValue );
-    	TRACES( RDebug::Print( _L("CSysApAppUi::SetSignalIndicatorGsmL gprsStatus: %d" ), gprsStatus ) );
-    	iSignalNotify->SetWcdmaStateL( EAknSignalWcdmaIndicatorOff );
-    	iSignalNotify->SetHsdpaStateL( EAknSignalHsdpaIndicatorOff );
-    	switch ( gprsStatus )
-            {
-            case EPSGprsContextActive:
-                signalGprsIndicatorState = EAknSignalGprsIndicatorContext;
-                signalIndicatorState = EAknSignalCommonPacketDataIndicatorContext;
-                iGprsActivated = ETrue;
-                iGprsSuspended = EFalse;
-                HandleGprsNotesL();
-                break;
-
-            case EPSGprsContextActivating:
-                signalGprsIndicatorState = EAknSignalGprsIndicatorEstablishingContext;
-                signalIndicatorState = EAknSignalCommonPacketDataIndicatorEstablishingContext;
-                iGprsActivated = EFalse;
-                iGprsSuspended = EFalse;
-                break;
-
-            case EPSGprsSuspend:
-                signalGprsIndicatorState = EAknSignalGprsIndicatorSuspended;
-                signalIndicatorState = EAknSignalCommonPacketDataIndicatorSuspended;
-                iGprsSuspended = ETrue;
-                HandleGprsNotesL();
-                break;
-
-            case EPSGprsAttach:
-                signalGprsIndicatorState = EAknSignalGprsIndicatorAttached;
-                signalIndicatorState = EAknSignalCommonPacketDataIndicatorAttached;
-                iGprsActivated = EFalse;
-                iGprsSuspended = EFalse;
-                break;
-
-            case EPSGprsMultibleContextActive:
-                signalGprsIndicatorState = EAknSignalGprsIndicatorMultipdp;
-                signalIndicatorState = EAknSignalCommonPacketDataIndicatorMultipdp;
-                iGprsActivated = ETrue;
-                iGprsSuspended = EFalse;
-                HandleGprsNotesL();
-                break;
-
-            case EPSGprsUnattached:
-            default:
-                signalGprsIndicatorState = EAknSignalGprsIndicatorOff;
-                signalIndicatorState = EAknSignalCommonPacketDataIndicatorOff;
-                iGprsSuspendedNoteShown = EFalse;
-                iGprsActivated = EFalse;
-                iGprsSuspended = EFalse;
-                iCallActivated = EFalse;
-                break;
-            }
-		}
-
-	if(bearerValue == EBearerEdgeGPRS) //EdgeGPRS connection
-		{
-		if( iSysApFeatureManager->Supported( KSysApFeatureIdUseEdgeGPRSIcon ) )
-	    	{
-	    	iSignalNotify->SetEdgeStateL( signalGprsIndicatorState );
-	    	}
-	    else
-        	{
-        	iSignalNotify->SetCommonPacketDataStateL( signalIndicatorState );
-        	}
-		}
-	else
-		{
-
-	    if ( iSysApFeatureManager->Supported( KSysApFeatureIdGprs_G_Icon ) )
-    	    {
-        	iSignalNotify->SetGprsStateL( signalGprsIndicatorState );
-        	}
-    	else
-        	{
-        	TRACES( RDebug::Print( _L("CSysApAppUi::SetSignalIndicatorGsmL SetCommonPacketDataStateL( %d )" ), signalIndicatorState ) );
-        	iSignalNotify->SetCommonPacketDataStateL( signalIndicatorState );
-        	}
-		}
+    iIgnoreNextPowerKeyUpEvent = ETrue;
+    // TRACES( RDebug::Print( _L("CSysApAppUi::Key was consumed") ) );
+    _LIT(KPowerPressKey,"Short power key");
+    HBufC* aString = HBufC16::NewLC(50);
+    TPtrC aStringPointer = aString->Des();
+    aStringPointer.Set(KPowerPressKey);
+    TRACES( RDebug::Print( _L("CSysApWsClient::RunL(): Key EEventKeyUp 01") ) );   
+    ShowExampleUiNoteL( aStringPointer );  
+    CleanupStack::PopAndDestroy(); // aString
     }
 
-// ----------------------------------------------------------------------------
-// CSysApAppUi::SetSignalIndicatorWcdmaL()
-// ----------------------------------------------------------------------------
-void CSysApAppUi::SetSignalIndicatorWcdmaL()
-    {
-    TInt wcdmaStatus;
-    wcdmaStatus = StateOfProperty( KUidSystemCategory, KPSUidWcdmaStatusValue );
-    TRACES( RDebug::Print( _L("CSysApAppUi::SetSignalIndicatorWcdmaL: wcdmaStatus: %d" ), wcdmaStatus ) );
 
-    if ( iSysApFeatureManager->Supported( KSysApFeatureIdGprs_G_Icon ) )
-        {
-        iSignalNotify->SetGprsStateL( EAknSignalGprsIndicatorOff );
-        }
-    else
-        {
-        iSignalNotify->SetCommonPacketDataStateL( EAknSignalCommonPacketDataIndicatorOff );
-        }
+// ----------------------------------------------------------------------------
+// CSysApAppUi::SetUsbAttachStatus
+// ----------------------------------------------------------------------------
+#ifndef RD_MULTIPLE_DRIVE
+void CSysApAppUi::SetUsbAttachStatus( const TBool aUsbAttached )
+    {
+    // Prevent double beep when USB file transfer gets activated but
+    // allow MMC inserted beep when:
+    // a) USB file transfer is active
+    // b) MMC is not inserted when USB cable is attached
+    iHideNextBeep = ( iMMCInserted && aUsbAttached );
+    }
+#else // RD_MULTIPLE_DRIVE
+void CSysApAppUi::SetUsbAttachStatus( const TBool aUsbAttached )
+    {
+    TRACES( RDebug::Print(
+        _L( "CSysApAppUi::SetUsbAttachStatus: aUsbAttached: %d" ),
+        aUsbAttached ) );
 
-    TInt signalWcdmaIndicatorState;
-    TInt signalHsdpaIndicatorState;
-
-    switch ( wcdmaStatus )
+    if ( aUsbAttached )
         {
-        case EPSWcdmaContextActive:
-            signalWcdmaIndicatorState = EAknSignalWcdmaIndicatorContext;
-            signalHsdpaIndicatorState = EAknSignalHsdpaIndicatorContext;
-            break;
-        case EPSWcdmaContextActivating:
-            signalWcdmaIndicatorState = EAknSignalWcdmaIndicatorEstablishingContext;
-            signalHsdpaIndicatorState = EAknSignalHsdpaIndicatorEstablishingContext;
-            break;
-        case EPSWcdmaSuspend:
-            signalWcdmaIndicatorState = EAknSignalWcdmaIndicatorSuspended;
-            signalHsdpaIndicatorState = EAknSignalHsdpaIndicatorSuspended;
-            break;
-        case EPSWcdmaAttach:
-            signalWcdmaIndicatorState = EAknSignalWcdmaIndicatorAttached;
-            signalHsdpaIndicatorState = EAknSignalHsdpaIndicatorAttached;
-            break;
-        case EPSWcdmaMultipleContextActive:
-            signalWcdmaIndicatorState = EAknSignalWcdmaIndicatorMultipdp;
-            signalHsdpaIndicatorState = EAknSignalHsdpaIndicatorMultipdp;
-            break;
-        case EPSWcdmaUnattached:
-        default:
-            signalWcdmaIndicatorState = EAknSignalWcdmaIndicatorAvailable;
-            signalHsdpaIndicatorState = EAknSignalHsdpaIndicatorAvailable;
-            break;
+          // For ignoring extra beeps caused by USB file transfer
+/*        iSysApDriveList->ResetDrivesInsertBeepIgnored();
+        iSysApDriveList->MarkDrivesInsertBeepIgnored( iInsertedMemoryCards );
+        // Will take care in next sub
+*/        }
+    }
+#endif // RD_MULTIPLE_DRIVE
+
+
+// ----------------------------------------------------------------------------
+// CSysApAppUi::UsbChargerDetector
+// ----------------------------------------------------------------------------
+//
+TSysApUsbChargerDetector& CSysApAppUi::UsbChargerDetector()
+    {
+    return iSysApUsbChargerDetector;
+    }
+
+
+// ----------------------------------------------------------------------------
+// CSysApAppUi::HandleAccessoryDisconnectedL()
+// ----------------------------------------------------------------------------
+
+void CSysApAppUi::HandleAccessoryDisconnectedL()
+    {
+    TRACES( RDebug::Print( _L("CSysApAppUi::HandleAccessoryDisconnectedL()" ) ) );
+
+
+    TAccMode accessoryState(EAccModeHandPortable);
+    if ( iSysApAccessoryObserver )
+        {
+        accessoryState = iSysApAccessoryObserver->GetAccessoryMode();
         }
 
-    TBool showHsdpaAvailable = EFalse;
-
-    if ( iSysApFeatureManager->Supported( KSysApFeatureIdUseHsdpaAvailableIcon ) )
+    if ( accessoryState == EAccModeHandPortable )
         {
-        // HSDPA Resource Availability information is a configurable feature.
-        showHsdpaAvailable = iSysApEtelConnector->HsdpaAvailable();
+        iSysApLightsController->AccessoryConnectedL( EFalse );
+        iSysApCenRepController->SetInt( KCRUidCoreApplicationUIsSysAp, KSysApAccessoryConnected, 0 );
         }
-    
-    TBool isHsdpaBearer = iSysApEtelConnector->IsBearerHsdpa();
-    
-    TRACES( RDebug::Print( _L("CSysApAppUi::SetSignalIndicatorWcdmaL: isHdpaBearer=%d, showHsdpaAvailable=%d" ),
-            isHsdpaBearer, showHsdpaAvailable ) );
-    
-    if ( isHsdpaBearer || showHsdpaAvailable )
-        {
-        iSignalNotify->SetWcdmaStateL( EAknSignalWcdmaIndicatorOff );
-    	iSignalNotify->SetHsdpaStateL( signalHsdpaIndicatorState );
-        }
-    else
-        {
-        iSignalNotify->SetHsdpaStateL( EAknSignalHsdpaIndicatorOff );
-        iSignalNotify->SetWcdmaStateL( signalWcdmaIndicatorState );
-        }
-    }
+
+    SetIhfIndicatorL();
+    SetHacIndicatorL();
 
-// ----------------------------------------------------------------------------
-// CSysApAppUi::HandleGprsNotesL()
-// ----------------------------------------------------------------------------
-
-void CSysApAppUi::HandleGprsNotesL()
-    {
-    TRACES( RDebug::Print( _L("CSysApAppUi::HandleGprsNotesL" ) ) );
-    if ( iSysApFeatureManager->Supported( KSysApFeatureIdGPRSNotes ) )
+    // If lock disabled because of accessory, reactivate it, unless phone call or alarm is ongoing
+    if ( iKeyLockOnBeforeCradle )
         {
-        // In WCDMA system, receiving or making calls has no effect to the possibly
-        // existing PDP contexts i.e. GPRS notes are not needed.
-        TInt networkMode = StateOfProperty( KPSUidNetworkInfo, KNWTelephonyNetworkMode );
-        TRACES( RDebug::Print( _L("CSysApAppUi::HandleGprsNotesL: networkMode %d" ), networkMode ) );
-        if ( networkMode != ENWNetworkModeWcdma )
+        iKeyLockOnBeforeCradle = EFalse;
+        if ( !iKeyLockOnBeforeCall && !iKeyLockOnBeforeAlarm )
             {
-            if ( iGprsActivated && iGprsSuspended && iCallActivated && !iGprsSuspendedNoteShown )
+            if ( !iDeviceLockEnabled )
                 {
-                StartGprsSuspendedTimer();
+                iKeyguardController->EnableKeyguard(ETrue);
                 }
-            else if ( iGprsSuspendedNoteShown && !iGprsSuspended )
+            else
                 {
-                ShowUiNoteL( EGprsResumedNote );
-                iGprsSuspendedNoteShown = EFalse;
-                iGprsSuspended = EFalse;
-                iCallActivated = EFalse;
+                iKeyguardController->EnableKeyguard(EFalse);
                 }
             }
         }
     }
 
-// ----------------------------------------------------------------------------
-// CSysApAppUi::SetIndicatorStateL( TInt aIndicator, TInt aState )
-// ----------------------------------------------------------------------------
-
-void CSysApAppUi::SetIndicatorStateL( const TInt aIndicator, const TInt aState ) const
-    {
-    CAknSmallIndicator* theIndicator = CAknSmallIndicator::NewLC( TUid::Uid( aIndicator ) );
-    theIndicator->SetIndicatorStateL( aState );
-    CleanupStack::PopAndDestroy(); //theIndicator
-    }
 
 // ----------------------------------------------------------------------------
-// CSysApAppUi::GoOnlineL()
+// CSysApAppUi::HandleAccessoryConnectedL()
 // ----------------------------------------------------------------------------
 
-void CSysApAppUi::GoOnlineL( TBool aDoProfileChange )
+void CSysApAppUi::HandleAccessoryConnectedL( TAccMode aAccessoryState )
     {
-    if ( iSysApFeatureManager->OfflineModeSupported() )
+    TRACES( RDebug::Print( _L("CSysApAppUi::HandleAccessoryConnectedL( aAccessoryState: %d ) "), aAccessoryState ) );
+
+    if ( aAccessoryState == EAccModeWirelessHeadset ||
+         aAccessoryState == EAccModeWiredHeadset ||
+         aAccessoryState == EAccModeHeadphones )
+        {
+        }
+    else if ( aAccessoryState == EAccModeLoopset )
+        {
+        }
+    else if ( aAccessoryState == EAccModeTextDevice )
         {
-        TRACES( RDebug::Print( _L("CSysApAppUi::GoOnlineL: going from off-line into on-line: aDoProfileChange=%d" ), aDoProfileChange ) );
-        // in case profile change is not needed, event handling for subsequent profile changes are must be allowed
-        iHandleNextProfileEvent = !aDoProfileChange;
-        iActivateBt = iSysApOfflineModeController->MustBtBeActivated();
+        }
+    else if ( aAccessoryState == EAccModeWirelessCarKit || aAccessoryState == EAccModeWiredCarKit )
+        {
+        }
+    else if ( aAccessoryState == EAccModeTVOut )
+        {
+        }
+    else if (aAccessoryState == EAccModeHDMI )
+            {
+            }
+
+    TInt swState( StateOfProperty( KPSUidStartup, KPSGlobalSystemState ) );
+    TRACES( RDebug::Print( _L("CSysApAppUi::HandleAccessoryConnectedL: swState: %d"), swState ) );
+
+    if( UiReady() || swState == ESwStateSecurityCheck )
+        {
+        iSysApLightsController->AccessoryConnectedL( ETrue );
+        }
 
-        if ( aDoProfileChange )
+    if ( ( ! iSysApOfflineModeController->OfflineModeActive() ))
+        {
+        if ( iSysApCenRepController->GetInt( KCRUidCoreApplicationUIsSysAp, KSysApAccessoryConnected ) < 1 )
+            // accessory not connected already
+             {
+            iSysApCenRepController->SetInt( KCRUidCoreApplicationUIsSysAp, KSysApAccessoryConnected, 1 );
+           }
+        }
+    
+    // Carkit and music stand have also light on permanently option that needs to be checked
+    if( aAccessoryState == EAccModeWiredCarKit || aAccessoryState == EAccModeMusicStand )
+        {
+        // When device is placed on a handsfree cradle, keyguard must be disabled (unless device is locked)
+        // Note: It is assumed that if carkit/music stand is connected, the phone is in the cradle.
+        if ( iKeyLockEnabled || iDeviceLockEnabled || iKeyLockOnBeforeCall || iKeyLockOnBeforeAlarm )
             {
-            TRAPD( err, ActivateProfileL( iSysApCenRepController->GetInt( KCRUidCoreApplicationUIsSysAp, KSysApProfileBeforeOfflineMode ) ) );
-            if ( err == KErrNotFound )
+            iKeyLockOnBeforeCradle = ETrue;
+
+            if ( iKeyLockEnabled && !iDeviceLockEnabled )
                 {
-                // Activate general profile instead, if previously used profile was not found
-                TRACES( RDebug::Print( _L("CSysApAppUi::GoOnlineL: Previously used profile was not found, restoring to general profile" ) ) );
-                ActivateProfileL(KGeneralProfileId);
+                iKeyguardController->DisableKeyguard(EFalse);
+                }
+            }
+        }
+    SetIhfIndicatorL();
+    SetHacIndicatorL();
+    }
+
+
+// ----------------------------------------------------------------------------
+// CSysApAppUi::SetHacIndicatorL()
+// ----------------------------------------------------------------------------
+void CSysApAppUi::SetHacIndicatorL()
+    {
+
+    if ( !iSysApCenRepHacSettingObserver )
+        {
+        // Do nothing if HAC setting observer has not been created yet
+        // This occurs in case some party is trying to set HAC indicator during
+        // ConstructL(), e.g. when switching from offline to online during startup
+        TRACES( RDebug::Print( _L("CSysApAppUi::SetHacIndicatorL: do nothing, HAC observer does not exist yet") ) );
+        return;
+        }
+
+    if ( iSysApCenRepHacSettingObserver->HacMode() )
+        {
+        TBool accessoryConnected ( EFalse );
+
+        TAccMode accMode(EAccModeHandPortable);
+
+        if ( iSysApAccessoryObserver )
+            {
+            accMode = iSysApAccessoryObserver->GetAccessoryMode();
+
+            if ( accMode != EAccModeHandPortable )
+                {
+                accessoryConnected = ETrue;
                 }
             }
 
-        iSysApOfflineModeController->SwitchFromOfflineToOnlineModeL();
-        TRACES( RDebug::Print( _L("CSysApAppUi::GoOnlineL: iActivateBt = %d" ), iActivateBt ) );
-        }
-    }
-
-// ----------------------------------------------------------------------------
-// CSysApAppUi::GoOfflineL()
-// ----------------------------------------------------------------------------
+//        TInt indicatorState = EAknIndicatorStateOn;
 
-void CSysApAppUi::GoOfflineL()
-    {
-    if ( iSysApFeatureManager->OfflineModeSupported() )
-        {
-        TRACES( RDebug::Print( _L("CSysApAppUi::GoOfflineL" ) ) );
-        iHandleNextProfileEvent = EFalse;
-        iDeactivateBt = ETrue;
-        ActivateProfileL( KOfflineModeProfileId );
-        iSysApOfflineModeController->SwitchFromOnlineToOfflineModeL();
-        }
-    }
-
-// ----------------------------------------------------------------------------
-// CSysApAppUi::SwitchFromOnlineToOfflineModeL()
-// ----------------------------------------------------------------------------
-void CSysApAppUi::SwitchFromOnlineToOfflineModeL()
-    {
-/*    if ( iSysApFeatureManager->FmTxSupported() )
-        {
-        TFmTxState state = static_cast<TFmTxState>(StateOfProperty( KPSUidHWRMFmTx, KHWRMFmTxStatus ));
-        switch ( state )
+        if ( !accessoryConnected ) // When accessory is not connected, check offline and call state
             {
-            case EFmTxStateActive:
-            case EFmTxStateInactive:
-            case EFmTxStateScanning:
-                ShowQueryL( ESysApUseFmTxInOfflineQuery ); // show "use fm tx in offline?" if FM TX is on
-                break;
-            
-            default:
-                // do nothing
-                break;                
-            }
-        }
-*/    iSysApOfflineModeController->SwitchFromOnlineToOfflineModeL();
-    }
+            if ( OfflineModeActive() ) // HAC indicator is not shown in offline mode
+                {
+ //               indicatorState = EAknIndicatorStateOff;
+                }
+            else
+                {
+                // during active call with IHF activated HAC indicator is not shown
+                TInt callState( StateOfProperty( KPSUidCtsyCallInformation, KCTsyCallState ) );
+                if ( callState < KErrNone )
+                    {
+                    callState = EPSCTsyCallStateNone;
+                    }
 
-// ----------------------------------------------------------------------------
-// CSysApAppUi::OfflineModeChangedL()
-// ----------------------------------------------------------------------------
-void CSysApAppUi::OfflineModeChangedL()
-    {
-#ifdef SYSAP_USE_STARTUP_UI_PHASE    
-    // if UI is not ready, don't update indicators
-    if ( !UiReady() )
-        {
-        return;
-        }
-#endif // SYSAP_USE_STARTUP_UI_PHASE
-    
-    // Update network bar indicator
-    if ( OfflineModeActive() )
-        {
-        UpdateSignalBarsL( KAknSignalOffLineMode );
+                if ( callState != EPSCTsyCallStateNone && IhfEnabledL() )
+                    {
+ //                   indicatorState = EAknIndicatorStateOff;
+                    }
+                }
+
+            }
+        else
+            {
+            // If an accessory is connected, HAC indicator should not be shown
+//            indicatorState = EAknIndicatorStateOff;
+            }
+
+ //       SetIndicatorStateL( EAknIndicatorHAC, indicatorState );
+
         }
     else
         {
-        UpdateSignalBarsL();    
-        }        
-    
-    // Update network mode indicator
-    SetSignalIndicatorL();
-    
-    // Update HAC indicator
-    SetHacIndicatorL();
+        // If HAC is not active, always disable indicator regardless of accessory state
+ //       SetIndicatorStateL( EAknIndicatorHAC, EAknIndicatorStateOff );
+        }
+
+
     }
 
-// ----------------------------------------------------------------------------
-// CSysApAppUi::OfflineModeActive()
-// ----------------------------------------------------------------------------
-TBool CSysApAppUi::OfflineModeActive()
-    {
-    return iSysApOfflineModeController->OfflineModeActive();
-    }
 
 // ----------------------------------------------------------------------------
 // CSysApAppUi::DoNotActivateBt()
@@ -2258,57 +1375,23 @@
     iSysApOfflineModeController->DoNotActivateBt();
     }
 
-// ----------------------------------------------------------------------------
-// CSysApAppUi::SetBtPowerState()
-// ----------------------------------------------------------------------------
-TInt CSysApAppUi::SetBtPowerState( TBool aBtState )
-    {
-    if ( iSysApBtController )
-        {
-        return iSysApBtController->SetPowerState( aBtState );
-        }
-    else
-        {
-        return KErrNotReady;
-        }
-    }
-
-// ----------------------------------------------------------------------------
-// CSysApAppUi::KeyLockState() const
-// ----------------------------------------------------------------------------
-
-TBool CSysApAppUi::KeyLockState() const
-    {
-    return iKeyLockEnabled;
-    }
 
 // ----------------------------------------------------------------------------
-// CSysApAppUi::DeviceLockState() const
+// CSysApAppUi::IhfEnabledL
 // ----------------------------------------------------------------------------
 
-TBool CSysApAppUi::DeviceLockState() const
-    {
-    return iDeviceLockEnabled;
-    }
-/*
-// ----------------------------------------------------------------------------
-// CSysApAppUi::ChangeFmTxStateL()
-// ----------------------------------------------------------------------------     
-void CSysApAppUi::ChangeFmTxStateL( TBool aEnable )
+TBool CSysApAppUi::IhfEnabledL()
     {
-    // disable fm transmission
-    CHWRMFmTx* fmtx = CHWRMFmTx::NewLC();
-    if ( aEnable )
-       {
-       fmtx->EnableL();
-       }
-    else 
-       {
-       fmtx->DisableL();
-       }
-    CleanupStack::PopAndDestroy( fmtx );
-    } 
-*/
+    TRACES( RDebug::Print( _L("CSysApAppUi::IhfEnabledL(): iSysApAudioRoutingObserver=0x%x"), iSysApAudioRoutingObserver ) );
+
+    if ( !iSysApAudioRoutingObserver ) // create observer if needed
+        {
+        iSysApAudioRoutingObserver = CSysApAudioRoutingObserver::NewL( *this );
+        }
+
+    return iSysApAudioRoutingObserver->IhfEnabled();
+    }
+
 
 // ----------------------------------------------------------------------------
 // CSysApAppUi::SetIhfIndicatorL()
@@ -2334,786 +1417,100 @@
     if( (callState != EPSCTsyCallStateNone && IhfEnabledL() && !accessoryConnected)
         || accMode == EAccModeMusicStand )  // Music stand always shows IHF indicator
         {
-        SetIndicatorStateL( EAknIndicatorIHFActive, EAknIndicatorStateOn );
-
         if ( accMode == EAccModeMusicStand )
             {
-            // hide other accessory indicators to prevent displaying of duplicate icons in some cases
-            // e.g. when wireless hf is connected
-            SetIndicatorStateL( EAknIndicatorLoopset, EAknIndicatorStateOff );
-            SetIndicatorStateL( EAknIndicatorTTY,     EAknIndicatorStateOff );
-            SetIndicatorStateL( EAknIndicatorHeadset, EAknIndicatorStateOff );
-            SetIndicatorStateL( EAknIndicatorHeadsetUnavailable, EAknIndicatorStateOff );
-            SetIndicatorStateL( EAknIndicatorCarkit, EAknIndicatorStateOff );
-            SetIndicatorStateL( EAknIndicatorTvOut, EAknIndicatorStateOff );
-            SetIndicatorStateL(  EAknIndicatorHDMI, EAknIndicatorStateOff );
+            // do nothing
             }
         }
     else
         {
-        SetIndicatorStateL( EAknIndicatorIHFActive, EAknIndicatorStateOff );
-        }
-    }
-
-// ----------------------------------------------------------------------------
-// CSysApAppUi::HandleSmsStorageNotificationL( TBool aSimStoreFull )
-// ----------------------------------------------------------------------------
-
-void CSysApAppUi::HandleSmsStorageNotificationL( TBool aSimStoreFull )
-    {
-    TRACES( RDebug::Print( _L("CSysApAppUi::HandleSmsStorageNotificationL: aSimStoreFull: %d "), aSimStoreFull ) );
-
-    if ( aSimStoreFull )
-        {
-        HBufC* noteStringBuf;
-        noteStringBuf = StringLoader::LoadLC( R_QTN_MEMLO_MEMORY_LOW_SIM_MES, iEikonEnv );
-        TPtr textBuffer = noteStringBuf->Des();
-        iSysApMsgSimMemLowQuery->StartL( textBuffer );
-        CleanupStack::PopAndDestroy();
-        }
-
-    SetEnvelopeIndicatorL();
-    }
-
-// ----------------------------------------------------------------------------
-// CSysApAppUi::HandleNspsRawKeyEventL()
-// ----------------------------------------------------------------------------
-
-void CSysApAppUi::HandleNspsRawKeyEventL()
-    {
-#ifdef __SYSAP_MODULE_TEST
-    ModuleTestShowUiNoteL( _L("Network wakeup from NSPS") );
-#endif
-
-    if ( iSysApEtelConnector )
-        {
-        iSysApEtelConnector->CommandNetCsWakeupOnNsps();
-        }
-    }
-
-// ----------------------------------------------------------------------------
-// CSysApAppUi::HandleNetworkNspsNotification( RMmCustomAPI::TNspsStatus aNspsStatus )
-// ----------------------------------------------------------------------------
-
-void CSysApAppUi::HandleNetworkNspsNotification( RMmCustomAPI::TNspsStatus aNspsStatus )
-    {
-    TRACES( RDebug::Print( _L("CSysApAppUi::HandleNetworkNspsNotification aNspsStatus:%d, iNsps:%d )" ), aNspsStatus, iNsps ) );
-    if( iSysApNspsHandler )
-        {
-        if( aNspsStatus == RMmCustomAPI::ENspsOn )
-            {
-            if( !iNsps )
-                {
-#ifdef __SYSAP_MODULE_TEST
-                TRAPD( err, ModuleTestShowUiNoteL( _L("Setting NSPS on") ) );
-#endif
-                iSysApNspsHandler->SetNspsOn();
-                iNsps = ETrue;
-                }
-            }
-        else if( aNspsStatus == RMmCustomAPI::ENspsOff )
-            {
-            if( iNsps )
-                {
-#ifdef __SYSAP_MODULE_TEST
-                TRAPD( err, ModuleTestShowUiNoteL( _L("Setting NSPS off") ) );
-#endif
-                iSysApNspsHandler->SetNspsOff();
-                iNsps = EFalse;
-                }
-            }
-        }
-    }
-
-// ----------------------------------------------------------------------------
-// CSysApAppUi::HandleMessageTonePlayingQuitability( TInt aTonePlayingStatus )
-// ----------------------------------------------------------------------------
-
-void CSysApAppUi::HandleMessageTonePlayingQuitability( TInt aTonePlayingStatus )
-    {
-    if( iSysApNspsHandler )
-        {
-        if( aTonePlayingStatus == ECoreAppUIsStopTonePlaying )
-            {
-            iSysApNspsHandler->SetMessageToneNotPlaying();
-            }
-        else if( aTonePlayingStatus == ECoreAppUIsTonePlaying )
-            {
-            iSysApNspsHandler->SetMessageTonePlaying();
-            }
-        }
-    }
-
-// ----------------------------------------------------------------------------
-// CSysApAppUi::ActivateKeyeventForwardingForLights()
-// ----------------------------------------------------------------------------
-
-void CSysApAppUi::ActivateKeyeventForwardingForLights(TBool aActivate)
-    {
-    if( iSysApNspsHandler )
-        {
-        if ( aActivate )
-            {
-            iSysApNspsHandler->ActivateKeyeventForwardingForLights();
-            }
-        else
-            {
-            iSysApNspsHandler->DeActivateKeyeventForwardingForLights();
-            }
-        }
-    }
-
-// ----------------------------------------------------------------------------
-// CSysApAppUi::StartShutDownTimerOnAlarmAndChargingStates()
-// ----------------------------------------------------------------------------
-
-void CSysApAppUi::StartShutDownTimerOnAlarmAndChargingStates()
-    {
-    if( !iAlarmOrChargingStateShutdownStarted )
-        {
-        if ( !iTimer )
-            {
-            TRAPD( err, iTimer = CPeriodic::NewL( EPriorityNormal ) );
-
-            if ( err != KErrNone )
-                {
-                TRACES( RDebug::Print( _L("CSysApAppUi::StartShutDownTimerOnAlarmAndChargingStates: CPeriodic::NewL failed: %d"), err ) );
-                return;
-                }
-            }
-        iTimer->Cancel();
-        iTimer->Start( KDelayBeforeShuttingDownInAlarmAndChargingStates,
-                       KDelayBeforeShuttingDownInAlarmAndChargingStates,
-                       TCallBack( DoShutdownOnAlarmStateAfterCallBack, this ) );
-        iAlarmOrChargingStateShutdownStarted = ETrue;
-        }
-    }
-
-// ----------------------------------------------------------------------------
-// CSysApAppUi::DoShutdownOnAlarmStateAfterCallBack( TAny* aObject )
-// ----------------------------------------------------------------------------
-
-TInt CSysApAppUi::DoShutdownOnAlarmStateAfterCallBack( TAny* aObject )
-    {
-    CSysApAppUi* appUi = STATIC_CAST( CSysApAppUi*, aObject );
-
-    if ( appUi->iTimer )
-        {
-        appUi->iTimer->Cancel();
-        }
-
-    TRAP_IGNORE( appUi->DoShutdownL( EFalse, KDummyReason ) );
-
-    return KErrNone;
-    }
-
-#ifndef RD_STARTUP_ANIMATION_CUSTOMIZATION
-// ----------------------------------------------------------------------------
-// CSysApAppUi::StartAnimTiming()
-// ----------------------------------------------------------------------------
-void CSysApAppUi::StartAnimTiming()
-    {
-    TRACES( RDebug::Print( _L("CSysApAppUi::StartAnimTiming() Start animation timer, time %d ms" ), iAnimationShowingTime  ) );
-
-    if ( !iAnimTimer )
-        {
-        TRAPD( err, iAnimTimer = CPeriodic::NewL( EPriorityNormal ) );
-
-        if ( err != KErrNone )
-            {
-            TRACES( RDebug::Print( _L("CSysApAppUi::StartAnimTiming() CPeriodic::NewL failed %d " ), err ) );
-            return;
-            }
-        }
-
-    iAnimTimer->Start(
-        iAnimationShowingTime*KCoefficientToMakeMicroToMilliSeconds,
-        iAnimationShowingTime*KCoefficientToMakeMicroToMilliSeconds,
-        TCallBack( DoStopAnimTiming, this ) );
-    }
-#endif // RD_STARTUP_ANIMATION_CUSTOMIZATION
-
-// ----------------------------------------------------------------------------
-// CSysApAppUi::DoStopAnimTiming( TAny* aObject )
-// ----------------------------------------------------------------------------
-
-TInt CSysApAppUi::DoStopAnimTiming( TAny* aObject )
-    {
-    TInt err(KErrNone);
-    CSysApAppUi* appUi = STATIC_CAST( CSysApAppUi*, aObject );
-
-    // This method could theoretically be called by two timers (iAnimTimer and one in CSysApShutdownAnimation),
-    // so a check is needed to prevent multiple executions.
-    if ( !(appUi->iShutdownContinued) )
-        {
-        appUi->iShutdownContinued = ETrue;
-
-        TRACES( RDebug::Print( _L("CSysApAppUi::DoStopAnimTiming() Animation timer completed or animation skipped" ) ) );
-
-#ifndef RD_STARTUP_ANIMATION_CUSTOMIZATION
-        if ( appUi->iAnimTimer )
-            {
-            appUi->iAnimTimer->Cancel();
-            }
-#endif // RD_STARTUP_ANIMATION_CUSTOMIZATION
-
-        if ( appUi->iTimer )
-            {
-            appUi->iTimer->Cancel();
-            }
-
-        TRACES( RDebug::Print( _L("CSysApAppUi::DoStopAnimTiming() Call ContinueShutdown(...)" ) ) );
-        appUi->ContinueShutdown();
-        TRACES( RDebug::Print( _L("CSysApAppUi::DoStopAnimTiming() end") ) );
-        }
-
-    return err;
-    }
-
-
-// ----------------------------------------------------------------------------
-// CSysApAppUi::StartGprsSuspendedTimer()
-// ----------------------------------------------------------------------------
-
-void CSysApAppUi::StartGprsSuspendedTimer()
-    {
-    TRACES( RDebug::Print( _L("CSysApAppUi::StartGprsSuspendedTimer()") ) );
-    if( !iAlarmOrChargingStateShutdownStarted ) // not relevant if shutting down
-        {
-        if ( !iTimer )
-            {
-            TRAPD( err, iTimer = CPeriodic::NewL( EPriorityNormal ) );
-
-            if ( err != KErrNone )
-                {
-                TRACES( RDebug::Print( _L("CSysApAppUi::StartGprsSuspendedTimer: CPeriodic::NewL failed: %d"), err ) );
-                return;
-                }
-            }
-
-        iTimer->Cancel();
-        iTimer->Start( KDelayBeforeShowingGprsSuspendedNote,
-                       KDelayBeforeShowingGprsSuspendedNote,
-                       TCallBack( ShowGprsSuspendedNoteAfterCallBack, this ) );
+        // do nothing
         }
     }
 
 // ----------------------------------------------------------------------------
-// CSysApAppUi::ShowGprsSuspendedNoteAfterCallBack( TAny* aObject )
+// CSysApAppUi::DoLightsTimeoutChangedL
 // ----------------------------------------------------------------------------
-
-TInt CSysApAppUi::ShowGprsSuspendedNoteAfterCallBack( TAny* aObject )
+void CSysApAppUi::DoLightsTimeoutChangedL( const TInt aTimeout )
     {
-    TRACES( RDebug::Print( _L("CSysApAppUi::ShowGprsSuspendedNoteAfterCallBack") ) );
-
-    CSysApAppUi* appUi = STATIC_CAST( CSysApAppUi*, aObject );
-
-    if ( appUi->iTimer )
-        {
-        appUi->iTimer->Cancel();
-        }
-
-    // Note is needed if call is still active and used network is not WCDMA
-    TInt callType = appUi->StateOfProperty( KPSUidCtsyCallInformation, KCTsyCallType );
-    TInt networkMode = appUi->StateOfProperty( KPSUidNetworkInfo, KNWTelephonyNetworkMode );
-    TRACES( RDebug::Print(
-        _L("CSysApAppUi::ShowGprsSuspendedNoteAfterCallBack: callType %d networkMode %d"),
-        callType, networkMode ) );
-    if ( EPSCTsyCallTypeCSVoice == callType && ENWNetworkModeWcdma != networkMode )
-        {
-        appUi->iGprsSuspendedNoteShown = ETrue;
-        TRAP_IGNORE( appUi->ShowUiNoteL( EGprsSuspendedNote ) );
-        }
-    return KErrNone;
+    iSysApLightsController->DoLightsTimeoutChangedL( aTimeout );
     }
 
+
 // ----------------------------------------------------------------------------
-// CSysApAppUi::HandleAccessoryConnectedL()
+// CSysApAppUi::DoSwStateNormalConstructionL()
 // ----------------------------------------------------------------------------
 
-void CSysApAppUi::HandleAccessoryConnectedL( TAccMode aAccessoryState )
+void CSysApAppUi::DoSwStateNormalConstructionL()
     {
-    TRACES( RDebug::Print( _L("CSysApAppUi::HandleAccessoryConnectedL( aAccessoryState: %d ) "), aAccessoryState ) );
+    // Let's ensure that the lights will remain on for 15 secs after sw state normal
+    User::ResetInactivityTime();
 
-    if ( aAccessoryState == EAccModeWirelessHeadset ||
-         aAccessoryState == EAccModeWiredHeadset ||
-         aAccessoryState == EAccModeHeadphones )
-        {
-        SetIndicatorStateL( EAknIndicatorLoopset, EAknIndicatorStateOff );
-        SetIndicatorStateL( EAknIndicatorTTY,     EAknIndicatorStateOff );
-        SetIndicatorStateL( EAknIndicatorHeadset, EAknIndicatorStateOn );
-        SetIndicatorStateL( EAknIndicatorHeadsetUnavailable, EAknIndicatorStateOff );
-        SetIndicatorStateL( EAknIndicatorCarkit, EAknIndicatorStateOff );
-        SetIndicatorStateL( EAknIndicatorTvOut, EAknIndicatorStateOff );
-        SetIndicatorStateL(  EAknIndicatorHDMI, EAknIndicatorStateOff );
-        }
-    else if ( aAccessoryState == EAccModeLoopset )
-        {
-        SetIndicatorStateL( EAknIndicatorHeadset, EAknIndicatorStateOff );
-        SetIndicatorStateL( EAknIndicatorTTY,     EAknIndicatorStateOff );
-        SetIndicatorStateL( EAknIndicatorLoopset, EAknIndicatorStateOn );
-        SetIndicatorStateL( EAknIndicatorHeadsetUnavailable, EAknIndicatorStateOff );
-        SetIndicatorStateL( EAknIndicatorCarkit, EAknIndicatorStateOff );
-        SetIndicatorStateL( EAknIndicatorTvOut, EAknIndicatorStateOff );
-        SetIndicatorStateL(  EAknIndicatorHDMI, EAknIndicatorStateOff );
-        }
-    else if ( aAccessoryState == EAccModeTextDevice )
+    TRACES( RDebug::Print( _L("CSysApAppUi::DoSwStateNormalConstructionL : START" ) ) );
+
+    // In case of unexpected reset (e.g. hidden boot) the keylock must be enabled silently. Locking is done
+    // prior to time-consuming initializations, because otherwise UI is in unlocked state for a few seconds.
+    if ( iSysApCenRepController->GetInt( KCRUidCoreApplicationUIsSysAp, KSysApKeyguardActive ) == 1  )
         {
-        SetIndicatorStateL( EAknIndicatorHeadset, EAknIndicatorStateOff );
-        SetIndicatorStateL( EAknIndicatorLoopset, EAknIndicatorStateOff );
-        SetIndicatorStateL( EAknIndicatorTTY,     EAknIndicatorStateOn );
-        SetIndicatorStateL( EAknIndicatorHeadsetUnavailable, EAknIndicatorStateOff );
-        SetIndicatorStateL( EAknIndicatorCarkit, EAknIndicatorStateOff );
-        SetIndicatorStateL( EAknIndicatorTvOut, EAknIndicatorStateOff );
-        SetIndicatorStateL(  EAknIndicatorHDMI, EAknIndicatorStateOff );
-        }
-    else if ( aAccessoryState == EAccModeWirelessCarKit || aAccessoryState == EAccModeWiredCarKit )
-        {
-        SetIndicatorStateL( EAknIndicatorHeadset, EAknIndicatorStateOff );
-        SetIndicatorStateL( EAknIndicatorLoopset, EAknIndicatorStateOff );
-        SetIndicatorStateL( EAknIndicatorTTY,     EAknIndicatorStateOff );
-        SetIndicatorStateL( EAknIndicatorHeadsetUnavailable, EAknIndicatorStateOff );
-        SetIndicatorStateL( EAknIndicatorCarkit, EAknIndicatorStateOn );
-        SetIndicatorStateL( EAknIndicatorTvOut, EAknIndicatorStateOff );
-        SetIndicatorStateL(  EAknIndicatorHDMI, EAknIndicatorStateOff );
-        }
-    else if ( aAccessoryState == EAccModeTVOut )
-        {
-        SetIndicatorStateL( EAknIndicatorHeadset, EAknIndicatorStateOff );
-        SetIndicatorStateL( EAknIndicatorLoopset, EAknIndicatorStateOff );
-        SetIndicatorStateL( EAknIndicatorTTY,     EAknIndicatorStateOff );
-        SetIndicatorStateL( EAknIndicatorHeadsetUnavailable, EAknIndicatorStateOff );
-        SetIndicatorStateL( EAknIndicatorCarkit, EAknIndicatorStateOff );
-        SetIndicatorStateL( EAknIndicatorTvOut, EAknIndicatorStateOn );
-        SetIndicatorStateL(  EAknIndicatorHDMI, EAknIndicatorStateOff );
-        }
-    else if (aAccessoryState == EAccModeHDMI )
-            {
-            SetIndicatorStateL( EAknIndicatorHeadset, EAknIndicatorStateOff );
-                    SetIndicatorStateL( EAknIndicatorLoopset, EAknIndicatorStateOff );
-                    SetIndicatorStateL( EAknIndicatorTTY,     EAknIndicatorStateOff );
-                    SetIndicatorStateL( EAknIndicatorHeadsetUnavailable, EAknIndicatorStateOff );
-                    SetIndicatorStateL( EAknIndicatorCarkit, EAknIndicatorStateOff );
-                    SetIndicatorStateL( EAknIndicatorTvOut, EAknIndicatorStateOff);
-                    SetIndicatorStateL(  EAknIndicatorHDMI, EAknIndicatorStateOn );
-            }
-
-    TInt swState( StateOfProperty( KPSUidStartup, KPSGlobalSystemState ) );
-    TRACES( RDebug::Print( _L("CSysApAppUi::HandleAccessoryConnectedL: swState: %d"), swState ) );
-
-    if( UiReady() || swState == ESwStateSecurityCheck )
-        {
-        iSysApLightsController->AccessoryConnectedL( ETrue );
+        TRACES( RDebug::Print( _L("CSysApAppUi::DoSwStateNormalConstructionL: enabling keylock") ) );
+        iKeyguardController->EnableKeyguard(ETrue);
         }
 
-    if ( ( ! iIgnoreAccessorySpecificProfileChanges ) && ( ! iSysApOfflineModeController->OfflineModeActive() ) )
-        {
-        TInt profileId( 0 );
-        TInt currentProfile( 0 );
-        currentProfile = ActiveProfileId();
+    // Initiate bearer change observation
+//    iSysApConnectionMonitorObserver = CSysApConnectionMonitorObserver::NewL( *this );
 
-        if ( iSysApCenRepController->GetInt( KCRUidCoreApplicationUIsSysAp, KSysApAccessoryConnected ) < 1 )
-            // accessory not connected already
-             {
-            iSysApCenRepController->SetInt( KCRUidCoreApplicationUIsSysAp, KSysApAccessoryConnected, 1 );
-            iSysApCenRepController->SetInt( KCRUidCoreApplicationUIsSysAp, KSysApActiveProfileBeforeAccessoryConnected, currentProfile );
-            }
+    TRACES( RDebug::Print( _L("SysAp: trying CSystemLock::NewL" ) ) );
+    iSysApSystemLock = CSystemLock::NewL();
 
-        if ( aAccessoryState == EAccModeWirelessCarKit )
-            {
-            profileId = iSysApCenRepController->ProfileIdForSelectedAccessory( ESysApWirelessCarkit );
-            }
-        else if( aAccessoryState == EAccModeWiredHeadset ||
-                 aAccessoryState == EAccModeWirelessHeadset )
-            {
-            profileId = iSysApCenRepController->ProfileIdForSelectedAccessory( ESysApHeadset );
-            }
-        else if( aAccessoryState == EAccModeLoopset  )
-            {
-            profileId = iSysApCenRepController->ProfileIdForSelectedAccessory( ESysApLoopset );
-            }
-        else if( aAccessoryState == EAccModeTextDevice )
-            {
-            profileId = iSysApCenRepController->ProfileIdForSelectedAccessory( ESysApTty );
-            }
-        else if( aAccessoryState == EAccModeTVOut || aAccessoryState == EAccModeHDMI )
-            {
-            profileId = iSysApCenRepController->ProfileIdForSelectedAccessory( ESysApTvOut );
-            }
-        else if( aAccessoryState == EAccModeHeadphones )
-            {
-            profileId = iSysApCenRepController->ProfileIdForSelectedAccessory( ESysApHeadphones );
-            }
-        else if ( aAccessoryState == EAccModeWiredCarKit )
-            {
-            profileId = iSysApCenRepController->ProfileIdForSelectedAccessory( ESysApCarkit );
-            }
-        else if ( aAccessoryState == EAccModeMusicStand )
-            {
-            profileId = iSysApCenRepController->ProfileIdForSelectedAccessory( ESysApMusicStand );
-            }
-
-        // Carkit and music stand have also light on permanently option that needs to be checked
-        if( aAccessoryState == EAccModeWiredCarKit || aAccessoryState == EAccModeMusicStand )
-            {
-            // When device is placed on a handsfree cradle, keyguard must be disabled (unless device is locked)
-            // Note: It is assumed that if carkit/music stand is connected, the phone is in the cradle.
-            if ( iKeyLockEnabled || iDeviceLockEnabled || iKeyLockOnBeforeCall || iKeyLockOnBeforeAlarm )
-                {
-                iKeyLockOnBeforeCradle = ETrue;
-
-                if ( iKeyLockEnabled && !iDeviceLockEnabled )
-                    {
-                    KeyLock().DisableWithoutNote();
-                    }
-                }
-            }
-
-        if( profileId != KActiveProfile )
-            {
-            /*-1 because the first item in Accessory default profiles shared data values
-            is KActiveProfile and that must be subtracted from the index of profile to be activated*/
-
-            profileId -= 1;
-
-            TRACES( RDebug::Print( _L("CSysApAppUi::HandleAccessoryConnectedL: current profile: %d, accessory profile: %d" ),
-                               currentProfile, profileId ) );
-
-            if ( profileId != currentProfile )
-                {
-                iAccessoryJustConnected = ETrue;
-                iSysApCenRepController->SetInt( KCRUidCoreApplicationUIsSysAp, KSysApProfileUpdateRequired, 1 );
-                ActivateProfileL( profileId );
-                }
-            }
+    
+    if ( iSysApFeatureManager->Supported( KSysApFeatureIdBatteryInfoPopup ) )
+        {
+        iSysApBatteryInfoController = CSysApBatteryInfoController::NewL( iSysApCenRepController->GetInt( KCRUidCoreApplicationUIsConf, 
+                                                                                                     KCoreAppUIsBatteryInformationLowThreshold ) );    
         }
-    SetIhfIndicatorL();
-    SetHacIndicatorL();
+    TRACES( RDebug::Print( _L("CSysApAppUi::DoSwStateNormalConstructionL : END" ) ) );
     }
 
-// ----------------------------------------------------------------------------
-// CSysApAppUi::HandleAccessoryDisconnectedL()
-// ----------------------------------------------------------------------------
-
-void CSysApAppUi::HandleAccessoryDisconnectedL()
-    {
-    TRACES( RDebug::Print( _L("CSysApAppUi::HandleAccessoryDisconnectedL()" ) ) );
 
 
-    TAccMode accessoryState(EAccModeHandPortable);
-    if ( iSysApAccessoryObserver )
-        {
-        accessoryState = iSysApAccessoryObserver->GetAccessoryMode();
-        }
+// ----------------------------------------------------------------------------
+// CSysApAppUi::DoSimChangedFromPreviousBootL()
+// ----------------------------------------------------------------------------
 
-    if ( accessoryState == EAccModeHandPortable )
-        {
-        SetIndicatorStateL( EAknIndicatorTvOut, EAknIndicatorStateOff );
-        SetIndicatorStateL( EAknIndicatorLoopset, EAknIndicatorStateOff );
-        SetIndicatorStateL( EAknIndicatorHeadset, EAknIndicatorStateOff );
-        SetIndicatorStateL( EAknIndicatorTTY,     EAknIndicatorStateOff );
-        SetIndicatorStateL( EAknIndicatorHeadsetUnavailable, EAknIndicatorStateOff );
-        SetIndicatorStateL( EAknIndicatorCarkit, EAknIndicatorStateOff );
-        SetIndicatorStateL(  EAknIndicatorHDMI, EAknIndicatorStateOff );
-
-        iSysApLightsController->AccessoryConnectedL( EFalse );
-
-        if ( ! iIgnoreAccessorySpecificProfileChanges )
-            {
-            TInt activeProfile ( ActiveProfileId() );
+void CSysApAppUi::DoSimChangedFromPreviousBootL()
+    {
+    TRACES( RDebug::Print( _L("CSysApAppUi::DoSimChangedFromPreviousBootL: iSimChangedDone=%d" ), iSimChangedDone ) );
 
-            TInt activeProfileBeforeConnectingAccessory(
-                 iSysApCenRepController->GetInt( KCRUidCoreApplicationUIsSysAp, KSysApActiveProfileBeforeAccessoryConnected )
-                                                        );
-            if ( activeProfileBeforeConnectingAccessory < 0 ) // error
-                {
-                activeProfileBeforeConnectingAccessory = 0; // General Profile
-                }
-            TRACES( RDebug::Print( _L("CSysApAppUi::HandleAccessoryDisconnectedL: active profile now: %d, active profile before: %d," ),
-                                   activeProfile, activeProfileBeforeConnectingAccessory ) );
-
-            if ( iSysApCenRepController->GetInt( KCRUidCoreApplicationUIsSysAp, KSysApProfileUpdateRequired ) == 1 )
-                {
-                iSysApCenRepController->SetInt( KCRUidCoreApplicationUIsSysAp, KSysApProfileUpdateRequired, 0 );
-                if ( activeProfile != activeProfileBeforeConnectingAccessory && ! iSysApOfflineModeController->OfflineModeActive() )
-                    {
-                    ActivateProfileL( activeProfileBeforeConnectingAccessory );
-                    }
-                }
-            iSysApCenRepController->SetInt( KCRUidCoreApplicationUIsSysAp, KSysApAccessoryConnected, 0 );
-            }
-        }
-
-    SetIhfIndicatorL();
-    SetHacIndicatorL();
-
-    // If lock disabled because of accessory, reactivate it, unless phone call or alarm is ongoing
-    if ( iKeyLockOnBeforeCradle )
+    if ( !iSimChangedDone  )
         {
-        iKeyLockOnBeforeCradle = EFalse;
-        if ( !iKeyLockOnBeforeCall && !iKeyLockOnBeforeAlarm )
-            {
-            if ( !iDeviceLockEnabled )
-                {
-                KeyLock().EnableKeyLock();
-                }
-            else
-                {
-                KeyLock().EnableAutoLockEmulation();
-                }
-            }
+        iSimChangedDone = ETrue;
+        CSysApSimChanged* simChanged = CSysApSimChanged::NewL( *this, iEikonEnv->FsSession() );
+        CleanupStack::PushL( simChanged );
+        simChanged->HandleSimChangedL();
+        CleanupStack::PopAndDestroy( simChanged );
         }
     }
 
-// ----------------------------------------------------------------------------
-// CSysApAppUi::HandleAccessoryProfileInStartupL()
-// ----------------------------------------------------------------------------
-
-void CSysApAppUi::HandleAccessoryProfileInStartupL()
-    {
-    TRACES( RDebug::Print( _L( "CSysApAppUi::HandleAccessoryProfileInStartupL" ) ) );
-
-    if ( !iSysApOfflineModeController->OfflineModeActive() )
-        {
-        iIgnoreAccessorySpecificProfileChanges = EFalse;
-        TBool accessoryConnectedInShutdown( EFalse );
-        TInt accessoryTemp( iSysApCenRepController->GetInt( KCRUidCoreApplicationUIsSysAp, KSysApAccessoryConnected ) );
-        if ( accessoryTemp == 1 )
-            {
-            accessoryConnectedInShutdown = ETrue;
-            }
-
-        TBool accessoryConnectedNow ( EFalse );
-
-        TAccMode accessoryState(EAccModeHandPortable);
-        if ( iSysApAccessoryObserver )
-            {
-            accessoryState = iSysApAccessoryObserver->GetAccessoryMode();
-            }
-
-        if ( accessoryState != EAccModeHandPortable )
-            {
-            accessoryConnectedNow = ETrue;
-            }
-        TRACES( RDebug::Print( _L( "CSysApAppUi::HandleAccessoryProfileInStartupL: accessoryConnectedInShutdown: %d, accessoryConnectedNow: %d" ),
-                              accessoryConnectedInShutdown, accessoryConnectedNow ) );
-
-        if ( accessoryConnectedInShutdown && !accessoryConnectedNow )
-            {
-            HandleAccessoryDisconnectedL();
-            }
-        else if ( !accessoryConnectedInShutdown && accessoryConnectedNow )
-            {
-            HandleAccessoryConnectedL( accessoryState );
-            }
-        else if ( !accessoryConnectedNow )
-            {
-            TInt activeProfile ( ActiveProfileId() );
-            iSysApCenRepController->SetInt( KCRUidCoreApplicationUIsSysAp, KSysApActiveProfileBeforeAccessoryConnected, activeProfile );
-            }
-        }
-    }
-
-#ifndef RD_MULTIPLE_DRIVE
-
-// ----------------------------------------------------------------------------
-// CSysApAppUi::ResolveUidFromThread()
-// ----------------------------------------------------------------------------
-TInt32 CSysApAppUi::ResolveUidFromThread( TUint aThreadId ) const
-    {
-    TInt resolvedUid = 0;
-
-    RThread appThread;
-    TInt err = appThread.Open( aThreadId );
-
-    if ( err == KErrNone )
-        {
-        resolvedUid = appThread.SecureId().iId;
-        }
-
-    appThread.Close();
-
-    TRACES( RDebug::Print( _L("CSysApAppUi::ResolveUidFromThread: err=%d, aThreadId=%d, resolvedUid=0x%x"),
-                           err, aThreadId, resolvedUid ) );
-
-    return resolvedUid;
-    }
 
 // ----------------------------------------------------------------------------
-// CSysApAppUi::CloseUIAppsInHotSwapL()
+// CSysApAppUi::IgnoreZeroNetworkBarNotifications
 // ----------------------------------------------------------------------------
-void CSysApAppUi::CloseUIAppsInHotSwapL()
+//
+void CSysApAppUi::IgnoreZeroNetworkBarNotifications(TBool aIgnore)
     {
-    TRACES( RDebug::Print( _L("CSysApAppUi::CloseUIAppsInHotSwapL") ) );
-
-    CArrayFixFlat<TInt>* wgIds=new(ELeave) CArrayFixFlat<TInt>(4);
-    CleanupStack::PushL(wgIds);
-    User::LeaveIfError(iCoeEnv->WsSession().WindowGroupList(0, wgIds));
-    TInt lastEntry=wgIds->Count()-1;
-    TRACES( RDebug::Print( _L( "CSysApAppUi::CloseUIAppsInHotSwapL: Found %d UI applications running." ), lastEntry + 1 ) );
-    TInt numberOfApplicationsToShutDown( 0 );
-    iApplicationScanningRoundNumber++;
-
-    for ( TInt i=lastEntry; i>=0; i--)
-        {
-        CApaWindowGroupName* doomedApp = CApaWindowGroupName::NewLC(iCoeEnv->WsSession(),wgIds->At(i));
-
-        TBool systemApp = doomedApp->IsSystem();
-        TBool hiddenApp = doomedApp->Hidden();
-
-        if ( systemApp || hiddenApp )
-            {
-            TRACES (
-                    TPtrC caption=doomedApp->Caption();
-                    RDebug::Print( _L("CSysApAppUi::CloseUIAppsInHotSwapL: Privileged app \"%S\" UID 0x%x will not be closed, system: %d, hidden: %d" ),
-                                   &caption,
-                                   doomedApp->AppUid().iUid,
-                                   systemApp,
-                                   hiddenApp);
-                    );
-            }
-        else if ( ( iFileManagerCloseDisabled && doomedApp->AppUid().iUid == KFileManagerAppUid ) ||
-                  doomedApp->AppUid().iUid == KAutolockAppUid )
-            {
-            // An additional failure protection: Autolock must not be closed in any circumstances
-            TRACES (
-                    TPtrC caption=doomedApp->Caption();
-                    RDebug::Print( _L("CSysApAppUi::CloseUIAppsInHotSwapL: Privileged app \"%S\" will not be closed, UID 0x%x"),
-                                   &caption,
-                                   doomedApp->AppUid().iUid );
-                    );
-            }
-        else if ( doomedApp->AppUid().iUid == 0 && !iTimeToKill )
-            {
-#ifdef _DEBUG
-            TApaTask task(iCoeEnv->WsSession());
-            task.SetWgId(wgIds->At(i));
-            TUint threadId = (TUint)(task.ThreadId());
-            TInt32 uid = ResolveUidFromThread( threadId );
-            // CApaWindowGroupName stores the application UID, and in early application startup state AppUid()-method returns 0
-            // In order not to accidentally close application that hasn't yet its window group properly set up, decicision whether
-            // to close the application is postponed, in maximum to the end of the waiting period.
-            TRACES ( RDebug::Print( _L("CSysApAppUi::CloseUIAppsInHotSwapL: Unknown app will not be closed yet, threadId=%d, UID 0x%x, size=%d"),
-                                    threadId, uid, sizeof(TApaTask) ) );
-#endif // _DEBUG
-            numberOfApplicationsToShutDown++; // wait note must be displayed
-            }
-        else
-            {
-            numberOfApplicationsToShutDown++;
-            TApaTask* task = new (ELeave) TApaTask(iCoeEnv->WsSession());
-            CleanupDeletePushL(task);
-            task->SetWgId(wgIds->At(i));
-
-            TRACES (
-                    const TDesC& caption = doomedApp->Caption();
-                    const TDesC& docname = doomedApp->DocName();
-                    const TDesC& wgname = doomedApp->WindowGroupName();
-                    TUid uid = doomedApp->AppUid();
-                    RDebug::Print( _L("CSysApAppUi::CloseUIAppsInHotSwapL: Closing app \"%S\" (ThreadId %d, WgId %d, UID 0x%X); Docname: %S, WGName : %S"),
-                                   &caption,
-                                   (TUint)(task->ThreadId()),
-                                   wgIds->At(i),
-                                   uid.iUid,
-                                   &docname,
-                                   &wgname);
-                    );
-
-            ResolveUidFromThread( (TUint)(task->ThreadId()) );
-
-            if ( iApplicationScanningRoundNumber == 1 )
-                {
-                task->EndTask(); // applications are kindly requested to close themselves on the first round
-                }
-            else if ( iTimeToKill )
-                {
-                TBool doKill = ETrue;
-
-                // final check, window group may still be uninitialized so use thread id for checking UID
-                if ( doomedApp->AppUid().iUid == 0 )
-                    {
-                    if ( ResolveUidFromThread( (TUint)(task->ThreadId()) ) == KAutolockAppUid )
-                        {
-                        doKill = EFalse;
-                        }
-                    }
-
-                if ( doKill )
-                    {
-                    TRACES( RDebug::Print( _L("CSysApAppUi::CloseUIAppsInHotSwapL: Killing app \"%S\""), &caption ) );
-                    task->KillTask(); // used after timeout on the last round
-                    }
-                }
-
-            CleanupStack::PopAndDestroy(); // task
-            }
-        CleanupStack::PopAndDestroy();  // doomedApp
-        }
-    CleanupStack::PopAndDestroy(); // wgIds
-
-    if ( numberOfApplicationsToShutDown > 0 && iApplicationScanningRoundNumber <= KMaxExitTimeInHotSwap )
-        {
-        TRACES( RDebug::Print( _L("CSysApAppUi::CloseUIAppsInHotSwapL: Show wait note, unless already showing") ) );
-        if ( !iSysApWaitNote )
-            {
-            HBufC* noteStringBuf = StringLoader::LoadLC( R_QTN_MEMC_WAIT_EJECT, iEikonEnv );
-            iSysApWaitNote = CSysApWaitNote::NewL( iSysApFeatureManager->CoverDisplaySupported() );
-            iSysApWaitNote->ShowNoteL( EClosingApplicationsNote, noteStringBuf );
-            CleanupStack::PopAndDestroy();
-            }
-
-        if ( iApplicationScanningRoundNumber >= KMaxExitTimeInHotSwap )
-            {
-            iTimeToKill = ETrue;
-            }
-
-        if ( !iSysApTimer )
-            {
-            iSysApTimer = new ( ELeave ) CSysApTimer( *this );
-            }
-
-        iSysApTimer->ActivateTimerL( KApplicationScanningInterval );
-        }
-    else
-        {
-        iFileManagerCloseDisabled = EFalse;
-        CompleteAppsShuttingInHotSwapL();
-        }
+    iIgnoreZeroNetworkBarNotifications = aIgnore;
     }
 
-#endif // RD_MULTIPLE_DRIVE
+
 
 // ----------------------------------------------------------------------------
-// CSysApAppUi::TimerExpiredL()
+// CSysApAppUi::SwitchFromOnlineToOfflineModeL()
 // ----------------------------------------------------------------------------
-void CSysApAppUi::TimerExpiredL()
+void CSysApAppUi::SwitchFromOnlineToOfflineModeL()
     {
-#ifndef RD_MULTIPLE_DRIVE
-    CloseUIAppsInHotSwapL();
-#endif // RD_MULTIPLE_DRIVE
+   iSysApOfflineModeController->SwitchFromOnlineToOfflineModeL();
     }
 
-#ifndef RD_MULTIPLE_DRIVE
-// ----------------------------------------------------------------------------
-// CSysApAppUi::CompleteAppsShuttingInHotSwapL()
-// ----------------------------------------------------------------------------
-void CSysApAppUi::CompleteAppsShuttingInHotSwapL()
-    {
-    TRACES( RDebug::Print( _L("CSysApAppUi::CompleteAppsShuttingInHotSwapL iMMCEjectUsed=%d, iMMCInserted=%d"), iMMCEjectUsed, iMMCInserted ) );
-    CancelWaitNote();
-
-    if ( iMMCEjectUsed ) // From Powerkey Menu
-        {
-        DismountMMC();
-        TRACES( RDebug::Print( _L( "CSysApAppUi::CompleteAppsShuttingInHotSwapL: Show note: Remove MMC and press OK...." ) ) );
-        ShowQueryL( ESysApRemoveMmcNote );
-        }
-    else if ( !iMMCInserted ) // The MMC might have been already re-mounted, that's why !iMMCInserted
-        {
-        ShowMMCDismountedDialogL();
-        }
-    }
-#endif // RD_MULTIPLE_DRIVE
 
 // ----------------------------------------------------------------------------
 // CSysApAppUi::InitCloseSimApplicationsL()
@@ -3125,6 +1522,7 @@
     CloseSimApplicationsL();
     }
 
+
 // ----------------------------------------------------------------------------
 // CSysApAppUi::CloseSimApplicationsL()
 // ----------------------------------------------------------------------------
@@ -3186,6 +1584,7 @@
         }
     }
 
+
 // ----------------------------------------------------------------------------
 // CSysApAppUi::DoCloseSimApplicationsAfterCallBack
 // ----------------------------------------------------------------------------
@@ -3203,6 +1602,63 @@
     return KErrNone;
     }
 
+
+// ----------------------------------------------------------------------------
+// CSysApAppUi::NotifyPowerSaveModeL
+// ----------------------------------------------------------------------------
+//
+void CSysApAppUi::NotifyPowerSaveModeL( TSysApPsmStatus aStatus )
+    {
+    TRACES( RDebug::Print( _L("CSysApAppUi::NotifyPowerSaveModeL aStatus: %d"), aStatus ) );
+
+    // cancel any active power saving query because user has changed the state manually
+    // CancelQuery( ESysApBattChargingPowerSavingQuery );
+    // CancelQuery( ESysApBattLowPowerSavingQuery );
+    // will take care in next sub
+    
+    switch ( aStatus )
+        {
+        case MSysApPsmControllerNotifyCallback::EPsmActivationComplete:
+             UpdateBatteryBarsL( StateOfProperty( KPSUidHWRMPowerState, KHWRMBatteryLevel ) );
+             ShowUiNoteL( EPowerSaveModeActivated );
+             break;
+        
+        case MSysApPsmControllerNotifyCallback::EPsmDeactivationComplete:
+             UpdateBatteryBarsL( StateOfProperty( KPSUidHWRMPowerState, KHWRMBatteryLevel ) );
+             ShowUiNoteL( EPowerSaveModeDeactivated );
+             break;
+            
+        case MSysApPsmControllerNotifyCallback::EPsmActivationFailed:
+            ShowUiNoteL( ECannotActivatePowerSaveMode );
+            break;
+            
+        case MSysApPsmControllerNotifyCallback::EPsmDeactivationFailed:
+            ShowUiNoteL( ECannotDeactivatePowerSaveMode );
+            break;            
+        
+        default:
+            break;   
+        }
+    }
+
+
+// ----------------------------------------------------------------------------
+// CSysApAppUi::ShowAlarmIndicatorL()
+// ----------------------------------------------------------------------------
+
+void CSysApAppUi::ShowAlarmIndicatorL( TBool aShowIndicator )
+    {
+    if ( aShowIndicator)
+        {
+        // do nothing
+        }
+    else
+        {
+        // do nothing
+        }
+    }
+
+
 // ----------------------------------------------------------------------------
 // CSysApAppUi::AlertUiAlertingL( const TBool aAlerting )
 // ----------------------------------------------------------------------------
@@ -3224,6 +1680,45 @@
     iSysApLightsController->AlarmOccuredL( aAlerting );
     }
 
+
+// ----------------------------------------------------------------------------
+// CSysApAppUi::HandleForcedLightsVTRequireL( const TInt aLightParameter )
+// ----------------------------------------------------------------------------
+
+void CSysApAppUi::HandleForcedLightsVTRequireL( const TInt aLightsParameter ) const
+    {
+    iSysApLightsController->HandleForcedLightsVTRequireL( aLightsParameter );
+    }
+
+
+// ----------------------------------------------------------------------------
+// CSysApAppUi::HandleForcedLightsSSRequireL( const TInt aLightParameter )
+// ----------------------------------------------------------------------------
+
+void CSysApAppUi::HandleForcedLightsSSRequireL( const TInt aLightsParameter ) const
+    {
+    iSysApLightsController->HandleForcedLightsSSRequireL( aLightsParameter );
+    }
+
+// ---------------------------------------------------------------------------- 
+// CSysApAppUi::HandleForcedLightsATCRequireL( const TInt aLightParameter ) 
+// ---------------------------------------------------------------------------- 
+void CSysApAppUi::HandleForcedLightsATCRequireL( const TInt aLightsParameter ) const 
+    { 
+    iSysApLightsController->HandleForcedLightsATCRequireL( aLightsParameter ); 
+    } 
+
+
+// ----------------------------------------------------------------------------
+// CSysApAppUi::HandleLightsRequireL()
+// ----------------------------------------------------------------------------
+
+void CSysApAppUi::HandleLightsRequireL() const
+    {
+    iSysApLightsController->HandleLightsRequireL();
+    }
+
+
 // ----------------------------------------------------------------------------
 // CSysApAppUi::AlertUiKeyLockOff( const TBool aKeyLockOff )
 // ----------------------------------------------------------------------------
@@ -3243,7 +1738,7 @@
                 iKeyLockOnBeforeAlarm = ETrue;
                 }
             }
-        KeyLock().DisableWithoutNote();
+        iKeyguardController->DisableKeyguard(EFalse);
         }
     else
         {
@@ -3254,61 +1749,33 @@
             TInt callState( StateOfProperty( KPSUidCtsyCallInformation, KCTsyCallState ) );
             if ( callState == EPSCTsyCallStateNone || callState == EPSCTsyCallStateConnected )
                 {
-                KeyLock().EnableAutoLockEmulation();
+                iKeyguardController->EnableKeyguard(EFalse);
                 }
             }
         else if ( iKeyLockOnBeforeAlarm && !iKeyLockOnBeforeCradle && !iKeyLockOnBeforeCall )
             {
-            KeyLock().EnableKeyLock();
+            iKeyguardController->EnableKeyguard(ETrue);
             }
         iKeyLockOnBeforeAlarm = EFalse;
         }
     }
 
-// ----------------------------------------------------------------------------
-// CSysApAppUi::HandleLightsRequireL()
-// ----------------------------------------------------------------------------
-
-void CSysApAppUi::HandleLightsRequireL() const
-    {
-    iSysApLightsController->HandleLightsRequireL();
-    }
 
 // ----------------------------------------------------------------------------
-// CSysApAppUi::HandleRawKeyEventLightsRequireL()
-// ----------------------------------------------------------------------------
-
-void CSysApAppUi::HandleRawKeyEventLightsRequireL() const
-    {
-    iSysApLightsController->HandleRawKeyEventLightsRequireL();
-    }
-
-// ----------------------------------------------------------------------------
-// CSysApAppUi::HandleForcedLightsVTRequireL( const TInt aLightParameter )
+// CSysApAppUi::DoNotEnableKeylock()
 // ----------------------------------------------------------------------------
 
-void CSysApAppUi::HandleForcedLightsVTRequireL( const TInt aLightsParameter ) const
+void CSysApAppUi::DoNotEnableKeylock()
     {
-    iSysApLightsController->HandleForcedLightsVTRequireL( aLightsParameter );
+    if ( !iKeyLockOnBeforeCradle )
+        {
+        iShowkeypadActivatedNoteAfterSoftReject = iKeyLockOnBeforeCall;
+        }
+
+    iKeyLockOnBeforeCall = EFalse;
     }
 
-// ----------------------------------------------------------------------------
-// CSysApAppUi::HandleForcedLightsSSRequireL( const TInt aLightParameter )
-// ----------------------------------------------------------------------------
 
-void CSysApAppUi::HandleForcedLightsSSRequireL( const TInt aLightsParameter ) const
-    {
-    iSysApLightsController->HandleForcedLightsSSRequireL( aLightsParameter );
-    }
-
-// ---------------------------------------------------------------------------- 
-// CSysApAppUi::HandleForcedLightsATCRequireL( const TInt aLightParameter ) 
-// ---------------------------------------------------------------------------- 
-void CSysApAppUi::HandleForcedLightsATCRequireL( const TInt aLightsParameter ) const 
-    { 
-    iSysApLightsController->HandleForcedLightsATCRequireL( aLightsParameter ); 
-    } 
-      
 // ----------------------------------------------------------------------------
 // CSysApAppUi::SwitchLightsOnSoftRejectL()
 // ----------------------------------------------------------------------------
@@ -3317,605 +1784,6 @@
     iSysApLightsController->SwitchLightsOnSoftRejectL();
     }
 
-// ----------------------------------------------------------------------------
-// CSysApAppUi::StateOfProperty()
-// ----------------------------------------------------------------------------
-TInt CSysApAppUi::StateOfProperty( const TUid& aCategory, const TUint aKey ) const
-    {
-    TInt err( KErrNone );
-    TInt value( 0 );
-    err = RProperty::Get( aCategory, aKey, value );
-    if ( err )
-        {
-        TRACES( RDebug::Print( _L("CSysApAppUi::StateOfProperty. RProperty::Get: err=%d"), err ) );
-        return err;
-        }
-    return value;
-    }
-
-// ----------------------------------------------------------------------------
-// CSysApAppUi::BluetoothPowerMode()
-// ----------------------------------------------------------------------------
-TInt CSysApAppUi::BluetoothPowerMode() const
-    {
-    return iSysApCenRepBtObserver->BluetoothPowerMode();
-    }
-
-// ----------------------------------------------------------------------------
-// CSysApAppUi::ActivateProfileL( const TInt aProfileId ) const
-// ----------------------------------------------------------------------------
-
-void CSysApAppUi::ActivateProfileL( const TInt aProfileId ) const
-    {
-    TRACES( RDebug::Print( _L("CSysApAppUi::ActivateProfile aProfileId: %d"), aProfileId ) );
-    //No use of returning the Profile error code since it only tells if the activation was succesfull or not.
-    iProfileEngine->SetActiveProfileL( aProfileId );
-    }
-
-// ----------------------------------------------------------------------------
-// CSysApAppUi::ActivateOnlineProfileL() const
-// ----------------------------------------------------------------------------
-
-void CSysApAppUi::ActivateOnlineProfileL() const
-    {
-    ActivateProfileL( iProfileToBeActivated );
-    }
-
-// ----------------------------------------------------------------------------
-// CSysApAppUi::ActiveProfileNameL( TPtr aProfileName ) const
-// ----------------------------------------------------------------------------
-
-void CSysApAppUi::ActiveProfileNameL( TPtr aProfileName )
-    {
-    TRACES( RDebug::Print( _L("CSysApAppUi::ActiveProfileNameL START") ) );
-    MProfile* profile = iProfileEngine->ActiveProfileL();
-    const MProfileName& mProfileName = profile->ProfileName();
-    aProfileName = mProfileName.Name();
-    profile->Release();
-    TRACES( RDebug::Print( _L("CSysApAppUi::ActiveProfileNameL END") ) );
-    }
-
-// ----------------------------------------------------------------------------
-// CSysApAppUi::CheckSilentModeL()
-// ----------------------------------------------------------------------------
-void CSysApAppUi::CheckSilentModeL()
-    {
-    TBool isSilent( EFalse );
-    MProfile* profile = iProfileEngine->ActiveProfileL();
-    isSilent = profile->IsSilent();
-    profile->Release();
-    if ( isSilent )
-        {
-        TRACES( RDebug::Print( _L("CSysApAppUi::CheckSilentModeL: active profile is SILENT") ) );
-        iSysApLightsController->SetSilentModeOn( ETrue );
-        }
-    else
-        {
-        TRACES( RDebug::Print( _L("CSysApAppUi::CheckSilentModeL: active profile is NOT SILENT") ) );
-        iSysApLightsController->SetSilentModeOn( EFalse );
-        }
-    }
-
-// ----------------------------------------------------------------------------
-// CSysApAppUi::HandleProfileChangedL( const TInt aValue )
-// ----------------------------------------------------------------------------
-void CSysApAppUi::HandleProfileChangedL( const TInt aNewProfileId )
-    {
-    TRACES( RDebug::Print( _L("CSysApAppUi::HandleProfileChangedL: aNewProfileId=%d"), aNewProfileId ) );
-    CheckSilentModeL();
-    if ( iHandleNextProfileEvent )
-        {
-        if ( iAccessoryJustConnected )
-            {
-            iAccessoryJustConnected = EFalse;
-            }
-        else
-            {
-            // if the user delibarately changes profiles, the selected profile will
-            // remain active after disconnecting an accessory.
-            iSysApCenRepController->SetInt( KCRUidCoreApplicationUIsSysAp, KSysApProfileUpdateRequired, 0 );
-            }
-
-		// Added as a part of REQ 415-6750 : Conditional UI-note for "Activated profile"
-        TInt   noNeedToShowTheNote = 0;      // if True, then note should not be shown
-        TInt    err = KErrNone;                            
-                                     
-      	err = RProperty::Get( KPSUidCoreApplicationUIs, KCoreAppUIsProfileActivatedNote, 
-                              noNeedToShowTheNote );   
-		/*
-  		If there occured an error, it is likely caused by the non-existing property. 
-  		So trying to set it only if no error occured for maintaining the default behavior. 
-		*/       
-        if( KErrNone == err )
-            { 
-            TInt error = RProperty::Set( KPSUidCoreApplicationUIs, KCoreAppUIsProfileActivatedNote, 
-                                     ECoreAppUIsProfileActivatedNoteNotShown );
-            }
-               
-        if(!noNeedToShowTheNote)  //    The value doesn't deny the showing, then...
-            {
-            ShowProfileNoteL();
-            }    
-        }
-
-    if ( aNewProfileId != KOfflineModeProfileId )
-        {
-        iActiveProfileBeforeOfflineMode = aNewProfileId;
-        iSysApCenRepController->SetInt( KCRUidCoreApplicationUIsSysAp, KSysApProfileBeforeOfflineMode, aNewProfileId );
-        }
-
-    if ( aNewProfileId == KOfflineModeProfileId && ! iSysApOfflineModeController->OfflineModeActive() )
-        {
-        if ( BtSapEnabled() )
-            {
-            // Choosing "Offline Mode" will disconnect BT SAP
-            // SwitchFromOnlineToOfflineModeL() will be called from CSysApBtSapController
-            iSysApBtSapController->SwitchingToOffline();
-            iSysApBtSapController->Disconnect();
-            }
-        else
-            {
-            SwitchFromOnlineToOfflineModeL();
-            }
-        }
-    else if ( aNewProfileId != KOfflineModeProfileId && iSysApOfflineModeController->OfflineModeActive() )
-        {
-        if ( BtSapEnabled() )
-            {
-            iSysApOfflineModeController->DoNotActivateRF(); // Will be activated after BT SAP disconnection
-            }
-        iSysApOfflineModeController->SwitchFromOfflineToOnlineModeL();
-        }
-    iHandleNextProfileEvent = ETrue;
-    }
-
-
-// ----------------------------------------------------------------------------
-// CSysApAppUi::RestoreProfileL()
-// ----------------------------------------------------------------------------
-
-void CSysApAppUi::RestoreProfileL( const TBool aOffline )
-    {
-    iHandleNextProfileEvent = EFalse;
-    if ( aOffline )
-        {
-        ActivateProfileL( KOfflineModeProfileId );
-        }
-    else
-        {
-        ActivateProfileL( iActiveProfileBeforeOfflineMode );
-        }
-    }
-
-// ----------------------------------------------------------------------------
-// CSysApAppUi::ActiveProfileId()
-// ----------------------------------------------------------------------------
-
-TInt CSysApAppUi::ActiveProfileId()
-    {
-    return iProfileEngine->ActiveProfileId();
-    }
-
-// ----------------------------------------------------------------------------
-// CSysApAppUi::ShowPowerKeyPopUpMenuL()
-// ----------------------------------------------------------------------------
-
-void CSysApAppUi::ShowPowerKeyPopUpMenuL()
-    {
-    TRACES( RDebug::Print(_L("CSysApAppUi::ShowPowerKeyPopUpMenuL iPowerKeyPopupMenuActive: %d" ),
-                          iPowerKeyPopupMenuActive ) );
-
-    if ( !iPowerKeyPopupMenuActive && !iDisablePowerkeyMenu 
-         && iSysApPowerKeyMenuObserver ) // normal state construction has been executed
-        {
-        iPowerKeyPopupMenuDismissed = EFalse;
-        iPowerkeyMenuPowerOffShown = EFalse;
-        CancelGlobalListQuery();
-
-        iGlobalListQuery = CAknGlobalListQuery::NewL();
-
-        iSysApPowerKeyMenuObserver->Cancel();
-
-        CDesCArray* profileNameCDesCArray; // Array for Powerkey Menu items
-
-        RArray<TInt> itemIdArray; // needed for cover UI
-        CleanupClosePushL(itemIdArray);
-
-        // make sure old profile names array is clean
-        delete iProfileNamesArray;
-        iProfileNamesArray = NULL;
-
-        // Must pop iProfileNamesArray here as cannot leave trap harness with uneven push/pop count.
-        // This is because profileEngine doesn't provide non-LC version of ProfilesNamesArrayLC
-        TRAPD( err,
-              iProfileNamesArray = iProfileEngine->ProfilesNamesArrayLC();
-              CleanupStack::Pop();
-             );
-
-        if ( err != KErrNone )
-            {
-            // creating menu failed, return (i.e. just don't show the menu)
-            TRACES( RDebug::Print(_L("CSysApAppUi::ShowPowerKeyPopUpMenuL iProfileEngine->ProfilesNamesArrayLC() ERROR: %d" ), err ) );
-            iNumberOfProfileNamesInPowerKeyMenu = 0;
-            }
-        else
-            {
-            iNumberOfProfileNamesInPowerKeyMenu = iProfileNamesArray->MdcaCount();
-            TRACES( RDebug::Print(_L("CSysApAppUi::ShowPowerKeyPopUpMenuL iNumberOfProfileNamesInPowerKeyMenu: %d" ),
-                                  iNumberOfProfileNamesInPowerKeyMenu ) );
-            }
-
-        if ( BtSapEnabled() )
-            {
-            profileNameCDesCArray = new( ELeave ) CDesCArrayFlat( iNumberOfProfileNamesInPowerKeyMenu + 4 );
-            }
-        else
-            {
-            profileNameCDesCArray = new( ELeave ) CDesCArrayFlat( iNumberOfProfileNamesInPowerKeyMenu + 3 );
-            }
-
-        CleanupStack::PushL( profileNameCDesCArray );
-        profileNameCDesCArray->Reset();
-        HBufC* itemStringBuf;
-
-        TInt powerMenuItemIndex( 0 );
-
-        // "Switch off" menu item
-        if ( !IsEncryptionOperationOngoingL() )
-            {
-        itemStringBuf = StringLoader::LoadLC( R_QTN_PWRC_SWITCH_OFF, iEikonEnv );
-        profileNameCDesCArray->InsertL( 0, itemStringBuf->Des() );
-        CleanupStack::PopAndDestroy(); // itemStringBuf
-        if ( iSysApFeatureManager->CoverDisplaySupported() )
-            {
-            itemIdArray.AppendL(SecondaryDisplay::EPwrMenuItemSwitchOff);
-            }
-            iPowerkeyMenuPowerOffShown = ETrue;
-        powerMenuItemIndex++;
-            }
-
-        iPowerkeyMenuLockKeypadShown     = EFalse;
-        iPowerkeyMenuExitSapShown        = EFalse;
-        iPowerkeyMenuLockSystemShown     = EFalse;
-        iPowerkeyMenuEjectShown          = EFalse;
-
-        iPowerkeyMenuLockKeypadSelection = KErrAccessDenied;
-        iPowerkeyMenuExitSapSelection    = KErrAccessDenied;
-        iPowerkeyMenuLockSystemSelection = KErrAccessDenied;
-
-#ifndef RD_MULTIPLE_DRIVE
-        iPowerkeyMenuEjectSelection     = KErrAccessDenied;
-#else // RD_MULTIPLE_DRIVE
-        iPowerkeyMenuEjectSelectionBase = KErrAccessDenied;
-#endif // RD_MULTIPLE_DRIVE
-
-        // "Lock keypad" menu item
-		
-		TInt callState ( StateOfProperty( KPSUidCtsyCallInformation, KCTsyCallState ) );
-		TInt callType ( StateOfProperty( KPSUidCtsyCallInformation, KCTsyCallType ) );
-		if ( !( callState == EPSCTsyCallStateConnected && callType == EPSCTsyCallTypeH324Multimedia ) )
-			{
-			if ( iSysApFeatureManager->GripNotSupported() ||
-				( (!iSysApFeatureManager->GripNotSupported() ) && ( StateOfProperty( KPSUidHWRM, KHWRMGripStatus ) ==  EPSHWRMGripClosed ) ) )
-				// "Lock keypad" command is shown always when there is no grip, and if there
-				// there is no grip, only when the grip is closed.
-				{
-				if ( CKeyLockPolicyApi::KeyguardAllowed() )
-					{
-					if ( iSysApFeatureManager->PenEnabled() )
-						{
-						itemStringBuf = StringLoader::LoadLC( R_QTN_PWRC_LOCK_DISPLAY, iEikonEnv );
-						}
-					else
-						{
-						itemStringBuf = StringLoader::LoadLC( R_QTN_PWRC_LOCK_KEYS, iEikonEnv );
-						}                
-					profileNameCDesCArray->AppendL( itemStringBuf->Des() );
-					CleanupStack::PopAndDestroy(); // itemStringBuf
-					if ( iSysApFeatureManager->CoverDisplaySupported() )
-						{
-						itemIdArray.AppendL(SecondaryDisplay::EPwrMenuItemLockKeypad);
-						}
-					iPowerkeyMenuLockKeypadShown = ETrue;
-					iPowerkeyMenuLockKeypadSelection = powerMenuItemIndex;
-					powerMenuItemIndex++;
-					}
-				}
-			}
-
-        // "Exit SIM access profile" menu item
-
-        if ( BtSapEnabled() )
-            {
-            TRACES( RDebug::Print(_L( "CSysApAppUi::ShowPowerKeyPopUpMenuL: show \"Exit SIM access profile\" item" ) ) );
-            itemStringBuf = StringLoader::LoadLC( R_QTN_PWRC_EXIT_SIM_ACCESS, iEikonEnv );
-            profileNameCDesCArray->AppendL( itemStringBuf->Des() );
-            CleanupStack::PopAndDestroy(); // itemStringBuf
-            if ( iSysApFeatureManager->CoverDisplaySupported() )
-                {
-                itemIdArray.AppendL(SecondaryDisplay::EPwrMenuItemExitBtSap);
-                }
-            iPowerkeyMenuExitSapShown = ETrue;
-            iPowerkeyMenuExitSapSelection = powerMenuItemIndex;
-            powerMenuItemIndex++;
-            }
-
-        // Profile menu items
-
-        TInt arrayIndex ( 0 );
-        TBufC<KMaxProfileNameLength> profileName;
-
-        for ( arrayIndex = 0; arrayIndex < iNumberOfProfileNamesInPowerKeyMenu; arrayIndex++ )
-            {
-            profileName = iProfileNamesArray->MdcaPoint( arrayIndex );
-            TPtr profileNamePtr = profileName.Des();
-            AknTextUtils::DisplayTextLanguageSpecificNumberConversion( profileNamePtr );
-            profileNameCDesCArray->AppendL( profileNamePtr );
-
-            if ( iSysApFeatureManager->CoverDisplaySupported() )
-                {
-                TInt profileId = ( iProfileNamesArray->ProfileName( arrayIndex ) )->Id();
-                itemIdArray.AppendL(SecondaryDisplay::EPwrMenuItemProfileItemBase+profileId);
-                }
-            powerMenuItemIndex++;
-            }
-
-        // "Lock device" menu item
-
-        callState = StateOfProperty( KPSUidCtsyCallInformation, KCTsyCallState );
-        
-        TInt devLockStatus( EAutolockStatusUninitialized );
-        devLockStatus = StateOfProperty( KPSUidCoreApplicationUIs, KCoreAppUIsAutolockStatus );  // check whether Autolock has been started
-        
-
-        if ( callState == EPSCTsyCallStateNone && devLockStatus != EAutolockStatusUninitialized )
-            {
-            TRACES( RDebug::Print(_L("CSysApAppUi::ShowPowerKeyPopUpMenuL: adding \"Lock device\", devLockStatus=%d" ), devLockStatus ) );
-			iPowerkeyMenuLockSystemShown = ETrue;
-            itemStringBuf = StringLoader::LoadLC( R_QTN_SET_SEC_LOCK_SYSTEM, iEikonEnv );
-            profileNameCDesCArray->AppendL( itemStringBuf->Des() );
-            CleanupStack::PopAndDestroy(); // itemStringBuf
-            if ( iSysApFeatureManager->CoverDisplaySupported() )
-                {
-                itemIdArray.AppendL(SecondaryDisplay::EPwrMenuItemLockDevice);
-                }
-            iPowerkeyMenuLockSystemShown = ETrue;
-            iPowerkeyMenuLockSystemSelection = powerMenuItemIndex;
-            powerMenuItemIndex++;
-            }
-
-        // "Eject MMC" menu item
-
-        TInt propertyValue( StateOfProperty( KPSUidUsbWatcher, KUsbWatcherSelectedPersonality ) );
-
-#ifndef RD_MULTIPLE_DRIVE
-			if ( !IsEncryptionOperationOngoingL() )
-			{
-        if ( iSysApFeatureManager->MmcHotSwapSupported() &&
-             iMMCInserted &&
-             iSysApFeatureManager->EjectRequiredInPowerMenu() &&
-             propertyValue != KUsbPersonalityIdMS )
-            {
-            iPowerkeyMenuEjectShown = ETrue;
-            TRACES( RDebug::Print(_L("CSysApAppUi::ShowPowerKeyPopUpMenuL: adding \"Eject\"" ) ) );
-            itemStringBuf = StringLoader::LoadLC( R_QTN_PWRC_EJECT_MMC, iEikonEnv );
-            profileNameCDesCArray->AppendL( itemStringBuf->Des() );
-            CleanupStack::PopAndDestroy(); // itemStringBuf
-            if ( iSysApFeatureManager->CoverDisplaySupported() )
-                {
-                itemIdArray.AppendL(SecondaryDisplay::EPwrMenuItemEjectMMC);
-                }
-            iPowerkeyMenuEjectShown = ETrue;
-            iPowerkeyMenuEjectSelection = powerMenuItemIndex;
-            powerMenuItemIndex++;
-            }
-        }
-
-#else // RD_MULTIPLE_DRIVE
-			if ( !IsEncryptionOperationOngoingL() )
-			{
-        if ( iSysApFeatureManager->MmcHotSwapSupported() &&
-             iSysApFeatureManager->EjectRequiredInPowerMenu() &&
-             propertyValue != KUsbPersonalityIdMS )
-            {
-            // Reset old eject status and dialog
-            iSysApDriveList->ResetDrivesToEject();
-            if ( iSysApConfirmationQuery )
-                {
-                if ( iSysApConfirmationQuery->CurrentQuery() == ESysApEjectMmcQuery )
-                    {
-                    iSysApConfirmationQuery->Cancel();
-                    }
-                }
-
-            // Append memory cards for eject selection
-            TInt count( iInsertedMemoryCards.Count() );
-            for ( TInt i( 0 ); i < count; ++i )
-                {
-                itemStringBuf = iSysApDriveList->GetFormattedDriveNameLC(
-                    iInsertedMemoryCards[ i ].iDrive,
-                    R_QTN_PWRC_EJECT_MEMORY_STORAGE );
-                profileNameCDesCArray->AppendL( *itemStringBuf );
-                CleanupStack::PopAndDestroy( itemStringBuf );
-
-                if ( iSysApFeatureManager->CoverDisplaySupported() )
-                    {
-                    itemIdArray.AppendL( SecondaryDisplay::EPwrMenuItemEjectItemBase + i );
-                    }
-                }
-            if ( count > 0 )
-                {
-                TRACES( RDebug::Print(_L("CSysApAppUi::ShowPowerKeyPopUpMenuL: added \"Eject\"" ) ) );
-                iPowerkeyMenuEjectShown = ETrue;
-                iPowerkeyMenuEjectSelectionBase = powerMenuItemIndex;
-                powerMenuItemIndex += count;
-                }
-            }
-				}
-#endif // RD_MULTIPLE_DRIVE
-        
-        // Activate/deactive power save mode
-        if ( iSysApPsmController ) // variable feature, not create if power save is not used
-            {
-            TBool showActivate = !(iSysApPsmController->FullPsmEnabled());
-            
-            TInt textId = ( showActivate ? R_QTN_PWRC_ACTIVATE_POWER_SAVING : R_QTN_PWRC_DEACTIVATE_POWER_SAVING );
-            
-            itemStringBuf = StringLoader::LoadLC( textId, iEikonEnv );
-            iSysApPsmController->SetNextUiOperation( showActivate );
-            
-            if ( iSysApFeatureManager->CoverDisplaySupported() )
-                {
-                itemIdArray.AppendL( showActivate ? 
-                                     SecondaryDisplay::EPwrMenuItemActivatePowerSaving :
-                                     SecondaryDisplay::EPwrMenuItemDeactivatePowerSaving );
-                }
-                
-            profileNameCDesCArray->AppendL( itemStringBuf->Des() );
-            CleanupStack::PopAndDestroy( itemStringBuf );
-                
-            iSysApPsmController->SetUiItemId( powerMenuItemIndex );
-            powerMenuItemIndex++;    
-            }
-        
-        TRACES( RDebug::Print(_L("CSysApAppUi::ShowPowerKeyPopUpMenuL NumberOfAllItemsInPowerKeyMenu: %d" ),
-                              profileNameCDesCArray->Count() ) );
-
-        iSysApPowerKeyMenuObserver->Start();
-
-        // Set secondary display data if necessary
-        if ( iSysApFeatureManager->CoverDisplaySupported() )
-            {
-            CAknSDData* sd = CAknSDData::NewL(SecondaryDisplay::KCatSysAp, SecondaryDisplay::ECmdShowPowerKeyListQuery, KNullDesC8);
-            sd->InsertGlobalListQueryItemIdsL(itemIdArray);
-            iGlobalListQuery->SetSecondaryDisplayData(sd); // ownership to notifier client
-            }
-
-        iGlobalListQuery->ShowListQueryL( (MDesCArray*) profileNameCDesCArray,
-                                          iSysApPowerKeyMenuObserver->iStatus,
-                                          KProfileListInitialIndex );
-
-        TRACES( RDebug::Print(_L("CSysApAppUi::ShowPowerKeyPopUpMenuL: list query shown" ) ) );
-
-        CleanupStack::PopAndDestroy( profileNameCDesCArray ); // profileNameCDesCArray
-        TRACES( RDebug::Print(_L("CSysApAppUi::ShowPowerKeyPopUpMenuL: profileNameCDesCArray popped" ) ) );
-
-        CleanupStack::Pop(&itemIdArray);
-        itemIdArray.Close();
-
-        // Without following variable set ETrue powerkey up event would change the hightlighted item to be
-        // the second one instead of the wanted first one.
-        iIgnoreNextPowerKeyUpEvent = ETrue;
-
-        if ( iSysApBatteryInfoController )        
-            {
-            iSysApBatteryInfoController->PowerMenuShownL();
-            }
-        
-        TRACES( RDebug::Print(_L("CSysApAppUi::ShowPowerKeyPopUpMenuL:end" ) ) );
-    }
-}
-
-// ----------------------------------------------------------------------------
-// CSysApAppUi::PowerKeyPopUpMenuSelectionDoneL( TInt aSelection )
-// ----------------------------------------------------------------------------
-
-void CSysApAppUi::PowerKeyPopUpMenuSelectionDoneL( TInt aSelection )
-    {
-    iPowerKeyPopupMenuDismissed = ETrue;
-    iPowerKeyPopupMenuActive = EFalse;
-    TRACES( RDebug::Print(_L("CSysApAppUi::PowerKeyPopUpMenuSelectionDoneL: START aSelection:%d" ), aSelection ) );
-    if ( aSelection == KPowerKeyMenuSelectionCancelled )
-        {
-        TRACES( RDebug::Print(_L("CSysApAppUi::PowerKeyPopUpMenuSelectionDoneL: Powerkey menu cancelled" ) ) );
-        }
-    else if( aSelection < KPowerKeyMenuSelectionCancelled )
-        {
-        iIgnoreNextPowerKeyUpEvent = EFalse;
-        }
-    else
-        {
-        TInt firstProfileItemIndex( 1 + Max( 0, iPowerkeyMenuLockKeypadSelection, iPowerkeyMenuExitSapSelection ) ); // index of "General" profile
-
-        if ( aSelection == KPowerKeyMenuSelectionSwitchOff )
-            {
-            TRACES( RDebug::Print(_L("CSysApAppUi::PowerKeyPopUpMenuSelectionDoneL: \"Switch off\" selected" ) ) );
-            DoShutdownL( EFalse, KDummyReason );
-            }
-
-        else if ( iPowerkeyMenuLockKeypadShown && aSelection == iPowerkeyMenuLockKeypadSelection )
-            {
-            TRACES( RDebug::Print(_L("CSysApAppUi::PowerKeyPopUpMenuSelectionDoneL: \"Lock keypad\" selected" ) ) );
-            KeyLock().EnableKeyLock();
-            }
-
-        else if ( iPowerkeyMenuExitSapShown && aSelection == iPowerkeyMenuExitSapSelection )
-            {
-            TRACES( RDebug::Print(_L("CSysApAppUi::PowerKeyPopUpMenuSelectionDoneL: \"Exit SAP\" selected" ) ) );
-            ShowQueryL( ESysApBtSapDisconnectQuery );
-            }
-
-        else if ( aSelection < firstProfileItemIndex + iNumberOfProfileNamesInPowerKeyMenu )
-            {
-            __ASSERT_DEBUG( iProfileNamesArray, User::Invariant() );
-
-            if ( iProfileNamesArray )
-                {
-                iProfileToBeActivated = ( iProfileNamesArray->ProfileName( aSelection - firstProfileItemIndex ) )->Id();
-
-                TRACES( RDebug::Print(_L("CSysApAppUi::PowerKeyPopUpMenuSelectionDoneL: profile id: %d selected" ), iProfileToBeActivated ) );
-                if ( ! iSysApOfflineModeController->OfflineModeActive() ||
-                    ( iProfileToBeActivated ) == KOfflineModeProfileId )
-                    {
-                    ActivateProfileL( iProfileToBeActivated );
-                    }
-                else
-                    {
-                    // iProfileToBeActivated profile will be activated from iSysApOfflineModeController if ok
-                    iSysApOfflineModeController->GoOnlineIfOkL();
-                    }
-                }
-            }
-
-        else if ( iPowerkeyMenuLockSystemShown && aSelection == iPowerkeyMenuLockSystemSelection )
-            {
-            TRACES( RDebug::Print(_L("CSysApAppUi::PowerKeyPopUpMenuSelectionDoneL: \"Lock system\" selected" ) ) );
-            iSysApSystemLock->SetLockedL();
-            }
-#ifndef RD_MULTIPLE_DRIVE
-        else if ( iPowerkeyMenuEjectShown && aSelection == iPowerkeyMenuEjectSelection )
-            {
-            TRACES( RDebug::Print(_L("CSysApAppUi::PowerKeyPopUpMenuSelectionDoneL: \"Eject\" selected" ) ) );
-            ShowQueryL( ESysApEjectMmcQuery );
-            }
-#else // RD_MULTIPLE_DRIVE
-        else if ( iPowerkeyMenuEjectShown &&
-                aSelection >= iPowerkeyMenuEjectSelectionBase &&
-                aSelection < iPowerkeyMenuEjectSelectionBase + iInsertedMemoryCards.Count() )
-            {
-            iDriveToEject =
-                iInsertedMemoryCards[ aSelection - iPowerkeyMenuEjectSelectionBase ].iDrive;
-            TRACES( RDebug::Print(
-                _L( "CSysApAppUi::PowerKeyPopUpMenuSelectionDoneL: \"Eject\" selected, drive=%d" ),
-                iDriveToEject ) );
-            iSysApDriveList->ResetDrivesToEject();
-            RProperty::Set( KPSUidUikon, KUikMMCInserted, 0 );
-            EjectMMCL();
-            }
-#endif // RD_MULTIPLE_DRIVE
-        else if ( iSysApPsmController && aSelection == iSysApPsmController->UiItemId() )
-            {
-            TRACES( RDebug::Print(_L("CSysApAppUi::PowerKeyPopUpMenuSelectionDoneL: \"Activate|Deactivate power save\" selected" ) ) );
-            iSysApPsmController->DoEnableFullPsm( iSysApPsmController->NextUiOperation() );
-            }
-
-        }
-
-    delete iProfileNamesArray;
-    iProfileNamesArray = NULL;
-
-    TRACES( RDebug::Print(_L("CSysApAppUi::PowerKeyPopUpMenuSelectionDoneL: END" ) ) );
-    }
 
 // ----------------------------------------------------------------------------
 // CSysApAppUi::SetDeviceLockEnabledL( const TBool aLockEnabled )
@@ -3937,7 +1805,7 @@
         {
         if( iKeyLockEnabled )
             {
-            KeyLock().DisableWithoutNote();
+            iKeyguardController->DisableKeyguard(EFalse);
             }
         }
     else
@@ -3949,1788 +1817,159 @@
         // Memory card needs to be unlocked when device is unlocked
         if ( iSysApFeatureManager->MmcHotSwapSupported() )
             {
-            RunUnlockNotifierL();
-            }
-        }
-    }
-
-// ----------------------------------------------------------------------------
-// CSysApAppUi::DoNotEnableKeylock()
-// ----------------------------------------------------------------------------
-
-void CSysApAppUi::DoNotEnableKeylock()
-    {
-    if ( !iKeyLockOnBeforeCradle )
-        {
-        iShowkeypadActivatedNoteAfterSoftReject = iKeyLockOnBeforeCall;
-        }
-
-    iKeyLockOnBeforeCall = EFalse;
-    }
-
-// ----------------------------------------------------------------------------
-// CSysApAppUi::DoShutdownL( const TBool aReset, const TSWStartupReason aSWStartupReason )
-// ----------------------------------------------------------------------------
-
-void CSysApAppUi::DoShutdownL( const TBool aReset, const TInt aResetReason )
-    {
-    TRACES( RDebug::Print(_L("CSysApAppUi::DoShutdownL: aResetReason:%d, aReset:%d" ),
-        aResetReason, aReset ) );
-#ifndef RD_STARTUP_ANIMATION_CUSTOMIZATION
-    TBool animationenabled( EFalse );
-#endif // RD_STARTUP_ANIMATION_CUSTOMIZATION
-
-    if( OkToInitiateShutdown() )
-        {
-        TRACES( RDebug::Print(_L("CSysApAppUi::DoShutdownL: Was OkToToInitiateShutdown" ) ) );
-
-
-        if ( !aReset && iSysApFeatureManager->Supported(KSysApFeatureIdGoodbyeNote) )
-            {
-            TRAPD( ignore, ShowShutdownNoteL() );
-            if ( ignore ) ignore = 0; // hide compiler warning about not using variable
-            }
-
-        if( !aReset )
-            {
-    #ifdef RD_STARTUP_ANIMATION_CUSTOMIZATION
-            TRAPD( err, ShowAnimationL() );
-            if ( err )
-                {
-                TRACES( RDebug::Print(_L("CSysApAppUi::DoShutdownL ShowAnimationL() leaved: %d" ), err ) );
-                CompleteShutdown(aReset, aResetReason);
-                }
-            }
-        else // aReset
-            {
-            CompleteShutdown(aReset, aResetReason);
-            }
-    #else // RD_STARTUP_ANIMATION_CUSTOMIZATION
-            TRAPD( err, animationenabled = ShowAnimationL() );
-            if ( err )
-                {
-                TRACES( RDebug::Print(_L("CSysApAppUi::DoShutdownL ShowAnimationL() leaved: %d" ), err ) );
-                }
-            }
-
-        if ( !animationenabled )
-            {
-            CompleteShutdown(aReset, aResetReason);
-            }
-    #endif // RD_STARTUP_ANIMATION_CUSTOMIZATION
-        }
-    else
-        {
-        TRACES( RDebug::Print(_L("CSysApAppUi::DoShutdownL: Was not OkToToInitiateShutdown" ) ) );
-        }
-    TRACES( RDebug::Print(_L("CSysApAppUi::DoShutdownL: END" ) ) );
-    }
-
-// ----------------------------------------------------------------------------
-// CSysApAppUi::ContinueShutdown()
-// ----------------------------------------------------------------------------
-
-void CSysApAppUi::ContinueShutdown()
-    {
-    TRACES( RDebug::Print(_L("CSysApAppUi::ContinueShutdown() started" ) ) );
-    CompleteShutdown();
-    TRACES( RDebug::Print(_L("CSysApAppUi::ContinueShutdown() completed" ) ) );
-    }
-
-// ----------------------------------------------------------------------------
-// CSysApAppUi::ShowAnimationL()
-// ----------------------------------------------------------------------------
-
-#ifdef RD_STARTUP_ANIMATION_CUSTOMIZATION
-void
-#else // RD_STARTUP_ANIMATION_CUSTOMIZATION
-TBool
-#endif // RD_STARTUP_ANIMATION_CUSTOMIZATION
-CSysApAppUi::ShowAnimationL()
-    {
-    TRACES( RDebug::Print(_L("CSysApAppUi::ShowAnimationL(): START" ) ) );
-
-    TRACES( RDebug::Print( _L("CSysApAppUi::ShowAnimationL: Initialise shutdown animation") ) );
-
-#ifdef RD_STARTUP_ANIMATION_CUSTOMIZATION
-
-    PrepareForShutdownAnimation();
-
-    iSysApShutdownAnimation = CSysApShutdownAnimation::NewL( *iSysApShutdownImage );
-    iSysApShutdownAnimation->Play( TCallBack( DoStopAnimTiming, this ) );
-
-    TRACES( RDebug::Print(_L("CSysApAppUi::ShowAnimationL(): End" ) ) );
-
-#else // RD_STARTUP_ANIMATION_CUSTOMIZATION
-    iSysApShutdownAnimation = CSysApShutdownAnimation::NewL( this );
-    AddToStackL( iSysApShutdownAnimation );
-    iAnimationShowingTime = iSysApShutdownAnimation->ShowingTime();
-    TRACES( RDebug::Print( _L("CSysApAppUi::ShowAnimationL: Shutdown animation initialised. Animation time = %d") ,iAnimationShowingTime) );
-
-    TBool ret_val( EFalse );
-
-    if ( iAnimationShowingTime )
-        {
-        if ( iSysApFeatureManager->CoverDisplaySupported() )
-            {
-            // Construct mediator observer
-            iSysApMediatorObserver = CSysApMediatorObserver::NewL( this );
-
-            // Sync animation
-            TInt err = iSysApMediatorObserver->SyncShutdownAnimation();
-
-            if ( err != KErrNone )
-                {
-                // Pretend coverUI synced instantly if error in issuing command.
-                ShutdownAnimationSyncOK();
-                }
-            }
-        else
-            {
-            // Pretend coverUI synced instantly when it is not supported.
-            ShutdownAnimationSyncOK();
-            }
-
-        ret_val = ETrue;
-        }
-
-    TRACES( RDebug::Print(_L("CSysApAppUi::ShowAnimationL(): returns: %d" ),ret_val ) );
-    return ret_val;
-#endif // RD_STARTUP_ANIMATION_CUSTOMIZATION
-    }
-
-#ifndef RD_STARTUP_ANIMATION_CUSTOMIZATION
-// ----------------------------------------------------------------------------
-// CSysApAppUi::ShutdownAnimationSyncOK()
-// ----------------------------------------------------------------------------
-
-void CSysApAppUi::ShutdownAnimationSyncOK()
-    {
-    TRACES( RDebug::Print(_L("CSysApAppUi::ShutdownAnimationSyncOK(): Call PrepareForShutdownAnimation()" ) ) );
-    PrepareForShutdownAnimation();//SysAp's internal preparation for ShutDown with animation
-    TRACES( RDebug::Print(_L("CSysApAppUi::ShutdownAnimationSyncOK(): Called PrepareForShutdownAnimation()" ) ) );
-    }
-#endif // RD_STARTUP_ANIMATION_CUSTOMIZATION
-
-// ----------------------------------------------------------------------------
-// CSysApAppUi::SkipShutdownAnimation()
-// ----------------------------------------------------------------------------
-
-void CSysApAppUi::SkipShutdownAnimation()
-    {
-    TRACES( RDebug::Print(_L("CSysApAppUi::SkipShutdownAnimation() " ) ) );
-
-#ifdef RD_STARTUP_ANIMATION_CUSTOMIZATION
-    if ( iSysApShutdownAnimation )
-        {
-        iSysApShutdownAnimation->Cancel();
-        }
-#else // RD_STARTUP_ANIMATION_CUSTOMIZATION
-    if ( iAnimationShowingTime )
-        {
-        iSysApShutdownAnimation->EndAnimation();
-        }
-#endif // RD_STARTUP_ANIMATION_CUSTOMIZATION
-    }
-
-// ----------------------------------------------------------------------------
-// CSysApAppUi::NotifyShutdownAnimationSkip()
-// ----------------------------------------------------------------------------
-
-void CSysApAppUi::NotifyShutdownAnimationSkip()
-    {
-    TRACES( RDebug::Print(_L("CSysApAppUi::NotifyShutdownAnimationSkip() " ) ) );
-
-    if ( iSysApMediatorObserver )
-        {
-        iSysApMediatorObserver->ShutdownAnimationSkipped();
-        }
-    }
-
-// ----------------------------------------------------------------------------
-// CSysApAppUi::CompleteShutdown()
-// ----------------------------------------------------------------------------
-
-void CSysApAppUi::CompleteShutdown( const TBool aReset, const TInt aResetReason )
-    {
-    TRACES( RDebug::Print(_L("CSysApAppUi::CompleteShutdown(): START" ) ) );
-
-    PrepareForShutdownImage();//SysAp's internal preparation for ShutDown with image
-
-    FreeResources();
-
-    if ( aReset )
-        {
-        __ASSERT_DEBUG( aResetReason >= RStarterSession::ELanguageSwitchReset &&
-                        aResetReason <= RStarterSession::EDataRestoreReset,
-                        User::Invariant() );
-        StarterSession().Reset( static_cast<RStarterSession::TResetReason>( aResetReason ) );
-        }
-    else
-        {
-        StarterSession().Shutdown();
-        }
-
-    StarterSession().Close();
-
-    TRACES( RDebug::Print(_L("CSysApAppUi::CompleteShutdown(): END" ) ) );
-    }
-
-#ifndef SYSAP_USE_STARTUP_UI_PHASE
-// ----------------------------------------------------------------------------
-// CSysApAppUi::DoStateChangedL(const RStarterSession::TGlobalState aSwState)
-// This method is not called after boot has finished.
-// ----------------------------------------------------------------------------
-
-void CSysApAppUi::DoStateChangedL(const RStarterSession::TGlobalState aSwState)
-    {
-    TRACES( RDebug::Print(_L("CSysApAppUi::DoStateChangedL: %d" ), aSwState ) );
-
-    switch ( aSwState )
-        {
-        case RStarterSession::ENormal:
-            SetStatusPaneLayoutL( ESysApNormal );
-            break;
-        case RStarterSession::ECharging:
-            SetStatusPaneLayoutL( ESysApCharging );
-            break;
-        case RStarterSession::EAlarm:
-            SetStatusPaneLayoutL( ESysApAlarm );
-            break;
-        default:
-            break;
-        };
-
-    TRAPD( simChangedErr, DoSimChangedFromPreviousBootL() );
-    TRACES( RDebug::Print( _L("CSysApAppUi::DoStateChangedL: simChangedErr = %d" ), simChangedErr ) );
-    simChangedErr = simChangedErr; // suppress 'variable not used' warning
-    LogsObserverL().HandleSimChangedCheckDoneL();
-
-    if ( iSysApFeatureManager->PowerSaveSupported() )
-        {
-        // create controller before checking battery state, so that power saving can be enabled during boot if needed
-        if ( !iSysApPsmController ) // created only in first state change
-            {
-            iSysApPsmController = CSysApPsmController::NewL( *this );        
-            }
-
-        // in charger boot explicitly disable partial power save mode
-        if ( aSwState == RStarterSession::ECharging && !iCharging )
-            {
-            iSysApPsmController->ChargerConnected();
-            iSysApPsmController->DoEnablePartialPsm( EFalse ); // disable partial power save now
+            // RunUnlockNotifierL();
+            // Need to handle feature for unlocking the MMC card
             }
         }
-
-    TInt state( StateOfProperty( KPSUidHWRMPowerState, KHWRMBatteryLevel ) );
-    //Also Charging status will be updated with the following function.
-    UpdateBatteryBarsL( state );
-
-    if( IsStateNormal() )
-        {
-        TRACES( RDebug::Print(_L("CSysApAppUi::DoStateChangedL to normal state.") ) );
-
-        DoSwStateNormalConstructionL();
-
-        InitializeStatusPaneAreaL();
-        CheckSilentModeL();
-        HandleAccessoryProfileInStartupL();
-
-        if ( iSysApFeatureManager->MmcSupported() )
-            {
-#ifndef RD_MULTIPLE_DRIVE
-            MountMMC();
-            MMCStatusChangedL();
-            iHideFirstBeep = EFalse;
-#else // RD_MULTIPLE_DRIVE
-            iSysApDriveList->MountDrive( iSysApDriveList->DefaultMemoryCard() );
-            UpdateInsertedMemoryCardsL();
-#endif // RD_MULTIPLE_DRIVE
-            }
-        if ( iSysApFeatureManager->MmcHotSwapSupported() )
-            {
-            iSysApMMCObserver->StartMountObserver();
-            }
-
-        
-        if ( iSysApPsmController )
-            {
-            if ( iCharging ) // if charger is connected on boot PSM queries may need to be shown
-                {
-                HandleChargingStatusL( StateOfProperty( KPSUidHWRMPowerState, KHWRMChargingStatus ) );
-                }
-            }
-        
-        TInt batteryStatus = StateOfProperty( KPSUidHWRMPowerState, KHWRMBatteryStatus );
-        TRACES( RDebug::Print(_L("CSysApAppUi::DoStateChangedL: batteryStatus %d" ), batteryStatus ) );
-        if(  batteryStatus == EBatteryStatusLow || batteryStatus == EBatteryStatusEmpty )
-            {
-            // low and empty battery states are informed to the user in device startup
-            HandleBatteryStatusL( batteryStatus );
-            }
-        else if ( iSysApPsmController && !iCharging )
-        	{
-				TRACES( RDebug::Print(_L("CSysApAppUi::DoStateChangedL: batteryStatus %d, iCharging %d -> disable partial psm" ), batteryStatus, iCharging ) );
-
-				iSysApPsmController->BatteryLow( EFalse );
-				iSysApPsmController->DoEnablePartialPsm( EFalse );
-			}
-
-        iSysApBtController = CreateSysApBtControllerL( *this );
-        iSysApBtSapController = CreateSysApBtSapControllerL( *this );
-
-        if ( iActivateBt )
-            {
-            TRACES( RDebug::Print(_L("CSysApAppUi::DoStateChangedL Activating BT" ) ) );
-            SetBtPowerState( ETrue );
-            }
-
-        if ( iDeactivateBt )
-            {
-            TRACES( RDebug::Print(_L("CSysApAppUi::DoStateChangedL Deactivating BT" ) ) );
-            SetBtPowerState( EFalse );
-            }
-        iSysApLocationPrivacyIndicator = CreateSysApLocationPrivacyIndicatorL( *this );
-        iSysApLocationPrivacyIndicator->InitL();
-
-        if ( ! iSysApUsbIndicatorController )
-            {
-            TRAPD ( usbErr, iSysApUsbIndicatorController = CreateSysApUsbIndicatorL( *this ) );
-            if ( usbErr )
-                {
-                TRACES( RDebug::Print(_L("CSysApAppUi::DoStateChangedL: error in constructing USB ind. controller %d" ), usbErr ) );
-                }
-            }
-
-        // Other late initializations.
-        // In order to prevent unexpected behaviour e.g. in OOM situations, these calls are made to ensure
-        // that the services are connected when they are needed for the first time.
-        if ( !StarterSession().Handle() )
-            {
-            User::Leave( KErrBadHandle );
-            }
-
-        if ( !KeyLock().Handle() )
-            {
-            User::Leave( KErrBadHandle );
-            }
-
-#ifdef __SYSAP_MODULE_TEST
-        ModuleTestShowUiNoteL( _L("SysAp: SW state normal!") );
-#endif
-        }
-
-    // Allow lights
-    iSysApLightsController->AllowLightsOn();
-    }
-
-#else // SYSAP_USE_STARTUP_UI_PHASE
-
-// ----------------------------------------------------------------------------
-// CSysApAppUi::HandleUiReadyAfterBootL()
-// Called when startup UI activities has been finished
-// ----------------------------------------------------------------------------
-
-void CSysApAppUi::HandleUiReadyAfterBootL()
-    {
-    TRACES( RDebug::Print(_L("CSysApAppUi::HandleUiReadyAfterBootL" ) ) );
-    
-    SetStatusPaneLayoutL( ESysApNormal );
-    
-    TInt state( StateOfProperty( KPSUidHWRMPowerState, KHWRMBatteryLevel ) );
-    //Also Charging status will be updated with the following function.
-    UpdateBatteryBarsL( state );
-    
-    DoSwStateNormalConstructionL();
-
-    InitializeStatusPaneAreaL();
-    CheckSilentModeL();
-    HandleAccessoryProfileInStartupL();
-    
-    if ( iSysApFeatureManager->MmcSupported() )
-        {
-#ifndef RD_MULTIPLE_DRIVE
-        MountMMC();
-        MMCStatusChangedL();
-        iHideFirstBeep = EFalse;
-#else // RD_MULTIPLE_DRIVE
-        iSysApDriveList->MountDrive( iSysApDriveList->DefaultMemoryCard() );
-        UpdateInsertedMemoryCardsL();
-#endif // RD_MULTIPLE_DRIVE
-        }
-    
-    if ( iSysApFeatureManager->MmcHotSwapSupported() )
-        {
-        iSysApMMCObserver->StartMountObserver();
-        }
-
-    if ( iSysApPsmController )
-        {
-        if ( iCharging ) // if charger is connected on boot PSM queries may need to be shown
-            {
-            HandleChargingStatusL( StateOfProperty( KPSUidHWRMPowerState, KHWRMChargingStatus ) );
-            }
-        }
-    
-    TInt batteryStatus = StateOfProperty( KPSUidHWRMPowerState, KHWRMBatteryStatus );
-    TRACES( RDebug::Print(_L("CSysApAppUi::HandleUiReadyAfterBootL: batteryStatus %d" ), batteryStatus ) );
-    if(  batteryStatus == EBatteryStatusLow || batteryStatus == EBatteryStatusEmpty )
-        {
-        // low and empty battery states are informed to the user in device startup
-        HandleBatteryStatusL( batteryStatus );
-        }
-    else if ( iSysApPsmController && !iCharging )
-      	{
-		    TRACES( RDebug::Print(_L("CSysApAppUi::HandleUiReadyAfterBootL: batteryStatus %d, iCharging %d -> disable partial psm" ), batteryStatus, iCharging ) );
-
-			iSysApPsmController->BatteryLow( EFalse );
-			iSysApPsmController->DoEnablePartialPsm( EFalse );
-        }
-
-    iSysApLocationPrivacyIndicator = CreateSysApLocationPrivacyIndicatorL( *this );
-    iSysApLocationPrivacyIndicator->InitL();
-
-    if ( ! iSysApUsbIndicatorController )
-        {
-        TRAPD ( usbErr, iSysApUsbIndicatorController = CreateSysApUsbIndicatorL( *this ) );
-        if ( usbErr )
-            {
-            TRACES( RDebug::Print(_L("CSysApAppUi::HandleUiReadyAfterBootL: error in constructing USB ind. controller %d" ), usbErr ) );
-            }
-        }
-    }
-
-// ----------------------------------------------------------------------------
-// CSysApAppUi::DoStateChangedL(const RStarterSession::TGlobalState aSwState)
-// This method is not called after boot has finished.
-// ----------------------------------------------------------------------------
-
-void CSysApAppUi::DoStateChangedL(const RStarterSession::TGlobalState aSwState)
-    {
-    TRACES( RDebug::Print(_L("CSysApAppUi::DoStateChangedL: %d" ), aSwState ) );
-
-    switch ( aSwState )
-        {
-        case RStarterSession::ENormal:
-            // status pane layout will updated when UI is ready
-            break;
-        case RStarterSession::ECharging:
-            SetStatusPaneLayoutL( ESysApCharging );
-            break;
-        case RStarterSession::EAlarm:
-            SetStatusPaneLayoutL( ESysApAlarm );
-            break;
-        default:
-            break;
-        };
-
-    TRAPD( simChangedErr, DoSimChangedFromPreviousBootL() );
-    TRACES( RDebug::Print( _L("CSysApAppUi::DoStateChangedL: simChangedErr = %d" ), simChangedErr ) );
-    simChangedErr = simChangedErr; // suppress 'variable not used' warning
-    LogsObserverL().HandleSimChangedCheckDoneL();
-
-    if ( iSysApFeatureManager->PowerSaveSupported() )
-        {
-        // create controller before checking battery state, so that power saving can be enabled during boot if needed
-        if ( !iSysApPsmController ) // created only in first state change
-            {
-            iSysApPsmController = CSysApPsmController::NewL( *this );        
-            }
-
-        // in charger boot explicitly disable partial power save mode
-        if ( aSwState == RStarterSession::ECharging )
-            {
-            iSysApPsmController->ChargerConnected();
-            iSysApPsmController->DoEnablePartialPsm( EFalse ); // disable partial power save now
-            }
-        }
-
-    if ( aSwState == RStarterSession::ECharging || aSwState == RStarterSession::EAlarm )
-        {
-        TInt state( StateOfProperty( KPSUidHWRMPowerState, KHWRMBatteryLevel ) );
-        //Also Charging status will be updated with the following function.
-        UpdateBatteryBarsL( state );    
-        }
-        
-    if( IsStateNormal() )
-        {
-        TRACES( RDebug::Print(_L("CSysApAppUi::DoStateChangedL to normal state.") ) );
-
-        iSysApBtController = CreateSysApBtControllerL( *this );
-        iSysApBtSapController = CreateSysApBtSapControllerL( *this );
-
-        if ( iActivateBt )
-            {
-            TRACES( RDebug::Print(_L("CSysApAppUi::DoStateChangedL Activating BT" ) ) );
-            SetBtPowerState( ETrue );
-            }
-
-        if ( iDeactivateBt )
-            {
-            TRACES( RDebug::Print(_L("CSysApAppUi::DoStateChangedL Deactivating BT" ) ) );
-            SetBtPowerState( EFalse );
-            }
-
-        // Other late initializations.
-        // In order to prevent unexpected behaviour e.g. in OOM situations, these calls are made to ensure
-        // that the services are connected when they are needed for the first time.
-        if ( !StarterSession().Handle() )
-            {
-            User::Leave( KErrBadHandle );
-            }
-
-        if ( !KeyLock().Handle() )
-            {
-            User::Leave( KErrBadHandle );
-            }
-
-#ifdef __SYSAP_MODULE_TEST
-        ModuleTestShowUiNoteL( _L("SysAp: SW state normal!") );
-#endif
-        }
-
-    // Allow lights
-    iSysApLightsController->AllowLightsOn();
-    }
-
-
-#endif // SYSAP_USE_STARTUP_UI_PHASE
-
-// ----------------------------------------------------------------------------
-// CSysApAppUi::UiReady()
-// 
-// ----------------------------------------------------------------------------
-
-TBool CSysApAppUi::UiReady() const
-    {
-#ifdef SYSAP_USE_STARTUP_UI_PHASE    
-    return iSysApStartupController->UiReady(); 
-#else // SYSAP_USE_STARTUP_UI_PHASE
-    // if startup UI phase information is not used, global system state normal is handled as UI idle state
-    return IsStateNormal();
-#endif // SYSAP_USE_STARTUP_UI_PHASE        
-    }
-
-// ----------------------------------------------------------------------------
-// CSysApAppUi::PrepareForShutdownAnimation()
-// ----------------------------------------------------------------------------
-void CSysApAppUi::PrepareForShutdownAnimation()
-    {
-    TRACES( RDebug::Print( _L("CSysApAppUi::PrepareForShutdownAnimation() begin") ) );
-
-#ifndef RD_STARTUP_ANIMATION_CUSTOMIZATION
-    TRACES( RDebug::Print( _L("CSysApAppUi::PrepareForShutdownAnimation() showtime = %d"), iAnimationShowingTime ) );
-    if ( iAnimationShowingTime )
-        {
-#endif // RD_STARTUP_ANIMATION_CUSTOMIZATION
-        static_cast<CAknAppUi*>(iEikonEnv->EikAppUi())->KeySounds()->PlaySound( EAvkonSIDPowerOffTone );
-        CancelGlobalListQuery();
-
-        if ( iSysApPowerKeyMenuObserver )
-            {
-            iSysApPowerKeyMenuObserver->Cancel();
-            }
-
-        // deactivate notifiers before showing the shutdown image
-        AknNotifierController::CancelAllNotifications();
-        AknNotifierController::HideAllNotifications(ETrue);
-        RWindowGroup groupWin = iCoeEnv->RootWin();
-        iCapturedAppskey = groupWin.CaptureKey( EKeyApplication, KModifierMask, KModifierMask );
-        iCapturedAppskeyUpAndDowns = groupWin.CaptureKeyUpAndDowns( EStdKeyApplication0, KModifierMask, KModifierMask );
-        iEikonEnv->RootWin().SetOrdinalPosition(0, ECoeWinPriorityAlwaysAtFront );
-
-        TRACES( RDebug::Print( _L("CSysApAppUi::PrepareForShutdownAnimation() Draw background image" ) ) );
-
-        ShowShutdownImage( KBackgroundImageID );
-
-#ifndef RD_STARTUP_ANIMATION_CUSTOMIZATION
-        TRACES( RDebug::Print( _L("CSysApAppUi::PrepareForShutdownAnimation() Show Shutdown animation" ) ) );
-        TInt err(0);
-        TRAP( err, iSysApShutdownAnimation->StartL( iLastPowerKeyWasShort ) );
-        if ( err )
-            {
-            TRACES( RDebug::Print( _L("SysAp: Shutdown animation fails. Error code: %d" ), err ) );
-            // Start animation timing immediatily if animation starting fails.
-            // Otherwise animation will call StartAnimTiming when it is ready.
-            StartAnimTiming();
-            }
-        }
-#endif // RD_STARTUP_ANIMATION_CUSTOMIZATION
-
-    TRACES( RDebug::Print( _L("CSysApAppUi::PrepareForShutdownAnimation() end") ) );
     }
 
 
 // ----------------------------------------------------------------------------
-// CSysApAppUi::PrepareForShutdownImage()
+// CSysApAppUi::HandleBatteryStatusL
 // ----------------------------------------------------------------------------
-
-void CSysApAppUi::PrepareForShutdownImage()
+//
+void CSysApAppUi::HandleBatteryStatusL( const TInt aValue )
     {
-    TRACES( RDebug::Print( _L("CSysApAppUi::PrepareForShutdownImage() START" ) ) );
-
-    // If RD_STARTUP_ANIMATION_CUSTOMIZATION is enabled, the following actions are always taken in PrepareForShutdownAnimation
-#ifndef RD_STARTUP_ANIMATION_CUSTOMIZATION
-    if ( !iAnimationShowingTime ) // actions already taken in PrepareForShutdownAnimation
+    TRACES( RDebug::Print( _L("CSysApAppUi::HandleBatteryStatusL aValue: %d"), aValue ) );
+    
+    if ( aValue == EBatteryStatusEmpty )
         {
-        static_cast<CAknAppUi*>(iEikonEnv->EikAppUi())->KeySounds()->PlaySound( EAvkonSIDPowerOffTone );
-        CancelGlobalListQuery();
-        
-        if ( iSysApPowerKeyMenuObserver )
-            {
-            iSysApPowerKeyMenuObserver->Cancel();
-            }
-        
-        // deactivate notifiers before showing the shutdown image
-        AknNotifierController::CancelAllNotifications();
-        AknNotifierController::HideAllNotifications(ETrue);
-        RWindowGroup groupWin = iCoeEnv->RootWin();
-        iCapturedAppskey = groupWin.CaptureKey( EKeyApplication, KModifierMask, KModifierMask );
-        iCapturedAppskeyUpAndDowns = groupWin.CaptureKeyUpAndDowns( EStdKeyApplication0, KModifierMask, KModifierMask );
-        }
-#endif // RD_STARTUP_ANIMATION_CUSTOMIZATION
-
-#ifndef __SYSAP_MODULE_TEST //to make errors during shutdown sequence being seen more easily
-    iEikonEnv->RootWin().SetOrdinalPosition(0, ECoeWinPriorityAlwaysAtFront );
-    TRACES( RDebug::Print( _L("CSysApAppUi::PrepareForShutdownImage() Show Shutdown image" ) ) );
-    ShowShutdownImage( EMbmSysapQgn_startup_screen );
-#endif
-    TRACES( RDebug::Print( _L("CSysApAppUi::PrepareForShutdownImage() END" ) ) );
-    }
-
-// ----------------------------------------------------------------------------
-// CSysApAppUi::SetStatusPaneLauoutL( const TSysApPhoneState aState )
-// ----------------------------------------------------------------------------
-
-void CSysApAppUi::SetStatusPaneLayoutL( const TSysApPhoneState aState )
-    {
-    TRACES( RDebug::Print( _L("CSysApAppUi::SetStatusPaneLayoutL aState: %d"), aState ) );
-    if( aState == ESysApNormal )
-        //Status pane cannot be even visible on Normal mode
-        {
-        StatusPane()->MakeVisible( EFalse );
-        StatusPane()->SwitchLayoutL( R_AVKON_STATUS_PANE_LAYOUT_EMPTY );
-        }
-    else if( aState == ESysApCharging )
-        //SysAp's statuspane is visible on Charging mode
-        {
-        StatusPane()->MakeVisible( ETrue );
-        StatusPane()->SwitchLayoutL( R_AVKON_STATUS_PANE_LAYOUT_POWER_OFF_RECHARGE );
+        //Display Recharge Battery note
+        ShowUiNoteL( ERechargeBatteryNote );
+        BatteryEmptyL();
         }
-    else if( aState == ESysApAlarm )
-    	{
-    	if ( !Layout_Meta_Data::IsLandscapeOrientation() )
-    		{
-    		// Portrait mode
-	        StatusPane()->MakeVisible( ETrue );
-	        StatusPane()->SwitchLayoutL( R_AVKON_STATUS_PANE_LAYOUT_POWER_OFF_RECHARGE );
-    		}
-    	else
-    		{
-    		// Landscape mode
-	        TInt layout = R_AVKON_STATUS_PANE_LAYOUT_POWER_OFF_RECHARGE;
-	        // For side softkey devices, use different layout
-	        if (AVKONENV->StatusPaneResIdForCurrentLayout(R_AVKON_STATUS_PANE_LAYOUT_USUAL) == R_AVKON_STACON_PANE_LAYOUT_USUAL_SOFTKEYS_RIGHT)
-	        	layout = R_AVKON_STACON_PANE_LAYOUT_EMPTY_SOFTKEYS_RIGHT;
-	        else if (AVKONENV->StatusPaneResIdForCurrentLayout(R_AVKON_STATUS_PANE_LAYOUT_USUAL) == R_AVKON_STACON_PANE_LAYOUT_USUAL_SOFTKEYS_LEFT)
-	        	layout = R_AVKON_STACON_PANE_LAYOUT_EMPTY_SOFTKEYS_LEFT;
-
-	        StatusPane()->MakeVisible( ETrue );
-	        StatusPane()->SwitchLayoutL( layout );
-    		}
-    	}
-    }
-
-// ----------------------------------------------------------------------------
-// CSysApAppUi::OkToInitiateShutdown()
-// ----------------------------------------------------------------------------
-
-TBool CSysApAppUi::OkToInitiateShutdown()
+    else if ( aValue == EBatteryStatusLow )
+        {
+        if ( iSysApPsmController && UiReady() )
+            {
+            iSysApPsmController->BatteryLow( ETrue );
+            
+                       
+            if ( iSysApPsmController->ShowActivateQuery())
+                {
+                // show activation query, replaces the first battery low query
+                ShowQueryL( ESysApBattLowPowerSavingQuery );
+                }
+            else // default low warning note must be shown
+                {
+                // activate partial power save mode on first low warning
+                iSysApPsmController->DoEnablePartialPsm( ETrue ); // activated on first warning note
+                //Display Battery Low note.
+                ShowUiNoteL( EBatteryLowNote );    
+                }                
+            }
+        else
+            {
+            //Display Battery Low note.
+            ShowUiNoteL( EBatteryLowNote );     
+            }            
+        }
+        
+    if ( iSysApBatteryInfoController )
     {
-    TInt swState;
-    RProperty::Get( KPSUidStartup, KPSGlobalSystemState, swState );
-
-    if( !iShutdownStarted &&
-        swState == ESwStateStartingCriticalApps ||
-        swState == ESwStateSelfTestOK ||
-        swState == ESwStateSecurityCheck ||
-        swState == ESwStateCriticalPhaseOK ||
-        swState == ESwStateEmergencyCallsOnly ||
-        swState == ESwStateCharging ||
-        swState == ESwStateAlarm ||
-        swState == ESwStateNormalRfOn ||
-        swState == ESwStateNormalRfOff ||
-        swState == ESwStateNormalBTSap ||
-        swState == ESwStateFatalStartupError )
-        {
-        iShutdownStarted = ETrue;
-        return ETrue;
-        }
-    else
-        {
-        return EFalse;
-        }
+     iSysApBatteryInfoController->BatteryStatusUpdated( aValue );
     }
-
-/**
- * To check the for an emergency call. 
- * 
- * @return ETrue if there is an emergency call active otherwise, EFalse.
- */
-TBool IsEmergencyCall()
-        {
-        TBool retVal( EFalse );
-        TInt err( KErrNone );
-        TInt state( 0 );
-     
-        err = RProperty::Get(KPSUidCtsyEmergencyCallInfo, KCTSYEmergencyCallInfo, state );
-        if ( err == KErrNone && state )
-            {
-            retVal = ETrue;            
-            }
-        return retVal;
-        }	
+      
+   }
 
 // ----------------------------------------------------------------------------
-// CSysApAppUi::HandleCurrentCallStateChangeL()
-// ----------------------------------------------------------------------------
-
-void CSysApAppUi::HandleCurrentCallStateChangeL( TInt aCurrentCallState )
-    {
-    TRACES( RDebug::Print( _L("CSysApAppUi::HandleCurrentCallStateChangeL: KUidCurrentCall: %d" ), aCurrentCallState ) );
-
-    if( iPowerKeyPopupMenuActive )
-        {
-        CancelGlobalListQuery();
-        }
-
-    switch ( aCurrentCallState )
-        {
-        case EPSCTsyCallStateRinging:
-            {
-            iSysApLightsController->CallComingInL( ETrue );
-            // Disable keylock when a call is coming in
-            if ( iKeyLockEnabled || iDeviceLockEnabled || iKeyLockOnBeforeCradle || iKeyLockOnBeforeAlarm )
-                {
-                TRACES( RDebug::Print( _L("CSysApAppUi::HandleCurrentCallStateChangeL: EPSCTsyCallStateRinging: disable keylock") ) );
-                iKeyLockOnBeforeCall = ETrue;
-
-                if ( iKeyLockEnabled || iDeviceLockEnabled )
-                    {
-                    if ( !iSysApFeatureManager->TouchUnlockStrokeSupported() )
-                        {
-                        KeyLock().DisableWithoutNote();
-                        }
-                    }
-                }
-            break;
-            }
-            
-        case EPSCTsyCallStateDialling:
-            {
-            // Disable keypad lock during an emergency call
-            // no need to disable the key lock when a call is made using the wireless car-kit
-            // but if the call is an emergency one then we will disable the keypad lock
-            if ( iKeyLockEnabled || iDeviceLockEnabled || iKeyLockOnBeforeCradle )
-                {
-                TRACES( RDebug::Print( _L("CSysApAppUi::HandleCurrentCallStateChangeL: EPSCTsyCallStateDialling: disable keylock") ) );
-                iKeyLockOnBeforeCall = ETrue;
-
-                if ( IsEmergencyCall() && (iKeyLockEnabled || iDeviceLockEnabled ))
-                    {
-                    KeyLock().DisableWithoutNote();
-                    }
-                }
-
-            // Enable signal & network indicators when an emergency call is made in Offline Mode
-            if( iSysApOfflineModeController->OfflineModeActive() )
-                    {
-                    // Signal indicators not updated with VoIP call
-                    if ( StateOfProperty(KPSUidCtsyCallInformation, KCTsyCallType) != EPSCTsyCallTypeVoIP) 
-                        {
-                        iEmergencyCallActive = ETrue;
-                        UpdateSignalBarsL();
-                        SetSignalIndicatorL();
-                        }
-                    }
-            break;
-            }
-            
-        case EPSCTsyCallStateConnected:
-            {
-            if (StateOfProperty(KPSUidCtsyCallInformation, KCTsyCallType) == EPSCTsyCallTypeCSVoice)
-                {
-                // Check if GPRS suspended note is required
-                iCallActivated = ETrue;
-                HandleGprsNotesL();
-                }
-            if ( iDeviceLockEnabled )
-                {
-                // Enable keylock via autolock emulation if device lock enabled. 
-                // Otherwise e.g. messages can be read using softkeys during ongoing call.
-                KeyLock().EnableAutoLockEmulation();
-                }
-            break;
-            }
-
-        case EPSCTsyCallStateNone:
-            {
-            // Reset timers in ScreenSaver and Autolock
-            User::ResetInactivityTime();
-
-            if ( iEmergencyCallActive )
-                {
-                iEmergencyCallActive = EFalse;
-                UpdateSignalBarsL( 0 );
-                SetSignalIndicatorL();
-                }
-            if ( iKeyLockOnBeforeCall )
-                {
-                TRACES( RDebug::Print( _L("CSysApAppUi::HandleCurrentCallStateChangeL: EPSCTsyCallStateNone: enable keylock") ) );
-                iKeyLockOnBeforeCall = EFalse;
-                if ( !iDeviceLockEnabled )
-                    {
-                    if ( !iKeyLockOnBeforeCradle && !iKeyLockOnBeforeAlarm &&
-                          !iSysApFeatureManager->TouchUnlockStrokeSupported() )
-                        {
-                        if ( iSysApCenRepController->GetInt( KCRUidCommonTelephonySettings, KSettingsSummaryAfterCall ) == 1 )
-                            {
-                            KeyLock().EnableWithoutNote(); // Let's not hide "Summary After Call" dialog
-                            }
-                        else
-                            {
-                            KeyLock().EnableKeyLock();
-                            }
-                        }
-                    }
-                else
-                    {
-                    KeyLock().EnableAutoLockEmulation();
-                    }
-                }
-            if ( iShowkeypadActivatedNoteAfterSoftReject )
-                {
-                ShowUiNoteL( EKeypadActiveNote );
-                iShowkeypadActivatedNoteAfterSoftReject = EFalse;
-                }
-            iCallActivated = EFalse;
-            break;
-            }
-            
-        default:
-            break;
-        }
-
-    if ( aCurrentCallState != EPSCTsyCallStateRinging )
-        {
-        iSysApLightsController->CallComingInL( EFalse );
-        }
-
-    SetIhfIndicatorL();
-    SetHacIndicatorL();
-    }
-
-// ----------------------------------------------------------------------------
-// CSysApAppUi::DoSwStateNormalConstructionL()
+// CSysApAppUi::ShowUiNoteL( const TSysApNoteIds aNote ) const
 // ----------------------------------------------------------------------------
 
-void CSysApAppUi::DoSwStateNormalConstructionL()
-    {
-    // Let's ensure that the lights will remain on for 15 secs after sw state normal
-    User::ResetInactivityTime();
-
-    TRACES( RDebug::Print( _L("CSysApAppUi::DoSwStateNormalConstructionL : START" ) ) );
-
-    // In case of unexpected reset (e.g. hidden boot) the keylock must be enabled silently. Locking is done
-    // prior to time-consuming initializations, because otherwise UI is in unlocked state for a few seconds.
-    if ( iSysApCenRepController->GetInt( KCRUidCoreApplicationUIsSysAp, KSysApKeyguardActive ) == 1  )
-        {
-        TRACES( RDebug::Print( _L("CSysApAppUi::DoSwStateNormalConstructionL: enabling keylock") ) );
-        KeyLock().EnableWithoutNote();
-        }
-
-    // Initiate bearer change observation
-    iSysApConnectionMonitorObserver = CSysApConnectionMonitorObserver::NewL( *this );
-
-    TRACES( RDebug::Print( _L("CSysApAppUi::DoSwStateNormalConstructionL: trying CSysApSsSettingsObserver::NewL()") ) );
-    iSysApSsSettingsObserver = CSysApSsSettingsObserver::NewL( *this );
-
-    TRACES( RDebug::Print( _L("CSysApAppUi::DoSwStateNormalConstructionL: trying new ( ELeave ) CSysApPowerKeyMenuObserver") ) );
-    iSysApPowerKeyMenuObserver = new( ELeave ) CSysApPowerKeyMenuObserver( *this );
-
-    TRACES( RDebug::Print( _L("SysAp: trying CSystemLock::NewL" ) ) );
-    iSysApSystemLock = CSystemLock::NewL();
-
-    iSysApCenRepCallForwardingObserver = CSysApCenRepCallForwardingObserver::NewL( *this );
-
-    iSysApCenRepMsgWaitingObserver = CSysApCenRepMsgWaitingObserver::NewL( *this );
-
-    
-    if ( iSysApFeatureManager->Supported( KSysApFeatureIdBatteryInfoPopup ) )
-        {
-        iSysApBatteryInfoController = CSysApBatteryInfoController::NewL( iSysApCenRepController->GetInt( KCRUidCoreApplicationUIsConf, 
-                                                                                                     KCoreAppUIsBatteryInformationLowThreshold ) );    
-        }
-    
-
-    TRACES( RDebug::Print( _L("CSysApAppUi::DoSwStateNormalConstructionL : END" ) ) );
-    }
-
-// ----------------------------------------------------------------------------
-// CSysApAppUi::DoSimChangedFromPreviousBootL()
-// ----------------------------------------------------------------------------
-
-void CSysApAppUi::DoSimChangedFromPreviousBootL()
-    {
-    TRACES( RDebug::Print( _L("CSysApAppUi::DoSimChangedFromPreviousBootL: iSimChangedDone=%d" ), iSimChangedDone ) );
-
-    if ( !iSimChangedDone  )
-        {
-        iSimChangedDone = ETrue;
-        CSysApSimChanged* simChanged = CSysApSimChanged::NewL( *this, iEikonEnv->FsSession() );
-        CleanupStack::PushL( simChanged );
-        simChanged->HandleSimChangedL();
-        CleanupStack::PopAndDestroy( simChanged );
-        }
-    }
-
-// ----------------------------------------------------------------------------
-// CSysApAppUi::CancelWaitNote()
-// ----------------------------------------------------------------------------
-
-void CSysApAppUi::CancelWaitNote()
+void CSysApAppUi::ShowUiNoteL( const TSysApNoteIds aNote ) const
     {
-    TRACES( RDebug::Print( _L("CSysApAppUi::CancelWaitNote" ) ) );
-    if ( iSysApWaitNote )
-        {
-        iSysApWaitNote->Cancel();
-        delete iSysApWaitNote;
-        iSysApWaitNote = NULL;
-        }
-    }
-
-// ----------------------------------------------------------------------------
-// CSysApAppUi::CancelGlobalListQuery()
-// ----------------------------------------------------------------------------
-
-void CSysApAppUi::CancelGlobalListQuery()
-    {
-    TRACES( RDebug::Print( _L("CSysApAppUi::CancelGlobalListQuery" ) ) );
-    if ( iGlobalListQuery )
-        {
-        iGlobalListQuery->CancelListQuery();
-        delete iGlobalListQuery;
-        iGlobalListQuery = NULL;
-        }
-    }
-
-#ifndef RD_MULTIPLE_DRIVE
-// ----------------------------------------------------------------------------
-// CSysApAppUi::MountMMC()
-// ----------------------------------------------------------------------------
-
-TInt CSysApAppUi::MountMMC()
-    {
-    TRACES( RDebug::Print( _L("CSysApAppUi::MountMMC") ) );
-    TInt err ( KErrNotSupported );
-    if ( iSysApFeatureManager->MmcSupported() )
-        {
-#ifdef __WINS__ // Let's sleep a second in WINS
-        User::After( 1000000 );
-#endif
-        err = iEikonEnv->FsSession().MountFileSystem( KFSName, KMMCDrive );
-        TRACES( RDebug::Print( _L("CSysApAppUi::MountMMC: RFs::MountFileSystem() returned: %d"), err ) );
-        if ( err == KErrInUse )
-            {
-            User::After( 1000000 );
-            err = iEikonEnv->FsSession().MountFileSystem( KFSName, KMMCDrive );
-            TRACES( RDebug::Print( _L("CSysApAppUi::MountMMC: RFs::MountFileSystem() returned: %d"), err ) );
-            }
-        }
-    return err;
-    }
-
-// ----------------------------------------------------------------------------
-// CSysApAppUi::DismountMMC()
-// ----------------------------------------------------------------------------
-
-TInt CSysApAppUi::DismountMMC()
-    {
-    TRACES( RDebug::Print( _L("CSysApAppUi::DismountMMC") ) );
-#ifdef __WINS__ // Let's sleep a second in WINS
-        User::After( 1000000 );
-#endif
-
-    TInt err ( KErrNotSupported );
-    if ( iSysApFeatureManager->MmcSupported() )
-        {
-        err = iEikonEnv->FsSession().DismountFileSystem( KFSName, KMMCDrive );
-        TRACES( RDebug::Print( _L("CSysApAppUi::DismountMMC: RFs::DismountFileSystem() returned: %d"), err ) );
-        }
-    return err;
-    }
+    TRACES( RDebug::Print( _L("CSysApAppUi::ShowUiNoteL aNote: %d"), aNote ) );
+    
+    TInt swState( StateOfProperty( KPSUidStartup, KPSGlobalSystemState ) );
 
-// ----------------------------------------------------------------------------
-// CSysApAppUi::EjectMMCL()
-// ----------------------------------------------------------------------------
-
-void CSysApAppUi::EjectMMCL()
-    {
-    TRACES( RDebug::Print( _L("CSysApAppUi::EjectMMCL") ) );
-    iMMCEjectUsed = ETrue;
-    iMMCPowerMenuEjectUsed = ETrue;
-    iTimeToKill = EFalse;
-    iApplicationScanningRoundNumber = 0;
-    CloseUIAppsInHotSwapL();
-    }
-
-#else // RD_MULTIPLE_DRIVE
-
-// ----------------------------------------------------------------------------
-// CSysApAppUi::EjectMMCL()
-// ----------------------------------------------------------------------------
-
-void CSysApAppUi::EjectMMCL()
-    {
-    // Called from eject confirm query, check drive inserted before start
-    TInt insertedIndex( CSysApDriveList::Find(
-        iInsertedMemoryCards, iDriveToEject ) );
-
-    TRACES( RDebug::Print(
-        _L( "CSysApAppUi::EjectMMCL: iMMCEjectUsed: %d, drive: %d, index: %d "),
-        iMMCEjectUsed, iDriveToEject, insertedIndex ) );
-
-    if ( insertedIndex != KErrNotFound )
-        {
-        iSysApDriveList->MarkDriveToEject(
-            iDriveToEject, CSysApDriveList::EEjectFromMenu );
-        iSysApDriveEjectHandler->StartEject();
-        }
-    iMMCEjectUsed = EFalse;
-    }
-
-#endif // RD_MULTIPLE_DRIVE
-
-// ----------------------------------------------------------------------------
-// CSysApAppUi::DisconnectBtSap()
-// ----------------------------------------------------------------------------
-
-void CSysApAppUi::DisconnectBtSap()
-    {
-    TRACES( RDebug::Print( _L("CSysApAppUi::DisconnectBtSap") ) );
-    iSysApBtSapController->Disconnect();
-    }
-
-#ifndef RD_MULTIPLE_DRIVE
-// ----------------------------------------------------------------------------
-// CSysApAppUi::RunUnlockNotifierL()
-// ----------------------------------------------------------------------------
-
-void CSysApAppUi::RunUnlockNotifierL( TSysApMemoryCardStatus aMemoryCardStatus )
-    {
-    TRACES( RDebug::Print( _L("CSysApAppUi::RunUnlockNotifierL: START") ) );
-    if ( iSysApFeatureManager->MmcSupported() )
-        {
-        if ( UiReady() )
+    if( UiReady() || swState == ESwStateSecurityCheck)
+      {
+          switch ( aNote )
             {
-            TSysApMemoryCardStatus memoryCardStatus;
-            if ( aMemoryCardStatus == ESysApMemoryCardStatusNotKnown )
+            case EBatteryLowNote:
+                {
+                 _LIT(KPowerPressKey,"Battery low");
+                 HBufC* aString = HBufC16::NewLC(100);
+                 TPtrC aStringPointer = aString->Des();
+                 aStringPointer.Set(KPowerPressKey);
+                 TRACES( RDebug::Print( _L("CSysApWsClient::RunL(): Key EEventKeyUp 01") ) );   
+                 ShowExampleUiNoteL( aStringPointer );
+                 CleanupStack::PopAndDestroy(); // aString
+                }
+                break;
+            case EBatteryFullNote:
                 {
-                memoryCardStatus = iSysApMMCObserver->MemoryCardStatus();
+                _LIT(KPowerPressKey,"Battery full");
+                HBufC* aString = HBufC16::NewLC(100);
+                TPtrC aStringPointer = aString->Des();
+                aStringPointer.Set(KPowerPressKey);
+                TRACES( RDebug::Print( _L("CSysApWsClient::RunL(): Key EEventKeyUp 01") ) );   
+                ShowExampleUiNoteL( aStringPointer );
+                CleanupStack::PopAndDestroy(); // aString
+                }
+                break;
+            case ERechargeBatteryNote:
+                {
+                iSysApLightsController->BatteryEmptyL( ETrue );
+                _LIT(KPowerPressKey,"Battery empty. Recharge");
+                HBufC* aString = HBufC16::NewLC(100);
+                TPtrC aStringPointer = aString->Des();
+                aStringPointer.Set(KPowerPressKey);
+                TRACES( RDebug::Print( _L("CSysApWsClient::RunL(): Key EEventKeyUp 01") ) );   
+                ShowExampleUiNoteL( aStringPointer );
+                CleanupStack::PopAndDestroy(); // aString
                 }
-            else
+                break;
+            case ENotChargingNote:
                 {
-                memoryCardStatus = aMemoryCardStatus;
+                _LIT(KPowerPressKey,"Not charging");
+                HBufC* aString = HBufC16::NewLC(100);
+                TPtrC aStringPointer = aString->Des();
+                aStringPointer.Set(KPowerPressKey);
+                TRACES( RDebug::Print( _L("CSysApWsClient::RunL(): Key EEventKeyUp 01") ) );   
+                ShowExampleUiNoteL( aStringPointer );
+                CleanupStack::PopAndDestroy(); // aString
                 }
-
-            TRACES( RDebug::Print( _L("CSysApAppUi::RunUnlockNotifierL: memoryCardStatus=%d"), memoryCardStatus ) );
-
-            switch ( memoryCardStatus )
+                break;
+            case EBatteryFullUnplugChargerNote:
                 {
-                case ESysApMemoryCardInserted:
-                    TRACES( RDebug::Print( _L("CSysApAppUi::RunUnlockNotifierL MMC inserted") ) );
-                    if ( aMemoryCardStatus == ESysApMemoryCardInserted )
-                        {
-                        RProperty::Set( KPSUidUikon, KUikMMCInserted, 1 );
-                        }
-                    break;
-                case ESysApMemoryCardLocked:
-                    {
-                    TRACES( RDebug::Print( _L("CSysApAppUi::RunUnlockNotifierL MMC locked") ) );
-                    RProperty::Set( KPSUidUikon, KUikMMCInserted, 0 );
-                    TInt callState = StateOfProperty( KPSUidCtsyCallInformation, KCTsyCallState );
-
-                    if (  (! ( iDeviceLockEnabled || iKeyLockEnabled ) ) &&
-                          callState != EPSCTsyCallStateRinging && // We don't want to see the MMC passwd query
-                          callState != EPSCTsyCallStateAlerting ) // when the user is e.g. making an emergency call
-                        {
-                        if ( iSysApFeatureManager->MemoryCardLockSupported() )
-                            {
-                            if ( ! iMemoryCardDialog )
-                                {
-                                TRACES( RDebug::Print( _L("CSysApAppUi::RunUnlockNotifierL: ACTIVATE MMC passwd query") ) );
-                                CAknMemoryCardDialog* mmcDialog = CAknMemoryCardDialog::NewLC( this );
-                                iMemoryCardDialog = mmcDialog; // temporary variable used for hiding codescanner error 
-                                iMemoryCardDialog->SetSelfPointer( &iMemoryCardDialog );
-                                iMemoryCardDialog->UnlockCardLD(); // when UnlockCardLD completes it calls UnlockComplete()
-                                }
-                            }
-                        else
-                            {
-                            // Since locked cards are not supported, notify user that card is locked.
-                            ShowQueryL( ESysApMemoryCardLockedNote );
-                            }
-                        }
-                    }
-                    break;
-
-                case ESysApMemoryCardNotInserted:
-                default:
-                    TRACES( RDebug::Print( _L("CSysApAppUi::RunUnlockNotifierL MMC not inserted") ) );
-                    if ( aMemoryCardStatus == ESysApMemoryCardNotInserted )
-                        {
-                        RProperty::Set( KPSUidUikon, KUikMMCInserted, 0 );
-                        }
+                /*	
+                TRACES( RDebug::Print( _L("CSysApWsClient::RunL(): Key EEventKeyUp 01") ) ); 
+                iSysApLightsController->BatteryEmptyL( ETrue );
+                 _LIT(KunplugCharger,"txt_power_dpopinfo_unplug_charger_to_save_energy");                 
+                 HBufC* unplugCharger = HbTextResolverSymbian::LoadL(KunplugCharger);
+                 _LIT(KbatteryFull,"txt_power_management_dpophead_100_full");
+                 HBufC* batteryFull = HbTextResolverSymbian::LoadL(KbatteryFull);
+                 CHbDeviceNotificationDialogSymbian::NotificationL(KbatteryFullIcon,*unplugCharger,*batteryFull);  
+                 */
+                 
+                 iSysApLightsController->BatteryEmptyL( ETrue );
+                 _LIT(KPowerPressKey,"Charging complete. Unplug charger to save energy.");
+                 HBufC* aString = HBufC16::NewLC(200);
+                 TPtrC aStringPointer = aString->Des();
+                 aStringPointer.Set(KPowerPressKey);
+                 TRACES( RDebug::Print( _L("CSysApWsClient::RunL(): Key EEventKeyUp 01") ) );   
+                 ShowExampleUiNoteL( aStringPointer );
+                 CleanupStack::PopAndDestroy(); // aString     
+                 }
+                break;
+            case EUnplugChargerNote:
+                {
+                _LIT(KPowerPressKey,"Unplug charger from power supply to save energy");
+                HBufC* aString = HBufC16::NewLC(250);
+                TPtrC aStringPointer = aString->Des();
+                aStringPointer.Set(KPowerPressKey);
+                TRACES( RDebug::Print( _L("CSysApWsClient::RunL(): Key EEventKeyUp 01") ) );   
+                ShowExampleUiNoteL( aStringPointer );
+                CleanupStack::PopAndDestroy(); // aString
                 }
+                break;
+            default:
+                break;
             }
         }
-    TRACES( RDebug::Print( _L("CSysApAppUi::RunUnlockNotifierL: END") ) );
-    }
-
-// ----------------------------------------------------------------------------
-// CSysApAppUi::UnlockComplete() from MAknMemoryCardDialogObserver
-// ----------------------------------------------------------------------------
-
-void CSysApAppUi::UnlockComplete( TInt aResult )
-    {
-    TRACES( RDebug::Print( _L("CSysApAppUi::UnlockComplete result: %d"), aResult ) );
-    if ( aResult == KErrNone )
-        {
-        RProperty::Set( KPSUidUikon, KUikMMCInserted, 1 );
-        }
     }
 
-// ----------------------------------------------------------------------------
-// CSysApAppUi::MMCStatusChangedL() from MSysApMemoryCardObserver
-// ----------------------------------------------------------------------------
-
-void CSysApAppUi::MMCStatusChangedL()
-    {
-    TRACES( RDebug::Print( _L( "CSysApAppUi::MMCStatusChangedL START: iMMCInserted: %d, iMMCEjectUsed: %d, iHideFirstBeep: %d, iHideNextBeep: %d" ), iMMCInserted, iMMCEjectUsed, iHideFirstBeep, iHideNextBeep ) );
-
-    if ( iSysApFeatureManager->MmcSupported() && !iShutdownStarted )
-        {
-        TSysApMemoryCardStatus memoryCardStatus = iSysApMMCObserver->MemoryCardStatus();
-        TRACES( RDebug::Print( _L( "CSysApAppUi::MMCStatusChangedL memoryCardStatus=%d" ), memoryCardStatus ) );
-
-        switch ( memoryCardStatus )
-            {
-            case ESysApMemoryCardInserted:
-            case ESysApMemoryCardLocked:
-                TRACES( RDebug::Print( _L( "CSysApAppUi::MMCStatusChangedL: MMC drive mounted" ) ) );
-                if ( ! iMMCInserted ) // MMC was not inserted before
-                    {
-                    TRACES( RDebug::Print( _L( "CSysApAppUi::MMCStatusChangedL: MMC newly inserted" ) ) );
-                    CancelWaitNote(); // just to be sure, the user might keep on closing and opening the MMC latch
-                    // An MMC has been newly inserted, so play a sound and check if its password protected
-
-                    if ( UiReady() )
-                        {
-                        if ( !iHideFirstBeep && !iHideNextBeep ) // starting up
-                            {
-                            Beep();
-                            // Switch lights on
-                            iSysApLightsController->MemoryCardInsertedL();
-                            }
-                        iHideNextBeep = EFalse;
-                        }
-
-                    iMMCPowerMenuEjectUsed = EFalse;
-                    iMMCEjectUsed = EFalse;
-                    iMMCInserted = ETrue;
-
-                    // No need to show ESysApRemoveMmcNote after MMC already mounted
-                    if ( iSysApConfirmationQuery )
-                        {
-                        if ( iSysApConfirmationQuery->CurrentQuery() == ESysApRemoveMmcNote )
-                            {
-                            iSysApConfirmationQuery->Cancel();
-                            }
-                        }
-
-                    // Check if the MMC is locked and unlock it if necessary
-                    RunUnlockNotifierL( memoryCardStatus );
-                    }
-                break;
-            default:
-                TRACES( RDebug::Print( _L( "CSysApAppUi::MMCStatusChangedL: MMC drive not mounted" ) ) );
-                delete iMemoryCardDialog; // sets itself to null
-                RProperty::Set( KPSUidUikon, KUikMMCInserted, 0 );
-                if ( iMMCInserted )
-                    {
-                    // No need to show ESysApEjectMmcQuery after MMC already removed
-                    if ( iSysApConfirmationQuery )
-                        {
-                        if ( iSysApConfirmationQuery->CurrentQuery() == ESysApEjectMmcQuery )
-                            {
-                            iSysApConfirmationQuery->Cancel();
-                            }
-                        }
-
-                    iMMCInserted = EFalse;
-
-                    TInt propertyValue( StateOfProperty( KPSUidUsbWatcher, KUsbWatcherSelectedPersonality ) );
-                    if ( !iMMCEjectUsed && propertyValue != KUsbPersonalityIdMS )
-                        {
-                        // if USB file transfer active, do not close applications
-                        // if eject selected in MMC App, MMC App takes care of the following and
-                        // if eject selected from powerkeymenu, applications have already been shutdown
-                        iTimeToKill = EFalse;
-                        iApplicationScanningRoundNumber = 0;
-                        CloseUIAppsInHotSwapL();
-                        }
-                    }
-                else
-                    {
-                    // If MMC was not previously inserted and eject was chosed from power key menu, attempt to remount.
-                    if ( iMMCPowerMenuEjectUsed )
-                        {
-                        TRACES( RDebug::Print( _L( "CSysApAppUi::MMCStatusChangedL: Attempt to remount" ) ) );
-                        MountMMC();
-                        // If mount was successful, unnecessary note will be canceled in insert notification handling.
-                        }
-                    }
-                break;
-            }
-
-        // Update memory card indicator status
-        SetMemoryCardIndicatorL();
-        }
-    TRACES( RDebug::Print( _L( "CSysApAppUi::MMCStatusChangedL   END: iMMCInserted: %d, iMMCEjectUsed: %d, iHideFirstBeep: %d, iHideNextBeep: %d" ), iMMCInserted, iMMCEjectUsed, iHideFirstBeep, iHideNextBeep ) );
-    }
-
-// ----------------------------------------------------------------------------
-// CSysApAppUi::ShowMMCDismountedDialogL()
-// ----------------------------------------------------------------------------
-
-void CSysApAppUi::ShowMMCDismountedDialogL()
-    {
-    TInt propertyValue( StateOfProperty( KPSUidUsbWatcher, KUsbWatcherSelectedPersonality ) );
-
-    // Do not show any note if USB file transfer is active.
-    if ( propertyValue != KUsbPersonalityIdMS )
-        {
-        if ( iSysApFeatureManager->MemoryCardHatchSupported() )
-            { // MMC hatch has been opened and MMC has been dismounted
-            TRACES( RDebug::Print( _L( "CSysApAppUi::ShowMMCDismountedDialogL: Show note: Remove MMC and press OK." ) ) );
-            ShowQueryL( ESysApRemoveMmcNote );
-            }
-        else
-            {
-            // MMC has been removed and dismounted
-            TRACES( RDebug::Print( _L( "CSysApAppUi::ShowMMCDismountedDialogL: Show note: You might have lost some data." ) ) );
-            // No confirmation but let's set this true to enable MMC passwd query
-            ShowUiNoteL( EMemoryCardRemovedWithoutEjectNote );
-            }
-        }
-    else
-        {
-        TRACES( RDebug::Print( _L( "CSysApAppUi::ShowMMCDismountedDialogL: No note shown, USB file transfer caused dismount." ) ) );
-        }
-    }
-
-// ----------------------------------------------------------------------------
-// CSysApAppUi::MMCDismountedDialogConfirmed
-// ----------------------------------------------------------------------------
-
-void CSysApAppUi::MMCDismountedDialogConfirmed()
-    {
-    TRACES( RDebug::Print( _L( "CSysApAppUi::MMCDismountedDialogConfirmed") ) );
-
-    // Try to remount just in case when eject was chosen from power key menu
-    if ( iMMCPowerMenuEjectUsed )
-        {
-        iMMCPowerMenuEjectUsed = EFalse;
-
-        if ( MountMMC() == KErrLocked ) // In case a locked card was not removed after all
-            {
-            TRAPD( err, MMCStatusChangedL() ); // This will update power menu and memory card icon. Also memory card password is requeried.
-            if ( err != KErrNone )
-                {
-                TRACES( RDebug::Print( _L( "CSysApAppUi::MMCDismountedDialogConfirmed: MMCStatusChangedL failed, err=%d"), err ) );
-                }
-            }
-        }
-
-    }
-
-#else // RD_MULTIPLE_DRIVE
-
-// ----------------------------------------------------------------------------
-// CSysApAppUi::MMCInsertedL
-// ----------------------------------------------------------------------------
-
-void CSysApAppUi::MMCInsertedL()
-    {
-    TRACES( RDebug::Print( _L( "CSysApAppUi::MMCInsertedL") ) );
-
-    if ( iSysApFeatureManager->MmcSupported() && !iShutdownStarted )
-		{
-		TBool normalState( UiReady() );
-
-		if ( normalState )
-			{
-			TInt defaultMemoryCard( iSysApDriveList->DefaultMemoryCard() );
-			TSysApMemoryCardStatus memoryCardStatus( iSysApDriveList->MemoryCardStatus( defaultMemoryCard ) );
-
-			TRACES( RDebug::Print(
-				_L( "CSysApAppUi::MMCInsertedL: drive: %d, memoryCardStatus: %d" ), defaultMemoryCard, memoryCardStatus ) );
-
-			switch ( memoryCardStatus )
-				{
-				case ESysApMemoryCardInserted: // Fall through
-				case ESysApMemoryCardLocked:
-					{
-					// Reset eject and unlock of inserted memory card
-					iSysApDriveList->ResetDriveToEject( defaultMemoryCard );
-					iSysApDriveList->ResetDriveUnlockQueryShown( defaultMemoryCard );
-
-					CancelWaitNote();
-
-					if ( memoryCardStatus == ESysApMemoryCardInserted )
-						{
-						TRACES( RDebug::Print(
-							_L( "CSysApAppUi::MMCInsertedL: memoryCardStatus ESysApMemoryCardInserted: %d" ), memoryCardStatus ) );
-						RProperty::Set( KPSUidUikon, KUikMMCInserted, 1 );
-						}
-					else
-						{
-						TRACES( RDebug::Print(
-							_L( "CSysApAppUi::MMCInsertedL: memoryCardStatus ESysApMemoryCardLocked: %d" ), memoryCardStatus ) );
-						RProperty::Set( KPSUidUikon, KUikMMCInserted, 0 );
-						}
-					break;
-					}
-				case ESysApMemoryCardNotInserted:
-					{
-					// Always reset eject and unlock of removed memory card
-					TBool isEject( iSysApDriveList->IsDriveToEject( defaultMemoryCard ) );
-
-					TRACES( RDebug::Print(
-						_L( "CSysApAppUi::MMCInsertedL: isEject: %d, drive: %d" ),
-						isEject, defaultMemoryCard ) );
-
-					iSysApDriveList->ResetDriveToEject( defaultMemoryCard );
-					iSysApDriveList->ResetDriveUnlockQueryShown( defaultMemoryCard );
-
-					TRACES( RDebug::Print(
-						_L( "SysApAppUi::MMCInsertedL: memoryCardStatus ESysApMemoryCardNotInserted: %d" ), memoryCardStatus ) );
-
-					RProperty::Set( KPSUidUikon, KUikMMCInserted, 0 );
-					break;
-					}
-				case ESysApMemoryCardStatusNotKnown: // Fall through
-				default:
-					{
-					break;
-					}
-				}
-				RunUnlockNotifierL();
-			}
-		}
-	}
-
-
-// ----------------------------------------------------------------------------
-// CSysApAppUi::RunUnlockNotifierL()
-// ----------------------------------------------------------------------------
-
-void CSysApAppUi::RunUnlockNotifierL()
-    {
-    TRACES( RDebug::Print(
-        _L("CSysApAppUi::RunUnlockNotifierL: START iDeviceLockEnabled: %d, iKeyLockEnabled: %d" ),
-         iDeviceLockEnabled, iKeyLockEnabled ) );
-
-    if ( !iSysApFeatureManager->MmcSupported() ||
-         iDeviceLockEnabled ||
-         iKeyLockEnabled ||
-         !UiReady() )
-        {
-        TRACES( RDebug::Print( _L("CSysApAppUi::RunUnlockNotifierL: END") ) );
-        return;
-        }
-
-    // We don't want to see the MMC passwd query
-    // when the user is e.g. making an emergency call
-    TInt callState( StateOfProperty( KPSUidCtsyCallInformation, KCTsyCallState ) );
-    if ( callState != EPSCTsyCallStateRinging &&
-        callState != EPSCTsyCallStateAlerting )
-        {
-        iSysApDriveUnlockHandler->StartUnlock();
-        }
-
-    TRACES( RDebug::Print(
-        _L("CSysApAppUi::RunUnlockNotifierL: END callState: %d"), callState ) );
-    }
-
-// ----------------------------------------------------------------------------
-// CSysApAppUi::MMCStatusChangedL() from MSysApMemoryCardObserver
-// ----------------------------------------------------------------------------
-
-void CSysApAppUi::MMCStatusChangedL( TInt aDrive )
-    {
-    TRACES( RDebug::Print(
-        _L( "CSysApAppUi::MMCStatusChangedL START: MMCCount: %d, iMMCEjectUsed: %d" ),
-        iInsertedMemoryCards.Count(), iMMCEjectUsed ) );
-
-    if ( iShutdownStarted || !iSysApFeatureManager->MmcSupported() )
-        {
-        TRACES( RDebug::Print(
-            _L( "CSysApAppUi::MMCStatusChangedL iShutdownStarted: %d END" ),
-            iShutdownStarted ) );
-        return;
-        }
-
-    TBool normalState( UiReady() );
-
-    TInt defaultMemoryCard( iSysApDriveList->DefaultMemoryCard() );
-    TSysApMemoryCardStatus memoryCardStatus( iSysApDriveList->MemoryCardStatus( aDrive ) );
-    TInt insertedIndex( CSysApDriveList::Find( iInsertedMemoryCards, aDrive ) );
-
-    TRACES( RDebug::Print(
-        _L( "CSysApAppUi::MMCStatusChangedL: normalState: %d, index: %d, drive: %d, memoryCardStatus: %d" ),
-        normalState, insertedIndex, aDrive, memoryCardStatus ) );
-
-    switch ( memoryCardStatus )
-        {
-        case ESysApMemoryCardInserted: // Fall through
-        case ESysApMemoryCardLocked:
-            {
-            if ( insertedIndex == KErrNotFound ) // Not inserted before
-                {
-                // Reset eject and unlock of inserted memory card
-                iSysApDriveList->ResetDriveToEject( aDrive );
-                iSysApDriveList->ResetDriveUnlockQueryShown( aDrive );
-
-                CancelWaitNote();
-
-                if ( aDrive == defaultMemoryCard )
-                    {
-                    if ( memoryCardStatus == ESysApMemoryCardInserted )
-                        {
-                         RProperty::Set( KPSUidUikon, KUikMMCInserted, 1 );
-                      	}
-                    else
-                        {
-                        RProperty::Set( KPSUidUikon, KUikMMCInserted, 0 );
-                        }
-                    }
-
-                if ( normalState )
-                    {
-                    // Ignore extra beep from USB file transfer
-                    TBool ignoreBeep(
-                        iSysApDriveList->IsDriveInsertBeepIgnored( aDrive ) );
-
-                    TRACES( RDebug::Print(
-                        _L( "CSysApAppUi::MMCStatusChangedL: ignoreBeep: %d, drive: %d" ),
-                        ignoreBeep, aDrive ) );
-
-                    if ( !ignoreBeep )
-                        {
-                        Beep();
-                        iSysApLightsController->MemoryCardInsertedL();
-                        }
-
-                    iSysApDriveList->ResetDriveInsertBeepIgnored( aDrive );
-
-                    // Keep ignoring extra beep if USB file transfer is active
-                    TInt propertyValue( StateOfProperty( KPSUidUsbWatcher, KUsbWatcherSelectedPersonality ) );
-
-                    TRACES( RDebug::Print(
-                        _L( "CSysApAppUi::MMCStatusChangedL: usbState: %d" ), propertyValue ) );
-
-                    if ( propertyValue == KUsbPersonalityIdMS )
-                        {
-                        iSysApDriveList->MarkDriveInsertBeepIgnored( aDrive );
-                        }
-                    }
-
-                if ( iDriveToDismount == aDrive && iSysApConfirmationQuery )
-                    {
-                    if ( iSysApConfirmationQuery->CurrentQuery() == ESysApRemoveMmcNote )
-                        {
-                        // User put back ejected memory card or did not remove it
-                        iSysApConfirmationQuery->Cancel();
-                        }
-                    }
-                RunUnlockNotifierL();
-                }
-            break;
-            }
-        case ESysApMemoryCardNotInserted:
-            {
-            // Always reset eject and unlock of removed memory card
-            TBool isEject( iSysApDriveList->IsDriveToEject( aDrive ) );
-
-            TRACES( RDebug::Print(
-                _L( "CSysApAppUi::MMCStatusChangedL: isEject: %d, drive: %d" ),
-                isEject, aDrive ) );
-
-            iSysApDriveList->ResetDriveToEject( aDrive );
-            iSysApDriveList->ResetDriveUnlockQueryShown( aDrive );
-
-            if ( insertedIndex != KErrNotFound ) // Inserted before
-                {
-                if ( memoryCardStatus == ESysApMemoryCardNotInserted )
-                    {
-                    // Reset extra beep ignore if memory card was removed without eject
-                    iSysApDriveList->ResetDriveInsertBeepIgnored( aDrive );
-                    }
-
-                CancelGlobalListQuery(); // Cancel power menu
-
-                if ( aDrive == defaultMemoryCard )
-                    {
-                    RProperty::Set( KPSUidUikon, KUikMMCInserted, 0 );
-                    }
-
-                if ( iSysApConfirmationQuery )
-                    {
-                    if ( iSysApConfirmationQuery->CurrentQuery() == ESysApEjectMmcQuery )
-                        {
-                        // User removed memory card too early
-                        iSysApConfirmationQuery->Cancel();
-                        // Allow application closing to execute.
-                        // Also FileManager is closed in this case, regardless where the eject was initiated from.
-                        iMMCEjectUsed = EFalse;
-                        }
-                    }
-
-                // Stop unlock of removed memory card
-                iSysApDriveUnlockHandler->StopUnlock( aDrive );
-
-                if ( !iMMCEjectUsed && !isEject )
-                    {
-                    TInt propertyValue( StateOfProperty( KPSUidUsbWatcher, KUsbWatcherSelectedPersonality ) );
-
-                    TRACES( RDebug::Print(
-                        _L( "CSysApAppUi::MMCStatusChangedL: usbState: %d" ), propertyValue ) );
-
-                    if ( propertyValue != KUsbPersonalityIdMS )
-                        {
-                        if ( iSysApFeatureManager->MemoryCardHatchSupported() )
-                            {
-                            // Store drive removed without eject and start eject handling
-                            iSysApDriveList->MarkDriveToEject(
-                                aDrive, CSysApDriveList::EEjectRemovedWithoutEject );
-                            iSysApDriveEjectHandler->StartEject();
-                            }
-                        else
-                            {
-                            // Just show the note
-                            ShowUiNoteL( EMemoryCardRemovedWithoutEjectNote );
-                            }
-                        }
-                    }
-                iMMCEjectUsed = EFalse;
-                }
-            break;
-            }
-        case ESysApMemoryCardStatusNotKnown: // Fall through
-        default:
-            {
-            break;
-            }
-        }
-
-    // Update inserted memory cards
-    iSysApDriveList->GetMemoryCardsL(
-        iInsertedMemoryCards, CSysApDriveList::EIncludeInserted );
-
-    // Update memory card indicator status
-    SetMemoryCardIndicatorL();
-
-    TRACES( RDebug::Print(
-        _L( "CSysApAppUi::MMCStatusChangedL END: MMCCount: %d, iMMCEjectUsed: %d" ),
-        iInsertedMemoryCards.Count(), iMMCEjectUsed ) );
-    }
-
-// ----------------------------------------------------------------------------
-// CSysApAppUi::ShowMMCDismountedDialogL()
-// ----------------------------------------------------------------------------
-
-TBool CSysApAppUi::ShowMMCDismountedDialogL(
-        TInt aDrive, CSysApDriveList::TDriveEjectType aEjectType )
-    {
-    TRACES( RDebug::Print(
-        _L( "CSysApAppUi::ShowMMCDismountedDialogL: aDrive: %d, aEjectType: %d" ),
-        aDrive, aEjectType ) );
-
-    TBool ret( EFalse );
-    iDriveToDismount = aDrive;
-    HBufC* driveName = iSysApDriveList->GetFormattedDriveNameLC(
-        aDrive,
-        R_QTN_EJECT_REMOVE_MEMORY_INFO );
-
-    if ( aEjectType == CSysApDriveList::EEjectFromMenu )
-        {
-        TRACES( RDebug::Print(
-            _L( "CSysApAppUi::ShowMMCDismountedDialogL: Show note: Remove MMC and press OK...." ) ) );
-        ShowQueryL( ESysApRemoveMmcNote, *driveName );
-        ret = ETrue;
-        }
-    else
-        {
-        // Memory card was removed without eject
-        TInt propertyValue( StateOfProperty( KPSUidUsbWatcher, KUsbWatcherSelectedPersonality ) );
-
-        // Do not show any note if USB file transfer is active.
-        if ( propertyValue != KUsbPersonalityIdMS )
-            {
-            if ( iSysApFeatureManager->MemoryCardHatchSupported() )
-                {
-                // MMC hatch has been opened and MMC has been dismounted
-                TRACES( RDebug::Print(
-                    _L( "CSysApAppUi::ShowMMCDismountedDialogL: Show note: Remove MMC and press OK." ) ) );
-                ShowQueryL( ESysApRemoveMmcNote, *driveName );
-                ret = ETrue;
-                }
-            else
-                {
-                iSysApDriveList->ResetDrivesToEject();
-
-                // MMC has been removed and dismounted
-                TRACES( RDebug::Print( _L(
-                    "CSysApAppUi::ShowMMCDismountedDialogL: Show note: You might have lost some data." ) ) );
-
-                // No confirmation but let's set this true to enable MMC passwd query
-                ShowUiNoteL( EMemoryCardRemovedWithoutEjectNote );
-                }
-            }
-        else
-            {
-            iSysApDriveList->ResetDrivesToEject();
-            TRACES( RDebug::Print(
-                _L( "CSysApAppUi::ShowMMCDismountedDialogL: No note shown, USB file transfer caused dismount." ) ) );
-            }
-        }
-
-    CleanupStack::PopAndDestroy( driveName );
-
-    TRACES( RDebug::Print(
-        _L( "CSysApAppUi::ShowMMCDismountedDialogL: ret: %d" ), ret ) );
-
-    return ret;
-    }
-
-// ----------------------------------------------------------------------------
-// CSysApAppUi::MMCDismountedDialogConfirmed
-// ----------------------------------------------------------------------------
-
-void CSysApAppUi::MMCDismountedDialogConfirmed()
-    {
-    TRACES( RDebug::Print(
-        _L( "CSysApAppUi::MMCDismountedDialogConfirmed: iDriveToDismount: %d" ),
-        iDriveToDismount ) );
-
-    // Try remount to check if drive was put back
-    iSysApDriveList->MountDrive( iDriveToDismount );
-    if ( !iSysApDriveEjectHandler->CompleteDismount( iDriveToDismount ) )
-        {
-        // When ready, check for locked memory cards and update indicators
-        TRAP_IGNORE( SetMemoryCardIndicatorL() );
-        TRAP_IGNORE( RunUnlockNotifierL() );
-        }
-    }
-
-#endif // RD_MULTIPLE_DRIVE
-
-// ----------------------------------------------------------------------------
-// CSysApAppUi::EjectStarted()
-// ----------------------------------------------------------------------------
-
-void CSysApAppUi::EjectStarted( TBool ejectStarted )
-    {
-    TRACES( RDebug::Print( _L( "CSysApAppUi::EjectStarted" ) ) );
-    iMMCEjectUsed = ejectStarted;
-    
-#ifndef RD_MULTIPLE_DRIVE
-    iFileManagerCloseDisabled = ejectStarted;
-#endif // RD_MULTIPLE_DRIVE
-}
-
-// ----------------------------------------------------------------------------
-// CSysApAppUi::DoLightsTimeoutChangedL
-// ----------------------------------------------------------------------------
-void CSysApAppUi::DoLightsTimeoutChangedL( const TInt aTimeout )
-    {
-    iSysApLightsController->DoLightsTimeoutChangedL( aTimeout );
-    }
-
-#ifdef __SYSAP_MODULE_TEST
-
-// ----------------------------------------------------------------------------
-// CSysApAppUi::ModuleTestShowUiNoteL()
-// ----------------------------------------------------------------------------
-
-void CSysApAppUi::ModuleTestShowUiNoteL( const TDesC& noteText ) const
-    {
-    CAknGlobalNote* note = CAknGlobalNote::NewLC();
-    note->SetTone( EAvkonSIDNoSound );
-    note->ShowNoteL( EAknGlobalInformationNote, noteText );
-    CleanupStack::PopAndDestroy(); // note
-    }
-
-#endif
-
-// ----------------------------------------------------------------------------
-// CSysApAppUi::ShowShutdownNoteL()
-// ----------------------------------------------------------------------------
-void CSysApAppUi::ShowShutdownNoteL()
-    {
-    TRACES( RDebug::Print( _L( "CSysApAppUi::ShowShutdownNoteL") ) );
-    ShowUiNoteL( EShutdownNote );
-    User::After( KTimeToShowShutdownNote );
-    }
-
-// ----------------------------------------------------------------------------
-// CSysApAppUi::Beep()
-// ----------------------------------------------------------------------------
-void CSysApAppUi::Beep()
-    {
-    static_cast<CAknAppUi*>(iEikonEnv->EikAppUi())->KeySounds()->PlaySound( EAvkonSIDInformationTone );
-    }
-
-// ----------------------------------------------------------------------------
-// CSysApAppUi::SimSupported()
-// ----------------------------------------------------------------------------
-TBool CSysApAppUi::SimSupported()
-    {
-    return iSysApFeatureManager->SimSupported();
-    }
-
-// ----------------------------------------------------------------------------
-// CSysApAppUi::IsStateNormal()
-//
-// ----------------------------------------------------------------------------
-TBool CSysApAppUi::IsStateNormal() const
-    {
-    TInt state;
-    TInt errorCode =
-        RProperty::Get( KPSUidStartup, KPSGlobalSystemState, state );
-    if ( errorCode == KErrNone )
-        {
-        return state == ESwStateNormalRfOn ||
-               state == ESwStateNormalRfOff ||
-               state == ESwStateNormalBTSap;
-        }
-    else
-        {
-        TRACES( RDebug::Print( _L( "CSysApAppUi::IsStateNormal: Failed to read global system state, error code %d." ), errorCode ) );
-        return EFalse;
-        }
-    }
 
 // ----------------------------------------------------------------------------
 // CSysApAppUi::BatteryEmptyL()
@@ -5743,761 +1982,222 @@
     iSysApCenRepController->SetInt( KCRUidCoreApplicationUIsSysAp, KSysApKeyguardActive, 0 );
     }
 
-// ----------------------------------------------------------------------------
-// CSysApAppUi::Max()
-// ----------------------------------------------------------------------------
-
-TInt CSysApAppUi::Max( const TInt aA, const TInt aB, const TInt aC )
-     {
-     TInt max( aA );
-     if ( aB > max )
-         {
-         max = aB;
-         }
-     if ( aC > max )
-         {
-         max = aC;
-         }
-     return max;
-     }
 
 // ----------------------------------------------------------------------------
-// CSysApAppUi::SetStarterState()
-// ----------------------------------------------------------------------------
-
-TInt CSysApAppUi::SetStarterState( const RStarterSession::TGlobalState aState )
-    {
-    if ( iSysApStartupController->GlobalStateChangeAllowed( aState ) )
-        {
-        TRACES( RDebug::Print( _L("CSysApAppUi::SetStarterState: aState=%d" ), aState ) );
-        return StarterSession().SetState( aState );
-        }
-    else
-        {
-        TRACES( RDebug::Print( _L("CSysApAppUi::SetStarterState: aState=%d - not allowed" ), aState ) );
-        return KErrNone;
-        }
-    }
-
-// ----------------------------------------------------------------------------
-// CSysApAppUi::GetBtSapDeviceNameL()
-// ----------------------------------------------------------------------------
-
-HBufC* CSysApAppUi::GetBtSapDeviceNameL()
-    {
-    return iSysApBtSapController->GetBtSapDeviceNameL();
-    }
-
-// ----------------------------------------------------------------------------
-// CSysApAppUi::ShowAlarmIndicatorL()
-// ----------------------------------------------------------------------------
-
-void CSysApAppUi::ShowAlarmIndicatorL( TBool aShowIndicator )
-    {
-    if ( aShowIndicator)
-        {
-        SetIndicatorStateL( EAknIndicatorAlarmClock, EAknIndicatorStateOn );
-        }
-    else
-        {
-        SetIndicatorStateL( EAknIndicatorAlarmClock, EAknIndicatorStateOff );
-        }
-    }
-
-// ----------------------------------------------------------------------------
-// CSysApAppUi::SimulateFlipKeyEventL()
+// CSysApAppUi::ShowQueryL()
 // ----------------------------------------------------------------------------
 
-void CSysApAppUi::SimulateFlipKeyEventL( TBool aFlipOpen )
+void CSysApAppUi::ShowQueryL( const TSysApConfirmationQueryIds /* aQueryId */, const TDesC& /* aValue */)
     {
-    TRACES( RDebug::Print( _L("CSysApAppUi::SimulateFlipKeyEventL: aFlipOpen: %d" ), aFlipOpen ) );
-
-    /*
-       Flip key is constructed when a flip notification via Pub&Sub is received. The reason behind
-       providing this as a key event is to enable unified handling of keys also with flip, and because
-       flip is captured&consumed by Avkon it is not possible to capture flip key events directly
-       from default handler/plugins.
-    */
-
-    TKeyEvent flipEvent;
-    flipEvent.iCode = aFlipOpen ? EKeyFlipOpen : EKeyFlipClose;
-    flipEvent.iScanCode = 0;
-    flipEvent.iModifiers = 0;
-	flipEvent.iRepeats = 0;
-
-    HandleKeyEventL( flipEvent, EEventKey );
+    // do nothing
     }
 
-// ----------------------------------------------------------------------------
-// CSysApAppUi::SetFlipOpenL()
-// ----------------------------------------------------------------------------
 
-void CSysApAppUi::SetFlipOpenL( TBool aFlipOpen )
-    {
-    iSysApLightsController->SetFlipOpenL( aFlipOpen );
-    }
 
 // ----------------------------------------------------------------------------
-// CSysApAppUi::SetGripOpenL()
-// ----------------------------------------------------------------------------
-void CSysApAppUi::SetGripOpenL( TBool aGripOpen )
-    {
-    iSysApLightsController->SetGripOpenL( aGripOpen );
-    }
-
+// CSysApAppUi::HandleChargingStatusL
 // ----------------------------------------------------------------------------
-// CSysApAppUi::SetNetworkConnectionAllowed()
-// ----------------------------------------------------------------------------
-
-void CSysApAppUi::SetNetworkConnectionAllowed( TCoreAppUIsNetworkConnectionAllowed aNetworkConnectionAllowed )
+//
+void CSysApAppUi::HandleChargingStatusL( const TInt aValue )
     {
-    TRACES( RDebug::Print( _L("CSysApAppUi::SetNetworkConnectionAllowed: status: %d" ), aNetworkConnectionAllowed ) );
-
-    iSysApCenRepController->SetInt( KCRUidCoreApplicationUIs, KCoreAppUIsNetworkConnectionAllowed, (TInt) aNetworkConnectionAllowed );
+    TRACES( RDebug::Print( _L("CSysApAppUi::HandleChargingStatusL aValue: %d"), aValue ) );
+    
+    TBool showNote( ETrue );
+    
+    UpdateBatteryBarsL( StateOfProperty( KPSUidHWRMPowerState, KHWRMBatteryLevel ) );
 
-    // Also set the Symbian PS key used for the same purpose:
-    RProperty::Set(KUidSystemCategory, KUidPhonePwr.iUid, aNetworkConnectionAllowed ? ESAPhoneOn : ESAPhoneOff);
-    }
-
-// ----------------------------------------------------------------------------
-// CSysApAppUi::GetTelServerL()
-// ----------------------------------------------------------------------------
-
-RTelServer* CSysApAppUi::GetTelServer()
-    {
-    if ( iSysApEtelConnector )
+    if ( iSysApPsmController && UiReady() ) 
+        {             
+        if ( iCharging && !iSysApPsmController->ChargerConnected() ) // first time after charger connection
+            {
+            iSysApPsmController->ConnectCharger( ETrue );
+            if ( iSysApPsmController->ShowDeactivateQuery() )
+                {
+                ShowQueryL( ESysApBattChargingPowerSavingQuery );
+                // Query is on the display. Don't show the note.
+                showNote = EFalse;               
+                }
+            else
+                {
+                iSysApPsmController->DoEnablePartialPsm( EFalse );
+                }              
+            }
+        else if ( aValue == EChargingStatusNotConnected )
+            {
+            iSysApPsmController->ConnectCharger( EFalse );
+            }            
+        }
+    if( showNote )
         {
-        return iSysApEtelConnector->GetTelServer();
-        }
-    else
-        {
-        return NULL;
+        HandleChargerNotesL( aValue );    
         }
     }
 
-// ----------------------------------------------------------------------------
-// CSysApAppUi::CoverDisplaySupported()
-// ----------------------------------------------------------------------------
-
-TBool CSysApAppUi::CoverDisplaySupported()
-    {
-    return iSysApFeatureManager->CoverDisplaySupported();
-    }
-
-// ----------------------------------------------------------------------------
-// CSysApAppUi::StarterSession()
-// ----------------------------------------------------------------------------
-
-RStarterSession& CSysApAppUi::StarterSession()
-    {
-    if ( !iStarterSession.Handle() )
-        {
-        // All server connections are tried to be made KTriesToConnectServer times because occasional
-        // fails on connections are possible at least on some servers
-        TRACES( RDebug::Print( _L("CSysApAppUi::StarterSession: trying RStarterSession::Connect()") ) );
-        TInt thisTry = 0;
-        TInt err;
-        while ( ( err = iStarterSession.Connect() ) != KErrNone && ( thisTry++ ) <= KTriesToConnectServer )
-            {
-            User::After( KTimeBeforeRetryingServerConnection );
-            }
-
-        if ( err != KErrNone )
-            {
-            // What do in error case?
-            TRACES( RDebug::Print( _L("CSysApAppUi::StarterSession: RStarterSession::Connect() failed with %d"), err ) );
-            }
-        }
-
-    return iStarterSession;
-    }
-
-// ----------------------------------------------------------------------------
-// CSysApAppUi::KeyLock()
-// ----------------------------------------------------------------------------
-
-RAknKeylock2& CSysApAppUi::KeyLock()
-    {
-    if ( !iKeyLock.Handle() )
-        {
-        // All server connections are tried to be made KTriesToConnectServer times because occasional
-        // fails on connections are possible at least on some servers
-        TInt thisTry = 0;
-        TInt err;
-
-        TRACES( RDebug::Print( _L("CSysApAppUi::KeyLock: trying RAknKeylock2::Connect()") ) );
-        thisTry = 0;
-        while ( ( err = iKeyLock.Connect() ) != KErrNone && ( thisTry++ ) <= KTriesToConnectServer )
-            {
-            User::After( KTimeBeforeRetryingServerConnection );
-            }
-
-        if ( err != KErrNone )
-            {
-            // What do in error case?
-            TRACES( RDebug::Print( _L("CSysApAppUi::KeyLock: RAknKeylock2::Connect() failed with %d"), err ) );
-            }
-        }
-
-    return iKeyLock;
-    }
 
 // ----------------------------------------------------------------------------
-// CSysApAppUi::CenRepController()
-// ----------------------------------------------------------------------------
-
-CSysApCenRepController& CSysApAppUi::CenRepController()
-    {
-    __ASSERT_ALWAYS( iSysApCenRepController, User::Panic( _L("CSysApAppUi::CenRepController"), KErrBadHandle ) );
-
-    return *iSysApCenRepController;
-    }
-
-// ----------------------------------------------------------------------------
-// CSysApAppUi::ExecCommandL
+// CSysApAppUi::HandleChargerNotesL()
 // ----------------------------------------------------------------------------
-//
-void CSysApAppUi::ExecCommandL( TSysapCommand aCommand )
+void CSysApAppUi::HandleChargerNotesL( const TInt aValue )
     {
-    ExecCommandL( aCommand, KNullDesC8 );
-    }
-
-// ----------------------------------------------------------------------------
-// CSysApAppUi::ExecCommandL
-// ----------------------------------------------------------------------------
-//
-void CSysApAppUi::ExecCommandL( TSysapCommand aCommand, const TDesC8& aParam )
-    {
-    TRACES( RDebug::Print(_L("CSysApAppUi::ExecCommandL: aCommand=%d"), aCommand ) );
-
-    switch ( aCommand )
+    TBool showNote(StateOfProperty( KPSUidCtsyCallInformation, KCTsyCallState ) !=  EPSCTsyCallStateRinging);
+    if ( aValue == EChargingStatusCharging )
+        {
+        iSysApLightsController->BatteryEmptyL( EFalse );
+        TRACES( RDebug::Print( _L("SysAp: charger connected") ) );
+        iSysApLightsController->ChargerConnectedL( ETrue );
+        ShowChargingNoteL();
+        }
+    //Display Not Charging note
+    else if ( aValue == EChargingStatusError )
+        {
+        if(showNote)
+            {
+            ShowUiNoteL( ENotChargingNote );
+            }
+        }
+    else if ( aValue == EChargingStatusChargingComplete )
         {
-        case EResetKeyguardState: // reset the internal keyguard flags of the SysAp, except for iKeyLockOnBeforeCradle
-            iKeyLockOnBeforeCall = EFalse;
-            iKeyLockOnBeforeAlarm = EFalse;
-            break;
-
-        case ECancelPowermenu: // hide power menu if it is visible
-            if( iPowerKeyPopupMenuActive )
-                {
-                CancelGlobalListQuery();
-                }
-            break;
-
-        case EUpdateLights: // apply key specific light handling
+        iSysApLightsController->ChargingCompleteL();
+        
+        TSysApNoteIds note( EBatteryFullNote );
+        
+        if ( !iSysApUsbChargerDetector.HostOnlyUsbChargingUsed() &&
+             iSysApFeatureManager->Supported( KSysApFeatureIdChargerReminderNotes ) )
+            {
+            note = EBatteryFullUnplugChargerNote;
+            }
+        iSysApUsbChargerDetector.Reset();
+        if(showNote)
             {
-            TUpdateLightsBuf lightBuf;
-            lightBuf.Copy( aParam );
-
-            switch ( lightBuf() )
+            ShowUiNoteL( note );
+            }
+        }
+    else if ( aValue == EChargingStatusNotConnected )
+        {
+        TRACES( RDebug::Print( _L("SysAp: charger removed") ) );
+        iSysApLightsController->ChargerConnectedL( EFalse );
+        
+        if ( !iSysApUsbChargerDetector.HostOnlyUsbChargingUsed() &&
+             iSysApFeatureManager->Supported( KSysApFeatureIdChargerReminderNotes ) )
+            {
+        if(showNote)
                 {
-                case EKeyGripClose:
-                    SetGripOpenL( EFalse );
-                    break;
-
-                case EKeyGripOpen:
-                    SetGripOpenL( ETrue );
-                    break;
-
-                case EKeyFlipClose:
-                    SetFlipOpenL( EFalse );
-                    break;
-
-                case EKeyFlipOpen:
-                    SetFlipOpenL( ETrue );
-                    break;
-
-                default:
-                    // No specific light handling for other keys.
-                    break;
+                ShowUiNoteL( EUnplugChargerNote );
                 }
             }
-            break;
-
-        default:
-            // do nothing in release builds since no harm is done
-            __ASSERT_DEBUG( EFalse, User::Panic( _L("CSysApAppUi::ExecCommandL: Invalid command"), KErrArgument ) );
-            break;
+        iSysApUsbChargerDetector.Reset();
+        }
+    else if ( aValue == EChargingStatusNotCharging )
+        {
+        TRACES( RDebug::Print( _L("SysAp: Not charging") ) );
+        }
+    else if ( aValue == EChargingStatusAlmostComplete )
+        {
+        TRACES( RDebug::Print( _L("SysAp: Charging almost complete") ) );
+        }
+    else if ( aValue == EChargingStatusChargingContinued )
+        {
+        //in this case we simply want to scroll the battery bars and not turn light on or show ui note
+        // set lights controller iBatteryEmpty to EFalse
+        iSysApLightsController->BatteryEmptyL( EFalse );
+        TRACES( RDebug::Print( _L("SysAp: charging continues") ) );
         }
     }
 
-// ----------------------------------------------------------------------------
-// CSysApAppUi::ExecQueryL
-// ----------------------------------------------------------------------------
-//
-void CSysApAppUi::ExecQueryL( TSysapQuery aQuery, TDes8& aReturn )
-    {
-    ExecQueryL( aQuery, aReturn, KNullDesC8 );
-    }
-
-// ----------------------------------------------------------------------------
-// CSysApAppUi::ExecQueryL
-// ----------------------------------------------------------------------------
-//
-void CSysApAppUi::ExecQueryL( TSysapQuery aQuery, TDes8& aReturn, const TDesC8& /*aParam*/ )
-    {
-    TRACES( RDebug::Print(_L("CSysApAppUi::ExecQueryL: aQuery=%d"), aQuery ) );
-
-    switch ( aQuery )
-        {
-        case EGetHwrmLight: // get handle to HWRM client session. Returns CHWRMLight*.
-            {
-            THwrmLightBuf retBuf( iSysApLightsController->GetHwrmLight() );
-            aReturn.Copy( retBuf );
-            }
-            break;
-
-        case EGetKeylock: // get handle to keylock client session. Returns RAknKeylock2*.
-            {
-            TKeyLockBuf retBuf( &(KeyLock()) );
-            aReturn.Copy( retBuf );
-            }
-            break;
-
-        default:
-            __ASSERT_DEBUG( EFalse, User::Panic( _L("CSysApAppUi::ExecQueryL: Invalid query"), KErrArgument ) );
-            User::Leave( KErrArgument );
-            break;
-        }
-    }
-
-// ----------------------------------------------------------------------------
-// CSysApAppUi::ShowShutdownImage
-// ----------------------------------------------------------------------------
-//
-TInt CSysApAppUi::ShowShutdownImage( TInt aBitmapId )
-    {
-    TRACES( RDebug::Print(_L("CSysApAppUi::ShowShutdownImage") ) );
-
-    TRAPD( err, ShowShutdownImageL( aBitmapId ) );
-
-    if ( err != KErrNone )
-        {
-        TRACES( RDebug::Print(_L("CSysApAppUi::ShowShutdownImageL failed, err=%d"), err ) );
-        }
-
-    return err;
-    }
-
-// ----------------------------------------------------------------------------
-// CSysApAppUi::ShowShutdownImageL
-// ----------------------------------------------------------------------------
-//
-void CSysApAppUi::ShowShutdownImageL( TInt aBitmapId )
-    {
-    TRACES( RDebug::Print(_L("CSysApAppUi::ShowShutdownImageL") ) );
-
-    if ( !iSysApShutdownImage ) // Shutdown image may be shown without entering normal state (e.g. charging), so construct here
-        {
-        TRACES( RDebug::Print( _L("CSysApAppUi::ShowShutdownImageL: trying CSysApShutdownImage::NewL()") ) );
-        iSysApShutdownImage = CSysApShutdownImage::NewL();
-        }
-
-    TRACES( RDebug::Print( _L("CSysApAppUi::ShowShutdownImageL: trying CSysApShutdownImage::ShowShutdownImageL()") ) );
-    iSysApShutdownImage->ShowShutdownImageL( aBitmapId );
-    }
 
 // ----------------------------------------------------------------------------
-// CSysApAppUi::IgnoreZeroNetworkBarNotifications
-// ----------------------------------------------------------------------------
-//
-void CSysApAppUi::IgnoreZeroNetworkBarNotifications(TBool aIgnore)
-    {
-    iIgnoreZeroNetworkBarNotifications = aIgnore;
-    }
-
-// ----------------------------------------------------------------------------
-// CSysApAppUi::BtSapEnabled()
+// CSysApAppUi::UpdateBatteryBarsL( const TInt aState )
 // ----------------------------------------------------------------------------
 
-TBool CSysApAppUi::BtSapEnabled()
+void CSysApAppUi::UpdateBatteryBarsL( const TInt  /* aState */)
     {
-    if ( iSysApBtSapController )
+    TInt state( StateOfProperty( KPSUidHWRMPowerState, KHWRMChargingStatus ) );
+//    TRACES( RDebug::Print( _L("CSysApAppUi::UpdateBatteryBarsL aState: %d, chargerState:%d"), aState, state ) );
+    HandleUsbCharger( state );
+    if( state == EChargingStatusCharging ||
+        state == EChargingStatusChargingContinued ||
+        state == EChargingStatusAlmostComplete )
         {
-        return iSysApBtSapController->BtSapEnabled();    
+        if ( !iCharging )
+            {
+            TRACES( RDebug::Print( _L("CSysApAppUi::UpdateBatteryBarsL: Starting Charging") ) );
+            iCharging = ETrue;
+            }
+        }
+    else
+        {
+        if ( iCharging )
+            {
+            TRACES( RDebug::Print( _L("CSysApAppUi::UpdateBatteryBarsL: Stopping Charging") ) );
+            iCharging = EFalse;
+            }
         }
     
-    return EFalse;
-    }
-
-// ----------------------------------------------------------------------------
-// CSysApAppUi::DeactivateBT
-// ----------------------------------------------------------------------------
-//
-void CSysApAppUi::DeactivateBT()
-    {
-    // Will deactivate BT when changing to normal mode
-    iDeactivateBt = ETrue;
-    }
-
-// ----------------------------------------------------------------------------
-// CSysApAppUi::SetHacIndicatorL()
-// ----------------------------------------------------------------------------
-void CSysApAppUi::SetHacIndicatorL()
-    {
-
-    if ( !iSysApCenRepHacSettingObserver )
+    if ( !iSysApPsmController ) // created here if first state change has not occurred yet
         {
-        // Do nothing if HAC setting observer has not been created yet
-        // This occurs in case some party is trying to set HAC indicator during
-        // ConstructL(), e.g. when switching from offline to online during startup
-        TRACES( RDebug::Print( _L("CSysApAppUi::SetHacIndicatorL: do nothing, HAC observer does not exist yet") ) );
-        return;
+        iSysApPsmController = CSysApPsmController::NewL( *this );        
         }
 
-    if ( iSysApCenRepHacSettingObserver->HacMode() )
+    if ( iSysApPsmController )
         {
-        TBool accessoryConnected ( EFalse );
-
-        TAccMode accMode(EAccModeHandPortable);
-
-        if ( iSysApAccessoryObserver )
-            {
-            accMode = iSysApAccessoryObserver->GetAccessoryMode();
-
-            if ( accMode != EAccModeHandPortable )
-                {
-                accessoryConnected = ETrue;
-                }
-            }
-
-        TInt indicatorState = EAknIndicatorStateOn;
-
-        if ( !accessoryConnected ) // When accessory is not connected, check offline and call state
+        if ( iSysApPsmController->FullPsmEnabled() )
             {
-            if ( OfflineModeActive() ) // HAC indicator is not shown in offline mode
-                {
-                indicatorState = EAknIndicatorStateOff;
-                }
-            else
-                {
-                // during active call with IHF activated HAC indicator is not shown
-                TInt callState( StateOfProperty( KPSUidCtsyCallInformation, KCTsyCallState ) );
-                if ( callState < KErrNone )
-                    {
-                    callState = EPSCTsyCallStateNone;
-                    }
-
-                if ( callState != EPSCTsyCallStateNone && IhfEnabledL() )
-                    {
-                    indicatorState = EAknIndicatorStateOff;
-                    }
-                }
-
+             // activate psm indicator 
             }
         else
             {
-            // If an accessory is connected, HAC indicator should not be shown
-            indicatorState = EAknIndicatorStateOff;
-            }
-
-        SetIndicatorStateL( EAknIndicatorHAC, indicatorState );
-
+            // deactivate psm indicator
+            }            
         }
-    else
+        
+       if ( iSysApBatteryInfoController )        
         {
-        // If HAC is not active, always disable indicator regardless of accessory state
-        SetIndicatorStateL( EAknIndicatorHAC, EAknIndicatorStateOff );
+         iSysApBatteryInfoController->BatteryLevelUpdatedL();
         }
+        
+     }
 
 
-    }
 
 // ----------------------------------------------------------------------------
-// CSysApAppUi::HandleResourceChangeL()
+// CSysApAppUi::ShowChargingNoteL()
 // ----------------------------------------------------------------------------
 
-void CSysApAppUi::HandleResourceChangeL( TInt aType )
+void CSysApAppUi::ShowChargingNoteL()
     {
-    TRACES( RDebug::Print( _L("CSysApAppUi::HandleResourceChangeL aType: %d"), aType ) );
-    CAknAppUi::HandleResourceChangeL(aType);
+    TRACES( RDebug::Print( _L("CSysApAppUi::ShowChargingNoteL") ) );
+    TBool showNote( ETrue );
 
-    if ( aType == KEikDynamicLayoutVariantSwitch )
+    TInt swState( StateOfProperty( KPSUidStartup, KPSGlobalSystemState ) );
+    TRACES( RDebug::Print( _L("CSysApAppUi::ShowChargingNoteL: swState: %d"), swState ) );
+
+    if( UiReady() || swState == ESwStateSecurityCheck )
         {
-#ifdef RD_STARTUP_ANIMATION_CUSTOMIZATION
-        iSysApShutdownImage->SetRect( ApplicationRect() );
-#endif // RD_STARTUP_ANIMATION_CUSTOMIZATION
-
-        TInt mode;
-        User::LeaveIfError( RProperty::Get( KPSUidStartup, KPSGlobalStartupMode, mode ) );
-
-        if ( mode == EStartupModeAlarm )
+        if ( StateOfProperty( KPSUidCtsyCallInformation, KCTsyCallState ) ==  EPSCTsyCallStateRinging )
+            {
+            showNote = EFalse;
+            }
+        TRACES( RDebug::Print( _L("CSysApAppUi::ShowChargingNoteL KCTsyCallState=%d"), StateOfProperty( KPSUidCtsyCallInformation, KCTsyCallState ) ) );
+        if ( showNote ) // Power Mgmt UI spec defines that no Charging note is shown while the phone is ringing/alerting
             {
-            SetStatusPaneLayoutL( ESysApAlarm );
+            /* 
+            TRACES( RDebug::Print( _L("CSysApWsClient::RunL(): Key EEventKeyUp 01") ) );   
+            _LIT(KChargingNote,"txt_power_management_dblist_charging");
+            HBufC* chargingNote = HbTextResolverSymbian::LoadL(KChargingNote);
+            CHbDeviceNotificationDialogSymbian::NotificationL(KNullDesC,*chargingNote);     
+            */
+             
+            _LIT(KChargingNote,"Charging");
+            HBufC* aString = HBufC16::NewLC(50);
+            TPtrC aStringPointer = aString->Des();
+            aStringPointer.Set(KChargingNote);
+            TRACES( RDebug::Print( _L("CSysApWsClient::RunL(): Key EEventKeyUp 01") ) );   
+            ShowExampleUiNoteL( aStringPointer );
+            CleanupStack::PopAndDestroy(); // aString            
             }
         }
     }
 
-// ----------------------------------------------------------------------------
-// CSysApAppUi::SetMemoryCardIndicatorL
-// ----------------------------------------------------------------------------
-
-void CSysApAppUi::SetMemoryCardIndicatorL()
-    {
-    if ( iSysApFeatureManager->Supported( KSysApFeatureIdMemoryCardIcon ) )
-        {
-#ifndef RD_MULTIPLE_DRIVE
-        TSysApMemoryCardStatus memoryCardStatus = iSysApMMCObserver->MemoryCardStatus();
-
-        TRACES( RDebug::Print( _L("CSysApAppUi::SetMemoryCardIndicatorL: memoryCardStatus=%d"), memoryCardStatus ) );
-
-        if ( memoryCardStatus == ESysApMemoryCardInserted || memoryCardStatus == ESysApMemoryCardLocked )
-#else // RD_MULTIPLE_DRIVE
-        TInt insertedCount( CSysApDriveList::NonUsbDriveCount( iInsertedMemoryCards ) );
-
-        TRACES( RDebug::Print( _L("CSysApAppUi::SetMemoryCardIndicatorL: insertedCount=%d"), insertedCount ) );
-
-        if ( insertedCount > 0 )
-#endif // RD_MULTIPLE_DRIVE
-            {
-            SetIndicatorStateL( EAknIndicatorMemoryCard, EAknIndicatorStateOn );
-            }
-        else
-            {
-            SetIndicatorStateL( EAknIndicatorMemoryCard, EAknIndicatorStateOff );
-            }
-        }
-    }
-
-// ----------------------------------------------------------------------------
-// CSysApAppUi::SysApFeatureManager
-// ----------------------------------------------------------------------------
-
-CSysApFeatureManager& CSysApAppUi::SysApFeatureManager()
-    {
-    __ASSERT_DEBUG( iSysApFeatureManager, User::Panic( _L("iSysApFeatureManager == NULL"), KErrBadHandle ) );
-
-    return *iSysApFeatureManager;
-    }
-
-// ----------------------------------------------------------------------------
-// CSysApAppUi::SetUsbAttachStatus
-// ----------------------------------------------------------------------------
-#ifndef RD_MULTIPLE_DRIVE
-void CSysApAppUi::SetUsbAttachStatus( const TBool aUsbAttached )
-    {
-    // Prevent double beep when USB file transfer gets activated but
-    // allow MMC inserted beep when:
-    // a) USB file transfer is active
-    // b) MMC is not inserted when USB cable is attached
-    iHideNextBeep = ( iMMCInserted && aUsbAttached );
-    }
-#else // RD_MULTIPLE_DRIVE
-void CSysApAppUi::SetUsbAttachStatus( const TBool aUsbAttached )
-    {
-    TRACES( RDebug::Print(
-        _L( "CSysApAppUi::SetUsbAttachStatus: aUsbAttached: %d" ),
-        aUsbAttached ) );
-
-    if ( aUsbAttached )
-        {
-        // For ignoring extra beeps caused by USB file transfer
-        iSysApDriveList->ResetDrivesInsertBeepIgnored();
-        iSysApDriveList->MarkDrivesInsertBeepIgnored( iInsertedMemoryCards );
-        }
-    }
-#endif // RD_MULTIPLE_DRIVE
-
-// ----------------------------------------------------------------------------
-// CSysApAppUi::IhfEnabledL
-// ----------------------------------------------------------------------------
-
-TBool CSysApAppUi::IhfEnabledL()
-    {
-    TRACES( RDebug::Print( _L("CSysApAppUi::IhfEnabledL(): iSysApAudioRoutingObserver=0x%x"), iSysApAudioRoutingObserver ) );
-
-    if ( !iSysApAudioRoutingObserver ) // create observer if needed
-        {
-        iSysApAudioRoutingObserver = CSysApAudioRoutingObserver::NewL( *this );
-        }
-
-    return iSysApAudioRoutingObserver->IhfEnabled();
-    }
-
-// ----------------------------------------------------------------------------
-// CSysApAppUi::IsDeviceModeKey
-// ----------------------------------------------------------------------------
-
-TBool CSysApAppUi::IsDeviceModeKey( const TKeyEvent& aKeyEvent ) const
-    {
-    return CSysApDefaultKeyHandler::IsDeviceModeKey( aKeyEvent );
-    }
-
-// ----------------------------------------------------------------------------
-// CSysApAppUi::ResourcesFreed
-// ----------------------------------------------------------------------------
-
-TBool CSysApAppUi::ResourcesFreed() const
-    {
-    return iResourcesFreed;
-    }
-
-/* 
-----------------------------------------------------------------------------
-CSysApAppUi::IsEncryptionOperationOngoingL()
-Introduced the code as a part of Sub : 405-3362 - Power Management SUB for ES 
-recapture functionalities in platform which support multidrive as well. 
--------------------------------------------------------------------------------
-*/
-TBool CSysApAppUi::IsEncryptionOperationOngoingL() const
-    {
-		TBool deFeatureSupported(EFalse);
-		FeatureManager::InitializeLibL();
-		deFeatureSupported = FeatureManager::FeatureSupported( KFeatureIdFfDeviceEncryptionFeature);
-		FeatureManager::UnInitializeLib();
-
-		if(deFeatureSupported)
-			{         
-			/**
-			 * Store the last memory status changed
-			 * 0: Idle. It can be Encrypted or Decrypted
-			 * 1: Encrypting
-			 * 2: Decrypting
-			 **/
-			 
-			RProperty deProperty;
-			User::LeaveIfError(deProperty.Attach(KDevEncProtectedUid, KDevEncOperationKey,EOwnerThread));
-			TInt deValue = 0;
-			if((deProperty.Get(deValue)== KErrNone)&&( deValue == EOpEncrypting || deValue == EOpDecrypting))
-				{
-				deProperty.Close();
-				return ETrue;
-				}
-			else
-				{
-				deProperty.Close();
-				return EFalse;
-				}
-			}
-		else
-			{
-			return EFalse;
-			}
-    }
-// ----------------------------------------------------------------------------
-// CSysApAppUi::EtelConnector
-// ----------------------------------------------------------------------------
-
-CSysApEtelConnector* CSysApAppUi::EtelConnector() const
-    {
-    return iSysApEtelConnector;
-    }
-
-#ifndef RD_MULTIPLE_DRIVE
-
-// ----------------------------------------------------------------------------
-// CSysApAppUi::EjectUsed
-// ----------------------------------------------------------------------------
-
-void CSysApAppUi::EjectUsed( TInt /*aDrive*/ )
-    {
-    }
-
-#else // RD_MULTIPLE_DRIVE
-
-// ----------------------------------------------------------------------------
-// CSysApAppUi::ShowEjectWaitNoteL
-// ----------------------------------------------------------------------------
-
-void CSysApAppUi::ShowEjectWaitNoteL( TInt aDriveToEject )
-    {
-    if ( iSysApWaitNote )
-        {
-        return;
-        }
-    HBufC* text = iSysApDriveList->GetFormattedDriveNameLC(
-        aDriveToEject,
-        0, // Not used
-        R_QTN_EJECTING_MEMORY_NAME_WAIT );
-    iSysApWaitNote = CSysApWaitNote::NewL(
-        iSysApFeatureManager->CoverDisplaySupported() );
-    iSysApWaitNote->ShowNoteL( EClosingApplicationsNote, text );
-    CleanupStack::PopAndDestroy( text );
-    }
-
-// ----------------------------------------------------------------------------
-// CSysApAppUi::IsEjectQueryVisible
-// ----------------------------------------------------------------------------
-
-TBool CSysApAppUi::IsEjectQueryVisible()
-    {
-    if ( !iSysApConfirmationQuery )
-        {
-        return EFalse;
-        }
-    TInt queryId( iSysApConfirmationQuery->CurrentQuery() );
-    return ( queryId == ESysApEjectMmcQuery || queryId == ESysApRemoveMmcNote );
-    }
-
-// ----------------------------------------------------------------------------
-// CSysApAppUi::UpdateInsertedMemoryCardsL
-// ----------------------------------------------------------------------------
-
-void CSysApAppUi::UpdateInsertedMemoryCardsL()
-    {
-    // Update inserted memory cards
-    iSysApDriveList->GetMemoryCardsL(
-        iInsertedMemoryCards, CSysApDriveList::EIncludeInserted );
-
-    // Update memory card indicator status
-    SetMemoryCardIndicatorL();
-
-    // Handle unlock
-    RunUnlockNotifierL();
-    }
-
-// ----------------------------------------------------------------------------
-// CSysApAppUi::EjectUsed
-// ----------------------------------------------------------------------------
-
-void CSysApAppUi::EjectUsed( TInt aDrive )
-    {
-    // Check drive inserted before starting eject confirm query
-    TInt insertedIndex( CSysApDriveList::Find( iInsertedMemoryCards, aDrive ) );
-
-    TRACES( RDebug::Print(
-        _L( "CSysApAppUi::EjectUsed: drive: %d, index: %d" ),
-        aDrive, insertedIndex ) );
-
-    if ( insertedIndex == KErrNotFound )
-        {
-        return;
-        }
-
-    iMMCEjectUsed = ETrue;
-    iDriveToEject = aDrive;
-    iSysApDriveList->ResetDrivesToEject();
-    TRAPD( err, EjectMMCL() );
-    if ( err != KErrNone )
-        {
-        TRACES( RDebug::Print(
-            _L( "CSysApAppUi::EjectUsed: err: %d" ), err ) );
-        iMMCEjectUsed = EFalse;
-        }
-    }
-
-#endif // RD_MULTIPLE_DRIVE
-
-// ----------------------------------------------------------------------------
-// CSysApAppUi::EjectMMCCanceled
-// ----------------------------------------------------------------------------
-
-void CSysApAppUi::EjectMMCCanceled()
-    {
-    // Called from eject confirm query, reset eject status
-#ifdef RD_MULTIPLE_DRIVE
-    iMMCEjectUsed = EFalse;
-#endif // RD_MULTIPLE_DRIVE
-    }
-
-// ----------------------------------------------------------------------------
-// CSysApAppUi::UsbChargerDetector
-// ----------------------------------------------------------------------------
-//
-TSysApUsbChargerDetector& CSysApAppUi::UsbChargerDetector()
-    {
-    return iSysApUsbChargerDetector;
-    }
 
 // ----------------------------------------------------------------------------
 // CSysApAppUi::HandleUsbCharger
@@ -6527,36 +2227,252 @@
     }
 
 // ----------------------------------------------------------------------------
-// CSysApAppUi::SetEnvelopeIndicatorL
+// CSysApAppUi::HandleCurrentCallStateChangeL()
 // ----------------------------------------------------------------------------
-//
-void CSysApAppUi::SetEnvelopeIndicatorL()
+
+void CSysApAppUi::HandleCurrentCallStateChangeL( TInt aCurrentCallState )
     {
-    TInt phoneStoreStatus( StateOfProperty( KUidPSSMSStackCategory, KUidPSSMSStackDiskSpaceMonitorKey ) );
-    TInt inboxStatus( StateOfProperty( KUidSystemCategory, KUidInboxStatusValue ) );
-    TBool simStoreFull( iSysApEtelConnector && iSysApEtelConnector->IsSimSmsStoreFull() );
+    TRACES( RDebug::Print( _L("CSysApAppUi::HandleCurrentCallStateChangeL: KUidCurrentCall: %d" ), aCurrentCallState ) );
+
+    switch ( aCurrentCallState )
+        {
+        case EPSCTsyCallStateRinging:
+            {
+            iSysApLightsController->CallComingInL( ETrue );
+            // Disable keylock when a call is coming in
+            if ( iKeyLockEnabled || iDeviceLockEnabled || iKeyLockOnBeforeCradle || iKeyLockOnBeforeAlarm )
+                {
+                TRACES( RDebug::Print( _L("CSysApAppUi::HandleCurrentCallStateChangeL: EPSCTsyCallStateRinging: disable keylock") ) );
+                iKeyLockOnBeforeCall = ETrue;
+
+                if ( iKeyLockEnabled || iDeviceLockEnabled )
+                    {
+                    if ( !iSysApFeatureManager->TouchUnlockStrokeSupported() )
+                        {
+                        iKeyguardController->DisableKeyguard(EFalse);
+                        }
+                    }
+                }
+            break;
+            }
+            
+        case EPSCTsyCallStateDialling:
+            {
+            // Disable keypad lock during an emergency call
+            // no need to disable the key lock when a call is made using the wireless car-kit
+            // but if the call is an emergency one then we will disable the keypad lock
+            if ( iKeyLockEnabled || iDeviceLockEnabled || iKeyLockOnBeforeCradle )
+                {
+                TRACES( RDebug::Print( _L("CSysApAppUi::HandleCurrentCallStateChangeL: EPSCTsyCallStateDialling: disable keylock") ) );
+                iKeyLockOnBeforeCall = ETrue;
+
+                if ( IsEmergencyCall() && (iKeyLockEnabled || iDeviceLockEnabled ))
+                    {
+                    iKeyguardController->DisableKeyguard(EFalse);
+                    }
+                }
+
+            // Enable signal & network indicators when an emergency call is made in Offline Mode
+            if( iSysApOfflineModeController->OfflineModeActive() )
+                    {
+                    // Signal indicators not updated with VoIP call
+                    if ( StateOfProperty(KPSUidCtsyCallInformation, KCTsyCallType) != EPSCTsyCallTypeVoIP) 
+                        {
+                        iEmergencyCallActive = ETrue;
+                        // not supporting this
+                        // UpdateSignalBarsL();
+                        // SetSignalIndicatorL();
+                        }
+                    }
+            break;
+            }
+            
+        case EPSCTsyCallStateConnected:
+            {
+            if (StateOfProperty(KPSUidCtsyCallInformation, KCTsyCallType) == EPSCTsyCallTypeCSVoice)
+                {
+                // Check if GPRS suspended note is required
+                iCallActivated = ETrue;
+                // not supporting this
+                // HandleGprsNotesL();
+                }
+            if ( iDeviceLockEnabled )
+                {
+                // Enable keylock via autolock emulation if device lock enabled. 
+                // Otherwise e.g. messages can be read using softkeys during ongoing call.
+                iKeyguardController->EnableKeyguard(EFalse);
+                }
+            break;
+            }
+
+        case EPSCTsyCallStateNone:
+            {
+            // Reset timers in ScreenSaver and Autolock
+            User::ResetInactivityTime();
 
-    TRACES( RDebug::Print(
-        _L("CSysApAppUi::SetEnvelopeIndicatorL() phoneStoreStatus %d, simStoreFull %d, inboxStatus %d"),
-        phoneStoreStatus, simStoreFull, inboxStatus ) );
+            if ( iEmergencyCallActive )
+                {
+                iEmergencyCallActive = EFalse;
+                // not supporting this
+                // UpdateSignalBarsL( 0 );
+                // SetSignalIndicatorL();
+                }
+            if ( iKeyLockOnBeforeCall )
+                {
+                TRACES( RDebug::Print( _L("CSysApAppUi::HandleCurrentCallStateChangeL: EPSCTsyCallStateNone: enable keylock") ) );
+                iKeyLockOnBeforeCall = EFalse;
+                if ( !iDeviceLockEnabled )
+                    {
+                    if ( !iKeyLockOnBeforeCradle && !iKeyLockOnBeforeAlarm &&
+                          !iSysApFeatureManager->TouchUnlockStrokeSupported() )
+                        {
+                        if ( iSysApCenRepController->GetInt( KCRUidCommonTelephonySettings, KSettingsSummaryAfterCall ) == 1 )
+                            {
+                            // Let's not hide "Summary After Call" dialog
+                            iKeyguardController->EnableKeyguard(EFalse);
+                            }
+                        else
+                            {
+                            iKeyguardController->EnableKeyguard(ETrue);
+                            }
+                        }
+                    }
+                else
+                    {
+                    iKeyguardController->EnableKeyguard(EFalse);
+                    }
+                }
+            if ( iShowkeypadActivatedNoteAfterSoftReject )
+                {
+                ShowUiNoteL( EKeypadActiveNote );
+                iShowkeypadActivatedNoteAfterSoftReject = EFalse;
+                }
+            iCallActivated = EFalse;
+            break;
+            }
+            
+        default:
+            break;
+        }
 
-    if ( phoneStoreStatus == ESmsDiskSpaceFull || simStoreFull )
+    if ( aCurrentCallState != EPSCTsyCallStateRinging )
         {
-        // Blink the Envelope indicator
-        SetIndicatorStateL( EAknIndicatorEnvelope, EAknIndicatorStateAnimate );
+        iSysApLightsController->CallComingInL( EFalse );
         }
-    else if ( inboxStatus == ESADocumentsInInbox )
+
+    SetIhfIndicatorL();
+    SetHacIndicatorL();
+    }
+
+
+
+/**
+ * To check the for an emergency call. 
+ * 
+ * @return ETrue if there is an emergency call active otherwise, EFalse.
+ */
+TBool CSysApAppUi::IsEmergencyCall()
         {
-        // Show the Envelope indicator.
-        SetIndicatorStateL( EAknIndicatorEnvelope, EAknIndicatorStateOn );
+        TBool retVal( EFalse );
+        TInt err( KErrNone );
+        TInt state( 0 );
+     
+        err = RProperty::Get(KPSUidCtsyEmergencyCallInfo, KCTSYEmergencyCallInfo, state );
+        if ( err == KErrNone && state )
+            {
+            retVal = ETrue;            
+            }
+        return retVal;
+        }
+
+
+
+// ----------------------------------------------------------------------------
+// CSysApAppUi::IsStateNormal()
+//
+// ----------------------------------------------------------------------------
+TBool CSysApAppUi::IsStateNormal() const
+    {
+    TInt state;
+    TInt errorCode =
+        RProperty::Get( KPSUidStartup, KPSGlobalSystemState, state );
+    if ( errorCode == KErrNone )
+        {
+        return state == ESwStateNormalRfOn ||
+               state == ESwStateNormalRfOff ||
+               state == ESwStateNormalBTSap;
         }
     else
         {
-        // Hide the Envelope indicator.
-        SetIndicatorStateL( EAknIndicatorEnvelope, EAknIndicatorStateOff );
+        TRACES( RDebug::Print( _L( "CSysApAppUi::IsStateNormal: Failed to read global system state, error code %d." ), errorCode ) );
+        return EFalse;
         }
     }
-    
+
+
+// ----------------------------------------------------------------------------
+// CSysApAppUi::HandleAccessoryProfileInStartupL()
+// ----------------------------------------------------------------------------
+
+void CSysApAppUi::HandleAccessoryProfileInStartupL()
+    {
+    TRACES( RDebug::Print( _L( "CSysApAppUi::HandleAccessoryProfileInStartupL" ) ) );
+
+    if ( !iSysApOfflineModeController->OfflineModeActive() )
+        {
+        iIgnoreAccessorySpecificProfileChanges = EFalse;
+        TBool accessoryConnectedInShutdown( EFalse );
+        TInt accessoryTemp( iSysApCenRepController->GetInt( KCRUidCoreApplicationUIsSysAp, KSysApAccessoryConnected ) );
+        if ( accessoryTemp == 1 )
+            {
+            accessoryConnectedInShutdown = ETrue;
+            }
+
+        TBool accessoryConnectedNow ( EFalse );
+
+        TAccMode accessoryState(EAccModeHandPortable);
+        if ( iSysApAccessoryObserver )
+            {
+            accessoryState = iSysApAccessoryObserver->GetAccessoryMode();
+            }
+
+        if ( accessoryState != EAccModeHandPortable )
+            {
+            accessoryConnectedNow = ETrue;
+            }
+        TRACES( RDebug::Print( _L( "CSysApAppUi::HandleAccessoryProfileInStartupL: accessoryConnectedInShutdown: %d, accessoryConnectedNow: %d" ),
+                              accessoryConnectedInShutdown, accessoryConnectedNow ) );
+
+        if ( accessoryConnectedInShutdown && !accessoryConnectedNow )
+            {
+            HandleAccessoryDisconnectedL();
+            }
+        else if ( !accessoryConnectedInShutdown && accessoryConnectedNow )
+            {
+            HandleAccessoryConnectedL( accessoryState );
+            }
+        else if ( !accessoryConnectedNow )
+            {
+            // not supporting this 
+            // TInt activeProfile ( ActiveProfileId() );
+            // SysApCenRepController->SetInt( KCRUidCoreApplicationUIsSysAp, KSysApActiveProfileBeforeAccessoryConnected, activeProfile );
+            }
+        }
+    }
+
+
+// ----------------------------------------------------------------------------
+// CSysApAppUi::CenRepController()
+// ----------------------------------------------------------------------------
+
+CSysApCenRepController& CSysApAppUi::CenRepController()
+    {
+    __ASSERT_ALWAYS( iSysApCenRepController, User::Panic( _L("CSysApAppUi::CenRepController"), KErrBadHandle ) );
+
+    return *iSysApCenRepController;
+    }
+
+
 // ----------------------------------------------------------------------------
 // CSysApAppUi::LogsObserverL
 // ----------------------------------------------------------------------------
@@ -6573,192 +2489,249 @@
     
     return *iSysApCenRepLogsObserver;
     }
-    
+
+
 // ----------------------------------------------------------------------------
-// CSysApAppUi::NotifyPowerSaveModeL
+// CSysApAppUi::HandleWlanIndicator()
 // ----------------------------------------------------------------------------
-//
-void CSysApAppUi::NotifyPowerSaveModeL( TSysApPsmStatus aStatus )
+void CSysApAppUi::HandleWlanIndicatorL( TInt aValue )
     {
-    TRACES( RDebug::Print( _L("CSysApAppUi::NotifyPowerSaveModeL aStatus: %d"), aStatus ) );
-
-    // cancel any active power saving query because user has changed the state manually
-    CancelQuery( ESysApBattChargingPowerSavingQuery );
-    CancelQuery( ESysApBattLowPowerSavingQuery );
-    
-    switch ( aStatus )
+    if ( aValue == EPSWlanIndicatorAvailable )
+        {
+        // do nothing
+        }
+    else if ( aValue == EPSWlanIndicatorActive )
+        {
+        // do nothing
+        }
+    else if ( aValue == EPSWlanIndicatorActiveSecure )
+        {
+        // do nothing
+        }
+    else // No indication required
         {
-        case MSysApPsmControllerNotifyCallback::EPsmActivationComplete:
-            UpdateBatteryBarsL( StateOfProperty( KPSUidHWRMPowerState, KHWRMBatteryLevel ) );
-            ShowUiNoteL( EPowerSaveModeActivated );
-            break;
-        
-        case MSysApPsmControllerNotifyCallback::EPsmDeactivationComplete:
-            UpdateBatteryBarsL( StateOfProperty( KPSUidHWRMPowerState, KHWRMBatteryLevel ) );
-            ShowUiNoteL( EPowerSaveModeDeactivated );
-            break;
-            
-        case MSysApPsmControllerNotifyCallback::EPsmActivationFailed:
-            ShowUiNoteL( ECannotActivatePowerSaveMode );
-            break;
-            
-        case MSysApPsmControllerNotifyCallback::EPsmDeactivationFailed:
-            ShowUiNoteL( ECannotDeactivatePowerSaveMode );
-            break;            
-        
-        default:
-            break;   
+        // do nothing
+        }
+    }
+
+void CSysApAppUi::ShowNotificationDialog(const TDesC& noteText)const
+{
+    //Todo:4.Notification--Just Popup message
+    //Todo: #include <HbDeviceNotificationDialogSymbian.h>
+    CHbDeviceNotificationDialogSymbian *notificationDialog =  CHbDeviceNotificationDialogSymbian::NewL();
+    CleanupStack::PushL(notificationDialog);
+    notificationDialog->SetTextL(noteText);//noteText with Qm file input
+    notificationDialog->SetTimeout(100);
+    notificationDialog->ShowL();
+    CleanupStack::PopAndDestroy(notificationDialog);
+}
+
+void CSysApAppUi::SetKeyLockEnabledL()
+    {
+    iKeyLockEnabled = ETrue;
+    iSysApCenRepController->SetInt( KCRUidCoreApplicationUIsSysAp, KSysApKeyguardActive, 1 );
+    // not supporting indicator 
+//    SetIndicatorStateL( EAknIndicatorKeyguard, EAknIndicatorStateOn );
+    iSysApLightsController->KeylockStateChangedL( ETrue );
+    }
+
+void CSysApAppUi::SetKeyLockDisabledL()
+    {
+    iKeyLockEnabled = EFalse;
+    iSysApCenRepController->SetInt( KCRUidCoreApplicationUIsSysAp, KSysApKeyguardActive, 0 );
+    // SetIndicatorStateL( EAknIndicatorKeyguard, EAknIndicatorStateOff );
+    if (! iDeviceLockEnabled )
+        {
+        iSysApLightsController->KeylockStateChangedL( EFalse );
+        if ( iSysApFeatureManager->MmcHotSwapSupported() )
+            {
+            if ( StateOfProperty( KPSUidCtsyCallInformation, KCTsyCallState ) !=  EPSCTsyCallStateRinging && StateOfProperty( KPSUidCtsyCallInformation, KCTsyCallState ) !=  EPSCTsyCallStateAlerting )
+                {
+                // RunUnlockNotifierL();
+                // need to handle MMC unlock query in next sub
+                }
+            }
         }
     }
 
-// ----------------------------------------------------------------------------
-// CSysApAppUi::HandleBatteryStatusL
-// ----------------------------------------------------------------------------
-//
-void CSysApAppUi::HandleBatteryStatusL( const TInt aValue )
+void CSysApAppUi::SetLightsOnUnlockNoteL()
+    {
+    iSysApLightsController->SetLightsOnUnlockNoteL();
+    }
+
+void CSysApAppUi::SetLightsOnEcsQueryL()
     {
-    TRACES( RDebug::Print( _L("CSysApAppUi::HandleBatteryStatusL aValue: %d"), aValue ) );
-    
-    if ( aValue == EBatteryStatusEmpty )
-        {
-        //Display Recharge Battery note
-        ShowUiNoteL( ERechargeBatteryNote );
-        BatteryEmptyL();
-        }
-    else if ( aValue == EBatteryStatusLow )
-        {
-        if ( iSysApPsmController && UiReady() )
-            {
-            iSysApPsmController->BatteryLow( ETrue );
-            
-            if ( iSysApPsmController->ShowActivateQuery())
-                {
-                // show activation query, replaces the first battery low query
-                ShowQueryL( ESysApBattLowPowerSavingQuery );
-                }
-            else // default low warning note must be shown
-                {
-                // activate partial power save mode on first low warning
-                iSysApPsmController->DoEnablePartialPsm( ETrue ); // activated on first warning note
-                //Display Battery Low note.
-                ShowUiNoteL( EBatteryLowNote );    
-                }                
-            }
-        else
-            {
-            //Display Battery Low note.
-            ShowUiNoteL( EBatteryLowNote );    
-            }            
-        }
-    
-    if ( iSysApBatteryInfoController )
-        {
-        iSysApBatteryInfoController->BatteryStatusUpdated( aValue );
-        }
-            
+    iSysApLightsController->SetLightsOnEcsQueryL();
+    }
+
+void CSysApAppUi::SetLightsOnSecurityQueryL()
+    {
+    iSysApLightsController->SetLightsOnSecurityQueryL();
+    }
+
+TBool CSysApAppUi::CheckLongPowerKeyPressed()
+    {
+    return iCheckLongPowerKeyEvent;
     }
 
-// ----------------------------------------------------------------------------
-// CSysApAppUi::HandleChargingStatusL
+
 // ----------------------------------------------------------------------------
-//
-void CSysApAppUi::HandleChargingStatusL( const TInt aValue )
+// CSysApAppUi::HandleKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType )
+// ----------------------------------------------------------------------------
+
+TKeyResponse CSysApAppUi::HandleKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType )
     {
-    TRACES( RDebug::Print( _L("CSysApAppUi::HandleChargingStatusL aValue: %d"), aValue ) );
-    
-    TBool showNote( ETrue );
-    
-    UpdateBatteryBarsL( StateOfProperty( KPSUidHWRMPowerState, KHWRMBatteryLevel ) );
-
-    if ( iSysApPsmController && UiReady() ) 
+    if ( ! iShutdownStarted )
         {
-        if ( iCharging ) // iCharging updated in UpdateBatteryBarsL
+        TRACES( RDebug::Print( _L("CSysApAppUi::HandleKeyEventL: aKeyEvent.iCode:%d, aKeyEvent.iScanCode:%d, aType:%d, iIgnoreNextPowerKeyUpEvent:%d, iPowerKeyPopupMenuActive:%d, iLastPowerKeyWasShort:%d, iPowerKeyPopupMenuDismissed:%d"),
+                               aKeyEvent.iCode, aKeyEvent.iScanCode, aType, iIgnoreNextPowerKeyUpEvent, iPowerKeyPopupMenuActive, iLastPowerKeyWasShort, iPowerKeyPopupMenuDismissed ) );
+
+#ifdef _DEBUG
+        // camery latency measurement environment instrumentation, don't remove
+        if ( aType == EEventKey && aKeyEvent.iCode == EKeyCamera )
             {
-            // cancel activation query if charger is connected while query is on display
-            CancelQuery( ESysApBattLowPowerSavingQuery );
+            TRACES( RDebug::Print( _L("e_KEY_EVENT_SENDING 0") ) );
             }
-             
-        if ( iCharging && !iSysApPsmController->ChargerConnected() ) // first time after charger connection
+#endif // _DEBUG
+
+        TKeyResponse response(EKeyWasNotConsumed);
+        if (response)
+            {
+            //Do nothing:: To supress warning
+            }
+        if (iSysApKeyManagement && aKeyEvent.iCode != EKeyPowerOff && aKeyEvent.iCode != 'E')
+            {
+            response = iSysApKeyManagement->HandleKeyEventL(aKeyEvent, aType );
+            }
+        
+        if( aType == EEventKey )
             {
-            iSysApPsmController->ConnectCharger( ETrue );
-            
-            if ( iSysApPsmController->ShowDeactivateQuery() )
-                {
-                ShowQueryL( ESysApBattChargingPowerSavingQuery );
-                // Query is on the display. Don't show the note.
-                showNote = EFalse;               
-                }
-            else
+            switch ( aKeyEvent.iCode )
                 {
-                iSysApPsmController->DoEnablePartialPsm( EFalse );
-                }                
+#ifdef _DEBUG
+                case 'E': //For testing
+                    Exit();
+                    break;
+#endif
+                case EKeyPowerOff:
+                    //Short power key press
+                    iKeyBoardRepeatCount++;
+                    if( aKeyEvent.iRepeats == 0 )
+                        {
+                        TRACES( RDebug::Print(_L("CSysApAppUi::HandleKeyEventL, Short powerkey") ) );
+                        iLastPowerKeyWasShort = ETrue;
+                        TRACES( RDebug::Print( _L("CSysApAppUi::Key was consumed by pressing short power") ) );          
+                        //Powermenu
+                        if (iPowerMenuDialog != NULL)
+                            {
+                            //PowerMenu already exist
+                            delete iPowerMenuDialog;
+                            iPowerMenuDialog = NULL;
+                            } 
+                            
+                        iPowerMenuDialog = CHbDevicePowerMenuSymbian::NewL(*this);
+                        iPowerMenuDialog->ShowL();                        
+                        iIgnoreNextPowerKeyRepeats = EFalse;
+                        }
+                    //Long power key press
+                    else if( aKeyEvent.iRepeats > 0 && iKeyBoardRepeatCount >= iSysApCenRepController->GetInt( KCRUidCoreApplicationUIsSysAp, KSysApPowerkeyRepeatcount ))
+                        {
+                        iKeyBoardRepeatCount = -1;
+                        TRACES( RDebug::Print(_L("CSysApAppUi::HandleKeyEventL, Long powerkey") ) );
+                        iLastPowerKeyWasShort = EFalse;
+                        HandleLongPowerKeyPressedL();
+                        }
+                    break;
+
+                default:
+                    {
+                    TKeyResponse response = EKeyWasNotConsumed;
+                    if (iSysApKeyManagement)
+                        {
+                        response = iSysApKeyManagement->HandleKeyEventL(aKeyEvent, aType );
+                        }
+
+                    if ( response == EKeyWasNotConsumed ) // none of the plugins consumed the key, offer it to default handling
+                        {
+                        iSysApDefaultKeyHandler->HandleKeyEventL( aKeyEvent, aType );
+                        }
+                    }
+                    break;
+                }
             }
-        else if ( aValue == EChargingStatusNotConnected )
+        else if( aType == EEventKeyUp )
             {
-            iSysApPsmController->ConnectCharger( EFalse );
-            
-            // cancel deactivation query if charger is disconnected while query is on display 
-            CancelQuery( ESysApBattChargingPowerSavingQuery );
-            }            
+            if( aKeyEvent.iScanCode == EStdKeyDevice2 )
+                {
+                if ( iIgnoreNextPowerKeyUpEvent )
+                    {
+                    if ( !iPowerKeyPopupMenuDismissed ) // If the popup menu has been dismissed, do nothing
+                        {
+                        iPowerKeyPopupMenuActive = ETrue;
+                        iIgnoreNextPowerKeyUpEvent = EFalse;
+                        }
+                    }
+                else if( iLastPowerKeyWasShort )
+                    {
+                    if ( iPowerKeyPopupMenuActive )
+                        {
+                        }
+                    }
+
+                }
+            }
+
+        TRACES( RDebug::Print( _L("CSysApAppUi::HandleKeyEventL:ended, aKeyEvent.iCode:%d, aKeyEvent.iScanCode:%d, aType:%d, iIgnoreNextPowerKeyUpEvent:%d, iPowerKeyPopupMenuActive:%d, iLastPowerKeyWasShort:%d, iPowerKeyPopupMenuDismissed:%d"),
+                               aKeyEvent.iCode, aKeyEvent.iScanCode, aType, iIgnoreNextPowerKeyUpEvent, iPowerKeyPopupMenuActive, iLastPowerKeyWasShort, iPowerKeyPopupMenuDismissed ) );
         }
-    if( showNote )
+    else // shutdown started
         {
-        HandleChargerNotesL( aValue );    
+        TRACES( RDebug::Print( _L("CSysApAppUi::HandleKeyEventL: aKeyEvent.iCode:%d, aKeyEvent.iScanCode:%d, aType:%d"),
+                               aKeyEvent.iCode, aKeyEvent.iScanCode, aType ) );
+
+        // When shutdown has been started, only device mode key events are passed to plug-in framework
+        // This for enabling plug-in activities during shutdown animation
+        if ( IsDeviceModeKey( aKeyEvent ) ) // Other key events are not passed, because they must cancel the shutdown animation as stated in UI spefication
+            {
+            if ( aType == EEventKey && iSysApKeyManagement )
+                {
+                iSysApKeyManagement->HandleKeyEventL( aKeyEvent, aType );
+                }
+            }
+        TRACES( RDebug::Print( _L("CSysApAppUi::HandleKeyEventL: ended") ) );
+        }
+    return EKeyWasConsumed;
+    }
+
+
+// ----------------------------------------------------------------------------
+// CSysApAppUi::HandleCommandL( TInt aCommand)
+// ----------------------------------------------------------------------------
+
+void CSysApAppUi::HandleCommandL( TInt aCommand )
+    {
+    TRACES( RDebug::Print( _L("CSysApAppUi::HandleCommandL aCommend: %d"), aCommand ) );
+    switch ( aCommand )
+        {
+        case EEikCmdExit:   // EAknCmdExit
+            Exit();
+            break;
+        default:
+            break;
         }
     }
 
-// ----------------------------------------------------------------------------
-// CSysApAppUi::HandleActivatePsmQueryResponse
-// ----------------------------------------------------------------------------
-//
-void CSysApAppUi::HandleActivatePsmQueryResponse( TBool aEnable )
+TBool CSysApAppUi::ReleasePowerMenuCustomDialogMemory()
     {
-    TRACES( RDebug::Print( _L("CSysApAppUi::HandleActivatePsmQueryResponse aEnable: %d"), 
-        aEnable ) );
-    
-    __ASSERT_DEBUG( iSysApPsmController, User::Invariant() );
-    
-    if ( aEnable )
+    if (iPowerMenuDialog!=NULL)
         {
-        iSysApPsmController->DoEnableFullPsm( ETrue );    
+        //PowerMenu already exist
+        delete iPowerMenuDialog;
+        iPowerMenuDialog = NULL;
+        return ETrue;
         }
-    else
-        {
-        iSysApPsmController->DoEnablePartialPsm( ETrue );     
-        }        
+    return EFalse;
     }
 
-// ----------------------------------------------------------------------------
-// CSysApAppUi::HandleDeactivatePsmQueryResponse
-// ----------------------------------------------------------------------------
-//
-void CSysApAppUi::HandleDeactivatePsmQueryResponse( TBool aDisable )
-    {
-    TRACES( RDebug::Print( _L("CSysApAppUi::HandleDeactivatePsmQueryResponse aDisable: %d"), 
-        aDisable ) );
 
-    __ASSERT_DEBUG( iSysApPsmController, User::Invariant() );
-    
-    if ( aDisable )
-        {
-        iSysApPsmController->DoEnableFullPsm( EFalse );        
-        }
-    }
-    
-// ----------------------------------------------------------------------------
-// CSysApAppUi::CancelQuery
-// ----------------------------------------------------------------------------
-//
-void CSysApAppUi::CancelQuery( TSysApConfirmationQueryIds aQueryId )
-    {
-    TRACES( RDebug::Print( _L("CSysApAppUi::CancelQuery aQueryId: %d"), aQueryId ) );
-
-    if ( iSysApConfirmationQuery )
-        {
-        if ( aQueryId == iSysApConfirmationQuery->CurrentQuery() || aQueryId == ESysApNoQuery )
-            {
-            iSysApConfirmationQuery->Cancel();
-            }
-        }
-    }
-// End of File
+//end of file
--- a/coreapplicationuis/SysAp/Src/SysApDocument.cpp	Tue Jun 15 16:07:48 2010 +0100
+++ b/coreapplicationuis/SysAp/Src/SysApDocument.cpp	Thu Jul 22 16:35:22 2010 +0100
@@ -31,7 +31,26 @@
 CSysApDocument::~CSysApDocument()
     {
     }
+/*
+// ---------------------------------------------------------
+// CSysApDocument::ConstructL()
+// ---------------------------------------------------------
+void CSysApDocument::ConstructL()
+    {
+    }
 
+// ---------------------------------------------------------
+// CSysApDocument::NewL()
+// ---------------------------------------------------------
+CSysApDocument* CSysApDocument::NewL(CEikApplication& aApp)     // CSysApp reference
+    {
+    CSysApDocument* self = new (ELeave) CSysApDocument(aApp);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(); // self
+    return self;
+    }
+*/
 // ----------------------------------------------------------------------------
 // CSysApDocument::CreateAppUiL()
 // constructs CSysApUi
@@ -46,7 +65,7 @@
 // ----------------------------------------------------------------------------
 void CSysApDocument::UpdateTaskNameL( CApaWindowGroupName* aWgName )
 	{
-	CAknDocument::UpdateTaskNameL( aWgName );
+	CEikDocument::UpdateTaskNameL( aWgName );
 	aWgName->SetHidden( ETrue );
 	}
 
--- a/coreapplicationuis/SysAp/Src/SysApFeatureManager.cpp	Tue Jun 15 16:07:48 2010 +0100
+++ b/coreapplicationuis/SysAp/Src/SysApFeatureManager.cpp	Thu Jul 22 16:35:22 2010 +0100
@@ -94,9 +94,9 @@
     TRACES( RDebug::Print( _L("CSysApFeatureManager::ConstructL: No power key supported=%d"), iNoPowerKeySupported ) );
     
 //    iFmTxSupported = FeatureManager::FeatureSupported( KFeatureIdFmtx );
- //   TRACES( RDebug::Print( _L("CSysApFeatureManager::ConstructL: FM TX supported=%d"), iFmTxSupported ) );
+//    TRACES( RDebug::Print( _L("CSysApFeatureManager::ConstructL: FM TX supported=%d"), iFmTxSupported ) );
 
-    iPenEnabled = AknLayoutUtils::PenEnabled();
+//    iPenEnabled = AknLayoutUtils::PenEnabled();
     TRACES( RDebug::Print( _L("CSysApFeatureManager::ConstructL: Pen enabled=%d"), iPenEnabled ) );
     
     iVmbxCallDivertIconSupported = FeatureManager::FeatureSupported( KFeatureIdVmbxCallDivertIcon );
@@ -180,11 +180,11 @@
                                                iGripNotSupported( ETrue ),
                                                iPowerSaveSupported( EFalse ),
                                                iNoPowerKeySupported( EFalse ),
-//                                               iFmTxSupported( EFalse ),
+                                               //iFmTxSupported( EFalse ),
                                                iPenEnabled( EFalse ),
                                                iVmbxCallDivertIconSupported( EFalse ),
                                                iTouchUnlockStrokeSupported( EFalse )
-//                                               iFmTxRdsTextSupported( EFalse )
+                                               //iFmTxRdsTextSupported( EFalse )
 
     {
     }
@@ -379,6 +379,7 @@
     return iFmTxSupported;
     }
 */
+
 // ----------------------------------------------------------------------------
 // CSysApFeatureManager::PenEnabled()
 // ----------------------------------------------------------------------------
--- a/coreapplicationuis/SysAp/Src/SysApLightsController.cpp	Tue Jun 15 16:07:48 2010 +0100
+++ b/coreapplicationuis/SysAp/Src/SysApLightsController.cpp	Thu Jul 22 16:35:22 2010 +0100
@@ -150,7 +150,7 @@
 
     TBool blinkEnabled = ETrue; 
                 
-    if( iSysApFeatureManager->Supported( KSysApFeatureIdNoFlasUiInSilentMode ) ) 
+    if( iSysApFeatureManager->Supported( KSysApFeatureIdNoFlasUiInSilentMode )) 
         {
         blinkEnabled = EFalse;
         }
--- a/coreapplicationuis/SysAp/Src/SysApPubSubObserver.cpp	Tue Jun 15 16:07:48 2010 +0100
+++ b/coreapplicationuis/SysAp/Src/SysApPubSubObserver.cpp	Thu Jul 22 16:35:22 2010 +0100
@@ -38,6 +38,7 @@
 #include "sysapremconobserver.h"
 #include <lbs/locationfwdomainpskeys.h>
 #include <smsuaddr.h>
+#include <avkondomainpskeys.h>
 
 #ifndef SYMBIAN_ENABLE_SPLIT_HEADERS
   #include <ASShdAlarm.h>
@@ -47,11 +48,13 @@
   #include <asshdalarm.h>
 #endif //SYMBIAN_ENABLE_SPLIT_HEADERS
 
-
 // CONSTANTS
 const TUint KCoreAppUIsMmcRemovedWithoutEjectCmdMask = 0xFFFF;
 const TUint KCoreAppUIsMmcRemovedWithoutEjectValShift = 16;
 
+const TUid KPSUidSecurityUIs = { 0x100059b5 };
+const TUint32 KSecurityUIsLights  = 0x00000308;
+
 // ============================ MEMBER FUNCTIONS ==============================
 
 // ----------------------------------------------------------------------------
@@ -93,10 +96,10 @@
     iOutboxStatusSubscriber->Subscribe();
     iIrdaStatusSubscriber = CSysApSubscriber::NewL( *this, KIrdaPropertyCategory, KIrdaStatus );
     iIrdaStatusSubscriber->Subscribe();
-    iGprsStatusSubscriber = CSysApSubscriber::NewL( *this, KUidSystemCategory, KPSUidGprsStatusValue );
-    iGprsStatusSubscriber->Subscribe();
-    iWcdmaStatusSubscriber = CSysApSubscriber::NewL( *this, KUidSystemCategory, KPSUidWcdmaStatusValue ); 
-    iWcdmaStatusSubscriber->Subscribe();
+//    iGprsStatusSubscriber = CSysApSubscriber::NewL( *this, KUidSystemCategory, KPSUidGprsStatusValue );
+//    iGprsStatusSubscriber->Subscribe();
+//    iWcdmaStatusSubscriber = CSysApSubscriber::NewL( *this, KUidSystemCategory, KPSUidWcdmaStatusValue ); 
+//    iWcdmaStatusSubscriber->Subscribe();
     iLocationGlobalPrivacySubscriber = CSysApSubscriber::NewL( *this, KUidSystemCategory, KPSUidLocationGlobalPrivacyValue );
     iLocationGlobalPrivacySubscriber->Subscribe();
     iRestoreBackupSubscriber = CSysApSubscriber::NewL( *this, KUidSystemCategory, conn::KUidBackupRestoreKey );
@@ -185,6 +188,15 @@
 
     iSmsPhoneStoreSubscriber = CSysApSubscriber::NewL( *this, KUidPSSMSStackCategory, KUidPSSMSStackDiskSpaceMonitorKey );
     iSmsPhoneStoreSubscriber->Subscribe();
+    
+    iKeylockEventSubscriber = CSysApSubscriber::NewL( *this, KPSUidAvkonDomain, KAknKeyguardStatus );
+    iKeylockEventSubscriber->Subscribe();
+    
+    iLightsOnRequestSubscriber = CSysApSubscriber::NewL( *this, KPSUidSecurityUIs, KSecurityUIsLights );
+    iLightsOnRequestSubscriber->Subscribe();
+    
+    iPowerMenuCustomDialogSubscriber = CSysApSubscriber::NewL( *this, KPSUidCoreApplicationUIs, KCoreAppUIsPowerMenuCustomDialogStatus );
+    iPowerMenuCustomDialogSubscriber->Subscribe();
     }
 
 // ----------------------------------------------------------------------------
@@ -202,8 +214,8 @@
     delete iInboxStatusSubscriber;
     delete iOutboxStatusSubscriber; 
     delete iIrdaStatusSubscriber;
-    delete iGprsStatusSubscriber; 
-    delete iWcdmaStatusSubscriber;
+//    delete iGprsStatusSubscriber; 
+//    delete iWcdmaStatusSubscriber;
     delete iHomeZoneStatusSubscriber;
     delete iNewEmailStatusSubscriber; 
     delete iLocationGlobalPrivacySubscriber;
@@ -236,6 +248,9 @@
     delete iVideoSharingIndicatorSubscriber;
     delete iGpsIndicatorSubscriber;
     delete iSmsPhoneStoreSubscriber;
+    delete iKeylockEventSubscriber;
+    delete iLightsOnRequestSubscriber;
+    delete iPowerMenuCustomDialogSubscriber;
     }
 
 
@@ -306,7 +321,8 @@
         {
         HandleHwrmFmTxCategoryL( aKey, value );
         }
-*/    else if ( aCategory == KPSUidDataSynchronizationInternalKeys )
+*/
+    else if ( aCategory == KPSUidDataSynchronizationInternalKeys )
         {
         HandleDataSyncCategoryL( aKey, value );
         }
@@ -318,6 +334,14 @@
         {
         HandleSmsStackCategoryL( aKey, value );
         }
+    else if ( aCategory == KPSUidAvkonDomain)
+        {
+        HandleLKeylockEventL( aKey, value );
+        }
+    else if ( aCategory == KPSUidSecurityUIs)
+        {
+        HandleLightsOnRequestL( aKey, value );
+        }
     }
 // ----------------------------------------------------------------------------
 // CSysApPubSubObserver::HandleCoreAppUIsCategoryL()
@@ -361,23 +385,23 @@
         case KCoreAppUIsUipInd:
             if ( aValue == ECoreAppUIsDoNotShow )
                 {
-                iSysApAppUi.SetIndicatorStateL( EAknIndicatorInstantMessage, EAknIndicatorStateOff ); 
+ //               iSysApAppUi.SetIndicatorStateL( EAknIndicatorInstantMessage, EAknIndicatorStateOff ); 
                 }
             else if ( aValue == ECoreAppUIsShow )
                 {
-                iSysApAppUi.SetIndicatorStateL( EAknIndicatorInstantMessage, EAknIndicatorStateOn ); 
+//                iSysApAppUi.SetIndicatorStateL( EAknIndicatorInstantMessage, EAknIndicatorStateOn ); 
                 }
             break;
         case KCoreAppUIsMessageToneQuit:
-            iSysApAppUi.HandleMessageTonePlayingQuitability( aValue );
+ //           iSysApAppUi.HandleMessageTonePlayingQuitability( aValue );
             break;
         case KCoreAppUIsNspsRawKeyEvent:
-            iSysApAppUi.HandleNspsRawKeyEventL();
+ //           iSysApAppUi.HandleNspsRawKeyEventL();
             break;
         case KCoreAppUIsLightsRawKeyEvent:
             if ( aValue == ECoreAppUIsKeyEvent )
                 {
-                iSysApAppUi.HandleRawKeyEventLightsRequireL();
+  //              iSysApAppUi.HandleRawKeyEventLightsRequireL();
                 }
             break;
         case KCoreAppUIsMmcRemovedWithoutEject:
@@ -385,27 +409,27 @@
             TUint cmd( aValue & KCoreAppUIsMmcRemovedWithoutEjectCmdMask );
             if ( cmd == ECoreAppUIsEjectCommandUsed )
                 {
-                iSysApAppUi.EjectStarted( ETrue );
+ //               iSysApAppUi.EjectStarted( ETrue );
                 }
             else if ( cmd == ECoreAppUIsEjectCommandNotUsed )
                 {
-                iSysApAppUi.EjectStarted( EFalse );
+ //               iSysApAppUi.EjectStarted( EFalse );
                 }
             else if ( cmd == ECoreAppUIsEjectCommandUsedToDrive )
                 {
                 TInt drive( aValue >> KCoreAppUIsMmcRemovedWithoutEjectValShift );
-                iSysApAppUi.EjectUsed( drive );
+ //               iSysApAppUi.EjectUsed( drive );
                 }
             break;
             }
         case KCoreAppUIsNewEmailStatus:
             if ( aValue == ECoreAppUIsNewEmail )
                 {
-                iSysApAppUi.SetIndicatorStateL( EAknIndicatorEmailMessage, EAknIndicatorStateOn );
+ //               iSysApAppUi.SetIndicatorStateL( EAknIndicatorEmailMessage, EAknIndicatorStateOn );
                 }
             else if ( aValue == ECoreAppUIsNoNewEmail )
                 {
-                iSysApAppUi.SetIndicatorStateL( EAknIndicatorEmailMessage, EAknIndicatorStateOff );
+ //               iSysApAppUi.SetIndicatorStateL( EAknIndicatorEmailMessage, EAknIndicatorStateOff );
                 }
             break;
 
@@ -423,68 +447,84 @@
         case KCoreAppUIsPoCIndicator:
             if ( aValue == ECoreAppUIsPocIndicatorOff || aValue == ECoreAppUIsPocIndicatorUninitialized )
                 {
-                iSysApAppUi.SetIndicatorStateL( EAknIndicatorPoC, EAknIndicatorStateOff );
-                iSysApAppUi.SetIndicatorStateL( EAknIndicatorPoCDnD, EAknIndicatorStateOff );
+ //               iSysApAppUi.SetIndicatorStateL( EAknIndicatorPoC, EAknIndicatorStateOff );
+ //               iSysApAppUi.SetIndicatorStateL( EAknIndicatorPoCDnD, EAknIndicatorStateOff );
                 }
             else if ( aValue == ECoreAppUIsPocIndicatorDoNotDisturb )
                 {
-                iSysApAppUi.SetIndicatorStateL( EAknIndicatorPoC, EAknIndicatorStateOff );
-                iSysApAppUi.SetIndicatorStateL( EAknIndicatorPoCDnD, EAknIndicatorStateOn );
+ //               iSysApAppUi.SetIndicatorStateL( EAknIndicatorPoC, EAknIndicatorStateOff );
+ //               iSysApAppUi.SetIndicatorStateL( EAknIndicatorPoCDnD, EAknIndicatorStateOn );
                 }
             else if ( aValue == ECoreAppUIsPocIndicatorConnectionOn )
                 {
-                iSysApAppUi.SetIndicatorStateL( EAknIndicatorPoC, EAknIndicatorStateOn );
-                iSysApAppUi.SetIndicatorStateL( EAknIndicatorPoCDnD, EAknIndicatorStateOff );
+//                iSysApAppUi.SetIndicatorStateL( EAknIndicatorPoC, EAknIndicatorStateOn );
+//                iSysApAppUi.SetIndicatorStateL( EAknIndicatorPoCDnD, EAknIndicatorStateOff );
                 }
             break;
         case KCoreAppUIsPoCMissedIndicator:
             if ( aValue == ECoreAppUIsPocMissedIndicatorOff || aValue == ECoreAppUIsPocMissedIndicatorUninitialized )
                 {
-                iSysApAppUi.SetIndicatorStateL( EAknIndicatorPoCMissed, EAknIndicatorStateOff );
+ //               iSysApAppUi.SetIndicatorStateL( EAknIndicatorPoCMissed, EAknIndicatorStateOff );
                 }
             else if ( aValue == ECoreAppUIsPocMissedIndicatorOn )
                 {
-                iSysApAppUi.SetIndicatorStateL( EAknIndicatorPoCMissed, EAknIndicatorStateOn );
+ //               iSysApAppUi.SetIndicatorStateL( EAknIndicatorPoCMissed, EAknIndicatorStateOn );
                 }
             break;
             
         case KCoreAppUIsTarmIndicator:
-            iSysApAppUi.HandleTarmIndicatorL( aValue );
+ //           iSysApAppUi.HandleTarmIndicatorL( aValue );
             break;
 
         case KCoreAppUIsMtvRecStatus:
             if ( aValue == ECoreAppUIsMtvRecStatusOn  )
                 {
-                iSysApAppUi.SetIndicatorStateL( EAknIndicatorMobileTVRec, EAknIndicatorStateOn );
+ //               iSysApAppUi.SetIndicatorStateL( EAknIndicatorMobileTVRec, EAknIndicatorStateOn );
                 }
             else if ( aValue == ECoreAppUIsMtvRecStatusOff || aValue == ECoreAppUIsMtvRecStatusUninitialized )
                 {
-                iSysApAppUi.SetIndicatorStateL( EAknIndicatorMobileTVRec, EAknIndicatorStateOff );
+ //               iSysApAppUi.SetIndicatorStateL( EAknIndicatorMobileTVRec, EAknIndicatorStateOff );
                 }
             break;
 
         case KCoreAppUIsMtvDvbhStatus:
             if ( aValue == ECoreAppUIsMtvDvbhStatusOn )
                 {
-                iSysApAppUi.SetIndicatorStateL( EAknIndicatorMobileTV, EAknIndicatorStateOn );
+ //               iSysApAppUi.SetIndicatorStateL( EAknIndicatorMobileTV, EAknIndicatorStateOn );
                 }
             else if ( aValue == ECoreAppUIsMtvDvbhStatusOff || aValue == ECoreAppUIsMtvDvbhStatusUninitialized )
                 {
-                iSysApAppUi.SetIndicatorStateL( EAknIndicatorMobileTV, EAknIndicatorStateOff );
+//                iSysApAppUi.SetIndicatorStateL( EAknIndicatorMobileTV, EAknIndicatorStateOff );
                 }
             break;
         
         case KCoreAppUIsVideoSharingIndicator:
             if ( aValue == ECoreAppUIsVideoSharingIndicatorOn )
                 {
-                iSysApAppUi.SetIndicatorStateL( EAknIndicatorVideoSharing, EAknIndicatorStateOn );
+ //               iSysApAppUi.SetIndicatorStateL( EAknIndicatorVideoSharing, EAknIndicatorStateOn );
                 }
             else if ( aValue == ECoreAppUIsVideoSharingIndicatorOff || aValue == ECoreAppUIsVideoSharingIndicatorUninitialized )
                 {
-                iSysApAppUi.SetIndicatorStateL( EAknIndicatorVideoSharing, EAknIndicatorStateOff );
+ //               iSysApAppUi.SetIndicatorStateL( EAknIndicatorVideoSharing, EAknIndicatorStateOff );
                 }
             break;
-
+            
+        case KCoreAppUIsPowerMenuCustomDialogStatus:
+            if ( aValue == ECoreAppUIsPowerMenuCustomDialogOn )
+                { 
+                TBool powerMenuMemoryStatus = EFalse;
+                powerMenuMemoryStatus = iSysApAppUi.ReleasePowerMenuCustomDialogMemory();
+                if(powerMenuMemoryStatus)
+                    {
+                    RProperty::Set( KPSUidCoreApplicationUIs, KCoreAppUIsPowerMenuCustomDialogStatus, ECoreAppUIsPowerMenuCustomDialogOff );
+                    }
+                }
+            else if ( aValue == ECoreAppUIsPowerMenuCustomDialogOff || aValue == ECoreAppUIsPowerMenuCustomDialogUninitialized )
+                {
+                   // do nothing
+                }
+            break;   
+        
         default:
             break;
         }
@@ -525,43 +565,43 @@
     switch ( aKey )
         {
         case KUidInboxStatusValue:
-            iSysApAppUi.SetEnvelopeIndicatorL();
+//            iSysApAppUi.SetEnvelopeIndicatorL();
             break;
 
         case KUidOutboxStatusValue:
             if ( aValue == ESADocumentsInOutbox )
                 {
-                iSysApAppUi.SetIndicatorStateL( EAknIndicatorOutbox, EAknIndicatorStateOn );
+ //               iSysApAppUi.SetIndicatorStateL( EAknIndicatorOutbox, EAknIndicatorStateOn );
                 }
             //Hide the Outbox indicator
             else if ( aValue == ESAOutboxEmpty )
                 {
-                iSysApAppUi.SetIndicatorStateL( EAknIndicatorOutbox, EAknIndicatorStateOff );
+//                iSysApAppUi.SetIndicatorStateL( EAknIndicatorOutbox, EAknIndicatorStateOff );
                 }
             break;
 
         case KIrdaStatus:
             if ( aValue == TIrdaStatusCodes::EIrLoaded || aValue == TIrdaStatusCodes::EIrBlocked || aValue == TIrdaStatusCodes::EIrDisconnected )
                 {
-                iSysApAppUi.SetIndicatorStateL( EAknIndicatorIrActive, EAknIndicatorStateAnimate );
+ //               iSysApAppUi.SetIndicatorStateL( EAknIndicatorIrActive, EAknIndicatorStateAnimate );
                 }
             else if ( aValue == TIrdaStatusCodes::EIrConnected )
                 {
-                iSysApAppUi.SetIndicatorStateL( EAknIndicatorIrActive, EAknIndicatorStateOn );
+ //               iSysApAppUi.SetIndicatorStateL( EAknIndicatorIrActive, EAknIndicatorStateOn );
                 }
             else if ( aValue == TIrdaStatusCodes::EIrUnloaded )
                 {
-                iSysApAppUi.SetIndicatorStateL( EAknIndicatorIrActive, EAknIndicatorStateOff );
+ //               iSysApAppUi.SetIndicatorStateL( EAknIndicatorIrActive, EAknIndicatorStateOff );
                 }
             break;
 
-        case KPSUidGprsStatusValue:
-        case KPSUidWcdmaStatusValue:        
-            iSysApAppUi.SetSignalIndicatorL();
-            break;
+//        case KPSUidGprsStatusValue:
+ //       case KPSUidWcdmaStatusValue:        
+ //           iSysApAppUi.SetSignalIndicatorL();
+//            break;
 
         case KPSUidLocationGlobalPrivacyValue:
-            iSysApAppUi.HandleLocationPrivacyIndicatorL( aValue );
+//            iSysApAppUi.HandleLocationPrivacyIndicatorL( aValue );
             break;
 
         case conn::KUidBackupRestoreKey:
@@ -594,7 +634,7 @@
     switch ( aKey )
         {
         case KHWRMBatteryLevel:
-            iSysApAppUi.UpdateBatteryBarsL( aValue );
+ //           iSysApAppUi.UpdateBatteryBarsL( aValue );
             break;
         
         case KHWRMBatteryStatus:
@@ -642,17 +682,17 @@
                     TRACES(RDebug::Print(_L("CSysApPubSubObserver::HandleHwrmFmTxCategoryL Active/Inactive -> Off transition")));
                     
     	            // turn any FM TX indicators off
-	                iSysApAppUi.SetIndicatorStateL( KFmTxActiveIndicator, EAknIndicatorStateOff );
-	                iSysApAppUi.SetIndicatorStateL( KFmTxNotSendingIndicator, EAknIndicatorStateOff );
+//	                iSysApAppUi.SetIndicatorStateL( KFmTxActiveIndicator, EAknIndicatorStateOff );
+//	                iSysApAppUi.SetIndicatorStateL( KFmTxNotSendingIndicator, EAknIndicatorStateOff );
                     
                     // give notification
                     if ( aValue == EFmTxStatePowerSaveAccessory )
                     	{
-                    	iSysApAppUi.ShowUiNoteL( EFmTxAccessoryStandbyNote );
+//                    	iSysApAppUi.ShowUiNoteL( EFmTxAccessoryStandbyNote );
                     	}
                     else
                     	{
-                    	iSysApAppUi.ShowUiNoteL( EFmTxOffNote );
+ //                   	iSysApAppUi.ShowUiNoteL( EFmTxOffNote );
                     	}
                     isFmTxTurnedOff = ETrue;                                                                           	
                     }
@@ -662,8 +702,8 @@
                     TRACES(RDebug::Print(_L("CSysApPubSubObserver::HandleHwrmFmTxCategoryL Active -> Inactive transition")));
                    
                     // enable not sending indicator
-	                iSysApAppUi.SetIndicatorStateL( KFmTxActiveIndicator, EAknIndicatorStateOff );                      
-                    iSysApAppUi.SetIndicatorStateL( KFmTxNotSendingIndicator, EAknIndicatorStateOn );                  
+//	                iSysApAppUi.SetIndicatorStateL( KFmTxActiveIndicator, EAknIndicatorStateOff );                      
+//                    iSysApAppUi.SetIndicatorStateL( KFmTxNotSendingIndicator, EAknIndicatorStateOn );                  
                     }
                 else if ( aValue == EFmTxStateActive )
                     {
@@ -671,8 +711,8 @@
                     TRACES(RDebug::Print(_L("CSysApPubSubObserver::HandleHwrmFmTxCategoryL Inactive -> Active transition")));
                     
                     // enable active indicator
-                    iSysApAppUi.SetIndicatorStateL( KFmTxNotSendingIndicator, EAknIndicatorStateOff );    
-                    iSysApAppUi.SetIndicatorStateL( KFmTxActiveIndicator, EAknIndicatorStateOn );					                
+//                    iSysApAppUi.SetIndicatorStateL( KFmTxNotSendingIndicator, EAknIndicatorStateOff );    
+//                    iSysApAppUi.SetIndicatorStateL( KFmTxActiveIndicator, EAknIndicatorStateOn );					                
                     }    
         
                 break;    
@@ -689,11 +729,11 @@
                     TRACES(RDebug::Print(_L("CSysApPubSubObserver::HandleHwrmFmTxCategoryL Off -> Active transition")));
                                         
                     // enable active indicator
-                    iSysApAppUi.SetIndicatorStateL( KFmTxNotSendingIndicator, EAknIndicatorStateOff );   
-                    iSysApAppUi.SetIndicatorStateL( KFmTxActiveIndicator, EAknIndicatorStateOn );					                  
+ //                   iSysApAppUi.SetIndicatorStateL( KFmTxNotSendingIndicator, EAknIndicatorStateOff );   
+ //                   iSysApAppUi.SetIndicatorStateL( KFmTxActiveIndicator, EAknIndicatorStateOn );					                  
                     
                     // give notification
-                    iSysApAppUi.ShowUiNoteL( EFmTxOnNote );
+ //                   iSysApAppUi.ShowUiNoteL( EFmTxOnNote );
                     isFmTxTurnedOn = ETrue;
                     }
                 else if ( aValue == EFmTxStateInactive || aValue == EFmTxStateScanning )
@@ -702,11 +742,11 @@
                 	TRACES(RDebug::Print(_L("CSysApPubSubObserver::HandleHwrmFmTxCategoryL Off -> Inactive transition")));
                 	
                     // enable not sending indicator
-	                iSysApAppUi.SetIndicatorStateL( KFmTxActiveIndicator, EAknIndicatorStateOff );                      
-                    iSysApAppUi.SetIndicatorStateL( KFmTxNotSendingIndicator, EAknIndicatorStateOn );                      	
+//	                iSysApAppUi.SetIndicatorStateL( KFmTxActiveIndicator, EAknIndicatorStateOff );                      
+ //                   iSysApAppUi.SetIndicatorStateL( KFmTxNotSendingIndicator, EAknIndicatorStateOn );                      	
                     
                     // give notification
-                    iSysApAppUi.ShowUiNoteL( EFmTxOnNote );
+ //                   iSysApAppUi.ShowUiNoteL( EFmTxOnNote );
                     isFmTxTurnedOn = ETrue;
                 	}                
                 break;                
@@ -794,16 +834,16 @@
         case KNWHomeZoneStatus:
             if ( aValue == ENWHomeZone )
                 {
-                iSysApAppUi.SetIndicatorStateL( EAknIndicatorHomeZone, EAknIndicatorStateOn );
+ //               iSysApAppUi.SetIndicatorStateL( EAknIndicatorHomeZone, EAknIndicatorStateOn );
                 }
             else if ( aValue == ENWNone || aValue == ENWCityZone )
                 {
-                iSysApAppUi.SetIndicatorStateL( EAknIndicatorHomeZone, EAknIndicatorStateOff );
+ //               iSysApAppUi.SetIndicatorStateL( EAknIndicatorHomeZone, EAknIndicatorStateOff );
                 }
             break; 
 
         case KNWTelephonyNetworkMode:
-            iSysApAppUi.SetSignalIndicatorL();
+ //           iSysApAppUi.SetSignalIndicatorL();
             break;
 
         default:
@@ -821,11 +861,11 @@
         case KHWRMFlipStatus:
             if ( aValue == EPSHWRMFlipClosed )
                 {
-                iSysApAppUi.SimulateFlipKeyEventL( EFalse );
+ //               iSysApAppUi.SimulateFlipKeyEventL( EFalse );
                 }
             else if ( aValue == EPSHWRMFlipOpen )
                 {
-                iSysApAppUi.SimulateFlipKeyEventL( ETrue );
+ //               iSysApAppUi.SimulateFlipKeyEventL( ETrue );
                 }
             break; 
 
@@ -844,11 +884,11 @@
         case KDataSyncStatus:
             if ( aValue > EDataSyncNotRunning )
                 {
-                iSysApAppUi.SetIndicatorStateL( EAknIndicatorSynchronization , EAknIndicatorStateOn );
+ //               iSysApAppUi.SetIndicatorStateL( EAknIndicatorSynchronization , EAknIndicatorStateOn );
                 }
             else
                 {
-                iSysApAppUi.SetIndicatorStateL( EAknIndicatorSynchronization, EAknIndicatorStateOff );
+  //              iSysApAppUi.SetIndicatorStateL( EAknIndicatorSynchronization, EAknIndicatorStateOff );
                 }
             break;
         
@@ -868,15 +908,15 @@
         case KPosIntGpsHwStatus:
             if ( aValue == EPosIntGpsHwOff )
                 {
-                iSysApAppUi.SetIndicatorStateL( EAknIndicatorGPS, EAknIndicatorStateOff );
+ //               iSysApAppUi.SetIndicatorStateL( EAknIndicatorGPS, EAknIndicatorStateOff );
                 }
             else if ( aValue == EPosIntGpsHwOn )    
                 {
-                iSysApAppUi.SetIndicatorStateL( EAknIndicatorGPS, EAknIndicatorStateOn );
+ //               iSysApAppUi.SetIndicatorStateL( EAknIndicatorGPS, EAknIndicatorStateOn );
                 }
             else if ( aValue == EPosIntGpsHwIntermediate )
                 {
-                iSysApAppUi.SetIndicatorStateL( EAknIndicatorGPS, EAknIndicatorStateAnimate );
+ //               iSysApAppUi.SetIndicatorStateL( EAknIndicatorGPS, EAknIndicatorStateAnimate );
                 }
             break;
         
@@ -893,8 +933,8 @@
     {
     switch ( aKey )
         {
-        case KUidPSSMSStackDiskSpaceMonitorKey:
-            iSysApAppUi.SetEnvelopeIndicatorL();
+        case KAknKeyguardStatus:
+ //           iSysApAppUi.SetEnvelopeIndicatorL();
             break;
 
         default:
@@ -902,7 +942,39 @@
         }
     }
 
-// End of File
+void CSysApPubSubObserver::HandleLKeylockEventL( const TUint /* aKey */, const TInt aValue )
+    {
+    switch( aValue )
+        {
+        case EEikKeyLockEnabled:
+            iSysApAppUi.SetKeyLockEnabledL();
+            break;
+        case EEikKeyLockDisabled:
+            iSysApAppUi.SetKeyLockDisabledL();    
+            break;
+        default:
+            break;
+       }
+    }
 
+void CSysApPubSubObserver::HandleLightsOnRequestL( const TUint /* aKey */, const TInt aValue )
+    {
+    switch ( aValue )
+        {
+        case EEikKeyLockLightsOnRequest:
+             iSysApAppUi.SetLightsOnUnlockNoteL();
+             break;
+        case EEikEcsQueryLights: // emergency note is shown
+             iSysApAppUi.SetLightsOnEcsQueryL();
+             break;
 
+        case EEikSecurityQueryLights: // for device lock security query
+             iSysApAppUi.SetLightsOnSecurityQueryL();
+             break;
 
+        default:
+            break;
+        }
+    }
+
+// End of File
--- a/coreapplicationuis/SysAp/Src/SysApSatObserver.cpp	Tue Jun 15 16:07:48 2010 +0100
+++ b/coreapplicationuis/SysAp/Src/SysApSatObserver.cpp	Thu Jul 22 16:35:22 2010 +0100
@@ -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 "Eclipse Public License v1.0"
@@ -18,8 +18,8 @@
 
 
 // INCLUDE FILES
-#include <RSatRefresh.h>
-#include <RSatSession.h>
+#include <rsatrefresh.h>
+#include <rsatsession.h>
 #include <e32debug.h>
 #include "SysApSatObserver.h"
 #include "SysAp.hrh"
--- a/coreapplicationuis/SysAp/Src/SysApShutdownImage.cpp	Tue Jun 15 16:07:48 2010 +0100
+++ b/coreapplicationuis/SysAp/Src/SysApShutdownImage.cpp	Thu Jul 22 16:35:22 2010 +0100
@@ -17,15 +17,20 @@
 
 
 // INCLUDE FILES
-#include <aknappui.h>
-#include <AknIconUtils.h>
-#include <AknUtils.h>
+//#include <aknappui.h>
+//#include <AknIconUtils.h>
+//#include <AknUtils.h>
+#include <eikenv.h>
 #include <coemain.h>
 #include <barsread.h> //use of TResourceReader
-#include <sysap.mbg>
+//#include <sysap.mbg>
 #include "SysApShutdownImage.h"
 #include "SysAp.hrh"
 #include <data_caging_path_literals.hrh>
+#include <HbDeviceMessageBoxSymbian.h>
+#include <SVGEngineInterfaceImpl.h>
+
+//_LIT(KDC_APP_BITMAP_DIR,"\\resource\\apps\\"); 
 
 // ============================ MEMBER FUNCTIONS ==============================
 
@@ -70,13 +75,16 @@
     {
     TRACES( RDebug::Print(_L("CSysApShutdownImage::ShowShutdownImageL:start" ) ) );
     TInt err ( 0 );
+    TRect rect(iCoeEnv->ScreenDevice()->SizeInPixels());
+    SetRect(rect);
+    TRACES( RDebug::Print(_L("CSysApShutdownImage::After:SetRect --Minus one" ) ) );
+    ActivateL();
 
-    SetRect(iAvkonAppUi->ApplicationRect());
-    ActivateL();
+    TRACES( RDebug::Print(_L("CSysApShutdownImage::After:ActivateL --Zero" ) ) );
 
     if ( aBitmapId )
         {
-        _LIT( KDirAndFile, "z:sysap.mif" );
+        _LIT( KDirAndFile, "z:qgn_sysap_screen.svg" );
         TParse* fp = new (ELeave) TParse();
         CleanupStack::PushL(fp);
         fp->Set( KDirAndFile, &KDC_APP_BITMAP_DIR, NULL );
@@ -99,27 +107,35 @@
                 delete iBitmap;
                 iBitmap = NULL;
                 // Ownership of bitmap is transferred to CSysApShutdownImage in CreateIconL
-                iBitmap = AknIconUtils::CreateIconL( fp->FullName(), aBitmapId );
-                TAknLayoutRect bitmapRect;
-                bitmapRect.LayoutRect( Rect(), AKN_LAYOUT_WINDOW_screen );
-                AknIconUtils::SetSize( iBitmap, bitmapRect.Rect().Size(), EAspectRatioPreservedAndUnusedSpaceRemoved );
+                iBitmap = ReadSVGL(fp->FullName());
+                TRACES( RDebug::Print(_L("CSysApShutdownImage::After:ReadSVGL --First" ) ) );
                 TInt xDelta=0; // for x coordinates
                 TInt yDelta=0; // for y coordinates
                 TSize bmpSizeInPixels = iBitmap->SizeInPixels();
+                TRACES( RDebug::Print(_L("CSysApShutdownImage::After:SizeInPixels --Second" ) ) );
                 //center image to the center of the screen
                 TRect rect = Rect();
                 xDelta=( rect.Width() - bmpSizeInPixels.iWidth ) / 2;
                 yDelta=( rect.Height() - bmpSizeInPixels.iHeight ) / 2;
                 TPoint pos = TPoint( xDelta , yDelta ); // displacement vector
                 //pos += rect.iTl; // bitmap top left corner position
+                TRACES( RDebug::Print(_L("CSysApShutdownImage::After:TPoint --Three" ) ) );
                 CWindowGc& gc = SystemGc();
+                TRACES( RDebug::Print(_L("CSysApShutdownImage::After:SystemGc --Four" ) ) );
                 ActivateGc();
+                TRACES( RDebug::Print(_L("CSysApShutdownImage::After:ActivateGc --Five" ) ) );
                 Window().Invalidate( rect );
+                TRACES( RDebug::Print(_L("CSysApShutdownImage::After:Invalidate --Six" ) ) );
                 Window().BeginRedraw( rect );
+                TRACES( RDebug::Print(_L("CSysApShutdownImage::After:BeginRedraw --Seven" ) ) );
                 gc.Clear();
+                TRACES( RDebug::Print(_L("CSysApShutdownImage::After:gc.Clear --Eight" ) ) );
                 gc.BitBlt( pos, iBitmap ); // CWindowGc member function
+                TRACES( RDebug::Print(_L("CSysApShutdownImage::After:gc.BitBlt --Nine" ) ) );
                 Window().EndRedraw();
+                TRACES( RDebug::Print(_L("CSysApShutdownImage::After:gc.EndRedraw --Ten" ) ) );
                 DeactivateGc();
+                TRACES( RDebug::Print(_L("CSysApShutdownImage::After:gc.DeactivateGc --Eleven" ) ) );
                 ControlEnv()->WsSession().Flush(); // force draw of the context
                 TRACES( RDebug::Print(_L("CSysApShutdownImage::ShowShutdownImageL:end" ) ) );
                 }
@@ -144,7 +160,60 @@
         ControlEnv()->WsSession().Flush(); // force draw of the context
 #endif // RD_STARTUP_ANIMATION_CUSTOMIZATION
         }
+    }
 
+// ----------------------------------------------------------------------------
+// CSysApShutdownImage::ShowShutdownImage()
+// ----------------------------------------------------------------------------
+CFbsBitmap* CSysApShutdownImage::ReadSVGL (TFileName aFileName)
+    {
+    TRACES( RDebug::Print(_L("CSysApShutdownImage::ReadSVGL:start" ) ) );    
+    TFontSpec fontspec;
+    TDisplayMode mode = EColor16MA;
+    TInt SIZE_X(360), SIZE_Y(360);
+    TSize size(SIZE_X, SIZE_Y);
+
+    //if ( mode >= (TDisplayMode)13 )  { mode = EColor16MA; }
+
+    CFbsBitmap* frameBuffer = new ( ELeave ) CFbsBitmap;
+    CleanupStack::PushL( frameBuffer );
+    frameBuffer->Create( size, mode );
+    
+    CSvgEngineInterfaceImpl* svgEngine = NULL;
+    svgEngine = CSvgEngineInterfaceImpl::NewL(frameBuffer, NULL, fontspec );    
+    
+    if (svgEngine == NULL)
+        {
+        TRACES( RDebug::Print(_L("CSysApShutdownImage::ReadSVGL:SVG engine creation failed" ) ) );   
+        }
+    
+    CleanupStack::PushL( svgEngine );
+    TInt domHandle = 0;
+    svgEngine->PrepareDom( aFileName, domHandle ) ;
+    if (domHandle == 0)
+        {
+        TRACES( RDebug::Print(_L("CSysApShutdownImage::ReadSVGL():DOM handle creation failed" ) ) );
+        }
+
+    CFbsBitmap* bitmap = new(ELeave) CFbsBitmap;    
+    CleanupStack::PushL( bitmap );
+    User::LeaveIfError( bitmap->Create( size, EColor64K ) );
+
+    svgEngine->UseDom( domHandle, bitmap, NULL ) ;
+    
+    MSvgError* err;
+    svgEngine->Start( err );
+    if (err->HasError())
+        {
+        TRACES( RDebug::Print(_L("CSysApShutdownImage::ReadSVGL(): SVG Engine Start failed" ) ) );
+        }
+
+    svgEngine->DeleteDom( domHandle );
+    CleanupStack::Pop( bitmap );
+    CleanupStack::PopAndDestroy( svgEngine );
+    CleanupStack::PopAndDestroy( frameBuffer );
+    TRACES( RDebug::Print(_L("CSysApShutdownImage::ReadSVGL:End" ) ) );   
+    return bitmap;
     }
 
 // ----------------------------------------------------------------------------
--- a/coreapplicationuis/SysAp/Src/SysApSimChanged.cpp	Tue Jun 15 16:07:48 2010 +0100
+++ b/coreapplicationuis/SysAp/Src/SysApSimChanged.cpp	Thu Jul 22 16:35:22 2010 +0100
@@ -117,13 +117,13 @@
     dateTime.Set( 2100, EJanuary, 1, 0, 0, 0, 0 );
     TTime date(dateTime);
     
-    TRACES( RDebug::Print( _L("CSysApSimChanged::ClearLogsL(): trying CLogClient::NewL") ) );
+/*    TRACES( RDebug::Print( _L("CSysApSimChanged::ClearLogsL(): trying CLogClient::NewL") ) );
     CLogClient* logClient = CLogClient::NewL( iFs );    
     logClient->ClearLog( date, active->iStatus );
-    
+*/    
     CActiveScheduler::Start();
 
-    delete logClient;
+//    delete logClient;
     CleanupStack::PopAndDestroy( active );
     }
     
@@ -136,7 +136,7 @@
     TRACES( RDebug::Print( _L("CSysApSimChanged::ClearSsSettingsL()") ) );
     
     // Reset SSSettings values
-    RSSSettings ssSettings;
+/*    RSSSettings ssSettings;
     User::LeaveIfError( ssSettings.Open( iSysApAppUi.GetTelServer() ) );
     
     TRACES( RDebug::Print( _L("CSysApSimChanged::ClearSsSettingsL(): trying RSSSettings::HandleSIMChanged") ) );
@@ -144,6 +144,7 @@
     ssSettings.Close();    
     
     User::LeaveIfError( err );
+*/
     }
 
 // -----------------------------------------------------------------------------
@@ -170,7 +171,7 @@
     if ( simNotOwned )
         {
         ClearRepositoriesL();
-        ClearLogsL();
+//        ClearLogsL();
         }
     }
 // =============== CShareActive MEMBER FUNCTIONS ===============================
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/coreapplicationuis/SysAp/Src/SysApTaskList.cpp	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,122 @@
+/*
+* Copyright (c) 2009 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+#include "SysApTaskList.h"
+#include <apgwgnam.h>
+
+CSysApTaskList* CSysApTaskList::NewL(RWsSession& aWsSession)
+	{
+	CSysApTaskList* self = NewLC(aWsSession);
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+ CSysApTaskList* CSysApTaskList::NewLC(RWsSession& aWsSession)
+	{
+	CSysApTaskList* self = new(ELeave) CSysApTaskList(aWsSession);
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	return self;
+	}
+
+CSysApTaskList::CSysApTaskList(RWsSession& aWsSession)
+: iWs(aWsSession)
+	{
+	}
+
+void CSysApTaskList::ConstructL()
+	{
+	UpdateListL();
+	}
+
+ CSysApTaskList::~CSysApTaskList()
+	{
+	iWgs.Close();
+	}
+
+ void CSysApTaskList::UpdateListL()
+	{
+	User::LeaveIfError(iWs.WindowGroupList(0, &iWgs));
+	}
+
+ const RArray<RWsSession::TWindowGroupChainInfo>& CSysApTaskList::WgArray() const
+	{
+	return iWgs;
+	}
+
+ TApaTask CSysApTaskList::FindRootApp(TUid aAppUid) const
+	{
+	TApaTask task(iWs);
+	task.SetWgId(0);		// initialise task to non-existant task
+	// wgId = 0 tells FindAppByUid to start looking for apps
+	TInt wgId=0;
+	FOREVER
+		{
+	 	CApaWindowGroupName::FindByAppUid(aAppUid, iWs, wgId);
+	 	// KErrNotFound means that no more apps can be found
+	 	if (wgId == KErrNotFound)
+	 		break;
+	 	if (IsRootWindowGroup(wgId))
+	 		{
+	 		// Found a root wg with the right app UID, return it.
+	 		task.SetWgId(wgId);
+	 		break;
+	 		}
+		}
+	return task;
+	}
+
+ TBool CSysApTaskList::IsRootWindowGroup(TInt aWgId) const
+	{
+	TInt count = iWgs.Count();
+	for (TInt ii=0; ii<count; ii++)
+		{
+        const RWsSession::TWindowGroupChainInfo& info = iWgs[ii];
+        // find the window group id and check that it has no parent
+        if (info.iId == aWgId)
+        	return (info.iParentId <= 0);
+		}
+	return EFalse;
+	}
+
+ TInt CSysApTaskList::FindParentWgId(TInt aWgId) const
+	{
+	TInt count = iWgs.Count();
+	for (TInt ii=0; ii<count; ii++)
+		{
+        const RWsSession::TWindowGroupChainInfo& info = iWgs[ii];
+        if (info.iId == aWgId && info.iParentId > 0 && info.iParentId != info.iId)
+        	return info.iParentId;
+		}
+	return 0;
+	}
+
+ TInt CSysApTaskList::FindChildWgId(TInt aWgId) const
+	{
+	TInt count = iWgs.Count();
+	for (TInt ii=0; ii<count; ii++)
+		{
+        const RWsSession::TWindowGroupChainInfo& info = iWgs[ii];
+        if (info.iParentId == aWgId && info.iId > 0 && info.iParentId != info.iId)
+        	return info.iId;
+		}
+	return 0;
+	}
+
+
+
+
+
--- a/coreapplicationuis/SysAp/Src/SysApTimer.cpp	Tue Jun 15 16:07:48 2010 +0100
+++ b/coreapplicationuis/SysAp/Src/SysApTimer.cpp	Thu Jul 22 16:35:22 2010 +0100
@@ -18,8 +18,8 @@
 
 // INCLUDES
 
-#include <avkon.hrh>
-#include <avkon.rsg>
+//#include <avkon.hrh>
+//#include <avkon.rsg>
 #include "SysAp.hrh"
 #include "SysApTimer.h"
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/coreapplicationuis/SysAp/Src/hbdevicepowermenusymbian.cpp	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,434 @@
+/*
+ * Copyright (c) 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"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ *
+ */
+
+#include <hbdevicedialogsymbian.h>
+#include <hbsymbianvariant.h>
+#include <coreapplicationuisdomainpskeys.h>
+#include "hbdevicepowermenusymbian.h"
+
+
+//These Keys will be used in CHbSymbianVariantMap
+//Donot Change these strings
+_LIT(KVolumeLevel, "VolumeLevel");
+_LIT(KSilenceLatchOn, "SilenceLatchOn");        //Used to latch silencebutton
+_LIT(KCypherOff, "CypherOff");                  //used to poweroffButtonEnabled/Disabled
+_LIT(KVibrationEnable, "VibrationEnable");
+_LIT(KOfflineEnable, "OfflineEnable");
+_LIT(KShutDown, "ShutDown");
+
+//used to load plugin 
+_LIT(KPluginIdentifier, "com.nokia.hb.devicepowermenu/1.0");
+
+
+NONSHARABLE_CLASS(CHbDevicePowerMenuPrivate) : public CBase, public MHbDeviceDialogObserver
+{
+public:
+    static CHbDevicePowerMenuPrivate* NewL(CHbDevicePowerMenuSymbian* aDialog);
+    virtual ~CHbDevicePowerMenuPrivate();
+
+    void ShowL();
+    void AddVariantL(const TDesC& aKey, const TAny* aData, CHbSymbianVariant::TType aDataType);
+
+    //Set Methods
+    void SetVolume(TInt aVolume);
+    void SetSilenceMode(TBool aEnable);
+    void SetOfflineMode(TBool aChecked);
+    void SetVibrationEnabled(TBool aEnable);
+    void SetPowerOffEnabled(TBool aEnable);
+
+public:
+    // MHbDeviceDialogObserver
+    void DataReceived(CHbSymbianVariantMap& aData);
+    void DeviceDialogClosed(TInt aCompletionCode);
+
+private: 
+    CHbDevicePowerMenuPrivate();
+    void ConstructL(CHbDevicePowerMenuSymbian* aDialog);
+
+private:
+    //symbian FW client intreface to load Qt.plugin
+    CHbDeviceDialogSymbian*         iDeviceDialog;
+    //Parameter for loading qt.plugin
+    CHbSymbianVariantMap*           iVariantMap;
+    //Symbian client interface for Powermenu
+    CHbDevicePowerMenuSymbian*      iPowerMenuManager;
+
+    //Variants used in VariantMap
+    TInt        iVolumeLevel;           //Volume level ranges 1 to 10
+    TBool       iSilenceLatchOn;        //Silence Enabled or Disbaled
+    TBool       iVibrationEnable;       //Master Vibarate enabled/Disabled
+    TBool       iOfflineEnable;         //Oflline Mode enabled or Disabled
+    TBool       iCypherOff;             //Encryption/Decryption ON/OFF
+};
+
+/**
+ * Create an object of CHbDevicePowerMenuPrivate
+ */
+CHbDevicePowerMenuPrivate* CHbDevicePowerMenuPrivate::NewL(CHbDevicePowerMenuSymbian* aDialog)
+    {
+    TRACES( RDebug::Print( _L("CHbDevicePowerMenuPrivate::NewL: START") ) );
+    CHbDevicePowerMenuPrivate* self = new (ELeave) CHbDevicePowerMenuPrivate();
+    CleanupStack::PushL(self);
+    self->ConstructL(aDialog);
+    CleanupStack::Pop(self);
+    TRACES( RDebug::Print( _L("CHbDevicePowerMenuPrivate::NewL: END") ) );
+    return self;
+    }
+
+/**
+ * Constructor
+ */
+CHbDevicePowerMenuPrivate::CHbDevicePowerMenuPrivate()
+    {
+    TRACES( RDebug::Print( _L("CHbDevicePowerMenuPrivate::Constructor") ) );
+    //Do nothing
+    }
+
+/**
+ * Destructor
+ */
+CHbDevicePowerMenuPrivate::~CHbDevicePowerMenuPrivate()
+    {
+    TRACES( RDebug::Print( _L("CHbDevicePowerMenuPrivate::Destructor: START") ) );
+    delete iDeviceDialog;
+    delete iVariantMap;
+    TRACES( RDebug::Print( _L("CHbDevicePowerMenuPrivate::Destructor: END") ) );
+    }
+
+/**
+ * Constrcuts all its member variables
+ */
+void CHbDevicePowerMenuPrivate::ConstructL(CHbDevicePowerMenuSymbian* aDialog)
+    {
+    TRACES( RDebug::Print( _L("CHbDevicePowerMenuPrivate::ConstructL: START") ) ); 
+    iPowerMenuManager = aDialog;
+    iDeviceDialog = CHbDeviceDialogSymbian::NewL();
+    iVariantMap = CHbSymbianVariantMap::NewL();
+    TRACES( RDebug::Print( _L("CHbDevicePowerMenuPrivate::ConstructL: END") ) ); 
+    }
+
+/**
+ * Builds all parameters required for showing the PowerMenu Dialog.
+ * Loads the required powermenu plugin and calls show on DeviceDialog.
+ * This Displays the Customized PowerMenu Widget. 
+ */
+void CHbDevicePowerMenuPrivate::ShowL()
+    {
+    TRACES( RDebug::Print( _L("CHbDevicePowerMenuPrivate::ShowL: START") ) ); 
+    AddVariantL(KVolumeLevel, &iVolumeLevel, CHbSymbianVariant::EInt);
+    AddVariantL(KSilenceLatchOn, &iSilenceLatchOn, CHbSymbianVariant::EBool);
+    AddVariantL(KVibrationEnable, &iVibrationEnable, CHbSymbianVariant::EBool);
+    AddVariantL(KOfflineEnable, &iOfflineEnable, CHbSymbianVariant::EBool);
+    AddVariantL(KCypherOff, &iCypherOff, CHbSymbianVariant::EBool);
+    //No shutdown varinat will be added to showL
+    User::LeaveIfError(iDeviceDialog->Show(KPluginIdentifier, *iVariantMap, this));
+    TRACES( RDebug::Print( _L("CHbDevicePowerMenuPrivate::ShowL: END") ) ); 
+    }
+
+/**
+ * Sets Volume to aVolume
+ */
+void CHbDevicePowerMenuPrivate::SetVolume(TInt aVolume)
+    {
+    TRACES( RDebug::Print( _L("CHbDevicePowerMenuPrivate::SetVolume: START") ) ); 
+    iVolumeLevel = aVolume;
+    TRACES( RDebug::Print( _L("CHbDevicePowerMenuPrivate::SetVolume: END") ) ); 
+    }
+
+/**
+ * Sets SilenceMode to Enable/Disable
+ */
+void CHbDevicePowerMenuPrivate::SetSilenceMode(TBool aEnable)
+    {
+    TRACES( RDebug::Print( _L("CHbDevicePowerMenuPrivate::SetSilenceMode: START") ) ); 
+    iSilenceLatchOn = aEnable;
+    TRACES( RDebug::Print( _L("CHbDevicePowerMenuPrivate::SetSilenceMode: END") ) ); 
+    }
+
+/**
+ * Sets OfflineMode to Checked/UnChecked
+ */
+void CHbDevicePowerMenuPrivate::SetOfflineMode(TBool aChecked)
+    {
+    TRACES( RDebug::Print( _L("CHbDevicePowerMenuPrivate::SetOfflineMode: START") ) ); 
+    iOfflineEnable = aChecked;
+    TRACES( RDebug::Print( _L("CHbDevicePowerMenuPrivate::SetOfflineMode: END") ) ); 
+    }
+
+/**
+ * Sets VibrationEnabled to Checked/UnChecked
+ */
+void CHbDevicePowerMenuPrivate::SetVibrationEnabled(TBool aChecked)
+    {
+    TRACES( RDebug::Print( _L("CHbDevicePowerMenuPrivate::SetVibrationEnabled: START") ) ); 
+    iVibrationEnable = aChecked;
+    TRACES( RDebug::Print( _L("CHbDevicePowerMenuPrivate::SetVibrationEnabled: END") ) ); 
+    }
+
+/**
+ * Sets PowerOffEnabled to Enable/Disable
+ */
+void CHbDevicePowerMenuPrivate::SetPowerOffEnabled(TBool aEnable)
+    {
+    TRACES( RDebug::Print( _L("CHbDevicePowerMenuPrivate::SetPowerOffEnabled: START") ) ); 
+    iCypherOff = aEnable;
+    TRACES( RDebug::Print( _L("CHbDevicePowerMenuPrivate::SetPowerOffEnabled: END") ) ); 
+    }
+
+/**
+ * Data received from HBDeviceDialog will hit by emit deviceDialogData in plugin
+ * The values received from UI will set to ControlPanel.
+ */
+void CHbDevicePowerMenuPrivate::DataReceived(CHbSymbianVariantMap& aData)
+    {
+    TRACES( RDebug::Print( _L("CHbDevicePowerMenuPrivate::DataReceived: START") ) ); 
+    // Updates received from the plugin.
+	//1. Volume
+	const CHbSymbianVariant* volumeVariant =  aData.Get(KVolumeLevel);
+	if(volumeVariant)
+		{
+        TRACES( RDebug::Print( _L("CHbDevicePowerMenuPrivate::DataReceived: volumeVariant::Start") ) );
+		TInt* volumeValue = volumeVariant->Value<TInt>();
+		if(volumeValue)
+			{
+			iVolumeLevel = *volumeValue;
+			iPowerMenuManager->iProfileEngine->SetMasterVolumeL( iVolumeLevel );
+			}
+	    TRACES( RDebug::Print( _L("CHbDevicePowerMenuPrivate::DataReceived:volumeVariant::End") ) );
+		}
+	
+	//2. Silence
+	const CHbSymbianVariant* SilenceVariant =  aData.Get(KSilenceLatchOn);
+	if(SilenceVariant)
+		{
+        TRACES( RDebug::Print( _L("CHbDevicePowerMenuPrivate::DataReceived: SilenceVariant::Start") ) );
+		TBool* LatchValue = SilenceVariant->Value<TBool>();
+		if(LatchValue)
+			{
+			iSilenceLatchOn = *LatchValue;
+			iPowerMenuManager->iProfileEngine->SetSilenceModeL( iSilenceLatchOn );//member in CHbDevicePowerMenuSymbian
+			}
+		TRACES( RDebug::Print( _L("CHbDevicePowerMenuPrivate::DataReceived: SilenceVariant::End") ) );
+		}
+	
+	//3. Vibration
+	const CHbSymbianVariant* VibrationVariant =  aData.Get(KVibrationEnable);
+	if(VibrationVariant)
+		{
+        TRACES( RDebug::Print( _L("CHbDevicePowerMenuPrivate::DataReceived: VibrationVariant::Start") ) );
+		TBool* VibrationValue = VibrationVariant->Value<TBool>();
+		if(VibrationValue)
+			{
+			iVibrationEnable = *VibrationValue;
+			iPowerMenuManager->iProfileEngine->SetMasterVibraL( iVibrationEnable );//member in CHbDevicePowerMenuSymbian
+			}
+        TRACES( RDebug::Print( _L("CHbDevicePowerMenuPrivate::DataReceived: VibrationVariant::End") ) );
+		}
+	
+	//4.Offline
+	const CHbSymbianVariant* OfflineVariant =  aData.Get(KOfflineEnable);
+	if(OfflineVariant)
+		{
+        TRACES( RDebug::Print( _L("CHbDevicePowerMenuPrivate::DataReceived: OfflineVariant::Start") ) );
+		TBool* OfflineValue = OfflineVariant->Value<TBool>();
+		if(OfflineValue)
+			{
+			iOfflineEnable = *OfflineValue;
+			User::LeaveIfError( iPowerMenuManager->iCenrepOffline->Set(  KSettingsAirplaneMode, iOfflineEnable )  ); 
+			}
+        TRACES( RDebug::Print( _L("CHbDevicePowerMenuPrivate::DataReceived: OfflineVariant::End") ) );
+		}
+	
+	//5.shutdown
+	const CHbSymbianVariant* ShutDownVariant =  aData.Get(KShutDown);
+	if(ShutDownVariant)
+		{
+        TRACES( RDebug::Print( _L("CHbDevicePowerMenuPrivate::DataReceived: ShutDownVariant::Start") ) );
+		TBool* ShutDownValue = ShutDownVariant->Value<TBool>();
+		if(ShutDownValue)
+			{
+			TBool shutDown = *ShutDownValue;
+			if (shutDown)
+			    {
+                iPowerMenuManager->iSysApServer.HandleLongPowerKeyPressedL();
+			    }
+			
+			}
+        TRACES( RDebug::Print( _L("CHbDevicePowerMenuPrivate::DataReceived: ShutDownVariant::End") ) );
+		}
+    TRACES( RDebug::Print( _L("CHbDevicePowerMenuPrivate::DataReceived: END") ) ); 
+	return;
+    }
+
+/**
+ * DeviceDialogClosed will be executed by the event emit deviceDialogClosed in plugin.
+ * This will be executed when   1. Tap out side the Dialog to Close
+ *                              2. When Power Off Button is clicked. 
+ */
+void CHbDevicePowerMenuPrivate::DeviceDialogClosed(TInt /*aCompletionCode*/)
+    {
+    TRACES( RDebug::Print( _L("CHbDevicePowerMenuPrivate::DeviceDialogClosed") ) ); 
+    // Inform sysap to release the memory of power menu custom dialog.
+    RProperty::Set( KPSUidCoreApplicationUIs, KCoreAppUIsPowerMenuCustomDialogStatus, ECoreAppUIsPowerMenuCustomDialogOn );
+    }
+
+/**
+ * Contrcuts VariantMap
+ */
+void CHbDevicePowerMenuPrivate::AddVariantL(const TDesC& aKey, const TAny* aData, CHbSymbianVariant::TType aDataType)
+    {
+    TRACES( RDebug::Print( _L("CHbDevicePowerMenuPrivate::AddVariantL: START") ) ); 
+    CHbSymbianVariant *variant = CHbSymbianVariant::NewL(aData, aDataType);
+    CleanupStack::PushL(variant);
+    //iVariantMap takes the ownerhip of variant
+    User::LeaveIfError(iVariantMap->Add(aKey, variant));
+    CleanupStack::Pop(variant);
+    TRACES( RDebug::Print( _L("CHbDevicePowerMenuPrivate::AddVariantL: End") ) ); 
+    }
+
+/*
+ * Creates an object of CHbDevicePowerMenuSymbian
+*/
+CHbDevicePowerMenuSymbian* CHbDevicePowerMenuSymbian::NewL(CSysApAppUi& aSysApServer)
+    {
+    TRACES( RDebug::Print( _L("CHbDevicePowerMenuSymbian::NewL: START") ) ); 
+    CHbDevicePowerMenuSymbian* self = new (ELeave) CHbDevicePowerMenuSymbian(aSysApServer);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    TRACES( RDebug::Print( _L("CHbDevicePowerMenuSymbian::NewL: END") ) ); 
+    return self;
+    }
+
+/*
+ *  Destructs the class.
+*/
+CHbDevicePowerMenuSymbian::~CHbDevicePowerMenuSymbian()
+    {
+    TRACES( RDebug::Print( _L("CHbDevicePowerMenuSymbian::Destructor: START") ) ); 
+    delete iCenrepProfile;
+    delete iCenrepOffline;
+    iProfileEngine->Release();
+    delete iPowerMenuPrivate;
+    TRACES( RDebug::Print( _L("CHbDevicePowerMenuSymbian::Destructor: End") ) ); 
+    }
+
+/*
+ * Executes the dialog asynchronously.
+*/
+void CHbDevicePowerMenuSymbian::ShowL()
+    {    
+    TRACES( RDebug::Print( _L("CHbDevicePowerMenuSymbian::ShowL: START") ) ); 
+    iPowerMenuPrivate->ShowL();
+    TRACES( RDebug::Print( _L("CHbDevicePowerMenuSymbian::ShowL: End") ) ); 
+    }
+
+/**
+ * Sets Volume to aVolume
+ */
+void CHbDevicePowerMenuSymbian::SetVolume(TInt aVolume)
+	{
+    TRACES( RDebug::Print( _L("CHbDevicePowerMenuSymbian::SetVolume: START") ) ); 
+    iPowerMenuPrivate->SetVolume(aVolume);
+    TRACES( RDebug::Print( _L("CHbDevicePowerMenuSymbian::SetVolume: End") ) ); 
+	}
+
+/**
+ * Sets SilenceMode to Enable/Disable
+ */
+void CHbDevicePowerMenuSymbian::SetSilenceMode(TBool aEnable)
+	{
+    TRACES( RDebug::Print( _L("CHbDevicePowerMenuSymbian::SetSilenceMode: START") ) ); 
+	iPowerMenuPrivate->SetSilenceMode(aEnable);
+    TRACES( RDebug::Print( _L("CHbDevicePowerMenuSymbian::SetSilenceMode: END") ) ); 
+	}
+
+/**
+ * Sets OfflineMode to Checked/UnChecked
+ */
+void CHbDevicePowerMenuSymbian::SetOfflineMode(TBool aChecked)
+	{
+    TRACES( RDebug::Print( _L("CHbDevicePowerMenuSymbian::SetOfflineMode: START") ) ); 
+	iPowerMenuPrivate->SetOfflineMode(aChecked);
+    TRACES( RDebug::Print( _L("CHbDevicePowerMenuSymbian::SetOfflineMode: End") ) ); 
+	}
+
+/**
+ * Sets VibrationEnabled to Checked/UnChecked
+ */
+void CHbDevicePowerMenuSymbian::SetVibrationEnabled(TBool aEnable)
+	{
+    TRACES( RDebug::Print( _L("CHbDevicePowerMenuSymbian::SetVibrationEnabled: START") ) ); 
+	iPowerMenuPrivate->SetVibrationEnabled(aEnable);
+    TRACES( RDebug::Print( _L("CHbDevicePowerMenuSymbian::SetVibrationEnabled: End") ) ); 
+	}
+
+/**
+ * Sets PowerOffEnabled to Enable/Disable
+ */
+void CHbDevicePowerMenuSymbian::SetPowerOffEnabled(TBool aEnable)
+	{
+    TRACES( RDebug::Print( _L("CHbDevicePowerMenuSymbian::SetPowerOffEnabled: START") ) ); 
+	iPowerMenuPrivate->SetPowerOffEnabled(aEnable);
+    TRACES( RDebug::Print( _L("CHbDevicePowerMenuSymbian::SetPowerOffEnabled: END") ) ); 
+	}
+
+/*
+ * Constructor.
+*/
+CHbDevicePowerMenuSymbian::CHbDevicePowerMenuSymbian(CSysApAppUi& aSysApServer)
+	:iSysApServer(aSysApServer)
+	{
+    TRACES( RDebug::Print( _L("CHbDevicePowerMenuSymbian::Constructor") ) ); 
+	//Do Nothing
+	}
+
+/*
+ * 2nd Constructor.
+ * Constructs and initializes all its meber variables
+*/
+void CHbDevicePowerMenuSymbian::ConstructL()
+    {
+    TRACES( RDebug::Print( _L("CHbDevicePowerMenuSymbian::ConstructL: START") ) ); 
+    iProfileEngine = ::CreateProfileEngineExtended2L();
+    iCenrepOffline = CRepository::NewL( KCRUidCommunicationSettings );
+    iCenrepProfile = CRepository::NewL( KCRUidProfileEngine );
+	iPowerMenuPrivate = CHbDevicePowerMenuPrivate::NewL(this);
+
+    //To Sync with Contro panel 
+	TBool airplaneMode(0);
+	User::LeaveIfError( iCenrepOffline->Get( KSettingsAirplaneMode, airplaneMode ) );
+	SetOfflineMode(airplaneMode);
+	
+	TInt masterVolume(0);
+	User::LeaveIfError( iCenrepProfile->Get( KProEngMasterVolume, masterVolume ) );
+	SetVolume(masterVolume);
+	
+	TBool masterVibrate(0);
+	User::LeaveIfError( iCenrepProfile->Get( KProEngMasterVibra, masterVibrate ) );
+	SetVibrationEnabled(masterVibrate);
+	
+	TBool silenceMode(EFalse);
+	User::LeaveIfError( iCenrepProfile->Get( KProEngSilenceMode, silenceMode ) );
+	SetSilenceMode(silenceMode);
+	
+	//Cypheroff is True when No encryption/Decryption is happening
+	TBool cypherOff(!(iSysApServer.IsEncryptionOperationOngoingL()));
+	SetPowerOffEnabled(cypherOff);
+    TRACES( RDebug::Print( _L("CHbDevicePowerMenuSymbian::ConstructL: END") ) ); 
+    }
+
--- a/coreapplicationuis/SysAp/Src/sysapbatteryinfocontroller.cpp	Tue Jun 15 16:07:48 2010 +0100
+++ b/coreapplicationuis/SysAp/Src/sysapbatteryinfocontroller.cpp	Thu Jul 22 16:35:22 2010 +0100
@@ -19,13 +19,8 @@
 #include <e32debug.h>
 #include <e32property.h>
 #include <StringLoader.h>
-#include <SysAp.rsg>
 #include "bsutil.h"
 #include <hwrmpowerstatesdkpskeys.h>
-#include <aknappui.h>
-#include <AknCapServerClient.h>
-#include <AknSgcc.h>
-#include "batterypopupcontrol.h"
 #include "sysapbatteryinfocontroller.h"
 #include "SysAp.hrh"
 
@@ -43,8 +38,8 @@
                                                         : iBsUtil( NULL ),
                                                           iCurrentCapacity( KNotInitialized ),
                                                           iThresholdCapacity( aThreshold  ),
-                                                          iBatteryInfoState( EBatteryInfoAboveThreshold ),
-                                                          iBatteryPopup( NULL )
+                                                          iBatteryInfoState( EBatteryInfoAboveThreshold )
+                                                          // iBatteryPopup( NULL )
     {
     // sanity check, fall back to hard coded default value
     const TInt min(0);
@@ -92,7 +87,7 @@
     {
     TRACES( RDebug::Print( _L("CSysApBatteryInfoController::~CSysApBatteryInfoController") ) );
     delete iBsUtil;
-    delete iBatteryPopup;
+    // delete iBatteryPopup;
     }
 
 // ---------------------------------------------------------------------------
@@ -183,38 +178,12 @@
 // CSysApBatteryInfoController::ShowBatteryPreviewPopupL
 // ---------------------------------------------------------------------------
 //
-void CSysApBatteryInfoController::ShowBatteryPreviewPopupL( TInt aCapacity )
+void CSysApBatteryInfoController::ShowBatteryPreviewPopupL( TInt /* aCapacity */ )
     {
-    TRACES( RDebug::Print( _L("CSysApBatteryInfoController::ShowBatteryPreviewPopupL: aCapacity=%d"), aCapacity ) );
-    
-    delete iBatteryPopup;
-    iBatteryPopup = NULL;
-    HBufC* popupTextBuf = StringLoader::LoadLC( R_QTN_BATTERY_STATUS_POPUP, aCapacity ); 
-    iBatteryPopup = CBatteryPopupControl::NewL( *popupTextBuf, KNullDesC );
-    CleanupStack::PopAndDestroy( popupTextBuf );
-        
-    // switch layout for showing the battery popup
-    CAknAppUi* appUi = static_cast<CAknAppUi*>(CCoeEnv::Static()->AppUi());
-    CEikStatusPane* statusPane = appUi->StatusPane();
+    // TRACES( RDebug::Print( _L("CSysApBatteryInfoController::ShowBatteryPreviewPopupL: aCapacity=%d"), aCapacity ) );
     
-    TInt currLayout = statusPane->CurrentLayoutResId();
-        
-    RAknUiServer* aknSrv = CAknSgcClient::AknSrv();
-    if ( aknSrv )
-        {
-        statusPane->SwitchLayoutL( aknSrv->StatusPaneResourceId()  );	
-        }    
-    // Trap for switching layout back to current.
-    TRAPD( err, iBatteryPopup->ShowPopUpL() );
-    
-    if( err )
-        {
-        TRACES( RDebug::Print( _L("CSysApBatteryInfoController::ShowBatteryPreviewPopupL ShowPopUpL() leaved: %d"), err ) );
-        }
-        
-    // restore layout
-    statusPane->SwitchLayoutL( currLayout );
-    
-    User::LeaveIfError( err );
+    // delete iBatteryPopup;
+    // iBatteryPopup = NULL;
+    // preview battery capacity
     }
 
--- a/coreapplicationuis/SysAp/Src/sysapdefaultkeyhandler.cpp	Tue Jun 15 16:07:48 2010 +0100
+++ b/coreapplicationuis/SysAp/Src/sysapdefaultkeyhandler.cpp	Thu Jul 22 16:35:22 2010 +0100
@@ -19,8 +19,9 @@
 #include <e32property.h>
 #include <eikon.hrh>
 #include <coemain.h>
-#include <aknkeylock.h>
-#include <AknTaskList.h>
+//#include <aknkeylock.h>
+//#include <AknTaskList.h>
+#include "SysApTaskList.h"
 #include <apgtask.h>
 #include <apgcli.h>
 #include <apgwgnam.h>
@@ -33,11 +34,13 @@
 #include <startupdomainpskeys.h>
 #include <hwrmdomainpskeys.h>
 #include <u32hal.h>
-#include <SysAp.rsg>
+//#include <SysAp.rsg>
 #include "sysapdefaultkeyhandler.h"
 #include "sysapcallback.h"
 #include "SysAp.hrh"
-#include "AknSgcc.h"
+#include <AknSgcc.h>
+//#include "sysapappui.h"
+#include <w32std.h>
 
 
 const TInt KModifierMask( 0 );
@@ -48,18 +51,18 @@
 // CSysApDefaultKeyHandler::CSysApDefaultKeyHandler
 // ---------------------------------------------------------------------------
 //
-CSysApDefaultKeyHandler::CSysApDefaultKeyHandler( MSysapCallback& aCallback ) :
+CSysApDefaultKeyHandler::CSysApDefaultKeyHandler( MSysapCallback& aCallback ):                                                      
                                                      iCallback(aCallback),
                                                      iCameraSupported(EFalse),
                                                      iCoverDisplaySupported(EFalse),
-                                                     iKeylock(NULL),
+//                                                     iKeylock(NULL),
                                                      iCapturedEKeyCamera(0),
                                                      iCapturedEKeyTwistOpen(0),
                                                      iCapturedEKeyTwistClose(0),
                                                      iCapturedEKeyGripOpen(0),
                                                      iCapturedEKeyGripClose(0),
-                                                     iCapturedEKeyPoC(0),
-                                                     iAknUiServerConnected(EFalse)
+                                                     iCapturedEKeyPoC(0)
+//                                                     iAknUiServerConnected(EFalse)
     {
     }
 
@@ -73,63 +76,23 @@
     
     RWindowGroup groupWin = CCoeEnv::Static()->RootWin();
     User::LeaveIfError ( iCapturedEKeyCamera = groupWin.CaptureKey( EKeyCamera, KModifierMask, KModifierMask ) );
-    User::LeaveIfError ( iCapturedEKeyTwistOpen = groupWin.CaptureKey( EKeyTwistOpen, KModifierMask, KModifierMask ) );
-    User::LeaveIfError ( iCapturedEKeyTwistClose = groupWin.CaptureKey( EKeyTwistClose, KModifierMask, KModifierMask ) );   
-    User::LeaveIfError ( iCapturedEKeyGripOpen = groupWin.CaptureKey( EKeyGripOpen, KModifierMask, KModifierMask ) ); 
-    User::LeaveIfError ( iCapturedEKeyGripClose = groupWin.CaptureKey( EKeyGripClose, KModifierMask, KModifierMask ) ); 
-    User::LeaveIfError ( iCapturedEKeyPoC = groupWin.CaptureKey( EKeyPoC, KModifierMask, KModifierMask ) ); 
-    
-    // flip key events don't need to be captured, because in current setup they are not real events but simulated by SysAp
-    // according to notifications received from P&S key that stores flip information
     
     FeatureManager::InitializeLibL();
     iCameraSupported = FeatureManager::FeatureSupported( KFeatureIdCamera );
     iCoverDisplaySupported = FeatureManager::FeatureSupported( KFeatureIdCoverDisplay );
     FeatureManager::UnInitializeLib();
-    
-    TKeyLockBuf lockBuf;
-    iCallback.ExecQueryL( MSysapCallback::EGetKeylock, lockBuf );  
-    iKeylock = lockBuf();
-    
-    __ASSERT_DEBUG( iKeylock, User::Panic( _L("CSysApDefaultKeyHandler::ConstructL: iKeylock not initialized"), KErrBadHandle ) );
-    
-    if ( iCoverDisplaySupported ) // if flip status is monitored, set the initial flip status now
-        {
-        TInt flipValue;
-        TInt err = RProperty::Get( KPSUidHWRM, KHWRMFlipStatus, flipValue );
-
-        TRACES( RDebug::Print( _L("CSysApDefaultKeyHandler::ConstructL: flipValue=%d, err=%d"), flipValue, err ) );
-        
-        if ( err == KErrNone )
-            {
-            switch ( flipValue )
-                {
-                case EPSHWRMFlipOpen:
-                    SetDisplayState( ETrue );
-                    break;
-                    
-                case EPSHWRMFlipClosed:
-                    SetDisplayState( EFalse );
-                    break;
-                    
-                case EPSHWRMFlipStatusUninitialized:
-                default:
-                    // set display state only if the current flip position is known
-                    break;
-                }
-            }
-        }
+ 
     }
 
 // ---------------------------------------------------------------------------
 // CSysApDefaultKeyHandler::NewL
 // ---------------------------------------------------------------------------
 //
-CSysApDefaultKeyHandler* CSysApDefaultKeyHandler::NewL( MSysapCallback& aCallback )
+CSysApDefaultKeyHandler* CSysApDefaultKeyHandler::NewL(MSysapCallback& aCallback )
     {
     TRACES( RDebug::Print( _L("CSysApDefaultKeyHandler::NewL()") ) );
     
-    CSysApDefaultKeyHandler* self = new( ELeave ) CSysApDefaultKeyHandler( aCallback) ;
+    CSysApDefaultKeyHandler* self = new( ELeave ) CSysApDefaultKeyHandler(aCallback) ;
     CleanupStack::PushL( self );
     self->ConstructL();
     CleanupStack::Pop( self );
@@ -144,17 +107,8 @@
 CSysApDefaultKeyHandler::~CSysApDefaultKeyHandler()
     {
     TRACES( RDebug::Print( _L("CSysApDefaultKeyHandler::~CSysApDefaultKeyHandler()") ) );
-    
-    iAknUiServer.Close();
-    
     RWindowGroup groupWin = CCoeEnv::Static()->RootWin();
-    groupWin.CancelCaptureKey( iCapturedEKeyCamera );
-    groupWin.CancelCaptureKey( iCapturedEKeyTwistOpen );
-    groupWin.CancelCaptureKey( iCapturedEKeyTwistClose );
-    groupWin.CancelCaptureKey( iCapturedEKeyGripOpen );
-    groupWin.CancelCaptureKey( iCapturedEKeyGripClose );
-    groupWin.CancelCaptureKey( iCapturedEKeyPoC );
-    
+    groupWin.CancelCaptureKey( iCapturedEKeyCamera );    
     }
     
 
@@ -176,58 +130,7 @@
         response = EKeyWasConsumed; // set again in default case if not consumed
         
         switch ( aKeyEvent.iCode )
-            {
-            case EKeyGripOpen:
-                TRACES( RDebug::Print(_L("CSysApDefaultKeyHandler::HandleKeyEventL: EKeyGripOpen") ) );
-                RProperty::Set( KPSUidHWRM, KHWRMGripStatus, EPSHWRMGripOpen );
-                if (!IsDeviceLocked())
-                    {
-                    iCallback.ExecCommandL( MSysapCallback::EResetKeyguardState );
-                    iKeylock->DisableKeyLock();
-                    iCallback.ExecCommandL( MSysapCallback::ECancelPowermenu );
-                    }
-                // apply default light control
-                iCallback.ExecCommandL( MSysapCallback::EUpdateLights, TUpdateLightsBuf(EKeyGripOpen) );
-                break;
-            
-            case EKeyGripClose:
-                TRACES( RDebug::Print(_L("CSysApDefaultKeyHandler::HandleKeyEventL: EKeyGripClosed") ) );
-                RProperty::Set( KPSUidHWRM, KHWRMGripStatus, EPSHWRMGripClosed );
-                iCallback.ExecCommandL( MSysapCallback::ECancelPowermenu );
-                if ( !IsDeviceLocked() && UiReady() )
-                    {
-                    iKeylock->OfferKeyLock();
-                    }
-                // apply default light control
-                iCallback.ExecCommandL( MSysapCallback::EUpdateLights, TUpdateLightsBuf(EKeyGripClose) );
-                break;
-            
-            case EKeyFlipOpen: // simulated key event
-                {
-                TRACES( RDebug::Print(_L("CSysApDefaultKeyHandler::HandleKeyEventL: EKeyFlipOpen") ) );
-                SetDisplayState( ETrue );
-                // apply default light control
-                iCallback.ExecCommandL( MSysapCallback::EUpdateLights, TUpdateLightsBuf(EKeyFlipOpen) );
-                }
-                break;
-            
-            case EKeyFlipClose: // simulated key event
-                TRACES( RDebug::Print(_L("CSysApDefaultKeyHandler::HandleKeyEventL: EKeyFlipClose") ) );
-                SetDisplayState( EFalse );
-                // apply default light control
-                iCallback.ExecCommandL( MSysapCallback::EUpdateLights, TUpdateLightsBuf(EKeyFlipClose) );
-                break;
-                
-            case EKeyTwistOpen:
-                TRACES( RDebug::Print(_L("CSysApDefaultKeyHandler::HandleKeyEventL: EKeyTwistOpen") ) );
-                RProperty::Set( KPSUidHWRM, KHWRMTwistStatus, EPSHWRMTwistOpen );
-                break;
-                
-            case EKeyTwistClose:
-                TRACES( RDebug::Print(_L("CSysApDefaultKeyHandler::HandleKeyEventL: EKeyTwistClose") ) );
-                RProperty::Set( KPSUidHWRM, KHWRMTwistStatus, EPSHWRMTwistClose );
-                break;                
-
+            {                              
             case EKeyCamera:
                 TRACES( RDebug::Print(_L("CSysApDefaultKeyHandler::HandleKeyEventL: EKeyCamera") ) );
                 if ( iCameraSupported && !IsDeviceLocked() && !DoShowKeysLockedNote() )
@@ -235,17 +138,10 @@
                     ActivateApplicationL( KSysApCamcorderUid );
                     }
                 break;
-                
-            case EKeyPoC:
-                TRACES( RDebug::Print(_L("CSysApDefaultKeyHandler::HandleKeyEventL: EKeyPoC") ) );
-                LaunchPocL();
-                break;                
-             
             default:
                 response = EKeyWasNotConsumed;
                 TRACES( RDebug::Print( _L("CSysApDefaultKeyHandler::CSysApDefaultKeyHandler: key was not consumed.") ) ); 
-                break;
-                    
+                break;               
             }
         }
     
@@ -318,15 +214,17 @@
 //
 void CSysApDefaultKeyHandler::ActivateApplicationL( const TUid aUid ) const
     {
+    TUid check = aUid;
+    
     TRACES( RDebug::Print( _L( "CSysApDefaultKeyHandler::ActivateApplicationL") ) );
     
     // Applications must not be activated before reaching normal system operation state
     if ( UiReady() )
         {
-        CAknTaskList* apaTaskList = CAknTaskList::NewL( CCoeEnv::Static()->WsSession() );
+        CSysApTaskList* apaTaskList = CSysApTaskList::NewLC( CCoeEnv::Static()->WsSession() );
         TApaTask apaTask = apaTaskList->FindRootApp( aUid ); // only root application should not be activated
-        delete apaTaskList;
-        
+        CleanupStack::PopAndDestroy( apaTaskList );
+                
         if ( apaTask.Exists() )
             {
             TRACES( RDebug::Print( _L( "CSysApDefaultKeyHandler::ActivateApplicationL: application brought to foreground") ) );
@@ -336,8 +234,8 @@
                 {
                 TRACES( RDebug::Print( _L("e_CAM_PRI_OFF_TO_ON 1") ) );
                 }
-#endif // _DEBUG            
-            CAknSgcClient::MoveApp ( apaTask.WgId(), ESgcMoveAppToForeground );
+#endif // _DEBUG                        
+            apaTask.BringToForeground();
             }
         else
             {
@@ -380,20 +278,8 @@
 void CSysApDefaultKeyHandler::LaunchPocL()
     {
     TRACES( RDebug::Print(_L("CSysApDefaultKeyHandler::LaunchPocL") ) );
-    
-    if ( UiReady() && !IsDeviceLocked() && !DoShowKeysLockedNote() )
-        {
-        CAiwServiceHandler* serviceHandler = CAiwServiceHandler::NewLC();
-        serviceHandler->AttachL( R_POC_AIW_INTEREST );
-            
-        CAiwGenericParamList* inParams = CAiwGenericParamList::NewLC();
-        inParams->AppendL(TAiwGenericParam( EGenericParamPoCLaunchView, TAiwVariant(EAiwPoCMainView)));
-        serviceHandler->ExecuteServiceCmdL( KAiwCmdPoC, *inParams, serviceHandler->OutParamListL());
-        
-        CleanupStack::PopAndDestroy( inParams );
-        CleanupStack::PopAndDestroy( serviceHandler);
-        }
-    }
+    // not supported
+  }
     
 // ----------------------------------------------------------------------------
 // CSysApDefaultKeyHandler::IsDeviceLocked()
@@ -451,25 +337,25 @@
     
     if ( !iAknUiServerConnected )
         {
-        err = iAknUiServer.Connect();
+/*        err = iAknUiServer.Connect();
         
         if ( err != KErrNone )
             {
-            TRACES( RDebug::Print( _L("CSysApDefaultKeyHandler::DoShowKeysLockedNote: RAknUiServer::Connect failed, err=%d"), err ) );
+ //           TRACES( RDebug::Print( _L("CSysApDefaultKeyHandler::DoShowKeysLockedNote: RAknUiServer::Connect failed, err=%d"), err ) );
             return ETrue; // assume that keypad/device is locked
             }
         iAknUiServerConnected = ETrue;            
-        }
+  */      }
     
-    TBool keysLocked;
-    err = iAknUiServer.ShowKeysLockedNote( keysLocked );
+    TBool keysLocked = EFalse;
+/*    err = iAknUiServer.ShowKeysLockedNote( keysLocked );
     
     if ( err != KErrNone )
         {
         TRACES( RDebug::Print( _L("CSysApDefaultKeyHandler::DoShowKeysLockedNote: RAknUiServer::ShowKeysLockedNote failed, err=%d"), err ) );
         keysLocked = ETrue; // assume that keypad/device is locked
         }
-        
+ */       
     return keysLocked;        
     }
 
@@ -500,3 +386,6 @@
     
     return response;        
     }
+
+
+
--- a/coreapplicationuis/SysAp/Src/sysapkeymanagement.cpp	Tue Jun 15 16:07:48 2010 +0100
+++ b/coreapplicationuis/SysAp/Src/sysapkeymanagement.cpp	Thu Jul 22 16:35:22 2010 +0100
@@ -134,6 +134,10 @@
             {
             iRootWindowGroup.CancelCaptureKeyUpAndDowns( info->iUpAndDownKeyHandles[upAndDownKeyHandleCounter] );
             }
+        for ( TInt keyHandleCounter = info->iLongKeyPressHandle.Count()-1; keyHandleCounter >= 0; keyHandleCounter-- )
+             {
+             iRootWindowGroup.CancelCaptureLongKey( info->iLongKeyPressHandle[keyHandleCounter] );
+             }
         }
     }
 
@@ -166,8 +170,10 @@
                                        captureKey, info->iPluginUid ) );
 			if (info->iIsKeyProvider)
 			    {
+			    TUint repeatValue = 0;
 			    TInt captureUpDownKey = info->iKeys[keyCounter].iScanCode;
 			    TUint modifiers = info->iKeys[keyCounter].iModifiers;
+			    repeatValue = info->iKeys[keyCounter].iRepeats; 
 			    
                 TInt32 keyHandle = iRootWindowGroup.CaptureKey( captureKey, modifiers, modifiers );
                 
@@ -196,6 +202,19 @@
                     //error of Append ignored, key will not be cancelled. We can live with that.
                     TRACES( RDebug::Print( _L("CSysApKeyManagement::CaptureKeys UpAndDowns: Append failed, error %d"), upAndDownKeyHandle ) );
                     }
+                if( repeatValue == 1 )
+                    {
+                    TInt32 longKeyPressHandle = iRootWindowGroup.CaptureLongKey( captureKey, captureKey,0, modifiers,0, ELongCaptureWaitShort);
+                    if ( longKeyPressHandle < KErrNone )
+                        {
+                       TRACES( RDebug::Print( _L("CSysApKeyManagement::CaptureLongKey : error %d"), longKeyPressHandle ) );
+                       continue; // other keys may be possible to capture, so continue
+                        }
+                    if ( ( longKeyPressHandle = info->iLongKeyPressHandle.Append( longKeyPressHandle ) ) != KErrNone ) //store handle for CancelCaptureKeyUpAndDowns
+                         {
+                          TRACES( RDebug::Print( _L("CSysApKeyManagement::CaptureLongKey : Append failed, error %d"), longKeyPressHandle ) );
+                         }                               
+                    }
 			    }
 			else
 			    {
--- a/coreapplicationuis/SysAp/Src/sysapremconobserver.cpp	Tue Jun 15 16:07:48 2010 +0100
+++ b/coreapplicationuis/SysAp/Src/sysapremconobserver.cpp	Thu Jul 22 16:35:22 2010 +0100
@@ -19,7 +19,7 @@
 // INCLUDE FILES
 #include <remconcoreapitarget.h>
 #include <remconinterfaceselector.h>
-#include <aknconsts.h>
+//#include <aknconsts.h>
 #include "sysapremconobserver.h"
 #include "SysApAppUi.h"
 
@@ -102,13 +102,13 @@
 	        || aOperationId == ERemConCoreApiMute )
 	        {
             // A volume key is pressed down
-/*            TRAPD( err, iSysApAppUi.ShowUiNoteL( EFmTxVolumeDisabledNote ) );
+            TRAPD( err, iSysApAppUi.ShowUiNoteL( EFmTxVolumeDisabledNote ) );
             
             if ( err != KErrNone )
                 {
                 TRACES( RDebug::Print( _L("CSysApRemConObserver::MrccatoCommand: err=%d"), err ) );
                 }
-*/	        }
+	        }
 	    }
 	}
 
--- a/coreapplicationuis/SysAp/rom/SysAp.iby	Tue Jun 15 16:07:48 2010 +0100
+++ b/coreapplicationuis/SysAp/rom/SysAp.iby	Thu Jul 22 16:35:22 2010 +0100
@@ -20,6 +20,7 @@
 #define __SysAp_IBY__
 
 file=ABI_DIR\BUILD_DIR\NspsWsPlugin.dll         SHARED_LIB_DIR\NspsWsPlugin.dll
+data=DATAZ_\resource\apps\qgn_sysap_screen.svg        resource\apps\qgn_sysap_screen.svg
 
 S60_APP_EXE(SysAp)
 S60_APP_AIF_RSC(SysAp)
--- a/coreapplicationuis/advancedtspcontroller/data/keyevent.rul	Tue Jun 15 16:07:48 2010 +0100
+++ b/coreapplicationuis/advancedtspcontroller/data/keyevent.rul	Thu Jul 22 16:35:22 2010 +0100
@@ -22,9 +22,9 @@
             />
             
             <Tsp
-            routingTable='01'            
+            routingTable='01'           
+	    ruleActiveAudio='00' 
             ruleForeground='01'
-            ruleActiveAudio='00'
             ruleLastPlayedAudio='03'
             ruleDefaultApp='02'
             defaultApplicationPhone='100058B3'
@@ -113,9 +113,8 @@
             ruleActiveAudio='00'
             ruleLastPlayedAudio='03'
             ruleForeground='01' 
-            ruleDefaultApp='02'
-            defaultApplicationPhone='100058B3'
-            transparentApplicationBTAudioMan='10208971'
+	    ruleLaunchDefaultApp='04'
+            defaultLaunchApp='102072C3'
             />
             
             <Tsp
@@ -130,7 +129,6 @@
             ruleLastPlayedAudio='03'
             ruleDefaultApp='02'
             defaultApplicationPhone='100058B3'
-            transparentApplicationBTAudioMan='10208971'
 	    />
             
             <Tsp
--- a/coreapplicationuis/advancedtspcontroller/group/RemConTspController.mmp	Tue Jun 15 16:07:48 2010 +0100
+++ b/coreapplicationuis/advancedtspcontroller/group/RemConTspController.mmp	Thu Jul 22 16:35:22 2010 +0100
@@ -29,7 +29,8 @@
 SOURCE          remcontspcontrollermain.cpp
 SOURCE          remcontspcontroller.cpp
 SOURCE          remconidlelistener.cpp
-SOURCE          remconeventtable.cpp
+SOURCE          remconeventtable.cpp 
+SOURCE          tsptriggerevents.cpp
 
 START RESOURCE  ../data/10282CD5.rss
 target          advancedtspcontroller.rsc
--- a/coreapplicationuis/advancedtspcontroller/group/bld.inf	Tue Jun 15 16:07:48 2010 +0100
+++ b/coreapplicationuis/advancedtspcontroller/group/bld.inf	Thu Jul 22 16:35:22 2010 +0100
@@ -10,7 +10,7 @@
 * Nokia Corporation - initial contribution.
 *
 * Contributors:
-* NTT DOCOMO, INC - BUG 2365
+* 
 *
 * Description:  Bld.inf file for Symbian's Remote Control framework related 
 *				 plug-ins that are used to deliver messages (e.g. accessory key 
@@ -18,6 +18,9 @@
 *
 */
 
+/*
+*NTT DOCOMO, INC - BUG 2365
+*/
 
 #include <platform_paths.hrh>
 
--- a/coreapplicationuis/advancedtspcontroller/inc/remcontspcontroller.h	Tue Jun 15 16:07:48 2010 +0100
+++ b/coreapplicationuis/advancedtspcontroller/inc/remcontspcontroller.h	Thu Jul 22 16:35:22 2010 +0100
@@ -29,9 +29,10 @@
 #include <cfclient.h>
 #include <cflistener.h>
 #include <AudioClientsListPSData.h>
+#include <remcon/clientinfo.h>
 #include "remconidlelistener.h"
 #include "remconeventtable.h"
-
+#include "tsptriggerevents.h"
 // CONSTANTS
 
 // MACROS
@@ -57,7 +58,10 @@
 class CRemConTspController : public CRemConTargetSelectorPlugin,
                  public MRemConTargetSelectorPluginInterfaceV2,
                  public MRemConTargetSelectorPluginInterfaceV3,
-			     public MCFListener
+                 public MRemConTargetSelectorPluginInterfaceV4,
+                 public MRemConTargetSelectorPluginInterfaceV5,
+			     public MCFListener,
+                 public MTspRulesTriggerObserver
 	{
 	public:		// Constructors and destructor
 		
@@ -243,6 +247,85 @@
                 const TClientInfo& aSender,
                 const TRemConAddress& aConnection);
         
+        /**
+        Called by RemCon to get the TSP to permit an incoming command. This is called
+        if the bearer has provided a target client for the command.  
+        
+        The implementor should decide if they wish to allow this command and then call
+        IncomingCommandPermitted on the observer with a suitable error. 
+        
+        @param aInterfaceUid The UID of the client interface.
+        @param aOperationId The operation ID of the command.
+        @param aClient a TClientInfo referring to the selected client
+        */
+        virtual void PermitIncomingCommand(
+            TUid aInterfaceUid,
+            TUint aOperationId, 
+            const TClientInfo& aClient);
+        
+        /**
+        Called by RemCon to get the TSP to permit an incoming Notify. This is called
+        if the bearer has provided a target client for the Notify.  
+        
+        The implementor should decide if they wish to allow this Notify and then call
+        IncomingNotifyPermitted on the observer with a suitable error. 
+        
+        @param aInterfaceUid The UID of the client interface.
+        @param aOperationId The operation ID of the Notify.
+        @param aClient a TClientInfo referring to the selected client
+        */
+        virtual void PermitIncomingNotify(
+            TUid aInterfaceUid,
+            TUint aOperationId, 
+            const TClientInfo& aClient);
+
+        /** 
+        Called by RemCon when a bearer that can address commands wishes to
+        inform the system that there has been a remote user action to 
+        select a different addressed client.
+        
+        The bearer will then route addressed commands to this client until
+        such time as SetRemoteAddressedClient is called again or the TSP
+        calls SetLocalAddressedClient.
+        
+        @param aBearerUid The bearer that has changed its addressed client
+        @param aClient The RemCon client that is now selected by the bearer
+        */
+        virtual void SetRemoteAddressedClient(const TUid& aBearerUid, 
+                const TClientInfo& aClient);
+        /** Called by RemCon when a new target client has connected.
+         
+         @aClientInfo The information about the new client.
+         */
+        void TargetClientAvailable(const TClientInfo& aClientInfo);
+        
+        /** Called by RemCon when a target client has disconnected. 
+         
+         @aClientInfo The information about the client that has disconnected.
+         */
+        void TargetClientUnavailable(const TClientInfo& aClientInfo);
+        
+        /** Called by RemCon when a bearer wishes to begin being informed when
+        the locally addressed player changes.  Once this function has been called
+        the TSP should inform RemCon via SetLocalAddressedPlayer each time the
+        player to which incoming commands from aBearer would be routed changes.
+        This might occur for example if a new application is launched, or if the
+        foreground application changes, depending on what the TSP's rules are
+        for deciding the target of the incoming message.  These updates should
+        occur until UnregisterLocalAddressedClientObserver is called.
+        
+        @param aBearerUid The bearer that wishes to be informed of updates
+        */
+        TInt RegisterLocalAddressedClientObserver(const TUid& aBearerUid);
+
+        /** Called by RemCon when a bearer wishes to stop being informed of 
+        changes to the local addresse client.
+        
+        @param aBearerUid The bearer that no longer wishes to be informed of updates
+        */
+        TInt UnregisterLocalAddressedClientObserver(const TUid& aBearerUid);
+
+        
 	    // From MCFListener
 	    
 	    /**
@@ -291,6 +374,8 @@
             const TDesC& aSource,
             const TDesC& aType );
             
+        // from MTspRulesTriggerObserver
+        void MtrtoEvaluateRoutingRules();
         /**
         * Gets the foreground application.
         * 
@@ -329,8 +414,9 @@
 	    void GetCorrectClientL(
             TUid aInterfaceUid,
         	TUint aKeyEvent,
-        	TSglQue<TClientInfo>& aClients );
-        
+        	TSglQue<TClientInfo>& aClients,
+        	TBool aLaunchingNewApplicationAllowed);
+
         void SetKeyEventTableL( const CCFActionIndication& aActionToExecute );        
 
         void ActivateApplicationL( const TUid aUid ) const;
@@ -352,12 +438,26 @@
         */
         TBool DeviceLocked() const;
 
-	private:    // Data
-	    
-	    // owned
-		CRemConIdleListener* iIdle;
-		
-		// Interface to P&S key that returns call state
+        /**
+         * Decide if locally addressed client should be updated.
+         */
+        TClientInfo* GetLocalAddressedClient();
+
+private:
+        NONSHARABLE_STRUCT(TClientObserver)
+            {
+        public:
+            TClientObserver(TUid aBearerUid) : iBearerUid(aBearerUid) {};
+        public:
+            TUid iBearerUid;
+            TSglQueLink iClientObserverQueLink;
+            };
+
+private:    // Data
+        // owned
+        CRemConIdleListener* iIdle;
+
+        // Interface to P&S key that returns call state
         RProperty iProperty;
         
         CCFClient* iCFClient;
@@ -371,6 +471,16 @@
         TProcessId iProcessIdActive;
 
         RPointerArray<CRemConEventTable> iArrayOfStoredTables;
+        
+        TSglQue<TClientObserver> iClientObservers;
+        
+        TSglQue<TClientInfo> iAvailableTargets;
+        
+        TSglQue<TClientInfo> iTargetsForAddressing;
+        
+        TClientInfo* iLocalAddressedClient;
+        
+        CTspTriggerEventsWatcher* iTriggerEventsWatcher;
 	
 	public:     // Friend classes
 	
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/coreapplicationuis/advancedtspcontroller/inc/tsptriggerevents.h	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,104 @@
+/*
+* Copyright (c) 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Observes changes in the default player that should be used for a bearer
+*/
+
+#include <e32base.h>
+#include <e32property.h>
+#include <w32std.h>
+
+
+NONSHARABLE_CLASS(MTspRulesTriggerObserver)
+    {
+public:
+    virtual void MtrtoEvaluateRoutingRules() = 0;
+    };
+
+NONSHARABLE_CLASS(CActiveAudioClientObserver) : public CActive
+    {
+public:
+    static CActiveAudioClientObserver* NewL(MTspRulesTriggerObserver& aObserver);
+    ~CActiveAudioClientObserver();
+
+private:
+    // from CActive
+    void RunL();
+    void DoCancel();
+    
+    CActiveAudioClientObserver(MTspRulesTriggerObserver& aObserver);
+    void ConstructL();
+
+private:
+    MTspRulesTriggerObserver& iObserver;
+    RProperty iAudioApplication;
+    };
+
+NONSHARABLE_CLASS(CTspClientMapperObserver) : public CActive
+    {
+public:
+    static CTspClientMapperObserver* NewL(MTspRulesTriggerObserver& aObserver);
+    ~CTspClientMapperObserver();
+
+private:
+    // from CActive
+    void RunL();
+    void DoCancel();
+    
+    CTspClientMapperObserver(MTspRulesTriggerObserver& aObserver);
+    void ConstructL();
+
+private:
+    MTspRulesTriggerObserver& iObserver;
+    RProperty iPlayingClients;
+    };
+
+NONSHARABLE_CLASS(CWsEventsObserver) : public CActive
+    {
+public:
+    static CWsEventsObserver* NewL(MTspRulesTriggerObserver& aObserver);
+    ~CWsEventsObserver();
+    
+private:
+    // from CActive
+    void RunL();
+    void DoCancel();
+    
+    CWsEventsObserver(MTspRulesTriggerObserver& aObserver);
+    void ConstructL();
+    
+private:
+    MTspRulesTriggerObserver& iObserver;
+    RWsSession iWsSession;
+    RWindowGroup iWindowGroup;
+    };
+
+NONSHARABLE_CLASS(CTspTriggerEventsWatcher) : public CBase
+    {
+public:
+    static CTspTriggerEventsWatcher* NewL(MTspRulesTriggerObserver& aObserver);
+    ~CTspTriggerEventsWatcher();
+    TInt AddBearer(TUid& aBearerUid);
+    TInt RemoveBearer(TUid& aBearerUid);
+
+private:
+    CTspTriggerEventsWatcher(MTspRulesTriggerObserver& aObserver);
+    void ConstructL();
+
+private:
+    MTspRulesTriggerObserver& iObserver;
+    CActiveAudioClientObserver* iAudioClientObserver;
+    CWsEventsObserver* iWsEventsObserver;
+    CTspClientMapperObserver* iClientMapperObserver;
+    };
+
--- a/coreapplicationuis/advancedtspcontroller/src/remcontspcontroller.cpp	Tue Jun 15 16:07:48 2010 +0100
+++ b/coreapplicationuis/advancedtspcontroller/src/remcontspcontroller.cpp	Thu Jul 22 16:35:22 2010 +0100
@@ -61,6 +61,8 @@
 // LOCAL CONSTANTS AND MACROS
 
 const TUint32 KUid3MusicPlayer = 0x102072C3;
+const TUint32 KUid3PhoneApp = 0x100058B3; 
+const TUint32 KUid3VoiceCmdApp = 0x102818e7;
 
 //#define __MODULE_TEST__
 
@@ -108,9 +110,11 @@
 // -----------------------------------------------------------------------------
 //
 
-CRemConTspController::CRemConTspController( 
-								MRemConTargetSelectorPluginObserver& aObserver )
-:	CRemConTargetSelectorPlugin( aObserver )
+CRemConTspController::CRemConTspController(MRemConTargetSelectorPluginObserver& aObserver )
+    : CRemConTargetSelectorPlugin( aObserver )
+    , iClientObservers(_FOFF(TClientObserver, iClientObserverQueLink))
+    , iAvailableTargets(_FOFF(TClientInfo, iLink))
+    , iTargetsForAddressing(_FOFF(TClientInfo, iLink2))
 	{
 	}
     
@@ -154,6 +158,24 @@
 	    }
     iArrayOfTables.ResetAndDestroy();
     iArrayOfStoredTables.ResetAndDestroy();
+    
+    TClientInfo* clientInfo;
+    while(!iAvailableTargets.IsEmpty())
+        {
+        clientInfo = iAvailableTargets.First();
+        iAvailableTargets.Remove(*clientInfo);
+        delete clientInfo;
+        }
+
+    TClientObserver* clientObserver;
+    while(!iClientObservers.IsEmpty())
+        {
+        clientObserver = iClientObservers.First();
+        iClientObservers.Remove(*clientObserver);
+        delete clientObserver;
+        }
+    iTargetsForAddressing.Reset(); 
+    delete iTriggerEventsWatcher;
 	COM_TRACE_( "[REMCONTSPCONTROLLER] CRemConTspController::~CRemConTspController() - return" );
 	}
 
@@ -186,6 +208,16 @@
 		ret = reinterpret_cast<TAny*>(
 			static_cast<MRemConTargetSelectorPluginInterfaceV3*>(this) );
 		}
+    else if ( aUid == TUid::Uid(KRemConTargetSelectorInterface4) )
+        {
+        ret = reinterpret_cast<TAny*>(
+            static_cast<MRemConTargetSelectorPluginInterfaceV4*>(this) );
+        }
+    else if ( aUid == TUid::Uid(KRemConTargetSelectorInterface5) )
+        {
+        ret = reinterpret_cast<TAny*>(
+            static_cast<MRemConTargetSelectorPluginInterfaceV5*>(this) );
+        }
 	COM_TRACE_1( "[REMCONTSPCONTROLLER] CRemConTspController::GetInterface() this=%d", ret );
 	return ret;
 	}
@@ -338,9 +370,7 @@
 #ifdef _DEBUG	
 	TraceRemconTargets( aClients );
 #endif
-	
-	TRAPD( err, GetCorrectClientL( aInterfaceUid, aOperationId, aClients ) );
-	
+	TRAPD( err, GetCorrectClientL( aInterfaceUid, aOperationId, aClients, ETrue ) );
 	Observer().IncomingCommandAddressed( err );
 	
 	COM_TRACE_( "[REMCONTSPCONTROLLER] CRemConTspController::AddressIncomingCommand() ends" );
@@ -397,6 +427,228 @@
     }
 
 // -----------------------------------------------------------------------------
+// CRemConTspController::PermitIncomingCommand
+// By default, permit all incoming addressed commands.  Check if the command
+// comes from the AVRCP bearer an if so launch the music player.
+// -----------------------------------------------------------------------------
+void CRemConTspController::PermitIncomingCommand(
+    TUid aInterfaceUid,
+    TUint aOperationId, 
+    const TClientInfo& aClient)
+    {
+	(void) aClient;  // Not used. 
+    // Here we need to check the incoming command.  If it is an AVRCP play
+    // command and there is no sensible handler running we should launch the
+    // MPX Music Player.  This is the same as for AddressIncomingCommand.
+    // Check if appropriate handler running
+    if ((aInterfaceUid != TUid::Uid(KRemConCoreApiUid)) ||
+         (aOperationId != ERemConCoreApiPlay) ||
+         GetLocalAddressedClient())
+        {
+        // no action needed, allow commmand
+        Observer().IncomingCommandPermitted(ETrue);
+        }
+     else 
+        {
+        // Launch an appropriate player in playing state. 
+        TRAPD(err, ActivateApplicationL(TUid::Uid(KUid3MusicPlayer)))
+        if(err != KErrNone)
+            {
+
+            }
+
+        //deny this command
+        Observer().IncomingCommandPermitted(EFalse);
+
+        // We will be informed when the MPX music player connects its client 
+        // session.  That will trigger a rules evaluation which will result in
+        // us informing interested bearers of the new local addressed player.
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CRemConTspController::PermitIncomingNotify
+// By default, permit all incoming addressed commands.  Check if the command
+// comes from the AVRCP bearer an if so launch the music player.
+// -----------------------------------------------------------------------------
+void CRemConTspController::PermitIncomingNotify(
+    TUid /*aInterfaceUid*/,
+    TUint /*aOperationId*/, 
+    const TClientInfo& /*aClient*/)
+    {
+    // No reason to stop these, just allow all
+    Observer().IncomingNotifyPermitted(ETrue);
+    }
+
+// -----------------------------------------------------------------------------
+// CRemConTspController::SetRemoteAddressedClient
+// Ignore this event.  We don't use what the remote has selected to influence
+// our routing policy.
+// -----------------------------------------------------------------------------
+void CRemConTspController::SetRemoteAddressedClient(const TUid& /*aBearerUid*/, 
+        const TClientInfo& /*aClient*/)
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CRemConTspController::TargetClientAvailable
+// A new client has connected.  Trigger a rule evaluation to see if we want to switch
+// to this client.
+// -----------------------------------------------------------------------------
+void CRemConTspController::TargetClientAvailable(const TClientInfo& aClientInfo)
+    {
+    COM_TRACE_1("[REMCONTSPCONTROLLER] CRemConTspController::TargetClientAvailable aClientInfo.SecureId=0x%x", aClientInfo.SecureId().iId);
+
+    TClientInfo* clientInfo;
+    TSglQueIter<TClientInfo> iter(iAvailableTargets);
+    
+    while((clientInfo = iter++) != NULL)
+        {
+        if(clientInfo->SecureId() == aClientInfo.SecureId())
+            {
+            // Found a client and clientInfo points to that now. 
+            break; 
+            }
+        }
+    
+    // If clientInfo was not found, create it and add to the available targets queue. 
+    if(!clientInfo)
+        {
+        TClientInfo* newTarget = new TClientInfo();
+        if(newTarget)
+            {
+            newTarget->ProcessId() = aClientInfo.ProcessId();
+            newTarget->SecureId() = aClientInfo.SecureId();
+            
+            // Add to our list of available targets
+            iAvailableTargets.AddLast(*newTarget);
+            }
+        }
+
+    // Re-evaluate what the default addressed player should be if someone is interested to know 
+    if(!iClientObservers.IsEmpty())
+        {
+        MtrtoEvaluateRoutingRules();
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CRemConTspController::TargetClientUnavailable
+// A client has disconnected.  Trigger a rule evaluation to see if our default
+// player has changed.
+// -----------------------------------------------------------------------------
+void CRemConTspController::TargetClientUnavailable(const TClientInfo& aClientInfo)
+    {
+    COM_TRACE_1("[REMCONTSPCONTROLLER] CRemConTspController::TargetClientUnavailable aClientInfo.SecureId=0x%x", aClientInfo.SecureId().iId);
+
+    // Remove this from our list of available targets
+    if(!iAvailableTargets.IsEmpty())
+        {
+        TClientInfo* clientInfo;
+        TSglQueIter<TClientInfo> iter(iAvailableTargets);
+        while((clientInfo = iter++) != NULL)
+            {
+            if(clientInfo->SecureId() == aClientInfo.SecureId())
+                {
+                iAvailableTargets.Remove(*clientInfo);
+                delete clientInfo;
+                break;
+                }
+            }
+        }
+
+    if(!iClientObservers.IsEmpty())
+        {
+        // Re-evaluate what the default addressed player should be if someone is listening. 
+        MtrtoEvaluateRoutingRules();
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CRemConTspController::RegisterLocalAddressedClientObserver
+// A bearer is interested in what the local addressed player is.  Start observing.
+// -----------------------------------------------------------------------------
+TInt CRemConTspController::RegisterLocalAddressedClientObserver(const TUid& aBearerUid)
+    {
+    COM_TRACE_1("[REMCONTSPCONTROLLER] CRemConTspController::RegisterLocalAddressedClientObserver aBearerUid.SecureId=0x%x", aBearerUid.iUid);
+    TInt err = KErrNone;
+    // Add this to our list of bearers interested in the default addressed player
+    TClientObserver* clientObserver = new TClientObserver(aBearerUid);
+
+    if(!clientObserver)
+        {
+        err = KErrNoMemory; 
+        }
+
+    // If this is our first interested bearer kick off the trigger events watcher.
+    // This will let us know if any event occurs that should trigger us to re-evaluate
+    // our addressing rules
+    if(!iTriggerEventsWatcher && err == KErrNone)
+        {
+        TRAP(err, iTriggerEventsWatcher = CTspTriggerEventsWatcher::NewL(*this));
+        if(err != KErrNone)
+            {
+            // If we couldn't create the events watcher the client Observer is not needed either.
+            delete clientObserver;
+            }
+        }
+
+    if(err == KErrNone)
+        {
+        // Finally add the observer to the queue if it's not there yet. 
+        TSglQueIter<TClientObserver> iter(iClientObservers);
+        TClientObserver* obsInQueue;
+        while((obsInQueue = iter++) != NULL)
+            {
+            if(obsInQueue->iBearerUid == aBearerUid)
+                {
+                err = KErrAlreadyExists; 
+                break;
+                }
+            }
+
+        if(!obsInQueue)
+            {
+            iClientObservers.AddLast(*clientObserver);
+            MtrtoEvaluateRoutingRules();
+            }
+        }
+
+    return err;
+    }
+
+// -----------------------------------------------------------------------------
+// CRemConTspController::UnregisterLocalAddressedClientObserver
+// The bearer is no longer interested in observering default client changes.
+// -----------------------------------------------------------------------------
+TInt CRemConTspController::UnregisterLocalAddressedClientObserver(const TUid& aBearerUid)
+    {
+    COM_TRACE_1("[REMCONTSPCONTROLLER] CRemConTspController::UnregisterLocalAddressedClientObserver aBearerUid.SecureId=0x%x", aBearerUid.iUid);
+    // Remove this from our list of bearers interested in the default addressed player.
+    // If there are no interested bearers left then we can stop watching for rules
+    // triggers.
+    TSglQueIter<TClientObserver> iter(iClientObservers);
+    TClientObserver* clientObserver;
+    while((clientObserver = iter++) != NULL)
+        {
+        if(clientObserver->iBearerUid == aBearerUid)
+            {
+            iClientObservers.Remove(*clientObserver);
+	    delete clientObserver;
+            break;
+            }
+        }
+    
+    if(iClientObservers.IsEmpty())
+        {
+        delete iTriggerEventsWatcher;
+        iTriggerEventsWatcher = NULL;
+        }
+    
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
 // CRemConTspController::GetCorrectClientL
 // Defines remote targets to which command will be sent.
 // (other items were commented in a header).
@@ -405,10 +657,12 @@
 void CRemConTspController::GetCorrectClientL(
     TUid aInterfaceUid,
 	TUint aKeyEvent,
-	TSglQue<TClientInfo>& aClients )
+	TSglQue<TClientInfo>& aClients,
+	TBool aLaunchingNewApplicationAllowed)
 	{
 	COM_TRACE_1( "[REMCONTSPCONTROLLER] CRemConTspController::GetCorrectClientL() Start aInterfaceUid %d", aInterfaceUid );
 	COM_TRACE_1( "[REMCONTSPCONTROLLER] CRemConTspController::GetCorrectClientL() Start aKeyEvent %d", aKeyEvent );
+
     TInt numOfTables = iArrayOfTables.Count();
     RArray<TInt> rulesArray;
     CleanupClosePushL( rulesArray );
@@ -513,6 +767,7 @@
             	    TProcessId processId = target->ProcessId();
             	    if( iProcessIdForeground == processId )
             	        {
+                        COM_TRACE_( "[REMCONTSPCONTROLLER] CRemConTspController::GetCorrectClientL() Foreground client found" );
             	        aClients.Reset();
             	        aClients.AddFirst( *target );
             	        found = ETrue;
@@ -613,7 +868,7 @@
             case CRemConEventTable::ELaunchDefaultApp:
                 {
                 COM_TRACE_( "[REMCONTSPCONTROLLER] CRemConTspController::GetCorrectClientL() Launch default application" );                
-                if ( !DeviceLocked() )
+                if ( !DeviceLocked() && aLaunchingNewApplicationAllowed )
                     {
                     TUid defaultLaunchAppUid;
                     
@@ -648,6 +903,9 @@
         else if( rulesArray.Count() - 1 == i )
             {
             COM_TRACE_( "[REMCONTSPCONTROLLER] CRemConTspController::GetCorrectClientL() No client found");
+            // Reset the list to reflect the fact that no clients were found. 
+            // The possible transparent clients will be added still. 
+            aClients.Reset();
             }
         }
 
@@ -657,7 +915,8 @@
         TClientInfo* target = transparentClients[ i ];
         if ( !FindRemconConnection( target->SecureId(), aClients ) ) // Add client only if not already found
             {
-            aClients.AddFirst( *target );
+            // Add to the end of the list, any other client should take priority over the transparent clients. 
+            aClients.AddLast( *target );  
             COM_TRACE_1( "[REMCONTSPCONTROLLER] CRemConTspController::GetCorrectClientL() transparent client 0x%x added", target->SecureId().iId );
             }
         }
@@ -1059,6 +1318,40 @@
     }
 
 // -----------------------------------------------------------------------------
+// CRemConTspController::MtrtoEvaluateRoutingRules
+// Evaluates the TSP's routing rules to determine if the local addressed player
+// has changed, and if so informs interested bearers
+// -----------------------------------------------------------------------------
+void CRemConTspController::MtrtoEvaluateRoutingRules()
+    {
+    COM_TRACE_( "[REMCONTSPCONTROLLER] CRemConTspController::MtrtoEvaluateRoutingRules() - Enter" ); 
+    TClientInfo* localAddressedClient = GetLocalAddressedClient();
+
+    if(!localAddressedClient)
+        {
+        // If there's no suitable client, then there's nothing to do here.   
+        COM_TRACE_( "[REMCONTSPCONTROLLER] CRemConTspController::MtrtoEvaluateRoutingRules() No local addressed client found" ); 
+        return; 
+        }
+
+    if(!iLocalAddressedClient || (localAddressedClient->SecureId() != iLocalAddressedClient->SecureId()))
+        {
+        // Local addressed player has changed (or wasn't set before).  
+        iLocalAddressedClient = localAddressedClient;
+        COM_TRACE_( "[REMCONTSPCONTROLLER] CRemConTspController::MtrtoEvaluateRoutingRules() Local addressed client has changed" ); 
+        TSglQueIter<TClientObserver> iter(iClientObservers);
+        TClientObserver* clientObserver;
+        while((clientObserver = iter++) != NULL)
+            {
+            COM_TRACE_( "[REMCONTSPCONTROLLER] CRemConTspController::MtrtoEvaluateRoutingRules() - informing observer" ); 
+            Observer().SetLocalAddressedClient(clientObserver->iBearerUid, *iLocalAddressedClient);
+            }
+        }
+    COM_TRACE_1( "[REMCONTSPCONTROLLER] CRemConTspController::MtrtoEvaluateRoutingRules() Local addressed client SID = 0x%x",  iLocalAddressedClient->SecureId().iId);
+    COM_TRACE_( "[REMCONTSPCONTROLLER] CRemConTspController::MtrtoEvaluateRoutingRules() - Return" ); 
+    }
+
+// -----------------------------------------------------------------------------
 // CRemConTspController::CreateAfterIdleL
 // Define the contexts when idle state has been loaded.
 // (other items were commented in a header).
@@ -1247,6 +1540,8 @@
             CApaCommandLine* apaCommandLine = CApaCommandLine::NewLC();
             apaCommandLine->SetExecutableNameL( appInfo.iFullName );
             apaCommandLine->SetCommandL( EApaCommandRun );            
+            _LIT8(Kparam, "play");
+            apaCommandLine->SetTailEndL( Kparam );
             apaLsSession.StartApp( *apaCommandLine );
             CleanupStack::PopAndDestroy( apaCommandLine );
             }
@@ -1485,4 +1780,50 @@
     return EFalse;
     }
 
+//----------------------------------------------------------------------------------
+// CRemConTspController::GetLocalAddressedClient
+// Uses TSP rules to determine what local addressed client should be.
+//-----------------------------------------------------------------------------------
+TClientInfo* CRemConTspController::GetLocalAddressedClient()
+    {
+    COM_TRACE_( "[REMCONTSPCONTROLLER] CRemConTspController::GetLocalAddressedClient() Entry");
+    // Create list of available clients to allow re-use of existing rule 
+    // evaluation function, GetCorrectClientL
+    iTargetsForAddressing.Reset();
+    TSglQueIter<TClientInfo> iter(iAvailableTargets);
+    TClientInfo* clientInfo;
+    while((clientInfo = iter++) != NULL)
+        {
+        iTargetsForAddressing.AddLast(*clientInfo);
+        }
+    
+#ifdef _DEBUG   
+    TraceRemconTargets( iTargetsForAddressing );
+#endif
+    
+    TRAPD(err, GetCorrectClientL(TUid::Uid(KRemConCoreApiUid), ERemConCoreApiPlay, iTargetsForAddressing, EFalse));
+    if(iTargetsForAddressing.IsEmpty() || err)
+        {
+        clientInfo = NULL;
+        COM_TRACE_( "[REMCONTSPCONTROLLER] CRemConTspController::GetLocalAddressedClient() No target Found");
+        }
+    else
+        {
+        // We don't want to set the phone application or voice command handler as local addressed client. 
+        // So choose the first item that is neither of those. The clientInfo may be NULL in the end. 
+        TSglQueIter<TClientInfo> localAddressedIter(iTargetsForAddressing);
+        while((clientInfo = localAddressedIter++) != NULL)
+            {
+            if( clientInfo->SecureId() != TSecureId(KUid3PhoneApp) || 
+                clientInfo->SecureId() != TSecureId(KUid3VoiceCmdApp) )
+                {
+                COM_TRACE_1( "[REMCONTSPCONTROLLER] CRemConTspController::GetLocalAddressedClient() Local addressed client SID = %08x",  clientInfo->SecureId().iId);
+                break;
+                }
+            }
+        }
+
+    return clientInfo;
+    }
+
 // End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/coreapplicationuis/advancedtspcontroller/src/tsptriggerevents.cpp	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,212 @@
+/*
+* Copyright (c) 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Observes changes in the default player that should be used for a bearer
+*/
+
+#include <AudioClientsListPSKeys.h>
+#include "tsptriggerevents.h"
+#include "RemConDebug.h"
+//-----------------------------------------------------------------------
+// CTspTriggerEventsWatcher
+//-----------------------------------------------------------------------
+CTspTriggerEventsWatcher* CTspTriggerEventsWatcher::NewL(MTspRulesTriggerObserver& aObserver)
+    {
+    CTspTriggerEventsWatcher* self = new(ELeave)CTspTriggerEventsWatcher(aObserver);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+CTspTriggerEventsWatcher::CTspTriggerEventsWatcher(MTspRulesTriggerObserver& aObserver)
+    : iObserver(aObserver)
+    {
+    }
+
+void CTspTriggerEventsWatcher::ConstructL()
+    {
+    // Create WServ event watcher
+    iWsEventsObserver = CWsEventsObserver::NewL(iObserver);
+    
+    // Create observer for audio routing
+    iAudioClientObserver = CActiveAudioClientObserver::NewL(iObserver);
+    
+    // Create observer for TSP client mapper
+    iClientMapperObserver = CTspClientMapperObserver::NewL(iObserver);
+    }
+
+CTspTriggerEventsWatcher::~CTspTriggerEventsWatcher()
+    {
+    delete iAudioClientObserver;
+    delete iWsEventsObserver;
+    delete iClientMapperObserver;
+    }
+
+//-----------------------------------------------------------------------
+// CWsEventsObserver
+//-----------------------------------------------------------------------
+CWsEventsObserver* CWsEventsObserver::NewL(MTspRulesTriggerObserver& aObserver)
+    {
+    CWsEventsObserver* self = new(ELeave)CWsEventsObserver(aObserver);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+CWsEventsObserver::~CWsEventsObserver()
+    {
+    Cancel(); 
+    iWindowGroup.Close(); 
+    iWsSession.Close();
+    }
+
+CWsEventsObserver::CWsEventsObserver(MTspRulesTriggerObserver& aObserver)
+    : CActive(CActive::EPriorityStandard), iObserver(aObserver), iWsSession(), iWindowGroup(iWsSession)
+    {
+    }
+
+void CWsEventsObserver::ConstructL()
+    {
+    // Register to recieve WServ events
+    CActiveScheduler::Add(this);    
+    User::LeaveIfError(iWsSession.Connect());
+    iWindowGroup = RWindowGroup(iWsSession); 
+    User::LeaveIfError(iWindowGroup.Construct(reinterpret_cast<TUint32>(this), EFalse));
+    iWindowGroup.SetOrdinalPosition(-1); 
+    iWindowGroup.DefaultOwningWindow(); 
+    iWindowGroup.EnableReceiptOfFocus(EFalse);    
+    iWindowGroup.EnableGroupListChangeEvents(); // For changes in z-order 
+    iWsSession.EventReady(&iStatus);
+    SetActive(); 
+    }
+
+
+void CWsEventsObserver::RunL()
+    {
+    COM_TRACE_( "[REMCONTSPCONTROLLER] CWsEventsObserver::RunL" );
+    TWsEvent event;
+    iWsSession.GetEvent(event);
+    iWsSession.EventReady(&iStatus);
+    SetActive(); 
+    if(event.Type() == EEventWindowGroupListChanged)
+        {
+        COM_TRACE_( "[REMCONTSPCONTROLLER] CWsEventsObserver::RunL - EEventWindowGroupListChanged" );
+        iObserver.MtrtoEvaluateRoutingRules();
+        }
+    }
+
+void CWsEventsObserver::DoCancel()
+    {
+    iWsSession.EventReadyCancel();
+    }
+
+//-----------------------------------------------------------------------
+// CActiveAudioClientObserver
+//-----------------------------------------------------------------------
+CActiveAudioClientObserver* CActiveAudioClientObserver::NewL(MTspRulesTriggerObserver& aObserver)
+    {
+    CActiveAudioClientObserver* self = new(ELeave)CActiveAudioClientObserver(aObserver);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+CActiveAudioClientObserver::~CActiveAudioClientObserver()
+    {
+    Cancel(); 
+    iAudioApplication.Close();
+    }
+
+CActiveAudioClientObserver::CActiveAudioClientObserver(MTspRulesTriggerObserver& aObserver)
+    : CActive(CActive::EPriorityStandard), iObserver(aObserver)
+    {
+    }
+
+void CActiveAudioClientObserver::ConstructL()
+    {
+    User::LeaveIfError(iAudioApplication.Attach(KPSUidMMFAudioServer, KAudioPolicyApplicationAudioStatePlaying));
+    CActiveScheduler::Add(this);    
+    iAudioApplication.Subscribe(iStatus);
+    SetActive(); 
+    }
+
+
+void CActiveAudioClientObserver::RunL()
+    {
+    // Doesn't matter what the value is - that'll be checked when evaluation
+    // the TSP target rules.  Inform the TSP of the value change and 
+    // re-subscribe.
+    COM_TRACE_( "[REMCONTSPCONTROLLER] CWsEventsObserver::RunL" );
+    iAudioApplication.Subscribe(iStatus);
+    SetActive(); 
+    iObserver.MtrtoEvaluateRoutingRules();
+    }
+
+void CActiveAudioClientObserver::DoCancel()
+    {
+    iAudioApplication.Cancel();
+    }
+
+//-----------------------------------------------------------------------
+// CTspClientMapperObserver
+//-----------------------------------------------------------------------
+CTspClientMapperObserver* CTspClientMapperObserver::NewL(MTspRulesTriggerObserver& aObserver)
+    {
+    CTspClientMapperObserver* self = new(ELeave)CTspClientMapperObserver(aObserver);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+CTspClientMapperObserver::~CTspClientMapperObserver()
+    {
+    Cancel(); 
+    }
+
+CTspClientMapperObserver::CTspClientMapperObserver(MTspRulesTriggerObserver& aObserver)
+    : CActive(CActive::EPriorityStandard), iObserver(aObserver)
+    {
+    }
+
+void CTspClientMapperObserver::ConstructL()
+    {
+    const TUid KTspClientMapperProperty = { 0x10200C70 };
+    const TUint32 KTspClientMapperKeyPlaying = 0x00000001;
+    User::LeaveIfError(iPlayingClients.Attach(KTspClientMapperProperty, KTspClientMapperKeyPlaying));
+    CActiveScheduler::Add(this);    
+    iPlayingClients.Subscribe(iStatus);
+    SetActive(); 
+    }
+
+
+void CTspClientMapperObserver::RunL()
+    {
+    // Doesn't matter what the value is - that'll be checked when evaluating
+    // the TSP target rules.  Inform the TSP of the value change and 
+    // re-subscribe.
+    COM_TRACE_( "[REMCONTSPCONTROLLER] CWsEventsObserver::RunL" );
+    iPlayingClients.Subscribe(iStatus);
+    SetActive(); 
+    iObserver.MtrtoEvaluateRoutingRules();
+    }
+
+void CTspClientMapperObserver::DoCancel()
+    {
+    iPlayingClients.Cancel();
+    }
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/coreapplicationuis/devicepowermenuplugin/devicepowermenuplugin.pro	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,63 @@
+#
+#############################################################################
+##
+## Copyright (c) 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"
+## which accompanies this distribution, and is available
+## at the URL "http://www.eclipse.org/legal/epl-v10.html".
+##
+## Initial Contributors:
+## Nokia Corporation - initial contribution.
+##
+## Contributors:
+##
+## Description:
+##
+#############################################################################
+#
+
+TEMPLATE = lib
+TARGET = DevicePowerMenuPlugin
+CONFIG += hb plugin
+
+INCLUDEPATH += $$MW_LAYER_SYSTEMINCLUDE	
+
+# Input
+HEADERS += 	.\inc\hbdevicepowermenuplugin_p.h 	\
+			.\inc\hbdevicepowermenupluginerrors_p.h 	\
+			.\inc\hbdevicepowermenuwidegt_p.h	
+
+			
+SOURCES += 	.\src\hbdevicepowermenuplugin.cpp \
+			.\src\hbdevicepowermenuwidegt.cpp
+			
+RESOURCES += hbdevicepowermenu.qrc
+
+MOC_DIR = ./tmp
+
+TRANSLATIONS	+=	power_menu.ts
+
+symbian:
+{
+TARGET.UID3 = 0x2002F375
+TARGET.CAPABILITY = ALL -TCB
+TARGET.EPOCALLOWDLLDATA = 1
+
+pluginstub.sources = DevicePowerMenuPlugin.dll
+pluginstub.path = /resource/plugins/devicedialogs
+DEPLOYMENT += pluginstub
+}
+
+symbian:
+{ 
+BLD_INF_RULES.prj_exports += \
+  "$${LITERAL_HASH}include <platform_paths.hrh>" \
+  "qmakepluginstubs/DevicePowerMenuPlugin.qtplugin   		/epoc32/data/z/pluginstub/DevicePowerMenuPlugin.qtplugin" \
+  ".\rom\devicepowermenuplugin.iby             				CORE_MW_LAYER_IBY_EXPORT_PATH(devicepowermenuplugin.iby)" \
+  ".\rom\devicepowermenu_resources.iby 						LANGUAGE_APP_LAYER_IBY_EXPORT_PATH(devicepowermenu_resources.iby)"
+}
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/coreapplicationuis/devicepowermenuplugin/docml/powermenu.docml	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,74 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<hbdocument context="pwr_grid" version="1.1">
+    <widget name="maindialog" type="HbDialog">
+        <point name="pos" x="1.19403un" y="0.44776un"/>
+        <widget name="container_1" role="HbDialog:contentWidget" type="HbWidget">
+            <widget name="Silence" type="HbPushButton">
+                <real name="z" value="2"/>
+                <string locid="txt_pm_button_silence" name="text" value="Silence"/>
+                <bool name="visible" value="TRUE"/>
+                <string name="state" value="normal"/>
+                <sizepolicy horizontalPolicy="MinimumExpanding" />
+            </widget>
+            <widget name="label" type="HbLabel">
+                <real name="z" value="4"/>
+                <string locid="txt_pm_setlabel_ringing_volume" name="plainText" value="Ringing volume"/>
+                <sizepolicy horizontalPolicy="MinimumExpanding" />
+            </widget>
+            <widget name="Volume" type="HbSlider">
+                <integer name="majorTickInterval" value="5"/>
+                <real name="z" value="3"/>
+                <enums name="orientation" value="Horizontal"/>
+                <integer name="minorTickInterval" value="2"/>
+                <integer name="value" value="30"/>
+                <sizepolicy horizontalPolicy="MinimumExpanding" />
+            </widget>
+            <widget name="Vibrate" type="HbCheckBox">
+                <string locid="txt_pm_list_vibrate" name="text" value="Vibrate"/>
+                <sizepolicy horizontalPolicy="MinimumExpanding" />
+            </widget>
+            <widget name="Offline" type="HbCheckBox">
+                <string locid="txt_pm_list_offline_airplane_mode" name="text" value="Offline (Airplane Mode)"/>
+                <sizepolicy horizontalPolicy="MinimumExpanding" />
+            </widget>
+            <widget name="PowerOff" type="HbPushButton">
+                <string locid="txt_pm_button_power_off" name="text" value="Power Off"/>
+                <string name="state" value="normal"/>
+                <sizepolicy horizontalPolicy="MinimumExpanding" />
+            </widget>
+            <real name="z" value="0"/>
+            <layout type="anchor">
+                <anchoritem dst="" dstEdge="LEFT" spacing="-0un" src="Silence" srcEdge="LEFT"/>
+                <anchoritem dst="" dstEdge="RIGHT" spacing="0un" src="Silence" srcEdge="RIGHT"/>
+                <anchoritem dst="" dstEdge="TOP" spacing="0un" src="Silence" srcEdge="TOP"/>
+                
+                <anchoritem dst="" dstEdge="LEFT" spacing="-0un" src="label" srcEdge="LEFT"/>
+                <anchoritem dst="" dstEdge="RIGHT" spacing="0un" src="label" srcEdge="RIGHT"/>
+                <anchoritem dst="Silence" dstEdge="BOTTOM" spacing="-1un" src="label" srcEdge="TOP"/>
+
+
+                <anchoritem dst="" dstEdge="LEFT" spacing="-0un" src="Volume" srcEdge="LEFT"/>
+                <anchoritem dst="" dstEdge="RIGHT" spacing="0un" src="Volume" srcEdge="RIGHT"/>
+                <anchoritem dst="label" dstEdge="BOTTOM" spacing="-1un" src="Volume" srcEdge="TOP"/>
+
+                <anchoritem dst="" dstEdge="LEFT" spacing="-0un" src="Vibrate" srcEdge="LEFT"/>
+                <anchoritem dst="" dstEdge="RIGHT" spacing="0un" src="Vibrate" srcEdge="RIGHT"/>
+                <anchoritem dst="Volume" dstEdge="BOTTOM" spacing="-0un" src="Vibrate" srcEdge="TOP"/>
+
+                <anchoritem dst="" dstEdge="LEFT" spacing="-0un" src="Offline" srcEdge="LEFT"/>
+                <anchoritem dst="" dstEdge="RIGHT" spacing="0un" src="Offline" srcEdge="RIGHT"/>
+                <anchoritem dst="Vibrate" dstEdge="BOTTOM" spacing="-0un" src="Offline" srcEdge="TOP"/>
+
+                <anchoritem dst="" dstEdge="LEFT" spacing="-0un" src="PowerOff" srcEdge="LEFT"/>
+                <anchoritem dst="" dstEdge="RIGHT" spacing="0un" src="PowerOff" srcEdge="RIGHT"/>
+                <anchoritem dst="Offline" dstEdge="BOTTOM" spacing="-1un" src="PowerOff" srcEdge="TOP"/>
+
+                <anchoritem dst="" dstEdge="BOTTOM" spacing="0un" src="PowerOff" srcEdge="BOTTOM"/>
+                                
+            </layout>
+        </widget>
+    </widget>
+    <metadata activeUIState="Common ui state" display="NHD-3.2-inch_portrait" unit="un">
+        <uistate name="Common ui state" sections="#common"/>
+    </metadata>
+</hbdocument>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/coreapplicationuis/devicepowermenuplugin/hbdevicepowermenu.qrc	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,11 @@
+<RCC>
+    <qresource prefix="/xml" >
+        <file alias="powermenu.docml" >docml/powermenu.docml</file>
+    </qresource>
+    <qresource prefix="/images" >
+        <file alias="decrement.svg" >images/decrement.svg</file>
+        <file alias="increment.svg" >images/increment.svg</file>
+        <file alias="muted.svg" >images/muted.svg</file>
+        <file alias="unmuted.svg" >images/unmuted.svg</file>
+    </qresource>
+</RCC>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/coreapplicationuis/devicepowermenuplugin/images/decrement.svg	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1 Tiny//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11-tiny.dtd">
+<svg baseProfile="tiny" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
+<polygon points="33.999,26 10,26 10,17.998 33.999,17.998 "/>
+<rect fill="#FFFFFF" height="4" width="20" x="12" y="20"/>
+</svg>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/coreapplicationuis/devicepowermenuplugin/images/increment.svg	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1 Tiny//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11-tiny.dtd">
+<svg baseProfile="tiny" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
+<polygon points="26.001,33.999 18,33.999 18,26.001 10,26.001 10,18 18,18 18,9.999 26.001,9.999 26.001,18 33.999,18   33.999,26.001 26.001,26.001 "/>
+<polygon fill="#FFFFFF" points="31.999,20 23.999,20 23.999,12 20,12 20,20 12,20 12,23.999 20,23.999 20,31.999 23.999,31.999   23.999,23.999 31.999,23.999 "/>
+</svg>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/coreapplicationuis/devicepowermenuplugin/images/muted.svg	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1 Tiny//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11-tiny.dtd">
+<svg baseProfile="tiny" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
+<path d="M25.824,21.015V8.411h-9.979l-1.025,1.6L8.354,3.545L3.651,8.242l6.797,6.795H4.931v15.818h6.671l4.24,6.625h9.982v-7.067  l7.902,7.905l4.697-4.703L25.824,21.015z M19.179,30.336L15.26,24.21h-3.682v-2.524h3.682l0.715-1.121l3.204,3.203V30.336z"/>
+<rect fill="#FFFFFF" height="2.648" transform="matrix(-0.7071 -0.7071 0.7071 -0.7071 21.1169 50.6082)" width="38.533" x="1.773" y="19.607"/>
+<polygon fill="#FFFFFF" points="21.179,32.835 18.403,32.835 14.166,26.209 9.578,26.209 9.578,19.685 14.166,19.685 14.463,19.219   12.279,17.037 6.931,17.037 6.931,28.855 12.695,28.855 16.937,35.48 23.824,35.48 23.824,28.579 21.179,25.936 "/>
+<polygon fill="#FFFFFF" points="18.403,13.06 21.179,13.06 21.179,16.202 23.824,18.847 23.824,10.412 16.937,10.412 16.332,11.355   18.259,13.284 "/>
+</svg>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/coreapplicationuis/devicepowermenuplugin/images/unmuted.svg	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1 Tiny//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11-tiny.dtd">
+<svg baseProfile="tiny" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
+<path d="M34.951,38.12l-5.054-4.302l1.282-1.521c0.877-1.04,8.324-10.39,0.111-18.605l-1.414-1.413l4.697-4.701l1.413,1.415  c12.695,12.699,0.386,27.46,0.259,27.606L34.951,38.12L34.951,38.12z"/>
+<path d="M30.761,14.545l-1.414-1.412l-3.521,3.521V8.411h-9.981l-4.24,6.624H4.93v15.82h6.674l4.24,6.625h9.981v-8.201l3.855,3.287  l1.298-1.521C33.574,28.005,36.864,20.643,30.761,14.545z M19.18,30.335l-3.921-6.128h-3.682v-2.522h3.682l3.921-6.128V30.335z   M25.918,26.742l-0.094,0.109v-7.844l0.237,0.236C29.324,22.505,26.277,26.318,25.918,26.742z"/>
+<path d="M27.476,17.83c4.622,4.622,0.158,9.979-0.031,10.203l2.014,1.714c2.181-2.554,4.957-8.725-0.11-13.788  L27.476,17.83z" fill="#FFFFFF"/>
+<path d="M34.576,10.406l-1.873,1.871c9.664,9.663,0.404,20.838,0.006,21.309l2.017,1.717  C34.838,35.17,45.974,21.811,34.576,10.406z" fill="#FFFFFF"/>
+<path d="M16.937,10.411l-4.242,6.625H6.931v11.819h5.764l4.242,6.625h6.887V10.411H16.937z M21.179,32.834h-2.776  l-4.237-6.626H9.578v-6.524h4.588l4.237-6.625h2.776V32.834z" fill="#FFFFFF"/>
+</svg>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/coreapplicationuis/devicepowermenuplugin/inc/hbdevicepowermenuplugin_p.h	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 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"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ *
+ */
+
+#ifndef HBDEVICEPOWERMENUPLUGIN_P_H
+#define HBDEVICEPOWERMENUPLUGIN_P_H
+
+#include <QObject>
+#include <QVariantMap>
+
+#include <hbdevicedialogplugin.h>
+
+//fwd Declaration
+class HbDevicePowerMenuPluginPrivate;
+
+class HbDevicePowerMenuPlugin : public HbDeviceDialogPlugin
+{
+    Q_OBJECT
+
+public:
+    friend class HbDevicePowerMenuPluginPrivate;
+
+    HbDevicePowerMenuPlugin();
+    ~HbDevicePowerMenuPlugin();
+
+    //Pure Virtual method of class HbDeviceDialogPluginInterface
+    HbDeviceDialogInterface *createDeviceDialog(const QString &deviceDialogType, const QVariantMap &parameters);
+    //Pure Virtual Mehods of class HbDeviceDialogPlugin
+    bool accessAllowed(const QString &deviceDialogType, const QVariantMap &parameters, const QVariantMap &securityInfo) const;
+    bool deviceDialogInfo(const QString &deviceDialogType, const QVariantMap &parameters, DeviceDialogInfo *info) const;
+    QStringList deviceDialogTypes() const;
+    PluginFlags pluginFlags() const;
+    int error() const;
+
+private:
+    Q_DISABLE_COPY(HbDevicePowerMenuPlugin)
+    HbDevicePowerMenuPluginPrivate *d;
+};
+
+#endif // HBDEVICEPOWERMENUPLUGIN_P_H
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/coreapplicationuis/devicepowermenuplugin/inc/hbdevicepowermenupluginerrors_p.h	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 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"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ *
+ */
+
+#ifndef HBDEVICEPOWERMENUPLUGINERRORS_P_H
+#define HBDEVICEPOWERMENUPLUGINERRORS_P_H
+
+#include <hbdevicedialog.h>
+#include <e32debug.h>
+#ifdef _DEBUG
+
+    #define TRACES( x ) x
+
+#else
+
+    #define TRACES( x )
+
+#endif
+
+
+// No error
+const int NoError = 0;
+// Illegal parameter error
+const int ParameterError = HbDeviceDialog::PluginErrors + 1;
+// Unknown device dialog error
+const int UnknownDeviceDialogError = HbDeviceDialog::PluginErrors + 2;
+
+#endif // HBDEVICEPOWERMENUPLUGINERRORS_P_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/coreapplicationuis/devicepowermenuplugin/inc/hbdevicepowermenuwidegt_p.h	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,95 @@
+/*
+ * Copyright (c) 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"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ *
+ */
+
+#ifndef HBDEVICEPOWERMENUWIDEGT_P_H
+#define HBDEVICEPOWERMENUWIDEGT_P_H
+
+
+#include <QObject>
+#include <QVariantMap>
+#include <hbdevicedialoginterface.h>
+#include <hbdevicedialog.h>
+#include <hbdialog.h>
+#include <hbdocumentloader.h>
+#include <HbTranslator.h>
+//For widgets used
+#include <hbpushbutton.h>
+#include <hbslider.h>
+#include <hbcheckBox.h>
+#include <hbinstance.h>
+
+class HbDevicePowerMenuWidget : public QObject, public HbDeviceDialogInterface
+{
+    Q_OBJECT
+    
+public:
+    HbDevicePowerMenuWidget(const QVariantMap &parameters);
+    ~HbDevicePowerMenuWidget();
+
+public:    
+	//HbDeviceDialogInterface methods to be implemented
+    bool setDeviceDialogParameters(const QVariantMap &parameters);
+    int deviceDialogError() const;
+    void closeDeviceDialog(bool byClient);
+    HbPopup *deviceDialogWidget() const;
+    virtual QObject *signalSender() const;
+    
+
+private:    
+    bool preConstructDialog();
+    void constructDialog(const QVariantMap &parameters);
+    void cleanupMemory();
+    
+private:
+    void customizeVolumeSlider();
+    void setSpeakerIcon();
+    bool IsValidHandles();
+
+private slots:    
+    void handleVolumeChanged(int aVolume);
+    void handleSilenceMode(bool aState);
+    void handleVibrationToggled(int aVibrationToggel);
+    void handleOfflineToggled(int aOfflineToggel);
+    void handlePowerOff(bool aState);
+    void closedialog();
+    
+signals:
+    void deviceDialogClosed();
+    void deviceDialogData(QVariantMap data);
+
+private:
+    Q_DISABLE_COPY(HbDevicePowerMenuWidget)
+
+    int 				mDeviceDialogError;             //DeviceDialogError
+    int                 mVolumeLevel;                   //shows current Volume Level
+    bool 				mShowVolume;                   //used to Enable or Disbale Volume                   
+    bool 				mVibrationChecked;             //Vibration enabled or Disabled
+    bool 				mOfflineChecked;               //offline enabled or Disabled
+    bool				mSilencelatched;                //SilenceMode Enabled or Disabled 
+    bool				mCypherOff;                     //Shows Encryption/Decryption ON/OFF
+    
+    HbDialog*			mDialogWidget;                  //Handle for Powermenu Dialog
+    HbPushButton*		mSilenceButton;                  //Handle for Silence button
+    HbSlider*			mVolumeSlider;                  //Handle for Slider
+    HbCheckBox*			mVibarte;                         //Handle for Vibration check Box
+    HbCheckBox*			mOffline;                         //Handle for Offline CheckBox
+    HbPushButton *		mPowerOffButton;                //Handle for PowerOff Button
+    HbDocumentLoader* 	mLoader;                         //Hnadle for Documnet Loader to load docml 
+    HbTranslator*       mHbTranslator;                  //Translator used for localization; loads translation files
+};
+
+#endif // HBDEVICEPOWERMENUWIDEGT_P_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/coreapplicationuis/devicepowermenuplugin/rom/devicepowermenu_resources.iby	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 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"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ *
+ */
+ 
+#ifndef __DEVICEPOWERMENU_RESOURCES_IBY__
+#define __DEVICEPOWERMENU_RESOURCES_IBY__
+
+//this iby is required for language specific things to be exported to Language iby layer
+#include <data_caging_paths_for_iby.hrh>
+
+data=DATAZ_\QT_TRANSLATIONS_DIR\power_menu.qm	QT_TRANSLATIONS_DIR\power_menu.qm
+
+
+#endif //__DEVICEPOWERMENU_RESOURCES_IBY__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/coreapplicationuis/devicepowermenuplugin/rom/devicepowermenuplugin.iby	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) 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"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ *
+ */
+ 
+#ifndef __DEVICEPOWERMENUPLUGIN_IBY__
+#define __DEVICEPOWERMENUPLUGIN_IBY__
+
+file = \epoc32\release\armv5\urel\DevicePowerMenuPlugin.dll  \sys\bin\DevicePowerMenuPlugin.dll UNPAGED
+data=\epoc32\data\z\pluginstub\DevicePowerMenuPlugin.qtplugin \resource\plugins\devicedialogs\DevicePowerMenuPlugin.qtplugin
+
+#endif //__DEVICEPOWERMENUPLUGIN_IBY__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/coreapplicationuis/devicepowermenuplugin/src/hbdevicepowermenuplugin.cpp	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,166 @@
+/*
+ * Copyright (c) 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"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ *
+ */
+
+//System includes
+#include <QtPlugin>
+#include <hbdevicedialog.h>
+
+//user includes
+#include "hbdevicepowermenuplugin_p.h"
+#include "hbdevicepowermenuwidegt_p.h"
+#include "hbdevicepowermenupluginerrors_p.h"
+
+//SysAp's Secure UID
+const quint32 KSecureUid = 0x100058F3;
+
+Q_EXPORT_PLUGIN2(devicepowermenuplugin, HbDevicePowerMenuPlugin)
+
+// This plugin implements a device dialog type
+static const struct 
+	{
+    const char *mTypeString;
+	} dialogInfos[] = {{"com.nokia.hb.devicepowermenu/1.0"}};
+
+class HbDevicePowerMenuPluginPrivate
+	{
+public:
+    HbDevicePowerMenuPluginPrivate() {mError = NoError;}
+    int mError;
+	};
+
+/**
+ * Constructor
+ */
+HbDevicePowerMenuPlugin::HbDevicePowerMenuPlugin()
+	{
+    TRACES( RDebug::Print( _L("HbDevicePowerMenuPlugin::Constructor:Begin") ) );
+    d = new HbDevicePowerMenuPluginPrivate;
+    TRACES( RDebug::Print( _L("HbDevicePowerMenuPlugin::Constructor:End") ) );
+	}
+
+/**
+ * Destructor
+ */
+HbDevicePowerMenuPlugin::~HbDevicePowerMenuPlugin()
+	{
+	TRACES( RDebug::Print( _L("HbDevicePowerMenuPlugin::Destructor:Begin") ) );
+    delete d;
+    TRACES( RDebug::Print( _L("HbDevicePowerMenuPlugin::Destructor:End") ) );
+	}
+
+/**
+ * This method is Pure Virtual in HbDeviceDialogPlugin 
+ * Checks if client is allowed to use device dialog widget
+ * Its a customized widget for Sysap, and allows only Sysap to use this plugin
+ */
+bool HbDevicePowerMenuPlugin::accessAllowed(const QString &deviceDialogType, const QVariantMap &parameters, const QVariantMap &securityInfo) const
+    {
+	TRACES( RDebug::Print( _L("HbDevicePowerMenuPlugin::accessAllowed:Begin") ) );
+    Q_UNUSED(deviceDialogType)
+    Q_UNUSED(parameters)
+    TBool secured(false);
+    quint32 secUid = static_cast<quint32>(securityInfo.value("sym-secureId").toInt());
+    if (secUid == KSecureUid )
+	    {
+        secured = true;
+	    }
+    TRACES( RDebug::Print( _L("HbDevicePowerMenuPlugin::accessAllowed:End") ) );
+    return secured;
+    }
+
+/**
+ * Creates device dialog widget
+ */
+HbDeviceDialogInterface *HbDevicePowerMenuPlugin::createDeviceDialog(const QString &deviceDialogType, const QVariantMap &parameters)
+	{
+	TRACES( RDebug::Print( _L("HbDevicePowerMenuPlugin::createDeviceDialog:Begin") ) );
+    d->mError = NoError;
+
+    HbDeviceDialogInterface *ret(NULL);
+    if (dialogInfos[0].mTypeString == deviceDialogType) 
+		{
+		 QVariantMap params = parameters;
+		 HbDevicePowerMenuWidget *powMenu = new HbDevicePowerMenuWidget(params);
+		 d->mError = powMenu->deviceDialogError();
+		 if (d->mError != NoError) 
+			 {
+			 delete powMenu;
+			 powMenu = NULL;
+			 }
+		 ret = powMenu;
+		} 
+    else 
+		{
+		 d->mError = UnknownDeviceDialogError;
+		 ret = NULL;
+		}
+    TRACES( RDebug::Print( _L("HbDevicePowerMenuPlugin::createDeviceDialog:End") ) );
+    return ret;
+	}
+
+/**
+ * Return information of device dialog the plugin creates
+ */
+bool HbDevicePowerMenuPlugin::deviceDialogInfo(const QString &deviceDialogType, const QVariantMap &parameters, DeviceDialogInfo *info) const
+	{
+	TRACES( RDebug::Print( _L("HbDevicePowerMenuPlugin::deviceDialogInfo:Begin") ) );
+    Q_UNUSED(parameters)
+    Q_UNUSED(deviceDialogType)
+
+    info->group = GenericDeviceDialogGroup;
+    info->flags = SecurityCheck;
+    info->priority = DefaultPriority;
+    TRACES( RDebug::Print( _L("HbDevicePowerMenuPlugin::deviceDialogInfo:End") ) );
+    return true;
+	}
+
+/**
+ * Return device dialog types this plugin implements
+ */
+QStringList HbDevicePowerMenuPlugin::deviceDialogTypes() const
+	{
+	TRACES( RDebug::Print( _L("HbDevicePowerMenuPlugin::deviceDialogTypes:Begin") ) );
+	QStringList types;
+	const int numTypes = sizeof(dialogInfos) / sizeof(dialogInfos[0]);
+	for(int i = 0; i < numTypes; i++) 
+		{
+		types.append(dialogInfos[i].mTypeString);
+		}
+	TRACES( RDebug::Print( _L("HbDevicePowerMenuPlugin::deviceDialogTypes:End") ) );
+	return types;
+	}
+
+/**
+ * Return plugin flags
+ */
+HbDeviceDialogPlugin::PluginFlags HbDevicePowerMenuPlugin::pluginFlags() const
+	{
+	TRACES( RDebug::Print( _L("HbDevicePowerMenuPlugin::pluginFlags:Begin") ) );
+	TRACES( RDebug::Print( _L("HbDevicePowerMenuPlugin::pluginFlags:End") ) );
+	return NoPluginFlags;
+	}
+
+/**
+ * Return last error
+ */
+int HbDevicePowerMenuPlugin::error() const
+	{
+	TRACES( RDebug::Print( _L("HbDevicePowerMenuPlugin::error:Begin") ) );
+	TRACES( RDebug::Print( _L("HbDevicePowerMenuPlugin::error:End") ) );
+	return d->mError;
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/coreapplicationuis/devicepowermenuplugin/src/hbdevicepowermenuwidegt.cpp	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,438 @@
+/*
+ * Copyright (c) 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"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ *
+ */
+
+
+#include "hbdevicepowermenuwidegt_p.h"
+#include "hbdevicepowermenupluginerrors_p.h"
+#include <HbInstance.h>
+
+//resuorces
+QString POWER_MENU_DOCML(":/xml/powermenu.docml");
+QString VOLUME_DECREASE_ICON(":/images/decrement.svg");
+QString VOLUME_INCREASE_ICON(":/images/increment.svg");
+QString VOLUME_UNMUTE_ICON(":/images/unmuted.svg");
+QString VOLUME_MUTE_ICON(":/images/muted.svg");
+//For Localization
+QString LOCALE_PATH("/resource/qt/translations/"); 
+QString TS_FILE("power_menu");
+
+//Widget names
+QString MAIN_DLG("maindialog");
+QString PWR_SILENCE("Silence");
+QString PWR_VOLUME("Volume");
+QString PWR_VIBARTE("Vibrate");
+QString PWR_OFFLINE("Offline");
+QString PWR_POWEROFF("PowerOff");
+QString PWR_CONTAINER("container_1");
+
+//DO not modify these strings
+QString KVolumeLevel("VolumeLevel");
+QString KSilenceLatchOn("SilenceLatchOn");            //Used to latch silencebutton	
+QString KVibrationEnable("VibrationEnable");
+QString KOfflineEnable("OfflineEnable");
+QString KCypherOff("CypherOff");            //used to poweroffButtonEnabled/Disabled 		
+QString KShutDown("ShutDown");
+
+//Used for Orientation of PowerMenu
+qreal KVerticalX = 175;
+//width of PowerMenu
+qreal KPMWidth = 360;
+
+/**
+ * Constructor
+ */
+HbDevicePowerMenuWidget::HbDevicePowerMenuWidget(const QVariantMap &parameters)
+	:mDeviceDialogError(NoError), 
+	 mVolumeLevel(0),
+	 mShowVolume(false), 
+	 mVibrationChecked(true),
+	 mOfflineChecked(true),
+	 mSilencelatched(true), 
+	 mCypherOff(true),
+	 mDialogWidget(NULL),
+	 mSilenceButton(NULL),
+	 mVolumeSlider(NULL), 
+	 mVibarte(NULL),
+	 mOffline(NULL),
+	 mPowerOffButton(NULL),
+	 mLoader(NULL), 
+	 mHbTranslator(NULL)
+    {
+    // mMainWindow(NULL),
+	TRACES( RDebug::Print( _L("HbDevicePowerMenuWidget::Constructor:Begin") ) );
+    if (preConstructDialog())
+        {
+        //Translator loaded succesfully then olny construct widgets
+        constructDialog(parameters);
+        }
+    TRACES( RDebug::Print( _L("HbDevicePowerMenuWidget::Constructor:End") ) );
+    }
+    
+/**
+ * Destructor
+ */
+HbDevicePowerMenuWidget::~HbDevicePowerMenuWidget()
+    {
+    TRACES( RDebug::Print( _L("HbDevicePowerMenuWidget::Destructor()") ) );
+    cleanupMemory();
+    }
+
+/**
+ * Implementation of HbDeviceDialogInterface method
+ * sets parameters of custom widget
+ */
+bool HbDevicePowerMenuWidget::setDeviceDialogParameters(const QVariantMap &parameters)
+	{
+	TRACES( RDebug::Print( _L("HbDevicePowerMenuWidget::setDeviceDialogParameters:Begin") ) );
+ 	if(parameters.contains(KVolumeLevel))
+		{
+		mVolumeLevel = parameters.value(KVolumeLevel).toInt();
+		}
+	if(parameters.contains(KSilenceLatchOn))
+		{
+		mSilencelatched = parameters.value(KSilenceLatchOn).toBool();
+		//If SilenceMode is Enabled then MasterVolume control is Disabled 
+		mShowVolume = mSilencelatched? false:true;
+		}
+	if(parameters.contains(KVibrationEnable))
+		{
+		mVibrationChecked = parameters.value(KVibrationEnable).toBool();
+		}
+	if(parameters.contains(KOfflineEnable))
+		{
+		mOfflineChecked = parameters.value(KOfflineEnable).toBool();
+		}
+	if(parameters.contains(KCypherOff))
+		{
+		mCypherOff = parameters.value(KCypherOff).toBool();
+		}
+    TRACES( RDebug::Print( _L("HbDevicePowerMenuWidget::setDeviceDialogParameters:End") ) );
+	return true;
+	}
+
+/**
+ * Returns error code
+ */
+int HbDevicePowerMenuWidget::deviceDialogError() const
+	{
+	TRACES( RDebug::Print( _L("HbDevicePowerMenuWidget::deviceDialogError") ) );
+	return mDeviceDialogError;
+	}
+
+/**
+ * Close DeviceDialog
+ */
+void HbDevicePowerMenuWidget::closeDeviceDialog(bool byClient)
+	{
+	TRACES( RDebug::Print( _L("HbDevicePowerMenuWidget::closeDeviceDialog:Begin") ) );
+    Q_UNUSED(byClient);
+    TRACES( RDebug::Print( _L("HbDevicePowerMenuWidget::closeDeviceDialog:End") ) );
+    mDialogWidget->close();
+	}
+
+/**
+ * Implementation of HbDeviceDialogInterface method
+ */
+HbPopup* HbDevicePowerMenuWidget::deviceDialogWidget() const
+	{
+	TRACES( RDebug::Print( _L("HbDevicePowerMenuWidget::deviceDialogWidget") ) );
+	return mDialogWidget;
+	}
+
+/**
+ * Implementation of HbDeviceDialogInterface method
+ * to get signals from action events
+ */
+QObject* HbDevicePowerMenuWidget::signalSender() const
+    {
+    TRACES( RDebug::Print( _L("HbDevicePowerMenuWidget::signalSender") ) );
+    return const_cast<HbDevicePowerMenuWidget*>(this);
+    }
+
+/**
+ * Before loading docml and widgets Translator must be loaded
+ */
+bool HbDevicePowerMenuWidget::preConstructDialog()
+    {
+    TRACES( RDebug::Print( _L("HbDevicePowerMenuWidget::preConstructDialog:Begin") ) );
+    //Translator
+    mHbTranslator = new HbTranslator(LOCALE_PATH,TS_FILE);
+    if(!mHbTranslator)
+        {
+        //Translator is failed to create
+        mDeviceDialogError = UnknownDeviceDialogError;
+        TRACES( RDebug::Print( _L("HbDevicePowerMenuWidget::preConstructDialog:MemoryAllocation Failed") ) );
+        return false;
+        }
+    TRACES( RDebug::Print( _L("HbDevicePowerMenuWidget::preConstructDialog:End") ) );
+    return true;
+    }
+
+/**
+ * Constrcuts customized widget dialog by loading the UI from docml and
+ * initializes all parameters and attributes.
+ * Throws bad-memory on Un-succesful memory allocations
+ */
+void HbDevicePowerMenuWidget::constructDialog(const QVariantMap &parameters)
+	{
+	TRACES( RDebug::Print( _L("HbDevicePowerMenuWidget::constructDialog:Begin") ) );
+	bool dialogLoaded(false);
+	//Docml loader
+	mLoader = new HbDocumentLoader();
+	if(!mLoader)
+	    {
+        //Document Loader failed to create
+        mDeviceDialogError = UnknownDeviceDialogError;
+        cleanupMemory();
+        TRACES( RDebug::Print( _L("HbDevicePowerMenuWidget::constructDialog:mLoader::MemoryAllocation Failed") ) );        
+        return;
+	    }
+	mLoader->load(POWER_MENU_DOCML, &dialogLoaded);
+	Q_ASSERT_X(dialogLoaded, "HbDevicePowerMenuWidget", "Invalid xml file");
+	//Widgets
+	if (dialogLoaded)
+		{
+        //Dialog loaded succesfully from docml
+		TRACES( RDebug::Print( _L("HbDevicePowerMenuWidget::constructDialog:dialogLoaded:Begin") ) );
+        
+		//Initialize Parameters received
+        setDeviceDialogParameters(parameters);
+		mDialogWidget = qobject_cast <HbDialog *>(mLoader->findWidget(MAIN_DLG));
+		//Find the handles for all widget items
+		mSilenceButton = qobject_cast <HbPushButton *>(mLoader->findWidget(PWR_SILENCE));
+		mVolumeSlider = qobject_cast <HbSlider *>(mLoader->findWidget(PWR_VOLUME));
+		mVibarte = qobject_cast <HbCheckBox *>(mLoader->findWidget(PWR_VIBARTE));
+		mOffline = qobject_cast <HbCheckBox *>(mLoader->findWidget(PWR_OFFLINE));
+		mPowerOffButton = qobject_cast <HbPushButton *>(mLoader->findWidget(PWR_POWEROFF));	
+		QGraphicsWidget *widget(NULL);
+		widget = mLoader->findWidget(PWR_CONTAINER);
+		if (!(IsValidHandles()&&(widget)))
+		    {
+            //Atleast, One of the Handles are not allocated memory
+            mDeviceDialogError = UnknownDeviceDialogError;
+            cleanupMemory();
+            TRACES( RDebug::Print( _L("HbDevicePowerMenuWidget::constructDialog:Widgets::MemoryAllocation Failed") ) );            
+            return;
+		    }
+		//Sets Speaker icon
+        setSpeakerIcon();
+		//Customize slider to VolumeSlider
+		customizeVolumeSlider();
+		mDialogWidget->setContentWidget(widget);
+		//SetWidget Attributes
+		//1. Volume 
+	    mVolumeSlider->setSliderPosition(mVolumeLevel);
+	    mVolumeSlider->setEnabled(mShowVolume);
+	    //This will avoid IPC calls while dragging the Slider
+	    mVolumeSlider->setTracking(false);
+	    bool ok = connect(mVolumeSlider,SIGNAL(valueChanged(int)) , this , SLOT(handleVolumeChanged(int)));
+        Q_ASSERT_X(ok, "VolumeSlider", "Invalid IncrementDecrement Change");
+
+		//2.Silence Mode
+		mSilenceButton->setDown(mSilencelatched);
+		ok = connect(mSilenceButton,SIGNAL(clicked(bool)) , this , SLOT(handleSilenceMode(bool)));
+	    Q_ASSERT_X(ok, "SilenceButton", "Invalid Clicked");
+
+	    //3.Master Vibration
+	    mVibarte->setChecked(mVibrationChecked);
+	    ok = connect(mVibarte,SIGNAL(stateChanged(int)) , this , SLOT(handleVibrationToggled(int)));
+		Q_ASSERT_X(ok, "Vibrator", "Invalid Vibrator Toggeld");
+		
+		//4.Offline
+	    mOffline->setChecked(mOfflineChecked);
+	    ok = connect(mOffline,SIGNAL(stateChanged(int)) , this , SLOT(handleOfflineToggled(int)));
+		Q_ASSERT_X(ok, "Vibrator", "Invalid Offline Toggeld");  
+		
+		//5.Power off
+		mPowerOffButton->setEnabled(mCypherOff);
+		ok = connect(mPowerOffButton,SIGNAL(clicked(bool)) , this , SLOT(handlePowerOff(bool)));
+	    Q_ASSERT_X(ok, "PowerOffButton", "Invalid Clicked");	  
+	    
+        //Dialog dismiss only with Tap outside
+        mDialogWidget->setTimeout(HbPopup::NoTimeout);
+        mDialogWidget->setDismissPolicy(HbPopup::TapOutside);
+        mDialogWidget->setPreferredWidth(KPMWidth);
+        
+        connect(mDialogWidget,SIGNAL(aboutToClose()),this, SLOT(closedialog()));
+	    TRACES( RDebug::Print( _L("HbDevicePowerMenuWidget::constructDialog:dialogLoaded:End") ) );
+		}
+    TRACES( RDebug::Print( _L("HbDevicePowerMenuWidget::constructDialog:End") ) );
+	}
+
+/**
+ * Checks whether all Hadles for widgets DialogWidget, 
+ * SilenceButton, Vibrate, Offline and Poweroff Button allocated memory.
+ * Returns True, if all Handles allocated memory.
+ * Flase, atleast one of them NOT allocated memory.
+ */
+bool HbDevicePowerMenuWidget::IsValidHandles()
+    {
+    if((!mDialogWidget) || (!mSilenceButton) || (!mVolumeSlider)||(!mVibarte) || (!mOffline) || (!mPowerOffButton))
+        {
+        return false;
+        }
+    else{
+        //All handles are allocated memory
+        return true;
+        }
+    }
+
+/**
+ * Sets Mute/Unmute icon for Volume slider
+ * Mute/Unmute icon to display the current status of Silence Mode.
+ * Mute icon dispalyed when Device in Silence mode.
+ * Unmute icon dispalyed when Device Non-Silence mode. 
+ */
+void HbDevicePowerMenuWidget::setSpeakerIcon()
+	{
+	TRACES( RDebug::Print( _L("HbDevicePowerMenuWidget::setSpeakerIcon:Begin") ) );
+	QString speakerIcon= ( mSilencelatched )? VOLUME_MUTE_ICON : VOLUME_UNMUTE_ICON ;
+	mVolumeSlider->setElementIcon(HbSlider:: IconElement,HbIcon(speakerIcon));
+    TRACES( RDebug::Print( _L("HbDevicePowerMenuWidget::setSpeakerIcon:End") ) );
+	}
+
+
+/**
+ * Customizes the slider to Vloume Slider 
+ */
+void HbDevicePowerMenuWidget::customizeVolumeSlider()
+	{
+	TRACES( RDebug::Print( _L("HbDevicePowerMenuWidget::customizeVolumeSlider:Begin") ) );
+	//Construct Volume Slider from the HbSlider
+	mVolumeSlider->setSliderElements(QList<QVariant>()
+                                        << HbSlider::DecreaseElement 
+                                        << HbSlider::TrackElement
+                                        << HbSlider::IncreaseElement
+                                        << HbSlider::IconElement     );
+	
+	// To set DecreaseIcon and IncreseIcon
+	mVolumeSlider->setElementIcon(HbSlider::DecreaseElement, HbIcon(VOLUME_DECREASE_ICON));
+	mVolumeSlider->setElementIcon(HbSlider:: IncreaseElement, HbIcon(VOLUME_INCREASE_ICON));
+    //set Range of volume
+	mVolumeSlider->setRange(1,10);
+    TRACES( RDebug::Print( _L("HbDevicePowerMenuWidget::customizeVolumeSlider:End") ) );
+	}
+
+/**
+ * Slot
+ * Widget is about to Close. 
+ */
+void HbDevicePowerMenuWidget::closedialog()
+    {
+    TRACES( RDebug::Print( _L("HbDevicePowerMenuWidget::closedialog:Begin") ) );
+    emit deviceDialogClosed();
+    TRACES( RDebug::Print( _L("HbDevicePowerMenuWidget::closedialog:Begin") ) );
+    }
+
+/**
+ * Slot
+ */
+void HbDevicePowerMenuWidget::handleVolumeChanged(int aVolume)
+    {
+    TRACES( RDebug::Print( _L("HbDevicePowerMenuWidget::handleVolumeChanged:Begin") ) );
+    mVolumeLevel = aVolume;
+    //inform the client may be through data changed etc.
+    QVariantMap mDataToSend;
+    QVariant volume(mVolumeLevel);
+    mDataToSend.insert(KVolumeLevel, volume);
+    emit deviceDialogData(mDataToSend);
+    TRACES( RDebug::Print( _L("HbDevicePowerMenuWidget::handleVolumeChanged:Begin") ) );
+    }
+
+/**
+ * Slot
+ * Switch between the states to latch down and latch up.
+ * In case of Silence mode, The Silence button id latched down and Disables Volume control.
+ * In case of Non-Silence mode, The Silence button id latched Up and enables Volume control.
+ */
+void HbDevicePowerMenuWidget::handleSilenceMode(bool aState)
+	{
+	TRACES( RDebug::Print( _L("HbDevicePowerMenuWidget::handleSilenceMode:Begin") ) );
+	Q_UNUSED(aState);
+	mShowVolume = !(mShowVolume);
+	mSilencelatched = !(mSilencelatched);
+	mSilenceButton->setDown(mSilencelatched);
+	mVolumeSlider->setEnabled(mShowVolume);	
+    setSpeakerIcon();
+	//inform the client may be through data changed etc.
+    QVariantMap mDataToSend;
+    QVariant silence(mSilencelatched);
+    mDataToSend.insert(KSilenceLatchOn, silence);
+    emit deviceDialogData(mDataToSend);
+    TRACES( RDebug::Print( _L("HbDevicePowerMenuWidget::handleSilenceMode:End") ) );
+	}
+
+/**
+ * Slot
+ */
+void HbDevicePowerMenuWidget::handlePowerOff(bool aState)
+	{
+	TRACES( RDebug::Print( _L("HbDevicePowerMenuWidget::handlePowerOff:Begin") ) );
+	Q_UNUSED(aState);
+    QVariantMap mDataToSend;
+    QVariant shutdown(true);
+    mDataToSend.insert(KShutDown, shutdown);
+    emit deviceDialogData(mDataToSend);
+    emit deviceDialogClosed();
+    TRACES( RDebug::Print( _L("HbDevicePowerMenuWidget::handlePowerOff:End") ) );
+	}
+
+/**
+ * Slot
+ */
+void HbDevicePowerMenuWidget::handleOfflineToggled(int aOfflineToggel)
+	{
+	TRACES( RDebug::Print( _L("HbDevicePowerMenuWidget::handleOfflineToggled:Begin") ) );
+	mOfflineChecked = aOfflineToggel;
+    QVariantMap mDataToSend;
+    QVariant offline(mOfflineChecked);
+    mDataToSend.insert(KOfflineEnable, offline);
+    emit deviceDialogData(mDataToSend);
+    TRACES( RDebug::Print( _L("HbDevicePowerMenuWidget::handleOfflineToggled:End") ) );
+	}
+
+/**
+ * Slot
+ */
+void HbDevicePowerMenuWidget::handleVibrationToggled(int aVibrationToggel)
+	{
+	TRACES( RDebug::Print( _L("HbDevicePowerMenuWidget::handleVibrationToggled:Begin") ) );
+	mVibrationChecked = aVibrationToggel;
+    QVariantMap mDataToSend;
+    QVariant vibration(mVibrationChecked);
+    mDataToSend.insert(KVibrationEnable, vibration);
+    emit deviceDialogData(mDataToSend);
+    TRACES( RDebug::Print( _L("HbDevicePowerMenuWidget::handleVibrationToggled:End") ) );
+	}
+
+/**
+ * Cleans up memory allocations
+ */
+void HbDevicePowerMenuWidget::cleanupMemory()
+    {
+    TRACES( RDebug::Print( _L("HbDevicePowerMenuWidget::cleanupMemory:Begin") ) );
+    if(mLoader)
+        {
+        delete mLoader;
+        }
+    if(mHbTranslator)
+        {
+        delete mHbTranslator;    
+        }
+    TRACES( RDebug::Print( _L("HbDevicePowerMenuWidget::cleanupMemory:End") ) );
+    }
+
Binary file coreapplicationuis/rfsplugins/StarterRFSPlugin/conf/starterrfsplugin.confml has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/filehandling/fileconverterfw/group/ConarcTest.pkg	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,31 @@
+;
+; Copyright (c) 2009 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"
+; which accompanies this distribution, and is available
+; at the URL "http://www.eclipse.org/legal/epl-v10.html".
+;
+; Initial Contributors:
+; Nokia Corporation - initial contribution.
+;
+; Contributors:
+;
+; Description:
+;
+
+;Languages
+&EN
+
+
+;Localised Vendor name
+%{"ConarcTest.pkg EN"}
+
+; Vendor name
+: "ConarcTest"
+
+
+"\epoc32\data\z\conarctest\conarctest_run.bat"-"c:\conarctest_run.bat"
+"\epoc32\data\z\conarctest\conarctest_t_b64cnv.script"-"c:\conarctest\conarctest_t_b64cnv.script"
+"\epoc32\data\z\conarctest\conarctest_t_cnf.script"-"c:\conarctest\conarctest_t_cnf.script"
+"\epoc32\data\z\conarctest\conarctest_t_loadecomcnv.script"-"c:\conarctest\conarctest_t_loadecomcnv.script"
--- a/filehandling/fileconverterfw/group/app-framework_conarc.mrp	Tue Jun 15 16:07:48 2010 +0100
+++ b/filehandling/fileconverterfw/group/app-framework_conarc.mrp	Thu Jul 22 16:35:22 2010 +0100
@@ -1,19 +1,3 @@
-#
-# Copyright (c) 2009 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"
-# which accompanies this distribution, and is available
-# at the URL "http://www.eclipse.org/legal/epl-v10.html".
-#
-# Initial Contributors:
-# Nokia Corporation - initial contribution.
-#
-# Contributors:
-#
-# Description: 
-#
-
 component	app-framework_conarc
 source	\sf\mw\appsupport\filehandling\fileconverterfw
 binary	\sf\mw\appsupport\filehandling\fileconverterfw\group	all
--- a/filehandling/htmltorichtextconverter/group/app-services_chtmltocrtconv.mrp	Tue Jun 15 16:07:48 2010 +0100
+++ b/filehandling/htmltorichtextconverter/group/app-services_chtmltocrtconv.mrp	Thu Jul 22 16:35:22 2010 +0100
@@ -1,19 +1,3 @@
-#
-# Copyright (c) 2009 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"
-# which accompanies this distribution, and is available
-# at the URL "http://www.eclipse.org/legal/epl-v10.html".
-#
-# Initial Contributors:
-# Nokia Corporation - initial contribution.
-#
-# Contributors:
-#
-# Description: 
-#
-
 component	app-services_chtmltocrtconv
 source	\sf\mw\appsupport\filehandling\htmltorichtextconverter
 binary	\sf\mw\appsupport\filehandling\htmltorichtextconverter\group	all
--- a/filehandling/richtexttohtmlconverter/Group/app-services_richtexttohtmlconv.mrp	Tue Jun 15 16:07:48 2010 +0100
+++ b/filehandling/richtexttohtmlconverter/Group/app-services_richtexttohtmlconv.mrp	Thu Jul 22 16:35:22 2010 +0100
@@ -1,19 +1,3 @@
-#
-# Copyright (c) 2009 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"
-# which accompanies this distribution, and is available
-# at the URL "http://www.eclipse.org/legal/epl-v10.html".
-#
-# Initial Contributors:
-# Nokia Corporation - initial contribution.
-#
-# Contributors:
-#
-# Description: 
-#
-
 component	app-services_richtexttohtmlconv
 source	\sf\mw\appsupport\filehandling\richtexttohtmlconverter
 binary	\sf\mw\appsupport\filehandling\richtexttohtmlconverter\Group	all
--- a/hwresourceadaptation/hwresourcemgruiplugin/group/telephony_hwrmuiplugin.mrp	Tue Jun 15 16:07:48 2010 +0100
+++ b/hwresourceadaptation/hwresourcemgruiplugin/group/telephony_hwrmuiplugin.mrp	Thu Jul 22 16:35:22 2010 +0100
@@ -1,19 +1,3 @@
-#
-# Copyright (c) 2009 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"
-# which accompanies this distribution, and is available
-# at the URL "http://www.eclipse.org/legal/epl-v10.html".
-#
-# Initial Contributors:
-# Nokia Corporation - initial contribution.
-#
-# Contributors:
-#
-# Description: 
-#
-
 component	telephony_hwrmuiplugin
 source		\sf\mw\appsupport\hwresourceadaptation\hwresourcemgruiplugin
 binary		\sf\mw\appsupport\hwresourceadaptation\hwresourcemgruiplugin\group	all
--- a/layers.sysdef.xml	Tue Jun 15 16:07:48 2010 +0100
+++ b/layers.sysdef.xml	Thu Jul 22 16:35:22 2010 +0100
@@ -1,13 +1,13 @@
 <?xml version="1.0"?>
-<!DOCTYPE SystemDefinition SYSTEM "sysdef_1_4_0.dtd" [
+<!DOCTYPE SystemDefinition SYSTEM "sysdef_1_5_1.dtd" [
   <!ENTITY layer_real_source_path "sf/mw/appsupport" >
 ]>
 
-<SystemDefinition name="appsupport" schema="1.4.0">
+<SystemDefinition name="appsupport" schema="1.5.1">
   <systemModel>
     <layer name="mw_layer">
       <module name="appsupport">
-        <unit unitID="sydo.appsupport" name="appsupport" bldFile="&layer_real_source_path;/group" mrp="" />
+        <unit unitID="sydo.appsupport" name="appsupport" bldFile="&layer_real_source_path;" mrp="" proFile="appsupport.pro"/>
       </module>
       <module name="">
         <unit unitID="sydo.appsupport.appsupport_plat.flash_mmi_service_interface_custom_api" name="sydo_appsupport_appsupport_plat_flash_mmi_service_interface_custom_api" bldFile="&layer_real_source_path;/appsupport_plat/flash_mmi_service_interface_custom_api/group" mrp="" filter="!sf_build" />
--- a/openenvutils/commandshell/group/oetools_zsh.mrp	Tue Jun 15 16:07:48 2010 +0100
+++ b/openenvutils/commandshell/group/oetools_zsh.mrp	Thu Jul 22 16:35:22 2010 +0100
@@ -1,19 +1,3 @@
-#
-# Copyright (c) 2009 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"
-# which accompanies this distribution, and is available
-# at the URL "http://www.eclipse.org/legal/epl-v10.html".
-#
-# Initial Contributors:
-# Nokia Corporation - initial contribution.
-#
-# Contributors:
-#
-# Description: 
-#
-
 component oetools_zsh
 source \sf\mw\appsupport\openenvutils\commandshell
 
--- a/openenvutils/telnetserver/group/oetools_telnetd.mrp	Tue Jun 15 16:07:48 2010 +0100
+++ b/openenvutils/telnetserver/group/oetools_telnetd.mrp	Thu Jul 22 16:35:22 2010 +0100
@@ -1,19 +1,3 @@
-#
-# Copyright (c) 2009 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"
-# which accompanies this distribution, and is available
-# at the URL "http://www.eclipse.org/legal/epl-v10.html".
-#
-# Initial Contributors:
-# Nokia Corporation - initial contribution.
-#
-# Contributors:
-#
-# Description: 
-#
-
 component oetools_telnetd
 source \sf\mw\appsupport\openenvutils\telnetserver
 
--- a/package_definition.xml	Tue Jun 15 16:07:48 2010 +0100
+++ b/package_definition.xml	Thu Jul 22 16:35:22 2010 +0100
@@ -145,7 +145,7 @@
         <unit mrp="commonappservices/coreappstest/Group/app-services_CoreAppsTest.mrp" bldFile="commonappservices/coreappstest/Group"/>
       </component>
       <component id="appservicesdocs" name="Application Services Documentation" purpose="development" class="doc">
-        <unit mrp="commonappservices/appservicesdocs/app-services_documentation.mrp"/>
+        <unit mrp="commonappservices/doc_pub/app-services_documentation.mrp"/>
       </component>
       <component id="backuprestorenotification" name="Backup Restore Notification" introduced="8.1" purpose="optional">
         <unit bldFile="commonappservices/backuprestorenotification/group" mrp="commonappservices/backuprestorenotification/group/app-services_BackupRestoreNotification.mrp"/>
--- a/printingsupport/printinguisupport/group/BLD.INF	Tue Jun 15 16:07:48 2010 +0100
+++ b/printingsupport/printinguisupport/group/BLD.INF	Thu Jul 22 16:35:22 2010 +0100
@@ -1,4 +1,4 @@
-// Copyright (c) 1999-2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 1999-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"
@@ -31,7 +31,7 @@
 // specify the source file followed by its destination here
 // copy will be used to copy the source file to its destination
 // If there's no destination then the source file will be copied
-// to the same name in \epoc32\include
+// to the same name in /epoc32/include
 
 ../inc/PRNINF.H SYMBIAN_MW_LAYER_PUBLIC_EXPORT_PATH(prninf.h)
 ../inc/PRNPREV.H SYMBIAN_MW_LAYER_PUBLIC_EXPORT_PATH(prnprev.h)
--- a/printingsupport/printinguisupport/group/app-framework_print.mrp	Tue Jun 15 16:07:48 2010 +0100
+++ b/printingsupport/printinguisupport/group/app-framework_print.mrp	Thu Jul 22 16:35:22 2010 +0100
@@ -1,19 +1,3 @@
-#
-# Copyright (c) 2009 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"
-# which accompanies this distribution, and is available
-# at the URL "http://www.eclipse.org/legal/epl-v10.html".
-#
-# Initial Contributors:
-# Nokia Corporation - initial contribution.
-#
-# Contributors:
-#
-# Description: 
-#
-
 component	app-framework_print
 source	\sf\mw\appsupport\printingsupport\printinguisupport
 binary	\sf\mw\appsupport\printingsupport\printinguisupport\group	all
--- a/printingsupport/printinguisupport/inc/PRNSETUP.H	Tue Jun 15 16:07:48 2010 +0100
+++ b/printingsupport/printinguisupport/inc/PRNSETUP.H	Thu Jul 22 16:35:22 2010 +0100
@@ -1,4 +1,4 @@
-// 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 "Eclipse Public License v1.0"
@@ -29,10 +29,6 @@
 #include <prninf.h>
 #endif
 
-#ifndef SYMBIAN_ENABLE_MIXED_HEADERS
-#include <printinguisupport/prnpath.h>
-#endif
-
 /** 
 @publishedAll 
 @released */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sensorsupport/testsensor/data/ssyreference_config_template.xml	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,149 @@
+<!-- ssyreference_config_template.xml -->
+<!-- SsyReference configuration file template -->
+<!-- ************************************************************* -->
+<!-- * NOTE. DO NOT LEAVE ANY COMMENTS IN THE ACTUAL CONFIG FILE * -->
+<!-- ************************************************************* -->
+<SsyReferenceConfig>
+    <SsyGeneralInformation>
+        <!-- General information for SSY itself -->
+        <Properties>
+        <!-- General properties of the sensor -->
+    	  <!-- TSensrvProperty. Each property has its own item defined in here -->
+        	
+        	<!-- Property example 1 -->
+        	<PropertyItem PropertyId="TSensrvPropertyId"
+        	    ItemIndex="Item index in channel data structure"
+        		PropertyValue="Value of the property"
+        		MaxValue="Maximum value of data"
+        		MinValue="Minimum value of data"
+        		ReadOnly="Read only or modifiable"
+        		PropertyType="TSensrvPropertyType">
+            </PropertyItem>
+            <!-- Property example 2 -->
+        	<PropertyItem PropertyId="TSensrvPropertyId"
+        		ItemIndex="Item index in channel data structure"
+        		PropertyValue="Value of the property"
+        		MaxValue="Maximum value of data"
+        		MinValue="Minimum value of data"
+        		ReadOnly="Read only or modifiable"
+        		PropertyType="TSensrvPropertyType">
+            </PropertyItem>
+        </Properties>
+    </SsyGeneralInformation>
+    <ChannelInformationGroup ChannelCount="2">
+    	<!-- Channel definitions. Each channel item contains all information of one channel -->
+    	<!-- Channel example 1 -->
+    	<ChannelItem 
+    		ChannelId="This value is updated runtime when Sensrv has defined channel IDs" 
+    		ContextType="TSensrvContextType" 
+    		Quantity="TSensrvQuantity" 
+    		ChannelType="TSensrvChannelTypeId" 
+    		Location="Location of the sensor" 
+    		Vendor="Vendor ID"
+    		DataTypeId="data type ID identifies data type defined here. See sensrvchanneldatatypes.h">
+    		  <!-- One channel definition. Each channel has its own item block -->
+        	<!-- TSensrvChannelInfo. Contains information of this channel; Context type, Quantity etc. --> 
+        	
+        	<!-- Contains properties of this channel. -->
+        	<Properties>
+        	  <!-- TSensrvProperty. Each property has its own item defined in here -->
+        		<!-- Property example 3 -->
+    		    <PropertyItem PropertyId="TSensrvPropertyId"
+    		      ItemIndex="Item index in channel data structure"
+    		      PropertyValue="Value of the property"
+    		      MaxValue="Maximum value of data"
+    		      MinValue="Minimum value of data"
+    		      ReadOnly="Read only or modifiable"
+    		      PropertyType="TSensrvPropertyType">
+        		</PropertyItem>
+    		    <!-- Property example 4 -->
+    		    <PropertyItem PropertyId="TSensrvPropertyId"
+    		      ItemIndex="Item index in channel data structure"
+    		      PropertyValue="Value of the property"
+    		      MaxValue="Maximum value of data"
+    		      MinValue="Minimum value of data"
+    		      ReadOnly="Read only or modifiable"
+    		      PropertyType="TSensrvPropertyType">
+        		</PropertyItem>
+        	</Properties>
+
+            <!-- Channel data. Information of generated data by this channel.  -->
+            <!-- There may be several different (yet same type) data items. Next data item is added to  -->
+            <!-- buffer after the previous data items (all according to count) are added and last Interval is passed -->
+             
+            <ChannelData StartIntervalMs="Time in milliseconds to start filling buffer after StartChannelData()">
+                <ChannelDataItem DataTypeId="data type ID identifies data type defined here. See sensrvchanneldatatypes.h" count="Number of this data items to be added into buffer (with the same values)" 
+    			     									 IntervalMs="Time in milliseconds after next data item is added into buffer">
+                    <!-- Content of this channel item is dependent on the type of this channel. It must be one and only one of the following -->
+                    <SsyRefChannelDataAxis XAxis="Integer value of X Axis" YAxis="Integer value of Y Axis" ZAxis="Integer value of Z Axis" ><!-- This type has DataTypeID 0x00010001 --></SsyRefChannelDataAxis>
+                    <SsyRefChannelDataTapping Direction="direction of tapping"><!-- This type has DataTypeID 0x00010002 --></SsyRefChannelDataTapping>
+                </ChannelDataItem>
+
+                <!-- Next channel data item -->
+                <ChannelDataItem DataTypeId="data type ID identifies data type defined here. See sensrvchanneldatatypes.h" count="Number of this data items to be added into buffer (with the same values)" 
+    			     									 IntervalMs="Time in milliseconds after next data item is added into buffer">
+                    <!-- Content of this channel item is dependent on the type of this channel. It must be one and only one of the following -->
+                    <SsyRefChannelDataAxis XAxis="Integer value of X Axis" YAxis="Integer value of Y Axis" ZAxis="Integer value of Z Axis" ><!-- This type has DataTypeID 0x00010001 --></SsyRefChannelDataAxis>
+                    <SsyRefChannelDataTapping Direction="direction of tapping"><!-- This type has DataTypeID 0x00010002 --></SsyRefChannelDataTapping>
+                </ChannelDataItem>
+            </ChannelData>
+    	</ChannelItem>
+    	<!-- Channel example 2 -->
+    	<ChannelItem 
+    		ChannelId="This value is updated runtime when Sensrv has defined channel IDs" 
+    		ContextType="TSensrvContextType" 
+    		Quantity="TSensrvQuantity" 
+    		ChannelType="TSensrvChannelTypeId" 
+    		Location="Location of the sensor" 
+    		Vendor="Vendor ID"
+    		DataTypeId="data type ID identifies data type defined here. See sensrvchanneldatatypes.h">
+    		<!-- One channel definition. Each channel has its own item block -->
+        	<!-- TSensrvChannelInfo. Contains information of this channel; Context type, Quantity etc. -->
+        	
+            <!-- Contains properties of this channel. -->
+        	<Properties>
+        	  	 <!-- TSensrvProperty. Each property has its own item defined in here -->
+        		 <!-- Property example 5 -->
+    		    <PropertyItem PropertyId="TSensrvPropertyId"
+    		      ItemIndex="Item index in channel data structure"
+    		      PropertyValue="Value of the property"
+    		      MaxValue="Maximum value of data"
+    		      MinValue="Minimum value of data"
+    		      ReadOnly="Read only or modifiable"
+    		      PropertyType="TSensrvPropertyType">
+        		</PropertyItem>
+
+        		<!-- Property example 6 -->
+    		    <PropertyItem PropertyId="TSensrvPropertyId"
+    		      ItemIndex="Item index in channel data structure"
+    		      PropertyValue="Value of the property"
+    		      MaxValue="Maximum value of data"
+    		      MinValue="Minimum value of data"
+    		      ReadOnly="Read only or modifiable"
+    		      PropertyType="TSensrvPropertyType">
+        	    </PropertyItem>
+        	</Properties>
+
+            <!-- Channel data. Information of generated data by this channel.  -->
+            <!-- There may be several different (yet same type) data items. Next data item is added to  -->
+            <!-- buffer after the previous data items (all according to count) are added and last Interval is passed -->
+             
+            <ChannelData StartIntervalMs="Time in milliseconds to start filling buffer after StartChannelData()">
+                <ChannelDataItem DataTypeId="data type ID identifies data type defined here. See sensrvchanneldatatypes.h" count="Number of this data items to be added into buffer (with the same values)" 
+    			     									 IntervalMs="Time in milliseconds after next data item is added into buffer">
+                    <!-- Content of this channel item is dependent on the type of this channel. It must be one and only one of the following -->
+                    <SsyRefChannelDataAxis XAxis="Integer value of X Axis" YAxis="Integer value of Y Axis" ZAxis="Integer value of Z Axis" ><!-- This type has DataTypeID 0x00010001 --></SsyRefChannelDataAxis>
+                    <SsyRefChannelDataTapping Direction="direction of tapping"><!-- This type has DataTypeID 0x00010002 --></SsyRefChannelDataTapping>
+                    </ChannelDataItem>
+
+                <!-- Next channel data item -->
+                <ChannelDataItem DataTypeId="data type ID identifies data type defined here. See sensrvchanneldatatypes.h" count="Number of this data items to be added into buffer (with the same values)" 
+    			     									 IntervalMs="Time in milliseconds after next data item is added into buffer">
+                    <!-- Content of this channel item is dependent on the type of this channel. It must be one and only one of the following -->
+                    <SsyRefChannelDataAxis XAxis="Integer value of X Axis" YAxis="Integer value of Y Axis" ZAxis="Integer value of Z Axis" ><!-- This type has DataTypeID 0x00010001 --></SsyRefChannelDataAxis>
+                    <SsyRefChannelDataTapping Direction="direction of tapping"><!-- This type has DataTypeID 0x00010002 --></SsyRefChannelDataTapping>
+                </ChannelDataItem>
+            </ChannelData>
+    	</ChannelItem>
+    </ChannelInformationGroup>
+</SsyReferenceConfig>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sensorsupport/testsensor/data/ssyreferenceconfig.xml	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,144 @@
+<!-- ssyreferenceconfig.xml -->
+<!-- SSY reference configuration file-->
+<SsyReferenceConfig>
+    <SsyGeneralInformation>
+    </SsyGeneralInformation>
+    <ChannelInformationGroup ChannelCount="2">
+    	<ChannelItem
+    		ChannelId="5"
+    		ContextType="2" 
+    		Quantity="11" 
+    		ChannelType="0x10205081" 
+    		Location="NoLoc"
+    		Vendor="SsyRefVendor"
+    		DataTypeId="0x1020507F">
+    			<Properties>
+        		<PropertyItem PropertyId="0x00000002"
+    		      ItemIndex="0"
+    		      PropertyValue="100"
+    		      MaxValue="150"
+    		      MinValue="0"
+    		      ReadOnly="0"
+    		      PropertyType="1">
+    		     	<!-- Channel property, data rate, mandatory for all channels, see KSensrvPropIdDataRate  -->
+        		</PropertyItem>
+        		<PropertyItem PropertyId="0x00000004"
+    		      ItemIndex="0"
+    		      PropertyValue="1"
+    		      MaxValue="0"
+    		      MinValue="0"
+    		      ReadOnly="1"
+    		      PropertyType="1">
+    		     	<!-- Channel property, availability of the channel, mandatory for all channels, see KSensrvPropIdAvailability  -->
+        		</PropertyItem>
+          </Properties>
+          <ChannelData StartIntervalMs="3000">
+            <ChannelDataItem  DataTypeId="0x1020507F" count="1" IntervalMs="3000">
+              <SsyRefChannelDataTapping Direction="0x01"></SsyRefChannelDataTapping>
+            </ChannelDataItem>
+					  <ChannelDataItem DataTypeId="0x1020507F" count="1" IntervalMs="5000">
+              <SsyRefChannelDataTapping Direction="0x02"></SsyRefChannelDataTapping>
+            </ChannelDataItem>            
+          </ChannelData>
+    	</ChannelItem>
+    	<ChannelItem
+    		ChannelId="2"
+    		ContextType="2" 
+    		Quantity="10" 
+    		ChannelType="0x1020507E" 
+    		Location="Event%d" 
+    		Vendor="SsyRefVendor"
+    		DataTypeId="0x1020507E">
+        	<Properties>
+        		<!-- First four properties has same property Id, they are grouped to array property -->
+        		<!-- First is array info -2, which tells currently selected property, value = 1 -->
+        		<!-- Max and Min values tells max and min property array indexes, not the actual values -->
+        		<!-- Array index is mandatory only for array type of properties, by default it is -1 -->
+        		<PropertyItem PropertyId="0x00000002"
+        			ArrayIndex="-2"
+    		      ItemIndex="0"
+    		      PropertyValue="1"
+    		      MaxValue="2"
+    		      MinValue="0"
+    		      ReadOnly="0"
+    		      PropertyType="1">
+    		     	<!-- Channel property, data rate, mandatory for all channels, see KSensrvPropIdDataRate  -->
+        		</PropertyItem>
+        		<PropertyItem PropertyId="0x00000002"
+        			ArrayIndex="0"
+    		      ItemIndex="0"
+    		      PropertyValue="10"
+    		      MaxValue="0"
+    		      MinValue="0"
+    		      ReadOnly="1"
+    		      PropertyType="1">
+    		     	<!-- Channel property, data rate, mandatory for all channels, see KSensrvPropIdDataRate  -->
+        		</PropertyItem>
+        		<PropertyItem PropertyId="0x00000002"
+        			ArrayIndex="1"
+    		      ItemIndex="0"
+    		      PropertyValue="30"
+    		      MaxValue="0"
+    		      MinValue="0"
+    		      ReadOnly="1"
+    		      PropertyType="1">
+    		     	<!-- Channel property, data rate, mandatory for all channels, see KSensrvPropIdDataRate  -->
+        		</PropertyItem>
+        		<PropertyItem PropertyId="0x00000002"
+        			ArrayIndex="2"
+    		      ItemIndex="0"
+    		      PropertyValue="50"
+    		      MaxValue="0"
+    		      MinValue="0"
+    		      ReadOnly="1"
+    		      PropertyType="1">
+    		     	<!-- Channel property, data rate, mandatory for all channels, see KSensrvPropIdDataRate  -->
+        		</PropertyItem>
+        		<PropertyItem PropertyId="0x00000004"
+    		      ItemIndex="0"
+    		      PropertyValue="1"
+    		      MaxValue="0"
+    		      MinValue="0"
+    		      ReadOnly="1"
+    		      PropertyType="1">
+    		     	<!-- Channel property, availability of the channel, mandatory for all channels, see KSensrvPropIdAvailability  -->
+        		</PropertyItem>
+    		    <PropertyItem PropertyId="0x00000005"
+    		      ItemIndex="1"
+    		      PropertyValue="14.56"
+    		      MaxValue="128"
+    		      MinValue="1"
+    		      ReadOnly="0"
+    		      PropertyType="2">
+    		     	<!-- Channel item property, measure range for X-axis (item index = 1), see KSensrvPropIdMeasureRange  -->
+        		</PropertyItem>
+        		<PropertyItem PropertyId="0x00000005"
+    		      ItemIndex="2"
+    		      PropertyValue="20.65"
+    		      MaxValue="256"
+    		      MinValue="1"
+    		      ReadOnly="0"
+    		      PropertyType="2">
+    		     	<!-- Channel item property, measure range for Y-axis (item index = 2), see KSensrvPropIdMeasureRange  -->
+        		</PropertyItem>
+        		<PropertyItem PropertyId="0x00000005"
+    		      ItemIndex="3"
+    		      PropertyValue="10.56"
+    		      MaxValue="128"
+    		      MinValue="1"
+    		      ReadOnly="0"
+    		      PropertyType="2">
+    		     	<!-- Channel item property, measure range for Z-axis (item index = 3), see KSensrvPropIdMeasureRange  -->
+        		</PropertyItem>
+        	</Properties>
+          <ChannelData StartIntervalMs="5000">
+            <ChannelDataItem DataTypeId="0x1020507E" count="3" IntervalMs="4000">
+              <SsyRefChannelDataAxis XAxis="-50" YAxis="-32" ZAxis="44" ></SsyRefChannelDataAxis>
+            </ChannelDataItem>
+            <ChannelDataItem DataTypeId="0x1020507E" count="4" IntervalMs="5000">
+              <SsyRefChannelDataAxis XAxis="22" YAxis="49" ZAxis="55" ></SsyRefChannelDataAxis>
+            </ChannelDataItem>
+        </ChannelData>
+    	</ChannelItem>    	    
+    	</ChannelInformationGroup>
+</SsyReferenceConfig>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sensorsupport/testsensor/group/bld.inf	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,48 @@
+// bld.inf
+
+// Copyright (c) 2006-2009 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"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+
+
+PRJ_PLATFORMS
+    DEFAULT
+
+PRJ_EXPORTS
+    ssyreference.iby                		/epoc32/rom/include/ssyreference.iby
+
+    // Export config to SensorServers private folder.
+    // For emulator use.
+    ../data/ssyreferenceconfig.xml  		/epoc32/release/winscw/udeb/z/refssy/ssyreferenceconfig.xml
+    ../data/ssyreferenceconfig.xml  		/epoc32/release/winscw/urel/z/refssy/ssyreferenceconfig.xml
+
+    // For hardware use.
+    ../data/ssyreferenceconfig.xml  		/epoc32/data/z/refssy/ssyreferenceconfig.xml
+
+#ifdef SYMBIAN_OLD_EXPORT_LOCATION
+	../inc/ssyreferenceaccelerometer.h		/epoc32/include/sensors/channels/ssyreferenceaccelerometer.h
+#endif
+#ifdef SYMBIAN_OLD_EXPORT_LOCATION
+	../inc/ssyreferencemagnetometer.h		/epoc32/include/sensors/channels/ssyreferencemagnetometer.h
+#endif
+#ifdef SYMBIAN_OLD_EXPORT_LOCATION
+	../inc/ssyreferenceorientation.h		/epoc32/include/sensors/channels/ssyreferenceorientation.h
+#endif
+#ifdef SYMBIAN_OLD_EXPORT_LOCATION
+	../inc/ssyreferenceproximity.h			/epoc32/include/sensors/channels/ssyreferenceproximity.h
+#endif
+
+PRJ_MMPFILES
+    ssyreferenceplugin.mmp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sensorsupport/testsensor/group/ssyreference.iby	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,27 @@
+// ssyreference.iby
+
+// Copyright (c) 2006-2009 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"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+
+
+#ifndef SSYREFERENCE_IBY
+#define SSYREFERENCE_IBY
+
+#include <gmxml.iby>
+
+ECOM_PLUGIN(ssyreferenceplugin.dll, ssyreferenceplugin.rsc)
+data=DATAZ_\refssy\ssyreferenceconfig.xml       \refssy\ssyreferenceconfig.xml 
+#endif // SSYREFERENCE_IBY
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sensorsupport/testsensor/group/ssyreferenceplugin.mmp	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,58 @@
+// ssyreferenceplugin.mmp
+
+// Copyright (c) 2006-2009 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"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+
+
+#include <sensors/spi/sensrvresource.hrh> 
+
+TARGET          ssyreferenceplugin.dll
+TARGETTYPE      plugin
+VENDORID        0x70000001
+
+// ECom Dll recognition UID followed by the unique UID for this dll
+UID             0x10009D8D 0x10205089
+
+CAPABILITY      SENSOR_PLUGIN_CAPABILITIES
+
+SOURCEPATH      ../src
+SOURCE          ssyreferencechanneldataprovider.cpp
+SOURCE          ssyreferencecontrol.cpp
+SOURCE          ssyreferencepropertyprovider.cpp
+SOURCE          ssyreferencechannel.cpp
+SOURCE          ssyreferenceconfig.cpp
+SOURCE          ssyreferencecmdhandler.cpp
+SOURCE          ecomentrypoint.cpp
+
+USERINCLUDE     ../src
+
+SYSTEMINCLUDE   /epoc32/include
+SYSTEMINCLUDE   /epoc32/include/ecom
+SYSTEMINCLUDE   /epoc32/include/sensors
+SYSTEMINCLUDE	/epoc32/include/sensors/spi
+SYSTEMINCLUDE   /epoc32/include/sensors/channels
+
+// The resource name should have to be same as the third UID above
+START RESOURCE  ../src/10205089.rss
+TARGET          ssyreferenceplugin.rsc
+END
+
+LIBRARY         euser.lib
+LIBRARY         ecom.lib
+LIBRARY         sensrvutil.lib
+LIBRARY         xmlparser.lib      // for XML parser
+LIBRARY         efsrv.lib
+LIBRARY         xmldom.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sensorsupport/testsensor/group/syslibs_sensors_ssyreference.history.xml	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,21 @@
+<?xml version="1.0"?>
+<relnotes schema="1.0.0" name="Reference SSY">
+  <purpose>
+    Referencey SSY for testing the Sensors Framework.
+  </purpose>
+
+  <deliverystep number="1120" name="PREQ2039: Base Services: Sensor Server (tr2.1.5 Prototype)" osproject="Sphinx" revision="002">
+    <preq number="2039" title="Sensor server">
+      Update to Sensors framework as part of the Core OS 2 project.
+    </preq>
+    <milestone project="GT0461" number="3.2"/>
+  </deliverystep>
+  <deliverystep number="1105" name="PREQ2039: Base Services: Sensor Server (TR2 Prototype)" osproject="Sphinx" revision="001">
+    <preq number="2039" title="Sensor server">
+      Adding Reference SSY to Symbian OS as part of the Core OS 2 project.
+    </preq>
+    <cr number="1603" title="Bring PREQ2039 (Sensor server) into the scope of Sphinx"/>
+    <milestone project="GT0461" number="3.1"/>
+  </deliverystep>
+
+</relnotes>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sensorsupport/testsensor/group/syslibs_sensors_ssyreference.mrp	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,10 @@
+component	syslibs_sensors_ssyreference
+
+source	\sf\mw\appsupport\sensorsupport\testsensor
+
+exports	\sf\mw\appsupport\sensorsupport\testsensor\group
+binary	\sf\mw\appsupport\sensorsupport\testsensor\group	all
+
+notes_source	\component_defs\release.src
+
+ipr T
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sensorsupport/testsensor/inc/ssyreferenceaccelerometer.h	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,256 @@
+// ssyreferenceaccelerometer.h
+
+/*
+* Copyright (c) 2008-2009 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+
+
+/**
+ @file
+ @internalAll Sensor framework Reference SSY header file
+ @test
+*/
+
+
+#ifndef SSYREFERENCEACCELEROMETER_H
+#define SSYREFERENCEACCELEROMETER_H
+
+//  INCLUDES
+#include <e32base.h>
+#include <sensors/sensrvtypes.h> 
+
+
+// ACCELEROMETER RELATED CHANNELS 
+
+/**
+* - Name:          Accelerometer XYZ-axis data channel type
+* - Type:          Rawdata
+* - Datatype:      TSensrvAccelerometerAxisData
+* - Description:   Accelerometer x-, y-, z-axis data  
+*/
+const TSensrvChannelTypeId KSensrvChannelTypeIdAccelerometerXYZAxisData = 0x1020507E;
+
+// ACCELEROMETER RELATED PROPERTIES
+
+/**
+* - Name:         Axis active
+* - Type:         TInt 
+* - Scope:        Channel item property
+* - Mandatory:    No
+* - Capability:   None
+* - Description:  Indicates is sensor axis activated.
+*                 Value is one if the axis is activated, zero otherwise.
+*/
+const TSensrvPropertyId KSensrvPropIdAxisActive = 0x00001001;
+
+/**
+* - Name:         Axis threshold value
+* - Type:         TReal
+* - Scope:        Channel item property
+* - Mandatory:    No
+* - Capability:   None
+* - Description:  Threshold value for a sensor channel
+*/
+const TSensrvPropertyId KSensrvPropIdAxisThresholdValue = 0x00001002;
+
+// ACCELEROMETER RELATED DATATYPES
+
+/**
+* Accelerometer axis data type
+*/
+class TSensrvAccelerometerAxisData 
+    {
+public:
+    /**
+    * Channel data type Id number
+    */      
+    static const TSensrvChannelDataTypeId KDataTypeId = 0x1020507E;
+
+    /**
+     * Channel data type index numbers
+     */
+	enum TSensrvAccelerometerAxisDataIndexes
+          {
+           ETimeStamp = 0,
+           EAxisX,
+           EAxisY,
+           EAxisZ
+          }; 
+
+public:
+    /**
+    * - Item name:   Sampling time.
+    * - Item Index:  0
+    * - Conditions:  None
+    * - Description: Timestamp for a sample.
+    */   
+    TTime iTimeStamp;    
+
+    /**
+    * - Item name:   Accelerometer x-axis 
+    * - Item Index:  1
+    * - Conditions:  Single limit and range 
+    * - Description: Accelerometer values from x-axis 
+    */
+    TInt iAxisX;  
+
+    /**
+    * - Item name:   Accelerometer y-axis 
+    * - Item Index:  2
+    * - Conditions:  Single limit and range 
+    * - Description: Accelerometer values from y-axis 
+    */ 
+    TInt iAxisY;  
+
+    /**
+    * - Item name:   Accelerometer z-axis 
+    * - Item Index:  3
+    * - Conditions:  Single limit and range 
+    * - Description: Accelerometer values from z-axis 
+    */
+    TInt iAxisZ;  
+    };
+
+
+// TAPPING RELATED CHANNELS 
+
+/**
+* - Name:          Wakeup event channel type
+* - Type:          Event
+* - Datatype:      TSensrvTappingData
+* - Description:   Wakeup events 
+*/
+const TSensrvChannelTypeId KSensrvChannelTypeIdAccelerometerWakeupData = 0x1020507F;
+
+/**
+* - Name:          Double tapping event channel type
+* - Type:          Event
+* - Datatype:      TSensrvTappingData
+* - Description:   Double tapping events 
+*/
+const TSensrvChannelTypeId KSensrvChannelTypeIdAccelerometerDoubleTappingData = 0x10205081;
+
+// TAPPING RELATED PROPERTIES
+
+/**
+* - Name:         Tapping axis active
+* - Type:         TInt 
+* - Scope:        Channel item property
+* - Mandatory:    No
+* - Capability:   None
+* - Description:  Indicates is sensor axis activated.
+*                 Value is one if the axis is activated, zero otherwise.
+*/
+const TSensrvPropertyId KSensrvPropIdTappingAxisActive = 0x00001001;
+
+/**
+* - Name:         Tapping axis threshold value
+* - Type:         TReal
+* - Scope:        Channel item property
+* - Mandatory:    No
+* - Capability:   None
+* - Description:  Threshold value for a sensor channel
+*/
+const TSensrvPropertyId KSensrvPropIdTappingAxisThresholdValue = 0x00001002;
+
+/**
+* - Name:         Tap duration in milliseconds
+* - Type:         TInt
+* - Scope:        Channel property
+* - Mandatory:    No
+* - Capability:   None
+* - Description:  Tapping duration setting
+*/
+const TSensrvPropertyId KSensrvPropIdTapDurationValue = 0x00001003;
+
+/**
+* - Name:         Double tap latency 
+* - Type:         TInt
+* - Scope:        Channel property
+* - Mandatory:    No
+* - Capability:   None
+* - Description:  Double tap latency in milliseconds
+*/
+const TSensrvPropertyId KSensrvPropIdDblTapLatency = 0x00001004;
+
+/**
+* - Name:         Double tap interval
+* - Type:         TInt
+* - Scope:        Channel property
+* - Mandatory:    No
+* - Capability:   None
+* - Description:  Double tap interval in milliseconds
+*/
+const TSensrvPropertyId KSensrvPropIdDblTapInterval = 0x00001005;
+
+
+
+// TAPPING RELATED DATATYPES
+
+/**
+* Direction of the tapping data. If direction (plus or minus) is not known, 
+* direction is, for example in x-axis case 
+* KSensrvAccelerometerDirectionXplus | KSensrvAccelerometerDirectionXminus
+*/
+const TUint8 KSensrvAccelerometerDirectionXplus 	= 0x01;
+const TUint8 KSensrvAccelerometerDirectionXminus 	= 0x02;
+const TUint8 KSensrvAccelerometerDirectionYplus 	= 0x04;
+const TUint8 KSensrvAccelerometerDirectionYminus 	= 0x08;
+const TUint8 KSensrvAccelerometerDirectionZplus 	= 0x10;
+const TUint8 KSensrvAccelerometerDirectionZminus 	= 0x20;
+
+/**
+* Tapping data type
+*/
+class TSensrvTappingData 
+    {
+public:
+    /**
+    * Channel data type Id number
+    */      
+    static const TSensrvChannelDataTypeId KDataTypeId = 0x1020507F;
+
+	/**
+    * Channel data type index numbers
+    */
+	enum TSensrvAccelerometerAxisDataIndexes
+          {
+          ETimeStamp = 0,
+          EDirection
+          };
+
+public:
+    /**
+    * - Item name:   Sampling time.
+    * - Item Index:  0
+    * - Conditions:  None
+    * - Description: Timestamp for a sample.
+    */   
+    TTime iTimeStamp;    
+    
+    /**
+    * - Item name:   Tapping direction bitmask
+    * - Item Index:  1
+    * - Conditions:  Binary
+    * - Description: Direction bitmask of the tapping event. 
+    *                See constant definitions above.
+    */
+    TUint32 iDirection;  
+    };
+
+#endif //SSYREFERENCEACCELEROMETER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sensorsupport/testsensor/inc/ssyreferencemagnetometer.h	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,170 @@
+// ssyreferencemagnetometer.h
+
+/*
+* Copyright (c) 2008-2009 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+
+
+/**
+ @file
+ @internalAll Sensor framework Reference SSY header file
+ @test
+*/
+
+
+#ifndef SSYREFERENCEMAGNETOMETER_H
+#define SSYREFERENCEMAGNETOMETER_H
+
+//  INCLUDES
+#include <e32base.h>
+#include <sensors/sensrvtypes.h> 
+
+
+// MAGNETOMETER RELATED CHANNELS 
+
+/**
+* - Name:          Magnetometer XYZ-axis data channel type
+* - Type:          Rawdata
+* - Datatype:      TSensrvMagnetometerAxisData
+* - Description:   Magnetometer x-, y-, z-axis data  
+*/
+const TSensrvChannelTypeId KSensrvChannelTypeIdMagnetometerXYZAxisData = 0x2000BEE0;
+
+
+// MAGNETOMETER RELATED PROPERTIES
+
+/**
+* - Name:        Name of the property
+* - Type:        Defines type of the property (TInt/TReal/TBuf)
+* - Scope:       Defines a property scope. Property can be defined for a channel, 
+*                for a specific item in a channel or for a server related to 
+*                channel.
+* - Mandatory:   Defines is property mandatory
+* - Capability:  Capabilities needed to set this property
+* - Description: Description of the property
+*/
+
+/**
+* - Name:         Auto calibration active
+* - Type:         TInt 
+* - Scope:        Channel item property
+* - Mandatory:    No
+* - Capability:   None
+* - Description:  Indicates is auto calibration active.
+*                 Value is one if calibration is activated, zero otherwise.
+*/
+const TSensrvPropertyId KSensrvPropAutoCalibrationActive = 0x00001006;
+
+/**
+* - Name:         Calibration status
+* - Type:         TInt 
+* - Scope:        Channel item property
+* - Mandatory:    No
+* - Capability:   None
+* - Description:  Indicates the calibration level.
+*                 Calibration level scales between minimum and maximum value.
+*                 Maximum indicates that calibration level is at its best
+*                 level. Minimum indicates that calibration is undefined.
+*/
+const TSensrvPropertyId KSensrvPropCalibrationLevel = 0x00001007;
+
+// MAGNETOMETER RELATED DATATYPES
+
+/**
+* Magnetometer axis data type
+*/
+class TSensrvMagnetometerAxisData 
+    {
+public:
+    /**
+    * Channel data type Id number
+    */      
+    static const TSensrvChannelDataTypeId KDataTypeId = 0x2000BEE0;
+
+    /**
+    * Channel data type index numbers
+    */  
+    enum TSensrvMagnetometerAxisDataIndexes
+        {
+        ETimeStamp = 0,
+        EAxisX,
+        EAxisY,
+        EAxisZ
+        };
+
+public:
+
+    /**
+    * - Item name:   Sampling time.
+    * - Item Index:  0
+    * - Conditions:  None
+    * - Description: Timestamp for a sample.
+    */   
+    TTime iTimeStamp;    
+
+    /**
+    * - Item name:   Magnetometer x-axis 
+    * - Item Index:  1
+    * - Conditions:  Single limit and range 
+    * - Description: Magnetometer values from x-axis 
+    */
+    TInt iAxisXRaw;
+
+    /**
+    * - Item name:   Magnetometer y-axis 
+    * - Item Index:  2
+    * - Conditions:  Single limit and range 
+    * - Description: Magnetometer values from y-axis 
+    */ 
+    TInt iAxisYRaw;
+
+    /**
+    * - Item name:   Magnetometer z-axis 
+    * - Item Index:  3
+    * - Conditions:  Single limit and range 
+    * - Description: Magnetometer values from z-axis 
+    */
+    TInt iAxisZRaw;
+    
+    /**
+    * - Item name:   Magnetometer x-axis 
+    * - Item Index:  1
+    * - Conditions:  Single limit and range 
+    * - Description: Magnetometer values from x-axis 
+    */
+    TInt iAxisXCalibrated;
+
+    /**
+    * - Item name:   Magnetometer y-axis 
+    * - Item Index:  2
+    * - Conditions:  Single limit and range 
+    * - Description: Magnetometer values from y-axis 
+    */ 
+    TInt iAxisYCalibrated;
+
+    /**
+    * - Item name:   Magnetometer z-axis 
+    * - Item Index:  3
+    * - Conditions:  Single limit and range 
+    * - Description: Magnetometer values from z-axis 
+    */
+    TInt iAxisZCalibrated;
+    };
+
+#endif //SSYREFERENCEMAGNETOMETER_H
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sensorsupport/testsensor/inc/ssyreferenceorientation.h	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,172 @@
+// ssyreferenceorientation.h
+
+/*
+* Copyright (c) 2008-2009 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+
+
+/**
+ @file
+ @internalAll Sensor framework Reference SSY header file
+ @test
+*/
+
+
+#ifndef SSYREFERENCEORIENTATION_H
+#define SSYREFERENCEORIENTATION_H
+
+//  INCLUDES
+#include <e32base.h>
+#include <sensors/sensrvtypes.h> 
+
+
+// ORIENTATION RELATED CHANNELS
+
+/**
+* - Name:          Orientation event channel type
+* - Type:          Event
+* - Datatype:      TSensrvOrientationData
+* - Description:   Orientation events
+*/
+const TSensrvChannelTypeId KSensrvChannelTypeIdOrientationData = 0x10205088; 
+
+/**
+* - Name:          Rotation event channel type
+* - Type:          Event
+* - Datatype:      TSensrvRotationData
+* - Description:   Rotation events
+*/
+const TSensrvChannelTypeId KSensrvChannelTypeIdRotationData = 0x10205089; 
+
+// ORIENTATION RELATED DATATYPES
+
+class TSensrvOrientationData
+    {
+public:
+    /**
+    * Channel data type Id number
+    */      
+    static const TSensrvChannelDataTypeId KDataTypeId = 0x10205088;
+
+    /**
+    * Channel data type index numbers
+    */
+    enum TSensrvOrientationEventIndexes
+        {
+        ETimeStamp = 0,
+        EDeviceOrientation
+        }; 
+
+    /**
+    * Possible device orientations
+    */
+    enum TSensrvDeviceOrientation
+        {
+	    EOrientationUndefined = 0,
+	    EOrientationDisplayUp,
+	    EOrientationDisplayDown,
+	    EOrientationDisplayLeftUp,
+	    EOrientationDisplayRightUp,
+	    EOrientationDisplayUpwards,
+	    EOrientationDisplayDownwards	
+        };
+        
+public:
+        
+    /**
+    * - Item name:   Sampling time
+    * - Item Index:  0
+    * - Description: Timestamp for a sample
+    */   
+    TTime iTimeStamp;
+
+    /**
+    * - Item name:   Device orientation
+    * - Item Index:  1
+    * - Description: Contains one of the six basic orientations of the device
+    */   
+    TSensrvDeviceOrientation iDeviceOrientation;    
+    };
+
+
+class TSensrvRotationData
+    {
+public:
+    /**
+    * Channel data type Id number
+    */      
+    static const TSensrvChannelDataTypeId KDataTypeId = 0x10205089;
+    
+    /**
+    * Rotation axis value equals -1 when it cannot be defined. 
+    * The undefined situation varies depending on the sensor type. 
+    * In the case of an accelerometer, the rotation value cannot be defined 
+    * when the corresponding axis is parallel to the gravitational force or
+    * the device is in motion. In the case of a magnetometer, there are
+    * difficulties in measuring values, when the axis is parallel to the
+    * magnetic field.
+    */
+    static const TInt KSensrvRotationUndefined = -1; 
+
+    /**
+    * Channel data type index numbers
+    */ 
+    enum TSensrvRotationDataIndexes
+        {
+        ETimeStamp = 0,          
+        EDeviceRotationAboutXAxis,
+        EDeviceRotationAboutYAxis,
+        EDeviceRotationAboutZAxis,
+        };
+
+public:
+    /**
+    * - Item name:   Sampling time.
+    * - Item Index:  0
+    * - Description: Timestamp for a sample
+    */   
+    TTime iTimeStamp;
+  
+    /**
+    * - Item name:   Rotation about x-axis
+    * - Item Index:  1 
+    * - Description: Positive rotation in Cartesian coordinate system about the x-axis.
+    *                If the value cannot be defined it is set to KSensrvRotationUndefined.
+    */   
+    TInt iDeviceRotationAboutXAxis;  
+
+    /**
+    * - Item name:   Rotation about y-axis
+    * - Item Index:  2
+    * - Description: Positive rotation in Cartesian coordinate system about the y-axis.
+    *                If the value cannot be defined it is set to KSensrvRotationUndefined.
+    */   
+    TInt iDeviceRotationAboutYAxis;  
+      
+
+    /**
+    * - Item name:   Rotation about z-axis
+    * - Item Index:  3 
+    * - Description: Positive rotation in Cartesian coordinate system about the z-axis.
+    *                If the value cannot be defined it is set to KSensrvRotationUndefined.
+    */   
+    TInt iDeviceRotationAboutZAxis;  
+    };
+
+#endif //SSYREFERENCEORIENTATION_H
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sensorsupport/testsensor/inc/ssyreferenceproximity.h	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,101 @@
+// ssyreferenceproximity.h
+
+/*
+* Copyright (c) 2008-2009 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+
+
+/**
+ @file
+ @internalAll Sensor framework Reference SSY header file
+ @test
+*/
+
+
+#ifndef SSYREFERENCEPROXIMITY_H
+#define SSYREFERENCEPROXIMITY_H
+
+//  INCLUDES
+#include <e32base.h>
+#include <sensors/sensrvtypes.h> 
+
+
+// PROXIMITY RELATED CHANNELS
+
+/**
+* - Name: Proximity data channel
+* - Type: Event
+* - Datatype: TSensrvProximityMonitorData
+* - Description: Proximity status 
+*/
+const TSensrvChannelTypeId KSensrvChannelTypeIdProximityMonitor = 0x2000E585;
+
+// PROXIMITY RELATED DATATYPES
+
+/**
+* Proximity monitoring data type
+*/
+class TSensrvProximityData
+	{
+public:
+	/**
+	* Channel data type Id number
+	*/ 
+	static const TSensrvChannelDataTypeId KDataTypeId = 0x2000E585;
+
+    /**
+    * Channel data type index numbers
+    */ 
+    enum TSensrvProximityDataIndexes
+        {
+        ETimeStamp = 0,
+        EState
+        };
+
+    /**
+    * Possible values for proximito state
+    */ 
+    enum TProximityState
+        {
+        EProximityUndefined = 0,
+        EProximityIndiscernible,
+        EProximityDiscernible
+        };
+
+public:
+
+    /**
+    * - Item name:   Sampling time.
+    * - Item Index:  0
+    * - Conditions:  None
+    * - Description: Timestamp for a sample.
+    */   
+    TTime iTimeStamp; 
+
+	/**
+    * - Item name: Proximity state
+    * - Item Index: 0
+    * - Conditions: None
+    * - Description: -
+    */ 
+    TProximityState iProximityState;
+
+};
+
+#endif //SSYREFERENCEPROXIMITY_H
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sensorsupport/testsensor/src/10205089.rss	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,80 @@
+// 10205089.rss
+
+// Copyright (c) 2006-2009 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"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+
+
+#include <sensors/spi/sensrvresource.hrh>
+#include <ecom/registryinfov2.rh>
+
+//  RESOURCE DEFINITIONS 
+// -----------------------------------------------------------------------------
+// 
+// Declares info for SSYReference ECom plugin
+//
+// -----------------------------------------------------------------------------
+
+RESOURCE REGISTRY_INFO SSYReferencePlugin
+    {
+    // UID for the DLL. See ssyreferenceplugin.mmp
+    resource_format_version = RESOURCE_FORMAT_VERSION_2;
+    dll_uid = 0x10205089;
+    interfaces = 
+        {
+        INTERFACE_INFO
+            {
+            // UID of interface that is implemented
+            interface_uid = KSsyControlInterfaceUid;
+            implementations = 
+                {
+                BINARY_IMPLEMENTATION_INFO
+                    {
+                    implementation_uid = 0x10205088;
+                    version_no         = 1;
+                    display_name       = "SSYReferencePlugin";
+                    default_data       = {
+                                         // Double tap channel
+                                         0x01, // ChannelInfoVersion
+                                         0x2E, //  ChannelInfoLength
+                                         0x1E, // Flags
+                                         0x81, 0x50, 0x20, 0x10, // ChannelType
+                                         0x02, 0x00, 0x00, 0x00, // ContextType
+                                         0x0B, 0x00, 0x00, 0x00, // Quantity
+                                         0x05, 0x4e, 0x6f, 0x4c, 0x6f, 0x63, // Location: NoLoc
+                                         0x0C, 0x53, 0x73, 0x79, 0x52, 0x65, 0x66, 0x56, 0x65, 0x6E, 0x64, 0x6F, 0x72, // VendorId: SsyRefVendor
+                                         0x7F, 0x50, 0x20, 0x10, // ChannelDataTypeId
+                                         0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // ChannelSecurityPolicy
+                                         
+                                         // Accelerometer channel
+                                         0x01, // ChannelInfoVersion
+                                         0x30, //  ChannelInfoLength
+                                         0x1E, // Flags
+                                         0x7E, 0x50, 0x20, 0x10, // ChannelType
+                                         0x02, 0x00, 0x00, 0x00, // ContextType
+                                         0x0A, 0x00, 0x00, 0x00, // Quantity
+                                         0x07, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x25, 0x64, // Location  
+                                         0x0C, 0x53, 0x73, 0x79, 0x52, 0x65, 0x66, 0x56, 0x65, 0x6E, 0x64, 0x6F, 0x72, // VendorId: SsyRefVendor
+                                         0x7E, 0x50, 0x20, 0x10, // ChannelDataTypeId
+                                         0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF // ChannelSecurityPolicy
+
+                                         };
+                    opaque_data        = {};
+                    }
+                };
+            }
+        };
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sensorsupport/testsensor/src/ecomentrypoint.cpp	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,40 @@
+// ecomentrypoint.cpp
+
+// Copyright (c) 2006-2009 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"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+
+
+
+// INCLUDE FILES
+#include <e32std.h>
+#include <ecom/implementationproxy.h>
+#include "ssyreferencecontrol.h"
+
+// Define the interface UIDs
+const TImplementationProxy ImplementationTable[] =
+    {
+    IMPLEMENTATION_PROXY_ENTRY( 0x10205088,
+                                CSsyReferenceControl::NewL )
+    };
+
+// The one and only exported function that is the ECom entry point
+EXPORT_C const TImplementationProxy* ImplementationGroupProxy
+        (TInt& aTableCount)
+    {
+    aTableCount = sizeof( ImplementationTable ) / sizeof( TImplementationProxy );
+
+    return ImplementationTable;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sensorsupport/testsensor/src/ssyreferencechannel.cpp	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,443 @@
+// ssyreferencechannel.cpp
+
+// Copyright (c) 2006-2009 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"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+
+
+#include <sensors/spi/ssycallback.h>                     // MSsyCallback
+#include "ssyreferencechannel.h"
+#include "ssyreferencecontrol.h"             // SSY Control
+#include "ssyreferencepropertyprovider.h"    // iChannelPropertyProvider
+#include "ssyreferencechanneldataprovider.h" // iChannelDataProvider
+#include "ssyreferencetrace.h"
+#include "ssyreferencecmdhandler.h"
+
+
+// ======== MEMBER FUNCTIONS ========
+
+// ---------------------------------------------------------------------------
+// CSsyReferenceChannel C++ constructor
+// ---------------------------------------------------------------------------
+//
+CSsyReferenceChannel::CSsyReferenceChannel( CSsyReferenceControl& aSsyControl, TSensrvChannelInfo aChannelInfo ) :
+    iSsyControl( aSsyControl ),
+    iChannelInfo( aChannelInfo ),
+    iState( ESsyReferenceChannelIdle )
+    {
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceChannel::CSsyReferenceChannel()" ) ) );
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceChannel::CSsyReferenceChannel() - return" ) ) );
+    }
+
+
+// ---------------------------------------------------------------------------
+// Symbian 2nd phase constructor
+// ---------------------------------------------------------------------------
+//
+void CSsyReferenceChannel::ConstructL()
+    {
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceChannel::ConstructL()" ) ) );
+
+    // Create command handler
+    iCmdHandler = CSsyReferenceCmdHandler::NewL( *this );
+    
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceChannel::ConstructL() - return" ) ) );
+    }
+
+// ---------------------------------------------------------------------------
+// CSsyReferenceChannel::NewL
+// ---------------------------------------------------------------------------
+//
+CSsyReferenceChannel* CSsyReferenceChannel::NewL( CSsyReferenceControl& aSsyControl, TSensrvChannelInfo aChannelInfo )
+    {
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceChannel::NewL()" ) ) );
+    CSsyReferenceChannel* self = new ( ELeave ) CSsyReferenceChannel( aSsyControl, aChannelInfo );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceChannel::NewL() - return" ) ) );
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// Destructor
+// ---------------------------------------------------------------------------
+//
+CSsyReferenceChannel::~CSsyReferenceChannel()
+    {
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceChannel::~CSsyReferenceChannel()" ) ) );
+
+    // In case channel is not closed before destruction, providers are not deleted
+    if ( iChannelDataProvider )
+        {
+        delete iChannelDataProvider;
+        iChannelDataProvider = NULL;
+        }
+    
+    if ( iChannelPropertyProvider )
+        {
+        delete iChannelPropertyProvider;
+        iChannelPropertyProvider = NULL;
+        }
+
+    if ( iCmdHandler )
+        {
+        delete iCmdHandler;
+        iCmdHandler = NULL;
+        }
+
+    iProperties.Reset();
+    
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceChannel::~CSsyReferenceChannel() - return" ) ) );
+    }
+
+// ---------------------------------------------------------------------------
+// CSsyReferenceChannel::ChannelId
+// ---------------------------------------------------------------------------
+//
+TInt CSsyReferenceChannel::ChannelId()
+    {
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceChannel::ChannelId() - %i" ), iChannelInfo.iChannelId ) );
+    return iChannelInfo.iChannelId;
+    }
+
+// ---------------------------------------------------------------------------
+// CSsyReferenceChannel::SsyControl
+// ---------------------------------------------------------------------------
+//
+CSsyReferenceControl& CSsyReferenceChannel::SsyControl() const
+    {
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceChannel::SsyControl()" ) ) );
+    return iSsyControl;
+    }
+
+// ---------------------------------------------------------------------------
+// CSsyReferenceControl::SsyCmdHandler
+// ---------------------------------------------------------------------------
+//
+CSsyReferenceCmdHandler& CSsyReferenceChannel::CommandHandler() const
+    {
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceChannel::SsyCmdHandler()" ) ) );
+    return *iCmdHandler;
+    }
+
+// ---------------------------------------------------------------------------
+// CSsyReferenceChannel::FindPropertyL
+// ---------------------------------------------------------------------------
+//
+TSensrvProperty& CSsyReferenceChannel::FindPropertyL( 
+    const TSensrvPropertyId aPropertyId, 
+    TInt aItemIndex,
+    TInt aArrayIndex )
+    {
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceChannel::FindPropertyL()" ) ) );
+    TSensrvProperty* property = NULL;
+    TBool propertyFound( EFalse );
+
+    // Search property
+    for ( TInt i = 0; i < iProperties.Count() && !propertyFound; i++ )
+        {
+        property = static_cast<TSensrvProperty*>( &iProperties[i] );
+
+        // Compare property IDs and array index
+        if ( property->GetPropertyId() == aPropertyId )
+            {
+            // Compare item index if it is given
+            if ( ( KErrNotFound == aItemIndex ) || ( property->PropertyItemIndex() == aItemIndex ) )
+                {
+                // Correct property ID is found, now check is it array type of property.
+                // Either array indexes must match or propertys array index has to be array info
+                if ( ( property->GetArrayIndex() == aArrayIndex ) || 
+                     ( ( property->GetArrayIndex() == ESensrvArrayPropertyInfo ) && 
+                       ( ESensrvSingleProperty == aArrayIndex ) ) )
+                    {
+                    // Correct array index found
+                    propertyFound = ETrue;    
+                    }
+                }
+            }
+        }
+
+    // Leave if not found
+    if ( !propertyFound )
+        {
+        iSsyControl.FindPropertyL( aPropertyId, aArrayIndex, *property );
+        }
+
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceChannel::FindPropertyL() - return" ) ) );
+    return *property;
+    }
+
+// ---------------------------------------------------------------------------
+// CSsyReferenceChannel::FindAndUpdatePropertyL
+// ---------------------------------------------------------------------------
+//
+void CSsyReferenceChannel::FindAndUpdatePropertyL( const TSensrvProperty& aProperty )
+    {
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceChannel::FindAndUpdatePropertyL()" ) ) );
+    TBool propertyFound( EFalse );
+
+    // Search property
+    for ( TInt i = 0; i < iProperties.Count() && !propertyFound; i++ )
+        {
+        // Compare property IDs
+        if ( iProperties[i].GetPropertyId() == aProperty.GetPropertyId() )
+            {
+            // Compare item index if it is given
+            if ( ( KErrNotFound != aProperty.PropertyItemIndex() ) && 
+                 ( iProperties[i].PropertyItemIndex() == aProperty.PropertyItemIndex() ) )
+                {
+                // Property found -> update if possible
+                if ( iProperties[i].ReadOnly() )
+                    {
+                    User::Leave( KErrAccessDenied );
+                    }
+                // If modifiable, get type and update value
+                switch ( iProperties[i].PropertyType() )
+                    {
+                    case ESensrvIntProperty:
+                        {
+                        TInt value( 0 );
+                        aProperty.GetValue( value );
+                        iProperties[i].SetValue( value );
+                        break;
+                        }
+                    case ESensrvRealProperty:
+                        {
+                        TReal value( 0 );
+                        aProperty.GetValue( value );
+                        iProperties[i].SetValue( (TReal) value );
+                        break;
+                        }
+                    case ESensrvBufferProperty:
+                        {
+                        TBuf8<20> propValue;
+                        aProperty.GetValue( propValue );
+                        iProperties[i].SetValue( propValue );
+                        break;
+                        }
+                    default:
+                        {
+                        break;
+                        }
+                    }
+                propertyFound = ETrue;
+                }
+            }
+        }
+
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceChannel::FindPropertyL() - return" ) ) );
+    }
+
+// ---------------------------------------------------------------------------
+// CSsyReferenceChannel::GetProperties
+// ---------------------------------------------------------------------------
+//
+void CSsyReferenceChannel::GetProperties( RSensrvPropertyList& aPropertyList )
+    {
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceChannel::GetProperties()" ) ) );
+    // Copy properties one by one to param aPropertyList
+    TInt propCount( iProperties.Count() );
+    RSensrvPropertyList propList( propCount );
+
+    for ( TInt i = 0; i < propCount; i++ )
+        {
+        propList.Append( iProperties[i] );
+        }
+
+    aPropertyList = propList;
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceChannel::GetProperties() - return" ) ) );
+    }
+
+// ---------------------------------------------------------------------------
+// CSsyReferenceChannel::UpdateState
+// ---------------------------------------------------------------------------
+//
+void CSsyReferenceChannel::UpdateState( const TSsyReferenceChannelState aNewState )
+    {
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceChannel::UpdateState() - %i" ), aNewState ) );
+    iState = aNewState;
+    }
+
+// ---------------------------------------------------------------------------
+// CSsyReferenceChannel::ProcessResponse
+// ---------------------------------------------------------------------------
+//
+void CSsyReferenceChannel::ProcessResponse( TSsyReferenceMsg* aMessage )
+    {
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceChannel::ProcessResponse()" ) ) );
+    
+    if ( aMessage ) 
+        {
+        switch ( aMessage->Function() )
+            {
+            case ESsyReferenceOpenChannelResp:
+                {
+                // Open channel specific handling here
+                TRAPD( err, HandleOpenChannelRespL( aMessage->Error() ) );
+                if ( KErrNone != err )
+                    {
+                    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceChannel::ProcessResponse() - Error opening channel: %i" ), err ) );
+                    }
+                break;
+                }
+            case ESsyReferenceDataItemReceived:
+                {
+                // Send data item to data provider
+                TRAPD( err, iChannelDataProvider->ChannelDataReceivedL( aMessage ) );
+                if ( KErrNone != err )
+                    {
+                    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceChannel::ProcessResponse() - Error receiving data: %i" ), err ) );
+                    }
+                break;  
+                }
+            case ESsyReferenceCloseChannelResp:
+                {
+                // Close channel specific handling here
+                HandleCloseChannelResp();
+                break;  
+                }
+            default:
+                {
+                // This command was not intended to process here, try Control class
+                iSsyControl.ProcessResponse( aMessage );    
+                COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceChannel::ProcessResponse() - Unknown function" ) ) );
+                }
+            }
+        }
+
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceChannel::ProcessResponse() - return" ) ) );
+    }
+
+// ---------------------------------------------------------------------------
+// CSsyReferenceChannel::OpenChannel
+// ---------------------------------------------------------------------------
+//
+TInt CSsyReferenceChannel::OpenChannel()
+    {
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceChannel::OpenChannel()" ) ) );
+
+    TInt err( KErrAlreadyExists );
+
+    // Check that this channel is not already open
+    if ( ESsyReferenceChannelIdle == iState )
+        {
+        // Update state and issue request. Will continue in HandleOpenChannelResp
+        UpdateState( ESsyReferenceChannelOpening );
+
+        // Create message with function spesific information
+        // and pass it to command handler
+        err = iCmdHandler->ProcessCommand( TSsyReferenceMsg( ChannelId(), ESsyReferenceOpenChannel ) );
+        }
+
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceChannel::OpenChannel() - return" ) ) );
+    return err;
+    }
+
+// ---------------------------------------------------------------------------
+// CSsyReferenceChannel::HandleOpenChannelResp
+// ---------------------------------------------------------------------------
+//
+void CSsyReferenceChannel::HandleOpenChannelRespL( const TInt aError )
+    {
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceChannel::HandleOpenChannelResp()" ) ) );
+
+    // Open channel asynhronously and complete request with MSsyCallback::ChannelOpened() when
+    // channel is opened.
+
+    // Create instance of the data provider of this channel
+    iChannelDataProvider = CSsyReferenceChannelDataProvider::NewL( *this );
+    // Create instance of the property provider of this channel
+    iChannelPropertyProvider = CSsyReferencePropertyProvider::NewL( *this );
+
+    TInt error( aError );
+
+    // If channel opening succeeds, update state to Open
+    if ( KErrNone == aError )
+        {
+        // Update state to Open
+        UpdateState( ESsyReferenceChannelOpen );
+        // Get channel properties
+        TRAP( error, iSsyControl.SsyConfig().GetChannelPropertiesL( ChannelId(), iProperties ) );
+        }
+    else
+        {
+        // Channel opening failed, back to idle
+        UpdateState( ESsyReferenceChannelIdle ); 
+        }
+
+    // Complete transaction
+    iSsyControl.SsyCallback().ChannelOpened( ChannelId(),
+                                error,
+                                iChannelDataProvider,
+                                iChannelPropertyProvider );
+
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceChannel::HandleOpenChannelResp() - return" ) ) );
+    }
+
+// ---------------------------------------------------------------------------
+// CSsyReferenceChannel::CloseChannel
+// ---------------------------------------------------------------------------
+//
+TInt CSsyReferenceChannel::CloseChannel()
+    {
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceChannel::CloseChannel()" ) ) );
+
+    TInt err( KErrNotFound );
+
+    // Check that this channel is open
+    if ( ESsyReferenceChannelOpen == iState )
+        {
+        // Update state and issue request. Will continue in HandleCloseChannelResp
+        UpdateState( ESsyReferenceChannelClosing );
+        // Create message with function spesific information
+        // and pass it to command handler
+        err = iCmdHandler->ProcessCommand( TSsyReferenceMsg( ChannelId(), ESsyReferenceCloseChannel ) );
+        }
+
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceChannel::CloseChannel() - return" ) ) );
+    return err;
+    }
+
+// ---------------------------------------------------------------------------
+// CSsyReferenceChannel::HandleCloseChannelResp
+// ---------------------------------------------------------------------------
+//
+void CSsyReferenceChannel::HandleCloseChannelResp()
+    {
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceChannel::HandleCloseChannelResp()" ) ) );
+
+    // Close channel and complete request with MSsyCallback::ChannelClosed() when
+    // channel is closed.
+
+    // Delete providers
+    delete iChannelDataProvider;
+    iChannelDataProvider = NULL;
+
+    delete iChannelPropertyProvider;
+    iChannelPropertyProvider = NULL;
+
+    // Update state to idle
+    UpdateState( ESsyReferenceChannelIdle );
+
+    // Reset properties
+    iProperties.Reset();
+
+    // Complete transaction
+    iSsyControl.SsyCallback().ChannelClosed( ChannelId() );
+
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceChannel::HandleCloseChannelResp() - return" ) ) );
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sensorsupport/testsensor/src/ssyreferencechannel.h	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,228 @@
+// ssyreferencechannel.h
+
+/*
+* Copyright (c) 2006-2009 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+
+
+/**
+ @file
+ @internalComponent
+*/
+
+#ifndef SSYREFERENCECHANNEL_H
+#define SSYREFERENCECHANNEL_H
+
+#include <e32base.h>
+#include <sensors/sensrvtypes.h>
+#include "ssyreferenceconfig.h"
+
+class CSsyReferenceControl;
+class CSsyReferenceChannelDataProvider;
+class CSsyReferencePropertyProvider;
+class CSsyReferenceCmdHandler;
+
+/**
+ *  Main control class for SSY. Controls sensor basic functionality and provides mandatory 
+ *  ECOM interface specific things.
+ */
+class CSsyReferenceChannel : public CBase
+    {
+
+public:
+
+    /**
+     * Enumeration of the state of this channel
+     */
+    enum TSsyReferenceChannelState
+        {
+        ESsyReferenceChannelIdle,      // Channel created, not opened
+        ESsyReferenceChannelOpening,   // Processing channel opening
+        ESsyReferenceChannelOpen,      // Channel is open
+        ESsyReferenceChannelReceiving, // Channel is receiving data
+        ESsyReferenceChannelClosing    // Processing channel closing. After this state is idle
+        };
+
+public:
+
+    /**
+     * Two-phase constructor
+     *
+     * @param[in] aSsyControl Reference to SSY control instance.
+     * @param[in] aChannelInfo Information of this channel
+     * @return Pointer to created CSsyReferenceControl object
+     */
+    static CSsyReferenceChannel* NewL( CSsyReferenceControl& aSsyControl, TSensrvChannelInfo aChannelInfo );
+
+    /**
+     * Virtual destructor
+     */
+    virtual ~CSsyReferenceChannel();
+
+    /**
+     * Request for SSY to open a sensor channel asynchronously. 
+     * Response to the request is delivered through MSsyCallback::ChannelOpened().
+     * Initilizes SSY (and the sensor) to be ready for other control commands via
+     * data and property providers. Multiple OpenChannel()-requests can be
+     * active for different channels at the same time.
+     *
+     * @return Symbian error code
+     */
+    TInt OpenChannel();
+
+    /**
+     * Request to close a sensor channel asynchronously. 
+     * Response to the request is delivered through MSsyCallback::ChannelClosed().
+     * Multiple CloseChannel()-requests can be active for different channels 
+     * at the same time.
+     *
+     * @return Symbian error code
+     */  
+    TInt CloseChannel();
+
+    /**
+     * Returns ID of this channel
+     */
+    TInt ChannelId();
+
+    /**
+     * Handles response directed to this channel
+     *
+     * @param[in] aMessage Contains information of the response
+     */
+    void ProcessResponse( TSsyReferenceMsg* aMessage );
+
+    /**
+     * Updates the state of this channel
+     * 
+     * @param[in] aNewState State to update this channel
+     */
+    void UpdateState( const TSsyReferenceChannelState aNewState );
+
+    /**
+     * Reference to SsyControl
+     */
+    CSsyReferenceControl& SsyControl() const;
+
+    /**
+     * Reference to command handler
+     */
+    CSsyReferenceCmdHandler& CommandHandler() const;
+
+    /**
+     * Search property of given property id from the channel properties and 
+     * returns reference to that. Leaves with KErrNotFound if property is not found
+     *
+     * @param[in] aPropertyId Property ID to locate
+     * @param[in] aItemIndex Item index if this search conserns specific property
+     * @param[in] aArrayIndex Indicates array index of property
+     */
+    TSensrvProperty& FindPropertyL( const TSensrvPropertyId aPropertyId,
+                                    TInt aItemIndex = KErrNotFound,
+                                    TInt aArrayIndex = ESensrvSingleProperty );
+
+    /**
+     * Search property of given property id from the channel properties and 
+     * update property values, if not read only
+     *
+     * @param[in] aProperty Property to find and update
+     */
+    void FindAndUpdatePropertyL( const TSensrvProperty& aProperty );
+    
+
+    /**
+     * Copies properties to param PropertyList
+     *
+     * @param[in, out] aPropertyList List where to copy properties
+     */
+    void GetProperties( RSensrvPropertyList& aPropertyList );
+
+private:
+
+    /**
+     * C++ constructor.
+     *
+     * @param[in] aSsyControl Reference to SSY Control instance.
+     * @param[in] aChannelInfo Information of this channel
+     */
+    CSsyReferenceChannel( CSsyReferenceControl& aSsyControl, TSensrvChannelInfo aChannelInfo );
+
+    /**
+     * Symbian 2nd phase constructor.
+     */
+    void ConstructL();
+
+    /**
+     * Handles response for OpenChannel and completes transaction by calling 
+     * MSsyCallback::ChannelOpened
+     *
+     * @param[in] aError Error code indicating the channel opening status
+     */
+    void HandleOpenChannelRespL( const TInt aError );
+
+    /**
+     * Handles response for CloseChannel and completes transaction by calling 
+     * MSsyCallback::ChannelClosed
+     */
+    void HandleCloseChannelResp();
+
+    /**
+     * Handles response for StartChannelData. Loops all channel data items and sends 
+     * each item to ChannelDataProvider
+     */
+    void HandleDataReceivedResp();
+
+private: // data
+
+    /**
+     * Reference to SSY Control to send responses to Sensor Server
+     */
+    CSsyReferenceControl& iSsyControl;
+
+    /**
+     * Pointer to CSsyReferenceChannelDataProvider owned by this channel
+     */
+    CSsyReferenceChannelDataProvider* iChannelDataProvider;
+
+    /**
+     * Pointer to CSsyReferencePropertyProvider owned by this channel
+     */
+    CSsyReferencePropertyProvider* iChannelPropertyProvider;
+
+    /**
+     * Pointer to command handler
+     */
+    CSsyReferenceCmdHandler* iCmdHandler;
+
+    /**
+     * Information of this channel
+     */
+    TSensrvChannelInfo iChannelInfo;
+
+    /**
+     * State of this channel. See CSsyReferenceChannel::TSsyReferenceChannelState
+     */
+    TInt iState;
+
+    /**
+     * Property list of this channel
+     */
+    RSensrvPropertyList iProperties;
+    };
+
+#endif // SSYREFERENCECHANNEL_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sensorsupport/testsensor/src/ssyreferencechanneldataprovider.cpp	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,269 @@
+// ssyreferencechanneldataprovider.cpp
+
+// Copyright (c) 2006-2009 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"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+
+
+#include "ssyreferencechanneldataprovider.h"
+#include "ssyreferencetrace.h"
+#include "ssyreferencechannel.h"
+#include "ssyreferencecontrol.h"
+#include "ssyreferencecmdhandler.h"
+#include <sensors/spi/ssycallback.h>
+
+// ======== MEMBER FUNCTIONS ========
+
+// ---------------------------------------------------------------------------
+// CSsyReferenceChannelDataProvider C++ constructor
+// ---------------------------------------------------------------------------
+//
+CSsyReferenceChannelDataProvider::CSsyReferenceChannelDataProvider( CSsyReferenceChannel& aChannel ) :
+    iChannel( aChannel )
+    {
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceChannelDataProvider::CSsyReferenceChannelDataProvider()" ) ) );
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceChannelDataProvider::CSsyReferenceChannelDataProvider() - return" ) ) );
+    }
+
+
+// ---------------------------------------------------------------------------
+// Symbian 2nd phase constructor
+// ---------------------------------------------------------------------------
+//
+void CSsyReferenceChannelDataProvider::ConstructL()
+    {
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceChannelDataProvider::ConstructL()" ) ) );
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceChannelDataProvider::ConstructL() - return" ) ) );
+    }
+
+
+// ---------------------------------------------------------------------------
+// CSsyReferenceChannelDataProvider::NewL
+// ---------------------------------------------------------------------------
+//
+CSsyReferenceChannelDataProvider* CSsyReferenceChannelDataProvider::NewL( CSsyReferenceChannel& aChannel )
+    {
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceChannelDataProvider::NewL()" ) ) );
+    CSsyReferenceChannelDataProvider* self = new ( ELeave ) CSsyReferenceChannelDataProvider( aChannel );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceChannelDataProvider::NewL() - return" ) ) );
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// Destructor
+// ---------------------------------------------------------------------------
+//
+CSsyReferenceChannelDataProvider::~CSsyReferenceChannelDataProvider()
+    {
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceChannelDataProvider::~CSsyReferenceChannelDataProvider()" ) ) );
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceChannelDataProvider::~CSsyReferenceChannelDataProvider() - return" ) ) );
+    }
+
+// ---------------------------------------------------------------------------
+// CSsyReferenceChannelDataProvider::StartChannelDataL
+// ---------------------------------------------------------------------------
+//
+void CSsyReferenceChannelDataProvider::StartChannelDataL( 
+    const TSensrvChannelId aChannelId, 
+    TUint8* aBuffer, 
+    TInt aCount )
+    {
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceChannelDataProvider::StartChannelDataL()" ) ) );
+
+    if ( iChannel.ChannelId() != aChannelId )
+        {
+        User::Leave( KErrNotFound );
+        }
+
+    // Store buffer pointer
+    iDataBuffer = aBuffer;
+    iMaxCount = aCount;
+    iDataCount = 0;
+
+    // Udpate channel state
+    iChannel.UpdateState( CSsyReferenceChannel::ESsyReferenceChannelReceiving );
+
+    // Start receiving
+    iChannel.CommandHandler().ProcessCommand( TSsyReferenceMsg( aChannelId, ESsyReferenceStartChannelData ) );
+
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceChannelDataProvider::StartChannelDataL() - return" ) ) );
+    }
+
+// ---------------------------------------------------------------------------
+// CSsyReferenceChannelDataProvider::StopChannelDataL
+// ---------------------------------------------------------------------------
+//
+void CSsyReferenceChannelDataProvider::StopChannelDataL( const TSensrvChannelId aChannelId )
+    {
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceChannelDataProvider::StopChannelDataL()" ) ) );
+
+    // Leave if wrong channel
+    if ( iChannel.ChannelId() != aChannelId )
+        {
+        User::Leave( KErrNotFound );
+        }
+
+    // Udpate channel state
+    iChannel.UpdateState( CSsyReferenceChannel::ESsyReferenceChannelOpen );
+
+    // Stop receiving
+    iChannel.CommandHandler().ProcessCommand( TSsyReferenceMsg( aChannelId, ESsyReferenceStopChannelData ) );
+
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceChannelDataProvider::StopChannelDataL() - return" ) ) );
+    }
+
+// ---------------------------------------------------------------------------
+// CSsyReferenceChannelDataProvider::ForceBufferFilledL
+// ---------------------------------------------------------------------------
+//
+void CSsyReferenceChannelDataProvider::ForceBufferFilledL( const TSensrvChannelId aChannelId )
+    {
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceChannelDataProvider::ForceBufferFilledL()" ) ) );
+
+    // Leave if wrong channel
+    if ( iChannel.ChannelId() != aChannelId )
+        {
+        User::Leave( KErrNotFound );
+        }
+
+    // Send current buffer. Channel keeps receiveing
+    SendBufferFilled();
+
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceChannelDataProvider::ForceBufferFilledL() - return" ) ) );
+    }
+
+// -----------------------------------------------------------------------------
+// CSensrvTestCases::GetChannelDataProviderInterfaceL
+// -----------------------------------------------------------------------------
+//
+void CSsyReferenceChannelDataProvider::GetChannelDataProviderInterfaceL( TUid /*aInterfaceUid*/, 
+	                                        TAny*& aInterface )
+    {
+    aInterface = NULL;
+    }
+    
+// ---------------------------------------------------------------------------
+// CSsyReferenceChannelDataProvider::ChannelDataReceived
+// ---------------------------------------------------------------------------
+//
+void CSsyReferenceChannelDataProvider::ChannelDataReceivedL( TSsyReferenceMsg* aMessage )
+    {
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceChannelDataProvider::ChannelDataReceived()" ) ) );
+    
+    // Get base class from message
+    TSsyRefChannelDataBase* dataItemBase = aMessage->DataItem();
+
+    if ( !dataItemBase )
+        {
+        User::Leave( KErrArgument );
+        }
+
+    // get size of the object
+    TInt size( dataItemBase->Size() );
+
+    // First, resolve data item type
+    switch ( dataItemBase->ChannelDataType() )
+        {
+        case TSsyRefChannelDataBase::ESsyRefChannelTypeTapping:
+            {
+            // Cast data item base to tapping data item
+            TSsyRefChannelDataTapping* tappingData = static_cast<TSsyRefChannelDataTapping*>( dataItemBase );
+            TSensrvTappingData senSrvTapping;
+            senSrvTapping.iTimeStamp = tappingData->Timestamp();
+            senSrvTapping.iDirection = tappingData->Direction();
+
+            // Add mapped data item into buffer
+            AddDataToBuffer( reinterpret_cast<TUint8*>( &senSrvTapping ), size );
+            break;
+            }
+        case TSsyRefChannelDataBase::ESsyRefChannelTypeAxis:
+            {
+            // Cast data item base to Axis data item
+            TSsyRefChannelDataAxis* axisData = static_cast<TSsyRefChannelDataAxis*>( dataItemBase );
+            TSensrvAccelerometerAxisData senSrvAxis;
+            senSrvAxis.iTimeStamp = axisData->Timestamp();
+            senSrvAxis.iAxisX = axisData->XAxis();
+            senSrvAxis.iAxisY = axisData->YAxis();
+            senSrvAxis.iAxisZ = axisData->ZAxis();
+            
+            // Add data to buffer
+            AddDataToBuffer( reinterpret_cast<TUint8*>( &senSrvAxis ), size );
+            break;
+            }
+        case TSsyRefChannelDataBase::ESsyRefChannelTypeProximity:
+            {
+            // Cast data item base to tapping data item
+            TSsyRefChannelDataProximity* proximityData = static_cast<TSsyRefChannelDataProximity*>( dataItemBase );
+            TSensrvProximityData senSrvProximity;
+            senSrvProximity.iProximityState = ( TSensrvProximityData::TProximityState ) proximityData->ProximityState();
+
+            // Add mapped data item into buffer
+            AddDataToBuffer( reinterpret_cast<TUint8*>( &senSrvProximity ), size );
+            break;
+            }
+        default:
+            {
+            // Unknown data item -> Leave
+            User::Leave( KErrUnknown );
+            }
+        }
+    
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceChannelDataProvider::ChannelDataReceived() - return" ) ) );
+    }
+
+// ---------------------------------------------------------------------------
+// CSsyReferenceChannelDataProvider::AddDataToBuffer
+// ---------------------------------------------------------------------------
+//
+void CSsyReferenceChannelDataProvider::AddDataToBuffer( TUint8* aData, const TInt aSize )
+    {
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceChannelDataProvider::AddDataToBuffer()" ) ) );
+    // Write data to buffer. If buffer is full, send notification to SensorServer
+
+    // Write data bytes one by one to buffer pointer. The actual buffer is in Sensor Server    
+    for ( TInt i = 0; i < aSize; i++ )
+        {
+        *iDataBuffer++ = *aData++;
+        }
+    
+    // Increase number of items count
+    iDataCount++;
+
+    // Check is maximum data count received
+    if ( iDataCount == iMaxCount )
+        {
+        // Send BufferFilled notification to Sensor server
+        SendBufferFilled();
+        }
+
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceChannelDataProvider::AddDataToBuffer() - return" ) ) );
+    }
+
+// ---------------------------------------------------------------------------
+// CSsyReferenceChannelDataProvider::SendBufferFilled
+// ---------------------------------------------------------------------------
+//
+void CSsyReferenceChannelDataProvider::SendBufferFilled()
+    {
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceChannelDataProvider::SendBufferFilled()" ) ) );
+    // Send BufferFilled notification to Sensor server
+    iChannel.SsyControl().SsyCallback().BufferFilled( iChannel.ChannelId(), iDataCount, iDataBuffer, iMaxCount );
+    iDataCount = 0;
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceChannelDataProvider::SendBufferFilled() - return" ) ) );
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sensorsupport/testsensor/src/ssyreferencechanneldataprovider.h	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,149 @@
+// ssyreferencechanneldataprovider.h
+
+/*
+* Copyright (c) 2006-2009 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+
+
+/**
+ @file
+ @internalComponent
+*/
+
+#ifndef SSYREFERENCECHANNELDATAPROVIDER_H
+#define SSYREFERENCECHANNELDATAPROVIDER_H
+
+#include <sensors/spi/ssychanneldataprovider.h>
+
+class CSsyReferenceChannel;
+class TSsyReferenceMsg;
+
+/**
+ *  Channel data provider implementation.
+ */
+class CSsyReferenceChannelDataProvider : public CBase, public MSsyChannelDataProvider
+    {
+
+public:
+
+    /**
+     * Two-phase constructor
+     *
+     * @param[in] aChannel Reference to channel this provider belongs to
+     * @return Pointer to created CSsyReferenceControl object
+     */
+    static CSsyReferenceChannelDataProvider* NewL( CSsyReferenceChannel& aChannel );
+
+    /**
+     * Virtual destructor
+     */
+    virtual ~CSsyReferenceChannelDataProvider();
+
+// from base class MSsyChannelDataProvider
+
+    /**
+     * From MSsyChannelDataProvider
+     * Starts asynchronous data listening. Multiple OpenChannel()-requests
+     * can be active for different channels at the same time.
+     *
+     * @param[in] aBuffer Pointer to a data buffer 
+     * @param[in] aCount Indicates data buffer size as a count of the data objects.
+     */
+    void StartChannelDataL( const TSensrvChannelId aChannelId, TUint8* aBuffer, TInt aCount );
+
+    /**
+     * From MSsyChannelDataProvider
+     * Stops asynchronous data listening. The data buffer is not valid after call of 
+     * this function.
+     */
+    void StopChannelDataL( const TSensrvChannelId aChannelId );
+
+    /**
+     * From MSsyChannelDataProvider
+     * Forces SSY to call BufferFilled() regardless of how many data items have been
+     * written to buffer. Even if no data items have yet been written, BufferFilled()
+     * must be called.
+     */
+    void ForceBufferFilledL( const TSensrvChannelId aChannelId );
+
+    /** 
+    * Returns a pointer to a specified interface - to allow future extension
+    * of this class without breaking binary compatibility
+    *
+    * @param aInterfaceUid Identifier of the interface to be retrieved
+    * @param aInterface A reference to a pointer that retrieves the specified interface.
+    */
+    void GetChannelDataProviderInterfaceL( TUid aInterfaceUid, TAny*& aInterface );
+
+    /**
+     * Channel data item received
+     *
+     * @param[in] aMessage Contains channel item
+     */
+    void ChannelDataReceivedL( TSsyReferenceMsg* aMessage );
+
+private:
+
+    /**
+     * C++ constructor.
+     * @param[in] aChannel Reference to channel this provider belongs to
+     */
+    CSsyReferenceChannelDataProvider( CSsyReferenceChannel& aChannel );
+
+    /**
+     * Symbian 2nd phase constructor.
+     */
+    void ConstructL();
+
+    /**
+     * Adds data into buffer. 
+     *
+     *@param[in] aData Data to add to buffer
+     *@param[in] aSize Size of data
+     */
+    void AddDataToBuffer( TUint8* aData, const TInt aSize );
+
+    /**
+     * Sends BufferFilled notification to MSsyCallback
+     */
+    void SendBufferFilled();
+
+private: // data
+
+    /**
+     * Reference to channel for which this provider belongs to
+     */
+    CSsyReferenceChannel& iChannel;
+
+    /**
+     * Pointer to data buffer in Sensor Server side
+     */
+    TUint8* iDataBuffer;
+
+    /**
+     * Maximum requested data items
+     */
+    TInt iMaxCount;
+
+    /**
+     * Number of items in buffer
+     */
+    TInt iDataCount;
+    };
+
+#endif // SSYREFERENCECHANNELDATAPROVIDER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sensorsupport/testsensor/src/ssyreferencecmdhandler.cpp	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,367 @@
+// ssyreferencecmdhandler.cpp
+
+// Copyright (c) 2006-2009 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"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+
+
+#include <e32property.h>
+#include "ssyreferencecmdhandler.h"
+#include "ssyreferencecontrol.h"
+#include "ssyreferencechannel.h"
+#include "ssyreferencetrace.h"
+
+// ======== CONSTANTS ========
+const TInt KSsyRefShortDelay = 100; 
+
+// ======== MEMBER FUNCTIONS ========
+
+// ---------------------------------------------------------------------------
+// CSsyReferenceCmdHandler C++ constructor
+// ---------------------------------------------------------------------------
+//
+CSsyReferenceCmdHandler::CSsyReferenceCmdHandler( CSsyReferenceChannel& aSsyChannel ) :
+    CActive( EPriorityNormal ),
+    iSsyChannel( aSsyChannel )
+    {
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceCmdHandler::CSsyReferenceCmdHandler()" ) ) );
+    CActiveScheduler::Add( this );
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceCmdHandler::CSsyReferenceCmdHandler() - return" ) ) );
+    }
+
+
+// ---------------------------------------------------------------------------
+// Symbian 2nd phase constructor
+// ---------------------------------------------------------------------------
+//
+void CSsyReferenceCmdHandler::ConstructL()
+    {
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceCmdHandler::ConstructL()" ) ) );
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceCmdHandler::ConstructL() - return" ) ) );
+    }
+
+
+// ---------------------------------------------------------------------------
+// CSsyReferenceCmdHandler::NewL
+// ---------------------------------------------------------------------------
+//
+CSsyReferenceCmdHandler* CSsyReferenceCmdHandler::NewL( CSsyReferenceChannel& aSsyChannel )
+    {
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceCmdHandler::NewL()" ) ) );
+    CSsyReferenceCmdHandler* self = new ( ELeave ) CSsyReferenceCmdHandler( aSsyChannel );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceCmdHandler::NewL() - return" ) ) );
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// Destructor
+// ---------------------------------------------------------------------------
+//
+CSsyReferenceCmdHandler::~CSsyReferenceCmdHandler()
+    {
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceCmdHandler::~CSsyReferenceCmdHandler()" ) ) );
+
+    if ( iMessage )
+        {
+        // Send ProcessResponse
+        iMessage->SetError( KErrCancel );
+        iSsyChannel.ProcessResponse( iMessage );
+        delete iMessage;
+        iMessage = NULL;
+        }
+
+    if ( iTimer )
+        {
+        iTimer->Cancel();
+        delete iTimer;
+        }
+
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceCmdHandler::~CSsyReferenceCmdHandler() - return" ) ) );
+    }
+
+// ---------------------------------------------------------------------------
+// CSsyReferenceCmdHandler::ProcessCommand
+// ---------------------------------------------------------------------------
+//
+TInt CSsyReferenceCmdHandler::ProcessCommand( TSsyReferenceMsg aMessage )
+    {
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceCmdHandler::ProcessCommand()" ) ) );
+    TInt err( KErrAlreadyExists );
+    
+    // Special case, when channel is reciving, iMessage is not deleted after ProcessCommand
+    if ( aMessage.Function() == ESsyReferenceStopChannelData )
+        {
+        // Stop 'receiving'. No need to handle this asynchronously
+        if ( iTimer )
+            {
+            iTimer->Cancel();
+            delete iTimer;
+            iTimer = NULL;
+            }
+        
+        iDataItemArray.Reset();
+        iDataItemPtr = 0;
+        err = KErrNone;
+        // No need to send ProcessResponse either
+        delete iMessage;
+        iMessage = NULL;
+        }
+    else if ( !iMessage )
+        {
+        iMessage = new TSsyReferenceMsg( aMessage );
+        if(iMessage)
+            {
+            switch( aMessage.Function() )
+                {
+                case ESsyReferenceStartChannelData:
+                    {
+                    // Get channel data items and start 'receiving'
+                    IssueRequest();
+                    err = KErrNone;
+                    break;
+                    }
+                case ESsyReferenceOpenChannel:
+                    {
+                    // Open channel specific handling here
+                    IssueRequest();
+                    err = KErrNone;
+                    break;
+                    }
+                case ESsyReferenceCloseChannel:
+                    {
+                    // Close channel specific handling here
+                    IssueRequest();
+                    err = KErrNone;
+                    break;  
+                    }
+                default:
+                    {
+                    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceCmdHandler::ProcessCommand() - Unknown function" ) ) );
+                    err = KErrNotFound;
+                    }
+                }
+            }
+            else
+            {
+            err = KErrNoMemory;
+            }
+        }
+    else
+        {
+        err = KErrUnknown;
+        }
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceCmdHandler::ProcessCommand() - return" ) ) );
+    return err;
+    }
+
+// ---------------------------------------------------------------------------
+// CSsyReferenceCmdHandler::IssueRequest
+// ---------------------------------------------------------------------------
+//
+void CSsyReferenceCmdHandler::IssueRequest( TInt aError )
+    {
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceCmdHandler::IssueRequest()" ) ) );
+    // Provides synchronous function calls to be handled as asynchronous
+    if ( !IsActive() )
+        {
+        TRequestStatus *s = &iStatus;
+	    User::RequestComplete( s, aError );
+	    SetActive();
+        }
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceCmdHandler::IssueRequest() - return" ) ) );
+    }
+
+// ---------------------------------------------------------------------------
+// CSsyReferenceCmdHandler::SendResponse
+// ---------------------------------------------------------------------------
+//
+void CSsyReferenceCmdHandler::SendResponse( TInt aError )
+    {
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceCmdHandler::SendResponse()" ) ) );
+    // Send response to channel
+    if ( iMessage )
+        {
+        iMessage->SetError( aError );
+        iSsyChannel.ProcessResponse( iMessage );
+        delete iMessage;
+        iMessage = NULL;
+        }
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceCmdHandler::SendResponse() - return" ) ) );
+    }
+
+// ---------------------------------------------------------------------------
+// CSsyReferenceCmdHandler::RunL
+// ---------------------------------------------------------------------------
+//
+void CSsyReferenceCmdHandler::RunL()
+    {
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceCmdHandler::RunL() - %i" ), iStatus.Int() ) );
+    
+    TInt err( iStatus.Int() );
+
+    if ( iMessage )
+        {
+        switch( iMessage->Function() )
+            {
+            case ESsyReferenceStartChannelData:
+                {
+                TInt startInterval( 0 );
+                
+                // Get all Channel data information from config file
+                iSsyChannel.SsyControl().SsyConfig().
+                    GetChannelDataInformationL( iMessage->ChannelId(), iDataItemArray, startInterval );
+
+                // Check that channel data items were found
+                if ( iDataItemArray.Count() )
+                    {
+                    // If interval is zero, set small interval
+                    if ( startInterval == 0 )
+                        {
+                        startInterval = KSsyRefShortDelay;
+                        }
+
+                    // wait that interval
+                    if ( iTimer )
+                        {
+                        iTimer->Cancel();
+                        delete iTimer;
+                        iTimer = NULL;
+                        }
+
+                    // Reset pointer
+                    iDataItemPtr = 0;
+
+                    // Start timer and continue processing in callback function
+                    iTimer = CPeriodic::NewL( EPriorityNormal );
+                    iTimer->Start( startInterval * 1000, 0, TCallBack( DataItemCallback, this ) );
+                    }
+                break;
+                }
+            case ESsyReferenceOpenChannel:
+                {
+                // Open channel response specific handling here
+                iMessage->SetFunction( ESsyReferenceOpenChannelResp );
+                SendResponse();
+                break;
+                }
+            case ESsyReferenceCloseChannel:
+                {
+                // Close channel response specific handling here
+                iMessage->SetFunction( ESsyReferenceCloseChannelResp );
+                SendResponse();
+                break;  
+                }
+            default:
+                {
+                COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceCmdHandler::ProcessCommand() - Unknown function" ) ) );
+                err = KErrNotFound;
+                }
+            }
+        }
+
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceCmdHandler::RunL() - return" ) ) );
+    }
+
+// ---------------------------------------------------------------------------
+// CSsyReferenceCmdHandler::DoCancel
+// ---------------------------------------------------------------------------
+//
+void CSsyReferenceCmdHandler::DoCancel()
+    {
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceCmdHandler::DoCancel()" ) ) );
+
+    // Handle cancel for this channel. Cancel any ongoing requests
+    
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceCmdHandler::DoCancel() - return" ) ) );
+    }
+
+// ---------------------------------------------------------------------------
+// CSsyReferenceCmdHandler::RunError
+// ---------------------------------------------------------------------------
+//
+TInt CSsyReferenceCmdHandler::RunError( TInt /*aError*/ )
+    {
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceCmdHandler::RunError()" ) ) );
+
+    // Handle possible errors here and return KErrNone to prevent SSY from panic
+    
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceCmdHandler::RunError() - return" ) ) );
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// CSsyReferenceCmdHandler::DataItemCallback
+// ---------------------------------------------------------------------------
+//
+TInt CSsyReferenceCmdHandler::DataItemCallback( TAny* aThis )
+    {
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceCmdHandler::DataItemCallback()" ) ) );
+    return static_cast<CSsyReferenceCmdHandler*>( aThis )->GenerateChannelDataItem();
+    }
+
+// ---------------------------------------------------------------------------
+// CSsyReferenceCmdHandler::GenerateChannelDataItem
+// ---------------------------------------------------------------------------
+//
+TInt CSsyReferenceCmdHandler::GenerateChannelDataItem()
+    {
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceCmdHandler::GenerateChannelDataItem()" ) ) );
+
+    // Get next item from list and set pointer to next item
+    TSsyRefChannelDataBase dataItem = iDataItemArray[iDataItemPtr++];
+
+    // Get next item interval from data item
+    TInt nextInterval( dataItem.Interval() );
+
+    // Set timestamp to data item
+    TTime time;
+    time.HomeTime();
+    dataItem.SetTimestamp( time );
+
+    // If interval is zero, set small interval
+    if ( nextInterval == 0 )
+        {
+        nextInterval = KSsyRefShortDelay;
+        }
+
+    // Add data item to message
+    iMessage->SetDataItem( &dataItem );
+
+    // If in last data item, set pointer back to first item
+    if ( iDataItemArray.Count() == iDataItemPtr )
+        {
+        iDataItemPtr = 0;
+        }
+
+    // Send response and start new timer
+    iMessage->SetFunction( ESsyReferenceDataItemReceived );
+    iSsyChannel.ProcessResponse( iMessage );
+
+    if ( iTimer )
+        {
+        delete iTimer;
+        iTimer = NULL;
+        }
+
+    TRAP_IGNORE( iTimer = CPeriodic::NewL( EPriorityNormal );
+                 iTimer->Start( nextInterval * 1000, 0, TCallBack( DataItemCallback, this ) ); )
+
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceCmdHandler::GenerateChannelDataItem() - return" ) ) );
+    return KErrNone;
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sensorsupport/testsensor/src/ssyreferencecmdhandler.h	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,147 @@
+// ssyreferencecmdhandler.h
+
+/*
+* Copyright (c) 2006-2009 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+
+
+/**
+ @file
+ @internalComponent
+*/
+
+#ifndef SSYREFERENCECMDHANDLER_H
+#define SSYREFERENCECMDHANDLER_H
+
+#include <e32base.h>
+#include "ssyreferenceconfig.h"
+
+// FORWARD DECLARATIONS
+class CSsyReferenceChannel;
+
+/**
+ *  Command handler class for handling commands of one channel. Each opened 
+ *  channel has its own instance of this class
+ */
+class CSsyReferenceCmdHandler : public CActive
+    {
+
+public:
+
+    /**
+     * Two-phase constructor
+     *
+     * @param[in] aSsyChannel Reference to SSY Channel instance.
+     * @return Pointer to created CSsyReferenceCmdHandler object
+     */
+    static CSsyReferenceCmdHandler* NewL( CSsyReferenceChannel& aSsyChannel );
+
+    /**
+     * Virtual destructor
+     */
+    virtual ~CSsyReferenceCmdHandler();
+
+// from base class CSsyControl
+
+    /**
+     * Processes command specified in param aMessage. 
+     *
+     * @param[in] aMessage Contains command information to process
+     * @return Symbian error code
+     */
+    TInt ProcessCommand( TSsyReferenceMsg aMessage );
+
+    /**
+     * From CActive
+     */
+    void RunL();
+
+    /**
+     * From CActive
+     */
+    void DoCancel();
+
+    /**
+     * From CActive
+     */
+    TInt RunError( TInt aError );
+
+    /**
+     * Callback function for DataItem generation
+     */
+    static TInt DataItemCallback( TAny* aThis );
+    
+    /**
+     * Handles data item generation. Called from DataItemCallback
+     */
+    TInt GenerateChannelDataItem();
+
+private:
+
+    /**
+     * C++ constructor.
+     *
+     * @param[in] aSsyChannel Reference to SSY Channel instance.
+     */
+    CSsyReferenceCmdHandler( CSsyReferenceChannel& aSsyChannel );
+
+    /**
+     * Symbian 2nd phase constructor.
+     */
+    void ConstructL();
+
+    /**
+     * Makes synchronous calls asynchronous
+     */
+    void IssueRequest( TInt aError = KErrNone );
+
+    /**
+     * Sends response to channel
+     */
+    void SendResponse( TInt aError = KErrNone );
+
+private: // data
+
+    /**
+     * Reference to SSY Conrtol to send responses for commands
+     */
+    CSsyReferenceChannel& iSsyChannel;
+
+    /**
+     * Pointer to currently processing message
+     */
+    TSsyReferenceMsg* iMessage;
+
+    /**
+     * Data item array
+     */
+    TSsyRefDataItemArray iDataItemArray;
+
+    /**
+     * Pointer to next item to generate in iDataItemArray
+     */
+    TInt iDataItemPtr;
+
+    /**
+     * Periodic timer for generating channel data
+     */
+    CPeriodic* iTimer;
+    };
+
+#endif // SSYREFERENCECMDHANDLER_H
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sensorsupport/testsensor/src/ssyreferenceconfig.cpp	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,896 @@
+// ssyreferenceconfig.cpp
+
+// Copyright (c) 2006-2009 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"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+
+
+#include <sensors/sensrvtypes.h>
+#include <f32file.h>
+#include <gmxmldocument.h>
+#include <gmxmlelement.h>
+#include <sensors/channels/ssyreferenceaccelerometer.h>
+#include <sensors/channels/ssyreferencemagnetometer.h>
+#include <sensors/channels/ssyreferenceorientation.h>
+#include <sensors/channels/ssyreferenceproximity.h>
+
+#include "ssyreferencecontrol.h"
+#include "ssyreferenceconfig.h"
+#include "ssyreferencetrace.h"
+
+
+// ======== CONSTANTS =======
+_LIT( KSsyReferenceCfgFileOrig, "z:\\refssy\\ssyreferenceconfig.xml" );
+_LIT( KSsyReferenceCfgFileExt, "c:\\refssy\\ssyreferenceconfig.xml" );
+
+// Config file definitions
+
+// Maximum attribute length
+const TInt KSsyRefMaxAttribLength = 20;
+
+// TAG DEFINITIONS
+_LIT( KSsyRefRootTag, "SsyReferenceConfig" );                       // Ssy general information tag
+_LIT( KSsyRefGeneralInfoTag, "SsyGeneralInformation" );             // Ssy general information tag
+_LIT( KSsyRefChannelInfoGroupTag, "ChannelInformationGroup" );      // Channel information group tag
+_LIT( KSsyRefChannelItemTag, "ChannelItem" );                       // Channel item tag
+_LIT( KSsyRefChannelDataTag, "ChannelData" );                       // Channel data tag
+_LIT( KSsyRefChannelDataItemTag, "ChannelDataItem" );               // Channel data item tag
+
+_LIT( KSsyRefProperties, "Properties" );                            // Properties tag
+_LIT( KSsyRefPropertyItem, "PropertyItem" );                        // PropertyItem tag
+
+// Data item definitions
+_LIT( KSsyRefAxisDataItemTag, "SsyRefChannelDataAxis" );            // SsyRefChannelDataAxis data item tag
+_LIT( KSsyRefXAxis, "XAxis" );                                      // XAxis from SsyRefChannelDataAxis
+_LIT( KSsyRefYAxis, "YAxis" );                                      // YAxis from SsyRefChannelDataAxis
+_LIT( KSsyRefZAxis, "ZAxis" );                                      // ZAxis from SsyRefChannelDataAxis
+
+_LIT( KSsyRefTappingDataItemTag, "SsyRefChannelDataTapping" );      // SsyRefChannelDataTapping data item tag
+_LIT( KSsyRefDirection, "Direction" );                              // Direction from SsyRefChannelDataTapping
+
+_LIT( KSsyRefProximityDataItemTag, "SsyRefChannelDataProximity" );  // SsyRefChannelDataProximity data item tag
+_LIT( KSsyRefProximityState, "ProximityState" );                    // ProximityStatus from SsyRefChannelDataProximity
+
+// ATTRIBUTE DEFINITIONS
+_LIT( KSsyRefChannelCount, "ChannelCount" );    // Channel count from ChannelInformationGroup
+_LIT( KSsyRefChannelId, "ChannelId" );          // Channel ID from ChannelItem
+_LIT( KSsyRefContextType, "ContextType" );      // Context type from ChannelItem
+_LIT( KSsyRefQuantity, "Quantity" );            // Quantity from ChannelItem
+_LIT( KSsyRefChannelType, "ChannelType" );      // ChannelType from ChannelItem
+_LIT( KSsyRefLocation, "Location" );            // Location from ChannelItem
+_LIT( KSsyRefVendorId, "Vendor" );              // Vendor from ChannelItem
+
+
+// Channel data item specific attribute definitions
+_LIT( KSsyRefStartInterval, "StartIntervalMs" );              // StartInterval from ChannelData
+_LIT( KSsyRefDataItemCount, "count" );                        // count from ChannelDataItem
+_LIT( KSsyRefDataTypeID, "DataTypeId" );                      // DataTypeId from ChannelDataItem
+_LIT( KSsyRefInterval, "IntervalMs" );                        // IntervalMs from ChannelDataItem
+
+// Property spesific attributes
+_LIT( KSsyRefPropertyId, "PropertyId" );              // PropertyId from PropertyItem
+_LIT( KSsyRefArrayIndex, "ArrayIndex" );              // ArrayIndex from PropertyItem
+_LIT( KSsyRefItemIndex, "ItemIndex" );                // ItemIndex from PropertyItem
+_LIT( KSsyRefPropertyValue, "PropertyValue" );        // PropertyValue from PorpertyItem
+_LIT( KSsyRefPropertyType, "PropertyType" );          // PropertyType from PropertyItem
+_LIT( KSsyRefMaxValue, "MaxValue" );                  // MaxValue from PropertyItem
+_LIT( KSsyRefMinValue, "MinValue" );                  // MinValue from PorpertyItem
+_LIT( KSsyRefReadOnly, "ReadOnly" );                  // ReadOnly from PropertyItem
+
+
+// ======== MEMBER FUNCTIONS ========
+
+// ---------------------------------------------------------------------------
+// CSsyReferenceConfig C++ constructor
+// ---------------------------------------------------------------------------
+//
+CSsyReferenceConfig::CSsyReferenceConfig() :
+    CActive( EPriorityMuchLess )
+    {
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceConfig::CSsyReferenceConfig()" ) ) );
+    CActiveScheduler::Add( this );
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceConfig::CSsyReferenceConfig() - return" ) ) );
+    }
+
+
+// ---------------------------------------------------------------------------
+// Symbian 2nd phase constructor
+// ---------------------------------------------------------------------------
+//
+void CSsyReferenceConfig::ConstructL()
+    {
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceConfig::ConstructL()" ) ) );
+    // Create config file parser
+    iConfigParser = CMDXMLParser::NewL( this );
+
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceConfig::ConstructL() - return" ) ) );
+    }
+
+
+// ---------------------------------------------------------------------------
+// CSsyReferenceConfig::NewL
+// ---------------------------------------------------------------------------
+//
+CSsyReferenceConfig* CSsyReferenceConfig::NewL()
+    {
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceConfig::NewL()" ) ) );
+    CSsyReferenceConfig* self = new ( ELeave ) CSsyReferenceConfig();
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceConfig::NewL() - return" ) ) );
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// Destructor
+// ---------------------------------------------------------------------------
+//
+CSsyReferenceConfig::~CSsyReferenceConfig()
+    {
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceConfig::~CSsyReferenceConfig()" ) ) );
+    
+    if ( iConfigParser )
+        {
+        delete iConfigParser;
+        iConfigParser = NULL;
+        }
+
+    if ( iGenralInfoElement )
+        {
+        delete iGenralInfoElement;
+        iGenralInfoElement = NULL;
+        }
+
+    if ( iChannelGroupElement )
+        {
+        delete iChannelGroupElement;
+        iChannelGroupElement = NULL;
+        }
+
+    if ( iSsyReferenceConfig )
+        {
+        delete iSsyReferenceConfig;
+        iSsyReferenceConfig = NULL;
+        }
+
+    if ( iConfigFile )
+        {
+        delete iConfigFile;
+        iConfigFile = NULL;
+        }
+
+    iChannelPairArray.Reset();
+    
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceConfig::~CSsyReferenceConfig() - return" ) ) );
+    }
+
+// ---------------------------------------------------------------------------
+// CSsyReferenceConfig::InitConfig
+// ---------------------------------------------------------------------------
+//
+void CSsyReferenceConfig::InitConfigL()
+    {
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceConfig::InitConfig()" ) ) );
+    
+    // Open config file
+    RFs fileSession;
+    User::LeaveIfError( fileSession.Connect() );
+
+    // Locate extrenal file... 
+    RFile file;
+    TInt err( file.Open( fileSession, KSsyReferenceCfgFileExt, EFileRead ) );
+    file.Close();
+
+    // Check is external file found
+    if ( KErrNone == err )
+        {
+        // Use SSY with external configuration
+        User::LeaveIfError( iConfigParser->ParseFile( fileSession, KSsyReferenceCfgFileExt ) );
+        }
+    else
+        {
+        // Use SSY with original configuration
+
+        // Start parsing file and wait notification to ParseFileCompleteL
+        // XML Parser takes ownership of the RFs and closes it when file is parsed
+        User::LeaveIfError( iConfigParser->ParseFile( fileSession, KSsyReferenceCfgFileOrig ) );
+        }
+
+    iConfigFileParsed = EFalse;
+
+    // This active object has very low priority since XML parser uses Active objects also, 
+    // so it is mandatory to let XML parser to complete sooner than this active object
+    IssueRequest();
+    iSchedulerWait.Start(); // Blocks until file is parsed
+
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceConfig::InitConfig() - return" ) ) );
+    }
+
+// ---------------------------------------------------------------------------
+// CSsyReferenceConfig::IssueRequest
+// ---------------------------------------------------------------------------
+//
+void CSsyReferenceConfig::IssueRequest( TInt aError )
+    {
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceConfig::IssueRequest()" ) ) );
+    // Provides synchronous function calls to be handled as asynchronous
+    if ( !IsActive() )
+        {
+        SetActive();
+        TRequestStatus *s = &iStatus;
+	    User::RequestComplete( s, aError );
+        }
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceConfig::IssueRequest() - return" ) ) );
+    }
+
+// ---------------------------------------------------------------------------
+// CSsyReferenceConfig::RunL
+// ---------------------------------------------------------------------------
+//
+void CSsyReferenceConfig::RunL()
+    {
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceConfig::RunL() - %i" ), iStatus.Int() ) );
+
+    if ( iConfigFileParsed )
+        {
+        // Stop blocking
+        iSchedulerWait.AsyncStop();
+        }
+    else
+        {
+        // Continue RunL loop
+        IssueRequest();
+        }
+
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceConfig::RunL() - return" ) ) );
+    }
+
+// ---------------------------------------------------------------------------
+// CSsyReferenceConfig::DoCancel
+// ---------------------------------------------------------------------------
+//
+void CSsyReferenceConfig::DoCancel()
+    {
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceConfig::DoCancel()" ) ) );
+
+    // Stop blocking
+    iSchedulerWait.AsyncStop();
+    
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceConfig::DoCancel() - return" ) ) );
+    }
+
+// ---------------------------------------------------------------------------
+// CSsyReferenceConfig::RunError
+// ---------------------------------------------------------------------------
+//
+TInt CSsyReferenceConfig::RunError( TInt /*aError*/ )
+    {
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceConfig::RunError()" ) ) );
+
+    // Handle possible errors here and return KErrNone to prevent SSY from panic
+
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceConfig::RunError() - return" ) ) );
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// CSsyReferenceConfig::ParseFileCompleteL
+// ---------------------------------------------------------------------------
+//
+void CSsyReferenceConfig::ParseFileCompleteL()
+    {
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceConfig::ParseFileCompleteL()" ) ) );
+    // First get document
+    iConfigFile = iConfigParser->DetachXMLDoc();
+    // Then get document element
+    CMDXMLElement*  documentElement = iConfigFile->DocumentElement();
+    // Get root element, 'SsyReferenceConfig'
+    iSsyReferenceConfig = documentElement->FirstChildOfType( KSsyRefRootTag );
+    // Get gereral information element 
+    iGenralInfoElement = iSsyReferenceConfig->FirstChildOfType( KSsyRefGeneralInfoTag );
+    // Get channel information group element
+    iChannelGroupElement = iSsyReferenceConfig->FirstChildOfType( KSsyRefChannelInfoGroupTag );
+    // Get channel count
+    iChannelCount = GetAttributeIntValue( *iChannelGroupElement, KSsyRefChannelCount );
+
+    // No need to delete documentElement, it is owned by iConfigFile.
+    documentElement = NULL;
+    iConfigFileParsed = ETrue;
+
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceConfig::ParseFileCompleteL() - return" ) ) );
+    }
+
+// ---------------------------------------------------------------------------
+// CSsyReferenceConfig::GetAttributeIntValue
+// ---------------------------------------------------------------------------
+//
+TInt CSsyReferenceConfig::GetAttributeIntValue( CMDXMLElement& aElement, const TDesC& aAttrib )
+    {
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceConfig::GetAttributeIntValue()" ) ) );
+    COMPONENT_TRACE( ( _L( "  Element: %s", aElement.NodeName() ) ) );
+    COMPONENT_TRACE( ( _L( "  Attribute: %s", aAttrib ) ) );
+
+    TInt intValue( 0 );
+
+    // Check availability
+    if ( aElement.IsAttributeSpecified( aAttrib ) )
+        {
+        // Buffer to where to read value
+        TBufC<KSsyRefMaxAttribLength> buffer( KNullDesC );
+        TPtrC ptr( buffer );
+
+        // Read attribute value
+        aElement.GetAttribute( aAttrib, ptr );
+
+        // Cast literal value into TInt
+        TLex lexValue( ptr );
+        lexValue.Val( intValue );
+        }
+
+    COMPONENT_TRACE( ( _L( "  IntValue: %i", intValue ) ) );
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceConfig::GetAttributeIntValue() - return" ) ) );
+    return intValue;
+    }
+
+// ---------------------------------------------------------------------------
+// CSsyReferenceConfig::GetAttributeStrValue
+// ---------------------------------------------------------------------------
+//
+void CSsyReferenceConfig::GetAttributeStrValue( CMDXMLElement& aElement, const TDesC& aAttrib, TDes8& aTarget )
+    {
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceConfig::GetAttributeStrValue()" ) ) );
+    COMPONENT_TRACE( ( _L( "  Element: %s", aElement.NodeName() ) ) );
+    COMPONENT_TRACE( ( _L( "  Attribute: %s", aAttrib ) ) );
+
+    // Check availability
+    if ( aElement.IsAttributeSpecified( aAttrib ) )
+        {
+        // Buffer to where to read value
+        TBufC<KSsyRefMaxAttribLength> buffer( KNullDesC );
+        TPtrC ptr( buffer );
+
+        // Read attribute value
+        aElement.GetAttribute( aAttrib, ptr );
+
+        // Copy string from 16-bit descriptor to 8-bit descriptor
+        aTarget.Copy( ptr );
+        }
+
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceConfig::GetAttributeStrValue() - return" ) ) );
+    }
+
+// ---------------------------------------------------------------------------
+// CSsyReferenceConfig::GetAttributeHexValue
+// ---------------------------------------------------------------------------
+//
+TUint CSsyReferenceConfig::GetAttributeHexValue( CMDXMLElement& aElement, const TDesC& aAttrib )
+    {
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceConfig::GetAttributeHexValue()" ) ) );
+    COMPONENT_TRACE( ( _L( "  Element: %s", aElement.NodeName() ) ) );
+    COMPONENT_TRACE( ( _L( "  Attribute: %s", aAttrib ) ) );
+
+    TUint32 hexValue( 0 );
+
+    // Check availability
+    if ( aElement.IsAttributeSpecified( aAttrib ) )
+        {
+        // Buffer to where to read value
+        TBufC<KSsyRefMaxAttribLength> buffer( KNullDesC );
+        TPtrC ptr( buffer );
+
+        // Read attribute value
+        aElement.GetAttribute( aAttrib, ptr );
+
+        // Get bounded value and cast it into TUint32 (hex)
+        TRadix radix( EHex );
+        TUint limit( 0xFFFFFFFF );
+
+        // Append string into Lex and skip first two characters, 0x
+        TLex lexValue( ptr );
+        lexValue.Inc( 2 );
+
+        // Read value
+        lexValue.BoundedVal( hexValue, radix, limit );
+        }
+
+    COMPONENT_TRACE( ( _L( "  HexValue: %x", hexValue ) ) );
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceConfig::GetAttributeHexValue() - return" ) ) );
+    return hexValue;
+    }
+
+// ---------------------------------------------------------------------------
+// CSsyReferenceConfig::GetAttributeRealValue
+// ---------------------------------------------------------------------------
+//
+TReal CSsyReferenceConfig::GetAttributeRealValue( CMDXMLElement& aElement, const TDesC& aAttrib )
+    {
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceConfig::GetAttributeRealValue()" ) ) );
+    COMPONENT_TRACE( ( _L( "  Element: %s", aElement.NodeName() ) ) );
+    COMPONENT_TRACE( ( _L( "  Attribute: %s", aAttrib ) ) );
+
+    TReal realValue( 0 );
+
+    // Check availability
+    if ( aElement.IsAttributeSpecified( aAttrib ) )
+        {
+
+        // Buffer to where to read value
+        TBufC<KSsyRefMaxAttribLength> buffer( KNullDesC );
+        TPtrC ptr( buffer );
+
+        // Read attribute value
+        aElement.GetAttribute( aAttrib, ptr );
+
+        // Cast literal value into TReal
+        TLex lexValue( ptr );
+        TInt error = lexValue.Val( realValue );
+        if( error!=KErrNone )
+        	{
+        	realValue = error;
+        	}
+        }
+
+    COMPONENT_TRACE( ( _L( "  IntValue: %i", realValue ) ) );
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceConfig::GetAttributeRealValue() - return" ) ) );
+    return realValue;
+    }
+
+// ---------------------------------------------------------------------------
+// CSsyReferenceConfig::ChannelCount
+// ---------------------------------------------------------------------------
+//
+TInt CSsyReferenceConfig::ChannelCount()
+    {
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceConfig::ChannelCount() - %i" ), iChannelCount ) );
+    return iChannelCount;
+    }
+
+// ---------------------------------------------------------------------------
+// CSsyReferenceConfig::GenerateChannels
+// ---------------------------------------------------------------------------
+//
+void CSsyReferenceConfig::GenerateChannels( RSensrvChannelInfoList& aChannelList )
+    {
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceConfig::GenerateChannels()" ) ) );
+
+    // Initialize channel pair array
+    TSsyRefChannelIdArray tempArray( iChannelCount );
+    iChannelPairArray = tempArray;
+
+    // Go through Channel group element and get all information
+    TSensrvChannelInfo channelInfo;
+    CMDXMLElement* channelElement = iChannelGroupElement->FirstChildOfType( KSsyRefChannelItemTag );
+
+    while( channelElement )
+        {
+        // check is element correct type of node
+        if ( channelElement->NodeType() == CMDXMLNode::EElementNode )
+            {
+            // read channel identifier
+            iChannelPairArray.Append( TSsyRefChannelIdPair( GetAttributeIntValue( *channelElement, KSsyRefChannelId ) ) );
+
+            // Read attributes
+            channelInfo.iContextType = ( TSensrvContextType ) GetAttributeIntValue( *channelElement, KSsyRefContextType );
+            channelInfo.iQuantity = ( TSensrvQuantity ) GetAttributeIntValue( *channelElement, KSsyRefQuantity );
+            channelInfo.iChannelType = ( TSensrvChannelTypeId ) GetAttributeHexValue( *channelElement, KSsyRefChannelType );
+            GetAttributeStrValue( *channelElement, KSsyRefLocation, channelInfo.iLocation );
+            GetAttributeStrValue( *channelElement, KSsyRefVendorId, channelInfo.iVendorId );
+            channelInfo.iChannelDataTypeId = ( TSensrvChannelDataTypeId ) GetAttributeHexValue( *channelElement, KSsyRefDataTypeID );
+            
+            // Calculate data item size based on channel type
+            switch ( channelInfo.iChannelType )
+                {
+                case KSensrvChannelTypeIdAccelerometerXYZAxisData:
+                    {
+                    channelInfo.iDataItemSize = KSsyRefAxisDataItemSize;
+                    break;
+                    }
+                case KSensrvChannelTypeIdProximityMonitor:
+                    {
+                    channelInfo.iDataItemSize = KSsyRefProximityDataItemSize;
+                    break;
+                    }
+                case KSensrvChannelTypeIdAccelerometerWakeupData:
+                case KSensrvChannelTypeIdAccelerometerDoubleTappingData:
+                    {
+                    channelInfo.iDataItemSize = KSsyRefTappingDataItemSize;
+                    break;
+                    }
+                default:
+                    {
+                    channelInfo.iDataItemSize = 0;
+                    break;
+                    }
+                }
+
+            // Append channel info to list
+            aChannelList.Append( channelInfo );
+            }
+        channelElement = static_cast<CMDXMLElement*>( channelElement->NextSibling() );
+        }
+
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceConfig::GenerateChannels() - return" ) ) );
+    }
+
+// ---------------------------------------------------------------------------
+// CSsyReferenceConfig::GetChannelDataInformation
+// ---------------------------------------------------------------------------
+//
+void CSsyReferenceConfig::GetChannelDataInformationL( 
+    const TInt aSrvChannelId,
+    TSsyRefDataItemArray& aDataItemList, 
+    TInt& aStartInterval )
+    {
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceConfig::GetChannelDataInformation()" ) ) );
+
+    // First, get correct config channel element corresponding to aSrvChannelId
+    CMDXMLElement* channelElement = ChannelElement( aSrvChannelId );
+
+    if ( channelElement )
+        {
+        // Channel element found, get channel data group element
+        CMDXMLElement* groupElement = channelElement->FirstChildOfType( KSsyRefChannelDataTag );
+        
+        if ( groupElement )
+            {
+            // Get start interval
+            aStartInterval = GetAttributeIntValue( *groupElement, KSsyRefStartInterval );
+
+            // First, loop channel data items to get total count
+            CMDXMLElement* dataItemElement = groupElement->FirstChildOfType( KSsyRefChannelDataItemTag );
+
+            // Take channel data item type at this point. One channel can produce only one type of
+            // channel data item
+            TUint channelType( GetAttributeHexValue( *dataItemElement, KSsyRefDataTypeID ) );
+
+            TInt channelItemCount( 0 ); // Total number of data items
+            TInt definitionCount( 0 );  // Total number of different definitions
+
+            // Go through elements and get counters
+            while ( dataItemElement )
+                {
+                definitionCount++;
+                channelItemCount = channelItemCount + GetAttributeIntValue( *dataItemElement, KSsyRefDataItemCount );
+                // This will return NULL if no next sibling found
+                dataItemElement = static_cast<CMDXMLElement*>( dataItemElement->NextSibling() );
+                }
+
+            // Now, start all over to get item information
+            dataItemElement = groupElement->FirstChildOfType( KSsyRefChannelDataItemTag );
+
+            // Create temp array now that we know the data item count
+            TSsyRefDataItemArray tempArray( channelItemCount );
+
+            for ( TInt i = 0; i < definitionCount; i++ )
+                {
+                // Check element type
+                if ( dataItemElement->NodeType() == CMDXMLNode::EElementNode )
+                    {
+                    // First we get interval and count from channel item
+                    TInt interval( GetAttributeIntValue( *dataItemElement, KSsyRefInterval ) );
+                    TInt countOfType( GetAttributeIntValue( *dataItemElement, KSsyRefDataItemCount ) );
+
+                    // Read next child values to corresponding data type class
+                    switch ( channelType )
+                        {
+                        case TSensrvAccelerometerAxisData::KDataTypeId:
+                            {
+                            CMDXMLElement* axisDataElement = dataItemElement->FirstChildOfType( KSsyRefAxisDataItemTag );
+                            TInt axisX( GetAttributeIntValue( *axisDataElement, KSsyRefXAxis ) );
+                            TInt axisY( GetAttributeIntValue( *axisDataElement, KSsyRefYAxis ) );
+                            TInt axisZ( GetAttributeIntValue( *axisDataElement, KSsyRefZAxis ) );
+
+                            // Create channel data type item
+                            TSsyRefChannelDataAxis channelData( axisX, axisY, axisZ, interval );
+                            // add items into array
+                            for ( TInt k = 0; k < countOfType; k++ )
+                                {
+                                tempArray.Append( channelData );
+                                }
+                            break;
+                            }
+                        case TSensrvTappingData::KDataTypeId:
+                            {
+                            CMDXMLElement* tappingDataElement = dataItemElement->FirstChildOfType( KSsyRefTappingDataItemTag );
+                            TInt direction( GetAttributeHexValue( *tappingDataElement, KSsyRefDirection ) );
+                            
+                            // Create channel data type item
+                            TSsyRefChannelDataTapping channelData( direction, interval );
+                            // add items into array
+                            for ( TInt k = 0; k < countOfType; k++ )
+                                {
+                                tempArray.Append( channelData );
+                                }
+                            break;
+                            }
+                        case TSensrvProximityData::KDataTypeId:
+                            {
+                            CMDXMLElement* proximityDataElement = dataItemElement->FirstChildOfType( KSsyRefProximityDataItemTag );
+                            TInt state( GetAttributeIntValue( *proximityDataElement, KSsyRefProximityState ) );
+                            
+                            // Create channel data type item
+                            TSsyRefChannelDataProximity channelData( state, interval );
+                            // add items into array
+                            for ( TInt k = 0; k < countOfType; k++ )
+                                {
+                                tempArray.Append( channelData );
+                                }
+                            break;
+                            }
+                        default:
+                            {
+                            // Other data items are not supported
+                            User::Leave( KErrGeneral );
+                            }
+                        }
+                    }
+
+                // Get next channel data item element
+                dataItemElement = static_cast<CMDXMLElement*>( dataItemElement->NextSibling() );
+                }
+
+            // Compress temp array in case there were comments
+            tempArray.Compress();
+
+            // copy information to param array
+            aDataItemList = tempArray;
+            }
+        else
+            {
+            User::Leave( KErrNotFound );
+            }
+        }
+    else
+        {
+        User::Leave( KErrNotFound );
+        }
+
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceConfig::GetChannelDataInformation() - return" ) ) );
+    }
+
+// ---------------------------------------------------------------------------
+// CSsyReferenceConfig::GetElementPropertiesL
+// ---------------------------------------------------------------------------
+//
+void CSsyReferenceConfig::GetElementPropertiesL( 
+    CMDXMLElement& aElement, 
+    RSensrvPropertyList& aPropertyList )
+    {
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceConfig::GetElementPropertiesL()" ) ) );
+
+    // First we need 'Properties' element
+    CMDXMLElement* properties = aElement.FirstChildOfType( KSsyRefProperties );
+
+    if ( !properties )
+        {
+        // Wrong element... or properties are not defined
+        User::Leave( KErrNotFound );
+        }
+
+    // Get first property get started
+    CMDXMLElement* propertyItem = properties->FirstChildOfType( KSsyRefPropertyItem );
+    TInt propertyCount( 0 );
+
+    // Loop properties to get count of properties
+    while ( propertyItem )
+        {
+        propertyCount++;
+        propertyItem = static_cast<CMDXMLElement*>( propertyItem->NextSibling() ); // returns NULL if next not found
+        }
+    
+    if ( !propertyCount )
+        {
+        // Check that there are properties
+        User::Leave( KErrNotFound );
+        }
+
+    // Temporary property list now that we know the property count
+    RSensrvPropertyList tempList( propertyCount );
+
+    // Start loop again from the start and read each property
+    propertyItem = properties->FirstChildOfType( KSsyRefPropertyItem );
+    for ( TInt i = 0; i < propertyCount; i++ )
+        {
+        // Check element type
+        if ( propertyItem->NodeType() == CMDXMLNode::EElementNode )
+            {
+            // Read property values
+            const TSensrvPropertyId propertyId( ( TSensrvPropertyId )GetAttributeHexValue( *propertyItem, KSsyRefPropertyId ) );
+            const TInt itemIndex( GetAttributeIntValue( *propertyItem, KSsyRefItemIndex ) );
+            const TBool readOnly( ( TBool )GetAttributeIntValue( *propertyItem, KSsyRefReadOnly ) );
+            const TSensrvPropertyType propertyType( ( TSensrvPropertyType ) GetAttributeIntValue( *propertyItem, KSsyRefPropertyType ) );
+
+            // Array index must be handled in different way as it is not mandatory and it may not exist in XML file
+            TInt arrayIndex( ESensrvSingleProperty );
+
+            // Extra check is needed, otherwise this value is always '0' when it should be 'ESensrvSingleProperty' by default
+            if ( propertyItem->IsAttributeSpecified( KSsyRefArrayIndex ) )
+                {
+                // Attribute exists, now we can read the value
+                arrayIndex = GetAttributeIntValue( *propertyItem, KSsyRefArrayIndex );
+                }
+
+            // Resolve type, get correct type value and append property into list
+            switch ( propertyType )
+                {
+                case ESensrvIntProperty:
+                    {
+                    const TInt intValue( GetAttributeIntValue( *propertyItem, KSsyRefPropertyValue ) );
+                    const TInt maxValue( GetAttributeIntValue( *propertyItem, KSsyRefMaxValue ) );
+                    const TInt minValue( GetAttributeIntValue( *propertyItem, KSsyRefMinValue ) );
+                    TSensrvProperty property( propertyId, itemIndex, intValue, maxValue, minValue, readOnly, propertyType );
+                    property.SetArrayIndex( arrayIndex );
+                    tempList.Append( property );
+                    break;
+                    }
+                 case ESensrvRealProperty:
+                    {
+                    const TReal intValue( GetAttributeRealValue( *propertyItem, KSsyRefPropertyValue ) );
+                    const TReal maxValue( GetAttributeRealValue( *propertyItem, KSsyRefMaxValue ) );
+                    const TReal minValue( GetAttributeRealValue( *propertyItem, KSsyRefMinValue ) );
+                    TSensrvProperty property( propertyId, itemIndex, intValue, maxValue, minValue, readOnly, propertyType );
+                    property.SetArrayIndex( arrayIndex );
+                    tempList.Append( property );
+                    break;
+                    }
+                 case ESensrvBufferProperty:
+                    {
+                    TBuf8<KSensrvPropertyTextBufferSize> desValue;
+                    GetAttributeStrValue( *propertyItem, KSsyRefPropertyValue, desValue );
+                    TSensrvProperty property( propertyId, itemIndex, desValue, readOnly, propertyType );
+                    property.SetArrayIndex( arrayIndex );
+                    tempList.Append( property );
+                    break;
+                    }
+                default:
+                    {
+                    // Unknown property type -> leave
+                    User::Leave( KErrArgument );    
+                    }
+                }
+            }
+
+        // Next property
+        propertyItem = static_cast<CMDXMLElement*>( propertyItem->NextSibling() ); // returns NULL if next not found
+        }
+
+    // Compress temp list in case there were comment nodes
+    tempList.Compress();
+
+    // copy temp list to parameter list
+    aPropertyList = tempList;
+
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceConfig::GetElementPropertiesL() - return" ) ) );
+    }
+
+// ---------------------------------------------------------------------------
+// CSsyReferenceConfig::ChannelElement
+// ---------------------------------------------------------------------------
+//
+CMDXMLElement* CSsyReferenceConfig::ChannelElement( const TInt aSrvChannelId )
+    {
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceConfig::ChannelElement()" ) ) );
+
+    const TInt configId( ConfigChannelId( aSrvChannelId ) );
+    TBool channelFound( EFalse );
+    
+    // Loop channel group and match configId for the channel ID in element
+    CMDXMLElement* channelItemElement = iChannelGroupElement->FirstChildOfType( KSsyRefChannelItemTag );
+    
+    for ( TInt i = 0; i < iChannelCount && !channelFound; i++ )
+        {
+        TInt channelId( GetAttributeIntValue( *channelItemElement, KSsyRefChannelId ) );
+        if ( configId == channelId  )
+            {
+            // Channel found, no  need to loop
+            channelFound = ETrue;
+            }
+        else
+            {
+            // Take next channel
+            channelItemElement = static_cast<CMDXMLElement*>( channelItemElement->NextSibling() );
+            }
+        }
+
+    // If not found, return NULL
+    if ( !channelFound )
+        {
+        channelItemElement = NULL;
+        }
+
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceConfig::ChannelElement() - return" ) ) );
+    return channelItemElement;
+    }
+
+// ---------------------------------------------------------------------------
+// CSsyReferenceConfig::UpdateChannelIds
+// ---------------------------------------------------------------------------
+//
+void CSsyReferenceConfig::UpdateChannelIds( RSensrvChannelInfoList aChannelList )
+    {
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceConfig::UpdateChannelIds()" ) ) );
+    
+
+    if ( ChannelCount() == aChannelList.Count() )
+        {
+        for ( TInt i = 0; i < aChannelList.Count(); i++ )
+            {
+            iChannelPairArray[i].SetServerId( aChannelList[i].iChannelId );
+            }
+        }
+    
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceConfig::UpdateChannelIds() - return" ) ) );
+    }
+
+// ---------------------------------------------------------------------------
+// CSsyReferenceConfig::ConfigChannelId
+// ---------------------------------------------------------------------------
+//
+TInt CSsyReferenceConfig::ConfigChannelId( const TInt aSrvChannelId ) const
+    {
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceConfig::ConfigChannelId()" ) ) );    
+    TInt returnValue( 0 );
+    
+    for ( TInt i = 0; i < iChannelPairArray.Count(); i++ )
+        {
+        if ( iChannelPairArray[i].ServerId() == aSrvChannelId )
+            {
+            returnValue = iChannelPairArray[i].ConfigId();
+            }
+        }
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceConfig::ConfigChannelId() - return" ) ) );
+    return returnValue;
+    }
+
+// ---------------------------------------------------------------------------
+// CSsyReferenceConfig::GetSensorPropertiesL
+// ---------------------------------------------------------------------------
+//
+void CSsyReferenceConfig::GetSensorPropertiesL( RSensrvPropertyList& aPropertyList )
+    {
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceConfig::GetSensorPropertiesL()" ) ) );
+
+    // We already have SsyGeneralInformation element, read properties from that
+    GetElementPropertiesL( *iGenralInfoElement, aPropertyList );
+
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceConfig::GetSensorPropertiesL() - return" ) ) );
+    }
+
+// ---------------------------------------------------------------------------
+// CSsyReferenceConfig::GetChannelPropertiesL
+// ---------------------------------------------------------------------------
+//
+void CSsyReferenceConfig::GetChannelPropertiesL( 
+    const TInt aSrvChannelId, 
+    RSensrvPropertyList& aPropertyList )
+    {
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceConfig::GetChannelPropertiesL()" ) ) );
+
+    // Get channel element first
+    CMDXMLElement* channelElement = ChannelElement( aSrvChannelId );
+
+    if ( !channelElement )
+        {
+        // Leave, channel element is not found
+        User::Leave( KErrNotFound );
+        }
+
+    // Get properties of this channel element
+    GetElementPropertiesL( *channelElement, aPropertyList );
+
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceConfig::GetChannelPropertiesL() - return" ) ) );
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sensorsupport/testsensor/src/ssyreferenceconfig.h	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,522 @@
+// ssyreferenceconfig.h
+
+/*
+* Copyright (c) 2006-2009 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+
+
+/**
+ @file
+ @internalComponent
+*/
+
+
+#ifndef SSYREFERENCECONFIG_H
+#define SSYREFERENCECONFIG_H
+
+// INCLUDES
+#include <e32base.h>
+#include <sensors/sensrvtypes.h>
+#include <sensors/sensrvchannelinfo.h>
+#include <gmxmlparser.h>
+#include <sensors/channels/ssyreferenceaccelerometer.h>
+#include <sensors/channels/ssyreferencemagnetometer.h>
+#include <sensors/channels/ssyreferenceorientation.h>
+#include <sensors/channels/ssyreferenceproximity.h>
+
+// CONSTANTS
+// Data item sizes
+const TInt KSsyRefAxisDataItemSize = sizeof( TSensrvAccelerometerAxisData );
+const TInt KSsyRefTappingDataItemSize = sizeof( TSensrvTappingData );
+const TInt KSsyRefProximityDataItemSize = sizeof( TSensrvProximityData );
+
+// ENUMS
+enum TSsyReferenceFunctions
+    {
+    ESsyReferenceOpenChannel,
+    ESsyReferenceOpenChannelResp,
+    ESsyReferenceDataItemReceived,
+    ESsyReferenceCloseChannel,
+    ESsyReferenceCloseChannelResp,
+    ESsyReferenceStartChannelData,
+    ESsyReferenceStopChannelData
+    };
+
+/**
+ * Base class for Channel data types. Contains iChannelDataType which is set
+ * by derived classes on construction.
+ */
+class TSsyRefChannelDataBase
+    {
+    public:
+    /**
+     * Enumeration for possible channel data types
+     */
+    enum TSsyRefChannelDataType
+        {
+        ESsyRefChannelTypeTapping = 5000,
+        ESsyRefChannelTypeAxis,
+        ESsyRefChannelTypeProximity,
+        ESsyRefChannelTypeAmbientLight
+        };
+   
+    TInt  ChannelDataType() const { return iChannelDataType; }
+    TInt  Interval() const { return iInterval; }
+    
+    void SetTimestamp( const TTime aTimestamp ) { iTimestamp = aTimestamp; }
+    TTime Timestamp() const { return iTimestamp; }
+
+    TInt  Size() const { return iSize; }
+
+    protected:
+
+    /**
+     * Protected constructor as this class is not supposed to be instantiate
+     * directly.
+     */
+    TSsyRefChannelDataBase() {}
+
+    protected: // data
+
+    /**
+     * Identifies the type of data type class derived from this base class
+     */
+    TInt iChannelDataType;
+    
+    /**
+     * Interval. Indicates time in ms from previous item until next item is produced
+     */
+    TInt iInterval;
+
+    /**
+     * Timestamp. Time when this data item is generated.
+     */
+    TTime iTimestamp;
+
+    /**
+     * Size of one data item. This is filled by derived class
+     */
+    TInt iSize;
+
+    /**
+     * Axis data item values. 
+     * Accessible only from TSsyRefChannelDataAxis class
+     */
+    TInt iXAxis;
+    TInt iYAxis;
+    TInt iZAxis;
+
+    
+    /**
+     * Proximity data item values.
+     * Accessible only from TSsyRefChannelProximity class
+     */    
+    TInt iProximityState;
+
+    /**
+     * AmbientLight data item values.
+     * Accessible only from TSsyRefChannelAmbientLight class
+     */    
+    TInt iAmbientLightState;
+
+    /**
+     * Tapping data item values. Difrection of the tapping.
+     * Accessible only from TSsyRefChannelDataTapping class
+     */
+    TInt iDirection;
+    };
+
+// Type definition array for Data item base class
+typedef RArray<TSsyRefChannelDataBase> TSsyRefDataItemArray;
+
+/**
+ * Message item for SSY <--> Sensor communications
+ * Contains Channel ID for which the message belongs to,
+ * Function ID that identifies the command and
+ * error for error cases. 
+ */
+class TSsyReferenceMsg
+    {
+    public:
+
+    /**
+    * Constructor of the TSsyReferenceMsg
+    *
+    * @param[in] aChannelId Channel identifier
+    * @param[in] aFunction See TSsyReferenceFunctions
+    */  
+    TSsyReferenceMsg( TInt aChannelId, TInt aFunction ) : 
+        iChannelId( aChannelId ), 
+        iFunction( aFunction ),
+        iError( KErrNone )
+        {}
+
+    /**
+     * Copy constructor of the TSsyReferenceMsg
+     *
+     * @param[in] aMsg Object to be copied to constructed object
+     */    
+    TSsyReferenceMsg( const TSsyReferenceMsg& aMsg ) :
+        iChannelId( aMsg.iChannelId ),
+        iFunction( aMsg.iFunction ),
+        iError( aMsg.iError )
+        {}
+
+    TInt ChannelId() { return iChannelId; }
+
+    void SetFunction( TInt aFunction ) { iFunction = aFunction; }
+    TInt Function()  { return iFunction; }
+
+    void SetError( TInt aError ) { iError = aError; }
+    TInt Error()     { return iError; }
+
+    void SetDataItem( TSsyRefChannelDataBase* aDataItem ) { iDataItem = aDataItem; }
+    TSsyRefChannelDataBase* DataItem() const { return iDataItem; }
+
+    private: // data
+    
+    TInt iChannelId; // Identifies the channel
+    TInt iFunction;  // Identifies the command
+    TInt iError;     // Error is passed to response handler
+    
+    // Data item for received data. This is casted to correct data item 
+    // class implementation according to ChannelDataType
+    TSsyRefChannelDataBase* iDataItem;
+    };
+
+/**
+ * Tapping data type class implementation.
+ */
+class TSsyRefChannelDataTapping : public TSsyRefChannelDataBase
+    {
+    public:
+
+    TSsyRefChannelDataTapping( TInt aDirection, TInt aInterval  )
+        { 
+        iChannelDataType = ESsyRefChannelTypeTapping;
+        iSize = KSsyRefTappingDataItemSize;
+        iInterval = aInterval;
+        iDirection = aDirection;
+        }
+    
+    TInt Direction() const { return iDirection; }
+    };
+
+/**
+ * XYZ Axis data type class implementation.
+ */
+class TSsyRefChannelDataAxis : public TSsyRefChannelDataBase
+    {
+    public:
+
+    TSsyRefChannelDataAxis( TInt aXAxis, TInt aYAxis, TInt aZAxis, 
+                            TInt aInterval )
+        { 
+        iChannelDataType = ESsyRefChannelTypeAxis;
+        iSize = KSsyRefAxisDataItemSize;
+        iInterval = aInterval; 
+        iXAxis = aXAxis;
+        iYAxis = aYAxis;
+        iZAxis = aZAxis;
+        }
+    
+    TInt XAxis() const { return iXAxis; }
+    TInt YAxis() const { return iYAxis; }
+    TInt ZAxis() const { return iZAxis; }
+    };
+
+
+/**
+ * Proximity data type class implementation.
+ */
+class TSsyRefChannelDataProximity : public TSsyRefChannelDataBase
+    {
+    public:
+
+    TSsyRefChannelDataProximity( TInt aProximityState, TInt aInterval )
+        { 
+        iChannelDataType = ESsyRefChannelTypeProximity;
+        iSize = KSsyRefProximityDataItemSize;
+        iInterval = aInterval; 
+        iProximityState = aProximityState;
+        }
+    
+    TInt ProximityState() const { return iProximityState; }
+    };
+
+/**
+ * Channel ID pair class for pairing config file channel id and
+ * Sensor Server generated channel ID.
+ */
+class TSsyRefChannelIdPair
+    {
+    public:
+    /**
+    * Constructor of the TSsyRefChannelIdPair
+    *
+    * @param[in] aConfigChannelId Channel identifier from config file
+    */  
+    TSsyRefChannelIdPair( TInt aConfigChannelId ) : 
+        iConfigChannelId( aConfigChannelId )
+        {}
+
+    TInt ConfigId() const { return iConfigChannelId; }
+    TInt ServerId() const { return iSrvChannelId; }
+
+    void SetServerId( const TInt aSrvId ) { iSrvChannelId = aSrvId; }
+
+    private: // data
+    
+    TInt iConfigChannelId; // Config file ID of the channel
+    TInt iSrvChannelId;    // Sensor server assigned ID of the channel
+    };
+
+typedef RArray<TSsyRefChannelIdPair> TSsyRefChannelIdArray;
+
+
+// CONSTANTS
+
+/**
+ *  Configuration class for SSY reference plugin. Generates configured SSY channel information.
+ *  This keeps reference SSY implementation independent from 'sensor' it uses. This class is fully
+ *  modifiable regarding to the needs of this SSY. It may be for example accelerometer sensor 
+ *  without any changes in the SSY reference implementation. Only this class is modified.
+ */
+class CSsyReferenceConfig : public CActive, public MMDXMLParserObserver
+    {
+
+public:
+
+    /**
+     * Two-phase constructor
+     *
+     * @return Pointer to created CSsyReferenceControl object
+     */
+    static CSsyReferenceConfig* NewL();
+
+    /**
+     * Virtual destructor
+     */
+    virtual ~CSsyReferenceConfig();
+
+    /**
+     * From CActive
+     */
+    void RunL();
+
+    /**
+     * From CActive
+     */
+    void DoCancel();
+
+    /**
+     * From CActive
+     */
+    TInt RunError( TInt aError );
+
+    /**
+     * From MMDXMLParserObserver
+     *
+	 * Call back function used to inform a client of the Parser when a parsing operation completes.
+	 */
+	void ParseFileCompleteL();
+
+    /**
+	 * Starts parsing config file. This function blocks until file is parsed
+	 */
+	void InitConfigL();
+
+    /**
+     * Total number of channels this SSY provides
+     *
+     * @return Count of channels this SSY is configured to provide
+     */
+    TInt ChannelCount();
+
+    /**
+     * Generates channels this SSY is configured to provide
+     *
+     * @param[in,out] aChannnelList Filled with generated channels by this configurator
+     */
+    void GenerateChannels( RSensrvChannelInfoList& aChannelList );
+
+    /**
+     * Updates Sensor server's generated channel Ids
+     *
+     * @param[in] aChannnelList Same list as GenerateChannels produces but 
+     *                this contains channel identifiers
+     */
+    void UpdateChannelIds( RSensrvChannelInfoList aChannelList );
+
+    /**
+     * Reads all channel data information from config file and fills
+     * parameters with information
+     *
+     * @param[in]     aSrvChannelId Sensor server generated channel id of the target channel
+     * @param[in,out] aDataItemList Contains data item objects defined in config file. Each
+     *                Data item is presented as Data Item class derived from TSsyRefChannelDataBase.
+     *                List can contain only one type of derived channel data items
+     * @param[in,out] aStartInterval Contains start interval to start producing data items
+     */
+    void GetChannelDataInformationL( const TInt aSrvChannelId, 
+                                     TSsyRefDataItemArray& aDataItemList, 
+                                     TInt& aStartInterval );
+
+    /**
+     * Reads sensor properties from config file and adds them to list
+     *
+     * @param[out] aPropertyList List where to append properties
+     */
+    void GetSensorPropertiesL( RSensrvPropertyList& aPropertyList );
+
+    /**
+     * Reads channel properties from config file and adds them to list
+     *
+     * @param[in] aSenSrvChannelId Sensor server generated channel id
+     * @param[out] aPropertyList List where to append properties
+     */
+    void GetChannelPropertiesL( const TInt aSrvChannelId, 
+                                RSensrvPropertyList& aPropertyList );
+
+private:
+
+    /**
+     * C++ constructor.
+     */
+    CSsyReferenceConfig();
+
+    /**
+     * Symbian 2nd phase constructor.
+     */
+    void ConstructL();
+
+    /**
+     * Makes synchronous calls asynchronous
+     */
+    void IssueRequest( TInt aError = KErrNone );
+
+    /**
+     * Reads attribute value from element and casts it into TInt value
+     *
+     * @param[in] aElement Element from where to read attribute
+     * @param[in] aAttrib Attribute name which to read
+     * @return Integer value of read value
+     */
+    TInt GetAttributeIntValue( CMDXMLElement& aElement, const TDesC& aAttrib );
+
+    /**
+     * Reads attribute value from element and casts it into literal value
+     *
+     * @param[in] aElement Element from where to read attribute
+     * @param[in] aAttrib Attribute name which to read
+     * @param[in/out] aTarget Target descriptor where to copy read literal
+     */
+    void GetAttributeStrValue( CMDXMLElement& aElement, const TDesC& aAttrib, TDes8& aTarget );
+
+    /**
+     * Reads attribute value from element and casts it into TReal value
+     *
+     * @param[in] aElement Element from where to read attribute
+     * @param[in] aAttrib Attribute name which to read
+     * @return value of the attribute
+     */
+    TReal GetAttributeRealValue( CMDXMLElement& aElement, const TDesC& aAttrib );
+
+    /**
+     * Reads Hexadesimal attribute value from element and casts it into Integer value
+     *
+     * @param[in] aElement Element from where to read attribute
+     * @param[in] aAttrib Attribute name which to read
+     * @return Unsigned integer value of read Hexadesimal value
+     */
+    TUint GetAttributeHexValue( CMDXMLElement& aElement, const TDesC& aAttrib );
+
+    /**
+     * Compares Sensor server generated channel IDs and return corresponding 
+     * ConfigFile channel id
+     *
+     * @param[in] aSrvChannelId SenServer generated channel ID for which pair is needed
+     * @return ConfigFile channel ID that is paired with aSrvChannelId
+     */
+    TInt ConfigChannelId( const TInt aSrvChannelId ) const;
+
+    /**
+     * Searches channel element for given SensorServer generated channel ID
+     *
+     * @param[in] aSrvChannelId SenServer generated channel ID identifying wanted channel element
+     * @return Pointer to found channel element or NULL if not found
+     */
+    CMDXMLElement* ChannelElement( const TInt aSrvChannelId );
+
+    /**
+     * Reads properties from given element and adds them to list. 
+     * Element can be either 'SsyGenealInformation' or 'ChannelItem'
+     *
+     * @param[in]  aElement Element from where to read properties
+     * @param[out] aPropertyList List where to append properties
+     */
+    void GetElementPropertiesL( CMDXMLElement& aElement, RSensrvPropertyList& aPropertyList );
+
+
+private: // data
+    
+    /**
+     * Pointer of the config xml-file parser
+     */
+    CMDXMLParser* iConfigParser;
+
+    /**
+     * Contains Ssy general information element and all of its childs
+     */
+    CMDXMLElement* iGenralInfoElement;
+
+    /**
+     * Contains Ssy Channel information group element and all of its childs
+     * including each channel information and channel data for testing purpose
+     */
+    CMDXMLElement* iChannelGroupElement;
+
+    /**
+     * Number of channels defined in config file
+     */
+    TInt iChannelCount;
+
+    /**
+     * Active scheduler wait for blocking construction until config file is parsed
+     */
+    CActiveSchedulerWait iSchedulerWait;
+
+    /**
+     * Indicates is config file parsed
+     */
+    TBool iConfigFileParsed;
+
+    /**
+     * Channel ID pair array
+     */
+    TSsyRefChannelIdArray iChannelPairArray;
+
+    /**
+     * Elements of the config file. These needs to be stored
+     */
+    CMDXMLDocument* iConfigFile;
+    CMDXMLElement*  iSsyReferenceConfig; // Root of the config
+    };
+
+#endif //SSYREFERENCECONFIG_H
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sensorsupport/testsensor/src/ssyreferencecontrol.cpp	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,281 @@
+// ssyreferencecontrol.cpp
+
+// Copyright (c) 2006-2009 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"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+
+
+
+#include <sensors/spi/ssycallback.h>                     // MSsyCallback
+#include "ssyreferencecontrol.h"
+#include "ssyreferencetrace.h"
+#include "ssyreferencechannel.h"
+#include "ssyreferencecmdhandler.h"
+
+
+// ======== MEMBER FUNCTIONS ========
+
+// ---------------------------------------------------------------------------
+// CSsyReferenceControl C++ constructor
+// ---------------------------------------------------------------------------
+//
+CSsyReferenceControl::CSsyReferenceControl( MSsyCallback& aSsyCallback ) :
+    iSsyCallback( aSsyCallback )
+    {
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceControl::CSsyReferenceControl()" ) ) );
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceControl::CSsyReferenceControl() - return" ) ) );
+    }
+
+
+// ---------------------------------------------------------------------------
+// Symbian 2nd phase constructor
+// ---------------------------------------------------------------------------
+//
+void CSsyReferenceControl::ConstructL()
+    {
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceControl::ConstructL()" ) ) );
+
+    // Create configurator and start config file parsing
+    iConfigFile = CSsyReferenceConfig::NewL();
+    TRAPD( err, iConfigFile->InitConfigL() ); // This will block until config is ready
+
+    if ( KErrNone != err )
+        {
+        COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceControl::ConstructL() - Init config failed: %i" ), err ) );
+        }
+
+    // ---------------------------------------------------------------
+
+    // Store channel count for later use
+    const TInt channelCount( iConfigFile->ChannelCount() );
+
+    // Instantiate channel info list
+    RSensrvChannelInfoList channelInfoList( channelCount );
+    CleanupClosePushL( channelInfoList );
+
+    // Fills channel info list with generated channel info objects
+    iConfigFile->GenerateChannels( channelInfoList );
+
+    // Register channels. Sensor Server generates unique ID for each channel
+    iSsyCallback.RegisterChannelsL( channelInfoList );
+
+    // Update channel IDs to ConfigFile
+    iConfigFile->UpdateChannelIds( channelInfoList );
+
+    // Create channels
+    iChannelArray = new ( ELeave ) CArrayPtrFlat<CSsyReferenceChannel>( channelCount );
+    for ( TInt i = 0; i < channelCount; i++ )
+        {
+        CSsyReferenceChannel* channel = CSsyReferenceChannel::NewL( *this, channelInfoList[i] );
+        iChannelArray->AppendL( channel );
+        }
+
+    // Clean up
+    CleanupStack::PopAndDestroy( &channelInfoList );
+
+    // Get properties of this SSY. Leaves with KErrNotFound if not found. These properties are 
+    // not mandatory, so we can ignore that leave
+    TRAP_IGNORE( iConfigFile->GetSensorPropertiesL( iProperties ) );
+
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceControl::ConstructL() - return" ) ) );
+    }
+
+
+// ---------------------------------------------------------------------------
+// CSsyReferenceControl::NewL
+// ---------------------------------------------------------------------------
+//
+CSsyReferenceControl* CSsyReferenceControl::NewL( MSsyCallback& aSsyCallback )
+    {
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceControl::NewL()" ) ) );
+    CSsyReferenceControl* self = new ( ELeave ) CSsyReferenceControl( aSsyCallback );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceControl::NewL() - return" ) ) );
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// Destructor
+// ---------------------------------------------------------------------------
+//
+CSsyReferenceControl::~CSsyReferenceControl()
+    {
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceControl::~CSsyReferenceControl()" ) ) );
+
+    if ( iChannelArray )
+        {
+        if ( iChannelArray->Count() )
+            {
+            iChannelArray->ResetAndDestroy();
+            }
+        
+        delete iChannelArray;
+        }
+
+    if ( iConfigFile ) 
+        {
+        delete iConfigFile;
+        iConfigFile = NULL;
+        }
+
+    iProperties.Reset();
+
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceControl::~CSsyReferenceControl() - return" ) ) );
+    }
+
+// ---------------------------------------------------------------------------
+// CSsyReferenceControl::SsyCallback
+// ---------------------------------------------------------------------------
+//
+MSsyCallback& CSsyReferenceControl::SsyCallback() const
+    {
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceControl::SsyCallback()" ) ) );
+    return iSsyCallback;
+    }
+
+// ---------------------------------------------------------------------------
+// CSsyReferenceControl::SsyConfig
+// ---------------------------------------------------------------------------
+//
+CSsyReferenceConfig& CSsyReferenceControl::SsyConfig() const
+    {
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceControl::SsyConfig()" ) ) );
+    return *iConfigFile;
+    }
+
+// ---------------------------------------------------------------------------
+// CSsyReferenceControl::FindPropertyL
+// ---------------------------------------------------------------------------
+//
+void CSsyReferenceControl::FindPropertyL( 
+    const TSensrvPropertyId aPropertyId, 
+    const TInt aArrayIndex,
+    TSensrvProperty& aProperty )
+    {
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceControl::FindPropertyL()" ) ) );
+    TSensrvProperty* property = NULL;
+    TBool propertyFound( EFalse );
+
+    // Search property
+    for ( TInt i = 0; i < iProperties.Count() && !propertyFound; i++ )
+        {
+        property = static_cast<TSensrvProperty*>( &iProperties[i] );
+
+        // Compare property IDs
+        if ( property->GetPropertyId() == aPropertyId )
+            {
+            // Correct property ID is found, now check is it array type of property.
+            // Either array indexes must match or propertys array index has to be array info
+            if ( ( property->GetArrayIndex() == aArrayIndex ) || 
+                 ( ( property->GetArrayIndex() == ESensrvArrayPropertyInfo ) && 
+                   ( ESensrvSingleProperty == aArrayIndex ) ) )
+                {
+                // Correct array index found
+                propertyFound = ETrue;    
+                }
+            }
+        }
+
+    // Leave if not found
+    if ( !propertyFound )
+        {
+        User::Leave( KErrNotFound );
+        }
+
+    aProperty = *property;
+
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceControl::FindPropertyL() - return" ) ) );
+    }
+
+
+// ---------------------------------------------------------------------------
+// CSsyReferenceControl::FindChannel
+// ---------------------------------------------------------------------------
+//
+CSsyReferenceChannel* CSsyReferenceControl::FindChannelL( TSensrvChannelId aChannelID )
+    {
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceControl::FindChannel()" ) ) );
+    
+    if ( !iChannelArray )
+        {
+        User::Leave( KErrNotFound );
+        }
+
+    const TInt channelCount( iChannelArray->Count() );
+    CSsyReferenceChannel* channel = NULL;
+
+    // Check that there are channels
+    if ( channelCount ) 
+        {
+        // Loop channels until correct channel is found
+        for ( TInt i = 0; i < channelCount; i++ ) 
+            {
+            channel = iChannelArray->At( i );
+            
+            // Compare channel id
+            if ( channel->ChannelId() == aChannelID )
+                {
+                // Channel found, no need to loop rest
+                i = channelCount;
+                }
+            }
+        }
+
+    // Leave if channel is not found
+    if ( !channel )
+        {
+        User::Leave( KErrNotFound );
+        }
+
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceControl::FindChannel() - return" ) ) );
+    return channel;
+    }
+
+// ---------------------------------------------------------------------------
+// CSsyReferenceControl::OpenChannelL
+// ---------------------------------------------------------------------------
+//
+void CSsyReferenceControl::OpenChannelL( TSensrvChannelId aChannelID )
+    {
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceControl::OpenChannelL()" ) ) );
+    // Find and open channel
+    User::LeaveIfError( FindChannelL( aChannelID )->OpenChannel() );
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceControl::OpenChannelL() - return" ) ) );
+    }
+
+// ---------------------------------------------------------------------------
+// CSsyReferenceControl::CloseChannelL
+// ---------------------------------------------------------------------------
+//
+void CSsyReferenceControl::CloseChannelL( TSensrvChannelId aChannelID )
+    {
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceControl::CloseChannelL()" ) ) );
+    // Find and close channel
+    User::LeaveIfError( FindChannelL( aChannelID )->CloseChannel() );
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceControl::CloseChannelL() - return" ) ) );
+    }
+
+// ---------------------------------------------------------------------------
+// CSsyReferenceControl::ProcessResponse
+// ---------------------------------------------------------------------------
+//
+void CSsyReferenceControl::ProcessResponse( TSsyReferenceMsg* /*aMessage*/ )
+    {
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceControl::ProcessResponse()" ) ) );
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceControl::ProcessResponse() - return" ) ) );
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sensorsupport/testsensor/src/ssyreferencecontrol.h	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,156 @@
+// ssyreferencecontrol.h
+
+/*
+* Copyright (c) 2006-2009 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+
+
+/**
+ @file
+ @internalComponent
+*/
+
+#ifndef SSYREFERENCECONTROL_H
+#define SSYREFERENCECONTROL_H
+
+#include <sensors/spi/ssycontrol.h>
+#include "ssyreferenceconfig.h"
+
+// FORWARD DECLARATIONS
+class CSsyReferenceChannel;
+
+/**
+ *  Main control class for SSY. Controls sensor basic functionality and provides mandatory 
+ *  ECOM interface specific things.
+ */
+class CSsyReferenceControl : public CSsyControl
+    {
+
+public:
+
+    /**
+     * Two-phase constructor
+     *
+     * @param[in] aSsyCallback Reference to SSY callback instance.
+     * @return Pointer to created CSsyReferenceControl object
+     */
+    static CSsyReferenceControl* NewL( MSsyCallback& aSsyCallback );
+
+    /**
+     * Virtual destructor
+     */
+    virtual ~CSsyReferenceControl();
+
+// from base class CSsyControl
+
+    /**
+     * From CSsyControl
+     * Request for SSY to open a sensor channel asynchronously. 
+     * Response to the request is delivered through MSsyCallback::ChannelOpened().
+     * Initilizes SSY (and the sensor) to be ready for other control commands via
+     * data and property providers. Multiple OpenChannel()-requests can be
+     * active for different channels at the same time.
+     *
+     * @param[in] aChannelID Channel that is requested to be opened
+     * @return Symbian error code
+     */
+    void OpenChannelL( TSensrvChannelId aChannelID );
+
+    /**
+     * From CSsyControl
+     * Request to close a sensor channel asynchronously. 
+     * Response to the request is delivered through MSsyCallback::ChannelClosed().
+     * Multiple CloseChannel()-requests can be active for different channels 
+     * at the same time.
+     *
+     * @param[in] aChannelID Channel that is reqeusted to be closed
+     * @leave  Any One of the system wide error codes
+     */  
+    void CloseChannelL( TSensrvChannelId aChannelID );
+
+    /**
+     * Reference to SSY Callback instance
+     */
+    MSsyCallback& SsyCallback() const;
+
+    /**
+     * Reference to SSY Config file
+     */
+    CSsyReferenceConfig& SsyConfig() const;
+    /**
+     * Handles response to CSsyReferenceCmdHandler::ProcessCommand
+     *
+     * @param[in] aMessage Contains information of the response
+     */
+    void ProcessResponse( TSsyReferenceMsg* aMessage );
+
+    /**
+     * Search property of given property id from the channel properties and 
+     * returns reference to that. Leaves with KErrNotFound if property is not found
+     *
+     * @param[in]  aPropertyId Property ID to locate
+     * @param[in]  aArrayIndex Propertys array index
+     * @param[out] aProperty Contains found property
+     */
+    void FindPropertyL( const TSensrvPropertyId aPropertyId, 
+                        const TInt aArrayIndex,
+                        TSensrvProperty& aProperty );
+
+private:
+
+    /**
+     * C++ constructor.
+     *
+     * @param[in] aSsyCallback Reference to SSY callback instance.
+     */
+    CSsyReferenceControl( MSsyCallback& aSsyCallback );
+
+    /**
+     * Symbian 2nd phase constructor.
+     */
+    void ConstructL();
+
+    /**
+     * Finds and returns pointer to channel
+     */
+    CSsyReferenceChannel* FindChannelL( TSensrvChannelId aChannelID );
+
+private: // data
+
+    /**
+     * Reference to SSY CallBack to send responses to Sensor Server
+     */
+    MSsyCallback& iSsyCallback;
+
+    /**
+     * Pointer array of all channels provided by this SSY
+     */
+    CArrayPtrFlat<CSsyReferenceChannel>* iChannelArray;
+
+    /**
+     * Pointer to config file parser
+     */
+    CSsyReferenceConfig* iConfigFile;
+
+    /**
+     * Property list of general properties of this SSY
+     */
+    RSensrvPropertyList iProperties;
+    };
+
+#endif // SSYREFERENCECONTROL_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sensorsupport/testsensor/src/ssyreferencepropertyprovider.cpp	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,164 @@
+// ssyreferencepropertyprovider.cpp
+
+// Copyright (c) 2006-2009 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"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+
+
+#include "ssyreferencepropertyprovider.h"
+#include "ssyreferencetrace.h"
+#include "ssyreferencechannel.h"
+
+// ======== MEMBER FUNCTIONS ========
+
+// ---------------------------------------------------------------------------
+// CSsyReferencePropertyProvider C++ constructor
+// ---------------------------------------------------------------------------
+//
+CSsyReferencePropertyProvider::CSsyReferencePropertyProvider( CSsyReferenceChannel& aChannel ) :
+    iChannel( aChannel )
+    {
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferencePropertyProvider::CSsyReferencePropertyProvider()" ) ) );
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferencePropertyProvider::CSsyReferencePropertyProvider() - return" ) ) );
+    }
+
+
+// ---------------------------------------------------------------------------
+// Symbian 2nd phase constructor
+// ---------------------------------------------------------------------------
+//
+void CSsyReferencePropertyProvider::ConstructL()
+    {
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferencePropertyProvider::ConstructL()" ) ) );
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferencePropertyProvider::ConstructL() - return" ) ) );
+    }
+
+
+// ---------------------------------------------------------------------------
+// CSsyReferencePropertyProvider::NewL
+// ---------------------------------------------------------------------------
+//
+CSsyReferencePropertyProvider* CSsyReferencePropertyProvider::NewL( CSsyReferenceChannel& aChannel )
+    {
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferencePropertyProvider::NewL()" ) ) );
+    CSsyReferencePropertyProvider* self = new ( ELeave ) CSsyReferencePropertyProvider( aChannel );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferencePropertyProvider::NewL() - return" ) ) );
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// Destructor
+// ---------------------------------------------------------------------------
+//
+CSsyReferencePropertyProvider::~CSsyReferencePropertyProvider()
+    {
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferencePropertyProvider::~CSsyReferencePropertyProvider()" ) ) );
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferencePropertyProvider::~CSsyReferencePropertyProvider() - return" ) ) );
+    }
+
+// ---------------------------------------------------------------------------
+// CSsyReferencePropertyProvider::CheckPropertyDependenciesL
+// ---------------------------------------------------------------------------
+//
+void CSsyReferencePropertyProvider::CheckPropertyDependenciesL( 
+    const TSensrvChannelId /*aChannelId*/,
+    const TSensrvProperty& /*aProperty*/,
+    RSensrvChannelList& /*aAffectedChannels*/ )
+    {
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferencePropertyProvider::CheckPropertyDependenciesL()" ) ) );
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferencePropertyProvider::CheckPropertyDependenciesL() - return" ) ) );
+    }
+
+// ---------------------------------------------------------------------------
+// CSsyReferencePropertyProvider::SetPropertyL
+// ---------------------------------------------------------------------------
+//
+void CSsyReferencePropertyProvider::SetPropertyL( 
+    const TSensrvChannelId aChannelId,
+    const TSensrvProperty& aProperty )
+    {
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferencePropertyProvider::SetPropertyL()" ) ) );
+
+    if ( iChannel.ChannelId() != aChannelId )
+        {
+        User::Leave( KErrArgument );
+        }
+
+    // Search property. Leaves with KErrNotFound if property is not found. 
+    // Leaves with KErrAccessDenied if found property is Read only
+    iChannel.FindAndUpdatePropertyL( aProperty );
+    
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferencePropertyProvider::SetPropertyL() - return" ) ) );
+    }
+
+// ---------------------------------------------------------------------------
+// CSsyReferencePropertyProvider::GetPropertyL
+// ---------------------------------------------------------------------------
+//
+void CSsyReferencePropertyProvider::GetPropertyL( 
+    const TSensrvChannelId aChannelId,
+    TSensrvProperty& aProperty )
+    {
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferencePropertyProvider::GetPropertyL()" ) ) );
+    
+    if ( iChannel.ChannelId() != aChannelId && aChannelId != 0 )
+        {
+        User::Leave( KErrArgument );
+        }
+    else
+        {
+        // Search property. Leaves with KErrNotFound if property is not found
+        aProperty = iChannel.FindPropertyL( 
+                        aProperty.GetPropertyId(), 
+                        aProperty.PropertyItemIndex(),
+                        aProperty.GetArrayIndex() );
+        }
+
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferencePropertyProvider::GetPropertyL() - return" ) ) );
+    }
+
+// ---------------------------------------------------------------------------
+// CSsyReferencePropertyProvider::GetAllPropertiesL
+// ---------------------------------------------------------------------------
+//
+void CSsyReferencePropertyProvider::GetAllPropertiesL( 
+    const TSensrvChannelId aChannelId,
+    RSensrvPropertyList& aChannelPropertyList )
+    {
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferencePropertyProvider::GetAllPropertiesL()" ) ) );
+    
+    if ( iChannel.ChannelId() != aChannelId )
+        {
+        User::Leave( KErrArgument );
+        }
+
+    iChannel.GetProperties( aChannelPropertyList );
+
+    COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferencePropertyProvider::GetAllPropertiesL() - return" ) ) );
+    }
+
+// ---------------------------------------------------------------------------
+// CSsyReferencePropertyProvider::GetPropertyProviderInterfaceL
+// ---------------------------------------------------------------------------
+//
+void CSsyReferencePropertyProvider::GetPropertyProviderInterfaceL( TUid /*aInterfaceUid*/, 
+	                                        TAny*& aInterface )
+    {
+    aInterface = NULL;
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sensorsupport/testsensor/src/ssyreferencepropertyprovider.h	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,139 @@
+// ssyreferencepropertyprovider.h
+
+/*
+* Copyright (c) 2006-2009 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+
+
+/**
+ @file
+ @internalComponent
+*/
+
+
+#ifndef SSYREFERENCEPROPERTYPROVIDER_H
+#define SSYREFERENCEPROPERTYPROVIDER_H
+
+#include <sensors/spi/ssypropertyprovider.h>
+
+
+class CSsyReferenceChannel;
+
+/**
+ *  Channel property provider implementation.
+ */
+class CSsyReferencePropertyProvider : public CBase, public MSsyPropertyProvider
+    {
+
+public:
+
+    /**
+     * Two-phase constructor
+     *
+     * @param[in] aChannel Reference to channel this provider belongs to
+     * @return Pointer to created CSsyReferenceControl object
+     */
+    static CSsyReferencePropertyProvider* NewL( CSsyReferenceChannel& aChannel );
+
+    /**
+     * Virtual destructor
+     */
+    virtual ~CSsyReferencePropertyProvider();
+
+// from base class MSsyPropertyProvider
+
+    /**
+     * From MSsyPropertyProvider
+     * Check if property value affects other sensor channels already open.
+     * If the new property value is legal but affects somehow other channels' properties,
+     * SSY must return list of the affected channels so that the sensor server can
+     * check if the client allowed to set this property. If the SSY value 
+     * is not legal SSY must leave with KErrArgument-value.
+     *
+     * @param[in] aProperty Property to be checked. 
+     * @param[out] aAffectedChannels Return list of the channel which will be affected if the property 
+     *       value will be set.
+     * @leave KErrArgument If the property value is illegal.
+     */  
+    void CheckPropertyDependenciesL( const TSensrvChannelId aChannelId,
+                                     const TSensrvProperty& aProperty,
+                                     RSensrvChannelList& aAffectedChannels ); 
+
+    /**
+     * From MSsyPropertyProvider
+     * Set property for the channel. Before the sensor server sets the property value,
+     * it is checked with CheckPropertyDependenciesL()-function.
+     * This means a property value should always be valid for the SSY.
+     *
+     * @param[in] aProperty Rereference to a property object to be set
+     */  
+    void SetPropertyL( const TSensrvChannelId aChannelId, 
+                       const TSensrvProperty& aProperty );
+
+    /**
+     * From MSsyPropertyProvider
+     * Get channel property value. The property parameter contains channel id and
+     * item index. SSY fills values and attributes to the property object.
+     *
+     * @param[in, out] aProperty Reference to a property object to be filled
+     *     with property values and attributes.
+     */  
+    void GetPropertyL( const TSensrvChannelId aChannelId, 
+                       TSensrvProperty& aProperty );
+
+    /**
+     * From MSsyPropertyProvider
+     * Get all channel properties. Returns all properties which are related to this channel.
+     *
+     * @param[out] aChannelPropertyList List of the all properties of the channel.
+     */  
+    void GetAllPropertiesL( const TSensrvChannelId aChannelId,
+                            RSensrvPropertyList& aChannelPropertyList );
+
+    /** 
+    * Returns a pointer to a specified interface - to allow future extension
+    * of this class without breaking binary compatibility
+    *
+    * @param aInterfaceUid Identifier of the interface to be retrieved
+    * @param aInterface A reference to a pointer that retrieves the specified interface.
+    */
+    void GetPropertyProviderInterfaceL( TUid aInterfaceUid, 
+                                        TAny*& aInterface );
+
+private:
+
+    /**
+     * C++ constructor.
+     * @param[in] aChannel Reference to channel this provider belongs to
+     */
+    CSsyReferencePropertyProvider( CSsyReferenceChannel& aChannel );
+
+    /**
+     * Symbian 2nd phase constructor.
+     */
+    void ConstructL();
+
+private: // data
+
+    /**
+     * Reference to channel for which this provider belongs to
+     */
+    CSsyReferenceChannel& iChannel;
+    };
+
+#endif // SSYREFERENCEPROPERTYPROVIDER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sensorsupport/testsensor/src/ssyreferencetrace.h	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,117 @@
+// ssyreferencetrace.h
+
+/*
+* Copyright (c) 2006-2009 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+
+
+/**
+ @file
+ @internalComponent
+*/
+#ifndef SSYREFERENCETRACE_H
+#define SSYREFERENCETRACE_H
+
+
+// INCLUDES
+#include <e32svr.h>
+
+
+// PC-LINT OPTIONS
+// Removes null statement not in line by itself warnings from 
+// COMPONENT_TRACE macros
+//lint -esym(960,54)
+
+// Removes "area too small" pointer cast warnings.
+//lint -e826
+
+
+
+// CONSTANTS
+// MACROS
+#ifdef _DEBUG
+
+    #ifdef THREAD_TRACE_FLAG
+    
+        #define THREAD_TRACE RDebug::Print(RThread().Name());
+        
+    #else
+        
+        #define THREAD_TRACE
+        
+    #endif // #ifdef THREAD_TRACE_FLAG
+    
+    #ifdef BUFFER_TRACE_FLAG
+    
+        #define BUFFER_TRACE_DEBUG
+        #define DEBUG_PRINT_BUFFER DebugPrintBuffer();
+        #define BUFFER_TRACE( a ) RDebug::Print a 
+        
+    #else
+        
+        #define DEBUG_PRINT_BUFFER
+        #define BUFFER_TRACE( a )
+        
+    #endif // #ifdef THREAD_TRACE_FLAG
+
+    #ifdef COMPONENT_TRACE_FLAG
+
+        #define COMPONENT_TRACE( a ) THREAD_TRACE;RDebug::Print a 
+        #define COMPONENT_TRACE_DEBUG   
+        
+    #else // #ifdef COMPONENT_TRACE_FLAG
+
+        #define COMPONENT_TRACE( a )
+
+    #endif //#ifdef COMPONENT_TRACE_FLAG
+
+    #ifdef API_TRACE_FLAG
+
+        #define API_TRACE( a ) THREAD_TRACE;RDebug::Print a
+        #define API_TRACE_DEBUG
+
+    #else //#ifdef API_TRACE_FLAG
+
+        #define API_TRACE( a )
+
+    #endif //#ifdef API_TRACE_FLAG
+
+    #ifdef ERROR_TRACE_FLAG
+
+        #define ERROR_TRACE( a ) THREAD_TRACE;RDebug::Print a
+        #define ERROR_TRACE_DEBUG
+
+    #else //#ifdef ERROR_TRACE_FLAG
+
+        #define ERROR_TRACE( a )
+
+    #endif //#ifdef ERROR_TRACE_FLAG
+
+#else // #ifdef _DEBUG
+
+    #define COMPONENT_TRACE( a )
+    #define API_TRACE( a )
+    #define ERROR_TRACE( a )
+    #define BUFFER_TRACE( a )
+    #define THREAD_TRACE
+    #define DEBUG_PRINT_BUFFER
+
+#endif //#ifdef _DEBUG
+
+#endif // SSYREFERENCETRACE_H
+
--- a/startupservices/SplashScreen/src/SplashScreen.cpp	Tue Jun 15 16:07:48 2010 +0100
+++ b/startupservices/SplashScreen/src/SplashScreen.cpp	Thu Jul 22 16:35:22 2010 +0100
@@ -24,7 +24,7 @@
 #include <startupdomainpskeys.h>
 #include <SVGEngineInterfaceImpl.h>
 #include <gdi.h>
-#include <COEMAIN.H> 
+#include <coemain.h> 
 
 // USER INCLUDES
 #include "SplashScreen.h"
Binary file startupservices/Startup/conf/startup.confml has changed
Binary file startupservices/Startup/conf/startup_101F8763.crml has changed
--- a/startupservices/Startup/inc/StartupAppUi.h	Tue Jun 15 16:07:48 2010 +0100
+++ b/startupservices/Startup/inc/StartupAppUi.h	Thu Jul 22 16:35:22 2010 +0100
@@ -27,7 +27,7 @@
 #ifndef STARTUPAPPUI_H
 #define STARTUPAPPUI_H
 
-#include <secondarydisplay/secondarydisplaystartupapi.h>
+#include <SecondaryDisplay/SecondaryDisplayStartupAPI.h>
 
 
 // USER INCLUDES
--- a/startupservices/Startup/pubsub/startupappprivatepskeys.h	Tue Jun 15 16:07:48 2010 +0100
+++ b/startupservices/Startup/pubsub/startupappprivatepskeys.h	Thu Jul 22 16:35:22 2010 +0100
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2008 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"
@@ -38,4 +38,6 @@
                                       // and finished showing country & time queries.
     };
 
+const TUint32 KPSStartupAppStarted = 0x00000002;
+
 #endif // STARTUPAPPPRIVATEPSKEYS_H
--- a/startupservices/Startup/src/StartupAppUi.cpp	Tue Jun 15 16:07:48 2010 +0100
+++ b/startupservices/Startup/src/StartupAppUi.cpp	Thu Jul 22 16:35:22 2010 +0100
@@ -30,6 +30,7 @@
 #include <starterclient.h>
 #include <hbdevicemessageboxsymbian.h>
 #include "sanimstartupctrl.h"
+#include <apgtask.h>
 
 // USER INCLUDES
 #include "StartupAppUi.h"
@@ -98,6 +99,9 @@
 // ---------------------------------------------------------------------------
 void CStartupAppUi::ConstructL()
     {
+    RThread thread; //increase the thread priority to smooth the animation
+    thread.SetPriority(EPriorityAbsoluteForeground);
+    thread.Close();
     TRACES("CStartupAppUi::ConstructL()");
     TInt flags = EStandardApp;
    BaseConstructL( flags );
@@ -609,12 +613,24 @@
     {
     TRACES("CStartupAppUi::DoStartupEndPart()");
     TRACES("CStartupAppUi::DoStartupEndPart(): STARTUP OK");
-
-
-
-  
-    UpdateStartupUiPhase( EStartupUiPhaseAllDone );
-
+    
+    TBool ftuenabled=EFalse;
+    TInt err=KErrNone;
+#ifndef __WINSCW__
+    TRAP(err,
+            TInt enabled=0;
+            //open cenrep;
+            CRepository *cenrep=CRepository::NewLC(KCRUidStartupConf);
+            //check if ftu is enabled or not
+            User::LeaveIfError(cenrep->Get(KFtuStartupEnabled,enabled));
+            ftuenabled=!!enabled; //make sure we only have a boolean value here
+            CleanupStack::PopAndDestroy(cenrep);
+            );
+#endif     
+    if(!ftuenabled)
+        {
+        UpdateStartupUiPhase( EStartupUiPhaseAllDone );
+        }
 
     TRACES("CStartupAppUi::DoStartupEndPart(): Exit application.");
     iExitTimer->Start( 100000, 100000, TCallBack( DoExitApplication, this ) );
@@ -1244,9 +1260,9 @@
             switch( toState )
                 {
                 case EStartupStartupOK:
-                    iInternalState = EStartupStartupOK;
-                    TRACES("CStartupAppUi::DoNextStartupPhaseL(): InternalState : EStartupStartupOK");
-                    DoStartupEndPart();
+                        iInternalState = EStartupStartupOK;
+                        TRACES("CStartupAppUi::DoNextStartupPhaseL(): InternalState : EStartupInvokeAndWaitForFtu");
+                        DoStartupEndPart();
                     break;
                 case EStartupSystemFatalError:
                     SystemFatalErrorL();
--- a/startupservices/Startup/src/StartupApplication.cpp	Tue Jun 15 16:07:48 2010 +0100
+++ b/startupservices/Startup/src/StartupApplication.cpp	Thu Jul 22 16:35:22 2010 +0100
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2006 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 "Eclipse Public License v1.0"
@@ -21,6 +21,12 @@
 // INCLUDE FILES
 #include "StartupApplication.h"
 #include "StartupDocument.h"
+#include "startupappprivatepskeys.h"
+#include <e32property.h>
+
+//Security policies
+_LIT_SECURITY_POLICY_C1(KReadDeviceDataPolicy, ECapabilityReadDeviceData);
+_LIT_SECURITY_POLICY_C1(KWriteDeviceDataPolicy, ECapabilityWriteDeviceData);
 
 // ========================= MEMBER FUNCTIONS ================================
 
@@ -53,6 +59,12 @@
 
 GLDEF_C TInt E32Main()
     {
+    //Make sure startup app is only started once
+    TInt ret = RProperty::Define(KPSUidStartupApp, KPSStartupAppStarted, RProperty::EInt, KReadDeviceDataPolicy, KWriteDeviceDataPolicy);
+    if(ret!=KErrNone)
+        {
+        return KErrNone;
+        }
     return EikStart::RunApplication(NewApplication);
     }
 
--- a/startupservices/Startup/syserrcmd/src/syserrcmd.cpp	Tue Jun 15 16:07:48 2010 +0100
+++ b/startupservices/Startup/syserrcmd/src/syserrcmd.cpp	Thu Jul 22 16:35:22 2010 +0100
@@ -22,7 +22,7 @@
 
 #include <data_caging_path_literals.hrh>
 #include <featmgr.h>
-#include <secondarydisplay/secondarydisplaystartupapi.h>
+#include <SecondaryDisplay/SecondaryDisplayStartupAPI.h>
 #include <StringLoader.h>
 #include <startup.rsg>
 #include <stringresourcereader.h>
--- a/startupservices/startupanimation/sanimctrl/src/sanimstartupctrl.cpp	Tue Jun 15 16:07:48 2010 +0100
+++ b/startupservices/startupanimation/sanimctrl/src/sanimstartupctrl.cpp	Thu Jul 22 16:35:22 2010 +0100
@@ -25,7 +25,7 @@
 #include <Profile.hrh>
 #include <ProfileEngineSDKCRKeys.h>
 #include "sanimengine.h"
-#include <secondarydisplay/secondarydisplaystartupapi.h>
+#include <SecondaryDisplay/SecondaryDisplayStartupAPI.h>
 
 #include "sanimstartupctrl.h"
 #include "trace.h"
--- a/sysdef_1_4_0.dtd	Tue Jun 15 16:07:48 2010 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,86 +0,0 @@
- <!ELEMENT SystemDefinition (systemModel?, build?)>
- <!ATTLIST SystemDefinition
-  name CDATA #REQUIRED
-  schema CDATA #REQUIRED>
- <!ELEMENT systemModel (layer+)>
- <!ELEMENT layer (logicalset* | module*)*>
- <!ATTLIST layer
-  name CDATA #REQUIRED
-  levels CDATA #IMPLIED
-  span CDATA #IMPLIED>
- <!ELEMENT logicalset (logicalsubset* | module* | unit* | package* | prebuilt*)*>
- <!ATTLIST logicalset name CDATA #REQUIRED>
- <!ELEMENT logicalsubset (module* | unit* | package* | prebuilt*)*>
- <!ATTLIST logicalsubset name CDATA #REQUIRED>
- <!ELEMENT module (component* | unit* | package* | prebuilt*)*>
- <!ATTLIST module
-  name CDATA #REQUIRED
-  level CDATA #IMPLIED>
- <!ELEMENT component (unit* | package* | prebuilt*)*>
- <!ATTLIST component name CDATA #REQUIRED>
- <!ELEMENT unit EMPTY>
- <!ATTLIST unit
-  unitID ID #REQUIRED
-  name CDATA #REQUIRED
-  mrp CDATA #REQUIRED
-  filter CDATA #IMPLIED
-  bldFile CDATA #REQUIRED
-  priority CDATA #IMPLIED
-  contract CDATA #IMPLIED>
- <!ELEMENT package EMPTY>
- <!ATTLIST package
-  name CDATA #REQUIRED
-  mrp CDATA #REQUIRED
-  filter CDATA #IMPLIED
-  contract CDATA #IMPLIED>
- <!ELEMENT prebuilt EMPTY>
- <!ATTLIST prebuilt
-  name CDATA #REQUIRED
-  version CDATA #REQUIRED
-  late (Y|N) #IMPLIED
-  filter CDATA #IMPLIED
-  contract CDATA #IMPLIED>
- <!ELEMENT build (option* | target+ | targetList+ | unitList+ | configuration+)*>
- <!ELEMENT unitList (unitRef+)>
- <!ATTLIST unitList
-  name ID #REQUIRED
-  description CDATA #REQUIRED>
- <!ELEMENT unitRef EMPTY>
- <!ATTLIST unitRef unit IDREF #REQUIRED>
- <!ELEMENT targetList EMPTY>
- <!ATTLIST targetList
-  name ID #REQUIRED
-  description CDATA #REQUIRED
-  target IDREFS #REQUIRED>
- <!ELEMENT target EMPTY>
- <!ATTLIST target
-  name ID #REQUIRED
-  abldTarget CDATA #REQUIRED
-  description CDATA #REQUIRED>
- <!ELEMENT option EMPTY>
- <!ATTLIST option
-  name ID #REQUIRED
-  abldOption CDATA #REQUIRED
-  description CDATA #REQUIRED
-  enable (Y | N | y | n) #REQUIRED>
- <!ELEMENT configuration (unitListRef+ | layerRef+ | task+)*>
- <!ATTLIST configuration
-  name ID #REQUIRED
-  description CDATA #REQUIRED
-  filter CDATA #REQUIRED>
- <!ELEMENT task ( unitListRef* , (buildLayer | specialInstructions))>
- <!ELEMENT unitListRef EMPTY>
- <!ATTLIST unitListRef unitList IDREF #REQUIRED>
- <!ELEMENT layerRef EMPTY>
- <!ATTLIST layerRef layerName CDATA #REQUIRED>
- <!ELEMENT buildLayer EMPTY>
- <!ATTLIST buildLayer
-  command CDATA #REQUIRED
-  targetList IDREFS #IMPLIED
-  unitParallel (Y | N | y | n) #REQUIRED
-  targetParallel (Y | N | y | n) #IMPLIED>
- <!ELEMENT specialInstructions EMPTY>
- <!ATTLIST specialInstructions
-  name CDATA #REQUIRED
-  cwd CDATA #REQUIRED
-  command CDATA #REQUIRED>  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysdef_1_5_1.dtd	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,88 @@
+ <!ELEMENT SystemDefinition (systemModel?, build?)>
+ <!ATTLIST SystemDefinition
+  name CDATA #REQUIRED
+  schema CDATA #REQUIRED>
+ <!ELEMENT systemModel (layer+)>
+ <!ELEMENT layer (logicalset* | module*)*>
+ <!ATTLIST layer
+  name CDATA #REQUIRED
+  levels CDATA #IMPLIED
+  span CDATA #IMPLIED>
+ <!ELEMENT logicalset (logicalsubset* | module* | unit* | package* | prebuilt*)*>
+ <!ATTLIST logicalset name CDATA #REQUIRED>
+ <!ELEMENT logicalsubset (module* | unit* | package* | prebuilt*)*>
+ <!ATTLIST logicalsubset name CDATA #REQUIRED>
+ <!ELEMENT module (component* | unit* | package* | prebuilt*)*>
+ <!ATTLIST module
+  name CDATA #REQUIRED
+  level CDATA #IMPLIED>
+ <!ELEMENT component (unit* | package* | prebuilt*)*>
+ <!ATTLIST component name CDATA #REQUIRED>
+ <!ELEMENT unit EMPTY>
+ <!ATTLIST unit
+  unitID ID #REQUIRED
+  name CDATA #REQUIRED
+  mrp CDATA #REQUIRED
+  filter CDATA #IMPLIED
+  bldFile CDATA #REQUIRED
+  priority CDATA #IMPLIED
+  contract CDATA #IMPLIED
+  proFile CDATA #IMPLIED
+  qmakeArgs CDATA #IMPLIED>
+ <!ELEMENT package EMPTY>
+ <!ATTLIST package
+  name CDATA #REQUIRED
+  mrp CDATA #REQUIRED
+  filter CDATA #IMPLIED
+  contract CDATA #IMPLIED>
+ <!ELEMENT prebuilt EMPTY>
+ <!ATTLIST prebuilt
+  name CDATA #REQUIRED
+  version CDATA #REQUIRED
+  late (Y|N) #IMPLIED
+  filter CDATA #IMPLIED
+  contract CDATA #IMPLIED>
+ <!ELEMENT build (option* | target+ | targetList+ | unitList+ | configuration+)*>
+ <!ELEMENT unitList (unitRef+)>
+ <!ATTLIST unitList
+  name ID #REQUIRED
+  description CDATA #REQUIRED>
+ <!ELEMENT unitRef EMPTY>
+ <!ATTLIST unitRef unit IDREF #REQUIRED>
+ <!ELEMENT targetList EMPTY>
+ <!ATTLIST targetList
+  name ID #REQUIRED
+  description CDATA #REQUIRED
+  target IDREFS #REQUIRED>
+ <!ELEMENT target EMPTY>
+ <!ATTLIST target
+  name ID #REQUIRED
+  abldTarget CDATA #REQUIRED
+  description CDATA #REQUIRED>
+ <!ELEMENT option EMPTY>
+ <!ATTLIST option
+  name ID #REQUIRED
+  abldOption CDATA #REQUIRED
+  description CDATA #REQUIRED
+  enable (Y | N | y | n) #REQUIRED>
+ <!ELEMENT configuration (unitListRef+ | layerRef+ | task+)*>
+ <!ATTLIST configuration
+  name ID #REQUIRED
+  description CDATA #REQUIRED
+  filter CDATA #REQUIRED>
+ <!ELEMENT task ( unitListRef* , (buildLayer | specialInstructions))>
+ <!ELEMENT unitListRef EMPTY>
+ <!ATTLIST unitListRef unitList IDREF #REQUIRED>
+ <!ELEMENT layerRef EMPTY>
+ <!ATTLIST layerRef layerName CDATA #REQUIRED>
+ <!ELEMENT buildLayer EMPTY>
+ <!ATTLIST buildLayer
+  command CDATA #REQUIRED
+  targetList IDREFS #IMPLIED
+  unitParallel (Y | N | y | n) #REQUIRED
+  targetParallel (Y | N | y | n) #IMPLIED>
+ <!ELEMENT specialInstructions EMPTY>
+ <!ATTLIST specialInstructions
+  name CDATA #REQUIRED
+  cwd CDATA #REQUIRED
+  command CDATA #REQUIRED>  
--- a/sysresmonitoring/oommonitor/bwins/oommonitorU.DEF	Tue Jun 15 16:07:48 2010 +0100
+++ b/sysresmonitoring/oommonitor/bwins/oommonitorU.DEF	Thu Jul 22 16:35:22 2010 +0100
@@ -13,4 +13,8 @@
 	?SetMemoryMonitorTls@@YAXPAVCMemoryMonitor@@@Z @ 12 NONAME ; void SetMemoryMonitorTls(class CMemoryMonitor *)
 	?ThisAppIsNotExiting@ROomMonitorSession@@QAEXH@Z @ 13 NONAME ; void ROomMonitorSession::ThisAppIsNotExiting(int)
 	?WsSession@COomMonitorPlugin@@QAEAAVRWsSession@@XZ @ 14 NONAME ; class RWsSession & COomMonitorPlugin::WsSession(void)
+	?FreeRam@COomMonitorPluginV2@@UAEXXZ @ 15 NONAME ; void COomMonitorPluginV2::FreeRam(void)
+	?RequestOptionalRam@ROomMonitorSession@@QAEHHHHAAH@Z @ 16 NONAME ; int ROomMonitorSession::RequestOptionalRam(int, int, int, int &)
+	?RequestOptionalRam@ROomMonitorSession@@QAEXHHHAAVTRequestStatus@@@Z @ 17 NONAME ; void ROomMonitorSession::RequestOptionalRam(int, int, int, class TRequestStatus &)
+	?SetOomPriority@ROomMonitorSession@@QAEXW4TOomPriority@1@@Z @ 18 NONAME ; void ROomMonitorSession::SetOomPriority(enum ROomMonitorSession::TOomPriority)
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/data/oomconfig.xml	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,181 @@
+<!--
+ Copyright (c) 2004-2009 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"
+ which accompanies this distribution, and is available
+ at the URL "http://www.eclipse.org/legal/epl-v10.html".
+
+ Initial Contributors:
+ Nokia Corporation - initial contribution.
+
+ Contributors:
+
+ Description:
+
+-->
+
+
+<!-- This is the configuration file for the new OOM Monitor. This configuration file
+defines an OOM policy where RAM is released in the following order.
+
+1. Empty server caches (skin server cache, icon server cache, MDS cache, TFX server cache)
+2. Close applications that have not been used for more than 12 hours (including Browser and high priority applications)
+3. If Browser is in the background, empty Browser cache and close unused windows 
+4. Close always-on applications in the following order: Clock, Calendar, Messaging,  Contacts, Logs, Camera
+5. Close applications that have not been used for more than 15 minutes (including Browser but excluding high priority applications)
+6. Close Matrix UI if it has not been used for more than 15 seconds and continue closing WRT widgets immediately.
+7. Close WRT widgets
+8. Close other background applications that have been used within 15 minutes except Browser and high priority applications
+9. Close high priority applications
+10. If Browser is in the foreground, empty Browser cache and close unused windows 
+11. Close Browser in the background when it has been used within 15 minutes
+-->
+<oom_config>
+
+<!-- 	Low RAM and good RAM thresholds are defined here in kilobytes.
+	The max_app_close_batch indicates how many applications can be closed in parallel.
+	The value 1 means that applications are not closed in parallel.
+	default_wait_after_plugin defines how long is waited (in milliseconds) after
+	an OOM plugin is called and before the free RAM is checked to determine if more
+	actions are needed. This value is meaningful only when "check" or "estimate" sync mode is
+	used with plugins.
+-->
+	<global_settings low_ram_threshold="3637" good_ram_threshold="4900" swap_usage_monitored="true" low_swap_threshold="15000" good_swap_threshold="25000" max_app_close_batch="3" default_wait_after_plugin="10" max_app_exit_time="2000">
+	</global_settings>
+
+<!--	Application specific low RAM and good RAM thresholds are defined here. The higher values of
+the low and good thresholds are defined to avoid OOM errors with these applications when the default
+threshold values are used.
+-->
+	<app_specific_thresholds>
+		<app uid="10008d39" low_ram_threshold="8637" good_ram_threshold="9900"></app> <!-- Browser -->
+		<app uid="20001f63" low_ram_threshold="4637" good_ram_threshold="5900"></app> <!-- Maps -->
+		<app uid="101f857a" low_ram_threshold="5637" good_ram_threshold="6900"></app> <!-- camera -->
+		<app uid="10282822" low_ram_threshold="5637" good_ram_threshold="6900"></app> <!-- Widget UI -->
+		<app uid="200009ee" low_ram_threshold="8637" good_ram_threshold="9900"></app> <!-- Photos -->
+		<app uid="20007b39" low_ram_threshold="10637" good_ram_threshold="11900"></app> <!-- NGage -->
+	</app_specific_thresholds>
+
+<!--	The priority of closing each application is defined here.
+-->
+	<app_close_settings>
+
+<!--		The uid DEFAULT_APP refers to all applications, which priority is not specifically
+		defined in the conf file.
+-->
+		<close_app uid="DEFAULT_APP" priority="80" sync_mode="check">
+			<app_close_idle_priority idle_time="900" priority="50"></app_close_idle_priority>
+			<app_close_idle_priority idle_time="43200" priority="20"></app_close_idle_priority>
+		</close_app>
+<!--		The uid BUSY_APP refers to applications, which have set the OOM priority BUSY
+		by using the OOM Monitor API SetOomPriority(). The priority NEVER_CLOSE
+		means that the application is not closed at all.
+-->
+		<close_app uid="BUSY_APP" priority="NEVER_CLOSE" sync_mode="check"></close_app>
+
+<!--		The uid HIGH_PRIORITY_APP refers to applications, which have set the OOM priority HIGH
+		by using the OOM Monitor API SetOomPriority().
+-->
+		<close_app uid="HIGH_PRIORITY_APP" priority="90" sync_mode="check">
+			<app_close_idle_priority idle_time="43200" priority="20"></app_close_idle_priority>
+		</close_app>
+		<close_app uid="10005903" priority="80" sync_mode="check"> <!-- Clock -->
+			<app_close_idle_priority idle_time="900" priority="50"></app_close_idle_priority>
+			<app_close_idle_priority idle_time="43200" priority="40"></app_close_idle_priority>
+		</close_app>
+		<close_app uid="10005901" priority="80" sync_mode="check"> <!-- Calendar -->
+			<app_close_idle_priority idle_time="900" priority="50"></app_close_idle_priority>
+			<app_close_idle_priority idle_time="43200" priority="41"></app_close_idle_priority>
+		</close_app>
+		<close_app uid="100058c5" priority="80" sync_mode="check">  <!-- Messaging -->
+			<app_close_idle_priority idle_time="900" priority="50"></app_close_idle_priority>
+			<app_close_idle_priority idle_time="43200" priority="42"></app_close_idle_priority>
+		</close_app>
+		<close_app uid="101f4cce" priority="80" sync_mode="check"> <!-- Contacts -->
+			<app_close_idle_priority idle_time="900" priority="50"></app_close_idle_priority>
+			<app_close_idle_priority idle_time="43200" priority="43"></app_close_idle_priority>
+		</close_app>
+		<close_app uid="101f4cd5" priority="80" sync_mode="check"> <!-- Logs -->
+			<app_close_idle_priority idle_time="900" priority="50"></app_close_idle_priority>
+			<app_close_idle_priority idle_time="43200" priority="44"></app_close_idle_priority>
+		</close_app>
+		<close_app uid="101f857a" priority="80" sync_mode="check"> <!-- Camcorder -->
+			<app_close_idle_priority idle_time="900" priority="50"></app_close_idle_priority>
+			<app_close_idle_priority idle_time="43200" priority="45"></app_close_idle_priority>
+		</close_app>
+		<close_app uid="10008d39" priority="110" sync_mode="check"> <!-- Browser -->
+			<app_close_idle_priority idle_time="900" priority="50"></app_close_idle_priority>
+			<app_close_idle_priority idle_time="43200" priority="20"></app_close_idle_priority>
+		</close_app>
+		
+		<!--CWRTWidget.exe -->		
+		<close_app uid="200267C0" priority="100" sync_mode="check"> <!-- Ovi Widget UI -->
+            <app_close_idle_priority idle_time="900" priority="50"></app_close_idle_priority>
+            <app_close_idle_priority idle_time="43200" priority="30"></app_close_idle_priority>
+        </close_app>		
+		<!--CWRTWidget.exe  End -->
+		<!--CWRTWidget2.exe -->		
+		<close_app uid="200267D6" priority="80" sync_mode="check"> 
+            <app_close_idle_priority idle_time="900" priority="50"></app_close_idle_priority>
+            <app_close_idle_priority idle_time="43200" priority="30"></app_close_idle_priority>
+        </close_app>		
+		<!--CWRTWidget2.exe  End -->
+<!--		Widget UI plugin handles the closing of widgets. Widget UI application is not closed.
+-->
+		<close_app uid="10282822" priority="NEVER_CLOSE" sync_mode="check"> </close_app> <!-- Widget UI --> 
+		<close_app uid="101f4cd2" priority="NEVER_CLOSE" sync_mode="continue">
+			<app_close_idle_priority idle_time="15" priority="60"></app_close_idle_priority>
+			<foreground_app_priority if_foreground_app_id="10207218" priority="NEVER_CLOSE"></foreground_app_priority> <!-- Fast swap --> 
+		</close_app> <!-- Matrix UI -->
+		<close_app uid="10207a89" priority="NEVER_CLOSE" sync_mode="check">
+			<app_close_idle_priority idle_time="43200" priority="20"></app_close_idle_priority>
+		</close_app> <!-- Radio -->
+	</app_close_settings>
+<!--	The priority of executing each system plugin is defined here.
+	System plugin is a plugin, which priority is not related to any application.
+-->
+	<system_plugin_settings>
+<!--		The uid DEFAULT_PLUGIN refers to all plugins, which priority is not specificly
+		defined in the conf file.
+-->
+		<system_plugin uid="DEFAULT_PLUGIN" priority="10" sync_mode="continue"></system_plugin>
+		<system_plugin uid="10207140" priority="10" sync_mode="continue"></system_plugin> <!-- AKNSKINSOOMPLUGIN -->
+		<system_plugin uid="10281fe6" priority="10" sync_mode="continue"></system_plugin> <!-- AKNICONOOMPLUGIN -->
+		<system_plugin uid="10282e4f" priority="10" sync_mode="continue"></system_plugin> <!-- TFXSRVOOMPLUGIN -->
+		<system_plugin uid="2001b2c6" priority="10" sync_mode="continue"></system_plugin> <!-- MDSOOMPLUGIN -->
+	</system_plugin_settings>
+<!--	The priority of executing each application plugin is defined here.
+	Application plugin is a plugin, which priority depends on the target application.
+	The target application must be defined for each application plugin.
+	By default all plugins are system plugins unless specifically defined as application
+	plugin in this section.
+-->
+	<app_plugin_settings>
+		<app_plugin uid="10281f93" target_app_id="10008d39" priority="30" wait="100" sync_mode="check"> <!-- WEBENGINEMEMORYPLUGIN, target app Browser -->
+			<plugin_foreground_app_priority target_app_id="10008d39" priority="100"></plugin_foreground_app_priority>
+		</app_plugin>
+
+<!--	Widget memory plugin has very long plugin wait time because we don't want to unnecessarily
+	close any other applications after closing it. We call Widget memory plugin only if
+	Widget UI application is running in the background.
+-->
+		<app_plugin uid="10282855" target_app_id="10282822" priority="70" wait="3500" sync_mode="check" call_if_target_app_not_running="false"> <!-- WIDGETMEMORYPLUGIN, target app Widget UI -->
+			<plugin_foreground_app_priority target_app_id="10282822" priority="NEVER_CLOSE"></plugin_foreground_app_priority> <!-- target app Widget UI -->
+		</app_plugin>
+	<!--CWRTWidget.exe  -  Plugin -->	
+		
+		<app_plugin uid="200267D3" target_app_id="200267C0" priority="70" wait="3500" sync_mode="check" call_if_target_app_not_running="false"> 
+			<plugin_foreground_app_priority target_app_id="200267C0" priority="NEVER_CLOSE"></plugin_foreground_app_priority>
+		</app_plugin>
+	
+	<!--CWRTWidget.exe  -  Plugin   End-->		
+	<!--CWRTWidget2.exe  -  Plugin -->	
+		
+		<app_plugin uid="200267DB" target_app_id="200267D6" priority="50" wait="3500" sync_mode="check" call_if_target_app_not_running="false"> 
+			<plugin_foreground_app_priority target_app_id="200267D6" priority="NEVER_CLOSE"></plugin_foreground_app_priority>
+		</app_plugin>
+	
+	<!--CWRTWidget2.exe  -  Plugin   End-->		
+	</app_plugin_settings>
+</oom_config>
--- a/sysresmonitoring/oommonitor/eabi/oommonitorU.DEF	Tue Jun 15 16:07:48 2010 +0100
+++ b/sysresmonitoring/oommonitor/eabi/oommonitorU.DEF	Thu Jul 22 16:35:22 2010 +0100
@@ -17,4 +17,10 @@
 	_ZN20CAppOomMonitorPlugin4NewLE4TUid @ 16 NONAME
 	_ZTI17COomMonitorPlugin @ 17 NONAME ; #<TI>#
 	_ZTV17COomMonitorPlugin @ 18 NONAME ; #<VT>#
+	_ZN18ROomMonitorSession18RequestOptionalRamEiiiRi @ 19 NONAME
+	_ZN19COomMonitorPluginV27FreeRamEv @ 20 NONAME
+	_ZTI19COomMonitorPluginV2 @ 21 NONAME ; #<TI>#
+	_ZTV19COomMonitorPluginV2 @ 22 NONAME ; #<VT>#
+	_ZN18ROomMonitorSession18RequestOptionalRamEiiiR14TRequestStatus @ 23 NONAME
+	_ZN18ROomMonitorSession14SetOomPriorityENS_12TOomPriorityE @ 24 NONAME
 
--- a/sysresmonitoring/oommonitor/group/bld.inf	Tue Jun 15 16:07:48 2010 +0100
+++ b/sysresmonitoring/oommonitor/group/bld.inf	Thu Jul 22 16:35:22 2010 +0100
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2006 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 "Eclipse Public License v1.0"
@@ -18,16 +18,15 @@
 
 #include <platform_paths.hrh>
 
+PRJ_PLATFORMS
+DEFAULT
+
 PRJ_EXPORTS
-../rom/oommonitor.iby             CORE_MW_LAYER_IBY_EXPORT_PATH(oommonitor.iby)
+../rom/oommonitor.iby  CORE_MW_LAYER_IBY_EXPORT_PATH(oommonitor.iby)
+../data/oomconfig.xml  /epoc32/RELEASE/winscw/UDEB/Z/private/10207218/oomconfig.xml
+../data/oomconfig.xml  /epoc32/RELEASE/winscw/UREL/Z/private/10207218/oomconfig.xml
+../data/oomconfig.xml  /epoc32/data/Z/private/10207218/oomconfig.xml
 
 PRJ_MMPFILES
-
-#ifndef TOOLS
-
 oommonitor.mmp
-
-#endif
-
-PRJ_TESTMMPFILES
-// ../internal/oomtestplugin/oomtestplugin.mmp
+oommonitorlib.mmp
--- a/sysresmonitoring/oommonitor/group/oommonitor.mmp	Tue Jun 15 16:07:48 2010 +0100
+++ b/sysresmonitoring/oommonitor/group/oommonitor.mmp	Thu Jul 22 16:35:22 2010 +0100
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2006 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 "Eclipse Public License v1.0"
@@ -18,10 +18,22 @@
 
 #include <platform_paths.hrh>
 
+//uncomment both of these macros to use the CLIENT_REQUEST_QUEUE
+macro CLIENT_REQUEST_QUEUE
+#define CLIENT_REQUEST_QUEUE
+
 TARGET          oommonitor.dll
+
 TARGETTYPE      dll
 UID             0x1000008D 0x10282DBF
 
+NOEXPORTLIBRARY
+#ifdef WINS
+DEFFILE         ../bwins/oommonitor.DEF
+#else
+DEFFILE         ../eabi/oommonitor.DEF
+#endif
+
 CAPABILITY      CAP_GENERAL_DLL
 VENDORID        VID_DEFAULT
 
@@ -32,9 +44,38 @@
 MW_LAYER_SYSTEMINCLUDE
 
 SOURCEPATH      ../src
+SOURCE          oomIdletimerule.cpp
+SOURCE          oomaction.cpp
+SOURCE          oomactionconfig.cpp
+SOURCE          oomactionlist.cpp
+SOURCE          oomactionref.cpp
+SOURCE          oomappclosetimer.cpp
+SOURCE          oomappclosewatcher.cpp
+SOURCE          oomapplicationconfig.cpp
+SOURCE          oomcloseapp.cpp
+SOURCE          oomcloseappconfig.cpp
+SOURCE          oomconfig.cpp
+SOURCE          oomconfigparser.cpp
+SOURCE          oomforegroundrule.cpp
+SOURCE          oomglobalconfig.cpp
+SOURCE          oomlog.cpp
+SOURCE          oommemorymonitor.cpp
+SOURCE          oommemorymonitorserver.cpp
+SOURCE          oommemorymonitorsession.cpp
+SOURCE          oommonitor.cpp
 SOURCE          oommonitorplugin.cpp
 SOURCE          oommonitorsession.cpp
-SOURCE	        oommonitor.cpp
+SOURCE          oomoutofmemorywatcher.cpp
+SOURCE          oompanic.cpp
+SOURCE          oompluginwaiter.cpp
+SOURCE          oomrunplugin.cpp
+SOURCE          oomrunpluginconfig.cpp
+SOURCE          oomsubscribehelper.cpp
+SOURCE          oomwindowgrouplist.cpp
+SOURCE          oomwserveventreceiver.cpp
+#ifdef CLIENT_REQUEST_QUEUE
+SOURCE          oomclientrequestqueue.cpp
+#endif
 
 LIBRARY         euser.lib
 LIBRARY         apparc.lib
@@ -46,5 +87,8 @@
 LIBRARY         ecom.lib
 LIBRARY         hal.lib
 LIBRARY         efsrv.lib
-
-SMPSAFE
+LIBRARY         xmlframework.lib
+LIBRARY         cone.lib
+#ifdef _DEBUG
+LIBRARY         flogger.lib
+#endif 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/group/oommonitorlib.mmp	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,26 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Project definition file
+*
+*/
+
+TARGET          oommonitor.lib
+TARGETTYPE      IMPLIB
+UID             0x1000008D 0x10282DBF
+
+#ifdef WINS
+ DEFFILE         ../bwins/oommonitor.DEF
+#else
+ DEFFILE         ../eabi/oommonitor.DEF
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/inc/OomTraces.h	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,487 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Includes some common defines used in the OOM monitor app.
+*
+*/
+
+
+#ifndef OOMTRACES_H
+#define OOMTRACES_H
+
+#include "traceconfiguration.hrh"
+#include "tracedefs.h"
+
+#ifdef TRACE_INTO_FILE
+#include <flogger.h> // RFileLogger
+#else
+#include <e32debug.h> // RDebug
+#endif
+
+//-----------------------------------------------------------------------------
+// Constants
+//-----------------------------------------------------------------------------
+//
+
+/**
+* Prefix error trace
+*/
+#define _PREFIX_ERROR( aMsg ) _PREFIX_TRACE( "[ERROR: %d]: " L##aMsg )
+
+/**
+* Prefix info trace.
+*/
+#define _PREFIX_INFO( aMsg ) _PREFIX_TRACE( "[INFO]: " L##aMsg )
+
+/**
+* Define needed directories if TRACE_INTO_FILE macro in use
+*/
+#ifdef TRACE_INTO_FILE
+
+    _LIT( KDir, "oommonitor2" );
+    _LIT( KFile, "oommonitor2_log.txt" );
+    _LIT( KFullPath, "c:\\logs\\oommonitor2\\" );
+
+#endif
+
+//-----------------------------------------------------------------------------
+// Error trace macros
+//-----------------------------------------------------------------------------
+//
+#ifdef ERROR_TRACE
+
+    /**
+    * Error trace definitions.
+    */
+    #ifdef TRACE_INTO_FILE
+
+        #define ERROR( aErr, aMsg )\
+            {\
+            if( aErr < KErrNone )\
+                {\
+                RFileLogger::WriteFormat( KDir, KFile, EFileLoggingModeAppend, \
+                    _PREFIX_ERROR( aMsg ), aErr );\
+                }\
+            }
+        #define ERROR_1( aErr, aMsg, aP1 )\
+            {\
+            if( aErr < KErrNone )\
+                {\
+                RFileLogger::WriteFormat( KDir, KFile, EFileLoggingModeAppend, \
+                    _PREFIX_ERROR( aMsg ), aErr, aP1 );\
+                }\
+            }
+        #define ERROR_2( aErr, aMsg, aP1, aP2 )\
+            {\
+            if( aErr < KErrNone )\
+                {\
+                RFileLogger::WriteFormat( KDir, KFile, EFileLoggingModeAppend, \
+                    _PREFIX_ERROR( aMsg ), aErr, aP1, aP2 );\
+                }\
+            }
+        #define ERROR_3( aErr, aMsg, aP1, aP2, aP3 )\
+            {\
+            if( aErr < KErrNone )\
+                {\
+                RFileLogger::WriteFormat( KDir, KFile, EFileLoggingModeAppend, \
+                    _PREFIX_ERROR( aMsg ), aErr, aP1, aP2, aP3 );\
+                }\
+            }
+
+    #else//TRACE_INTO_FILE not defined
+
+        #define ERROR( aErr, aMsg )\
+            {\
+            if( aErr < KErrNone )\
+                {\
+                RDebug::Print( _PREFIX_ERROR( aMsg ), aErr );\
+                }\
+            }
+        #define ERROR_1( aErr, aMsg, aP1 )\
+            {\
+            if( aErr < KErrNone )\
+                {\
+                RDebug::Print( _PREFIX_ERROR( aMsg ), aErr, aP1 );\
+                }\
+            }
+        #define ERROR_2( aErr, aMsg, aP1, aP2 )\
+            {\
+            if( aErr < KErrNone )\
+                {\
+                RDebug::Print( _PREFIX_ERROR( aMsg ), aErr, aP1, aP2 );\
+                }\
+            }
+        #define ERROR_3( aErr, aMsg, aP1, aP2, aP3 )\
+            {\
+            if( aErr < KErrNone )\
+                {\
+                RDebug::Print( _PREFIX_ERROR( aMsg ), aErr, aP1, aP2, aP3 );\
+                }\
+            }
+
+    #endif//TRACE_INTO_FILE
+
+    #define ERROR_GEN( aMsg ) ERROR( KErrGeneral, aMsg )
+    #define ERROR_GEN_1( aMsg, aP1 ) ERROR_1( KErrGeneral, aMsg, aP1 )
+    #define ERROR_GEN_2( aMsg, aP1, aP2 ) ERROR_2( KErrGeneral, aMsg, aP1, aP2 )
+    #define ERROR_GEN_3( aMsg, aP1, aP2, aP3 ) ERROR_3( KErrGeneral, aMsg, aP1, aP3 )
+
+    #define ERROR_PARAM(_p) _p
+
+    #define TRAPD_ERR( aErr, aStmt ) TRAPD( aErr, aStmt )
+    #define TRAP_ERR( aErr, aStmt ) TRAP( aErr, aStmt )
+
+    #define TRAP_AND_LEAVE(_s,_t) \
+        { TRAPD(_e,_s); ERROR(_e,_t); User::LeaveIfError(_e); }
+
+#else//ERROR_TRACE not defined
+
+    #define ERROR( aErr, aMsg )
+    #define ERROR_1( aErr, aMsg, aP1 )
+    #define ERROR_2( aErr, aMsg, aP1, aP2 )
+    #define ERROR_3( aErr, aMsg, aP1, aP2, aP3 )
+    #define ERROR_GEN( aMsg )
+    #define ERROR_GEN_1( aMsg, aP1 )
+    #define ERROR_GEN_2( aMsg, aP1, aP2 )
+    #define ERROR_GEN_3( aMsg, aP1, aP2, aP3 )
+
+    #define ERROR_PARAM(_p)
+
+    #define TRAPD_ERR( aErr, aStmt ) TRAP_IGNORE( aStmt )
+    #define TRAP_ERR( aErr, aStmt )  TRAP_IGNORE( aStmt )
+
+    #define TRAP_AND_LEAVE(_s,_t) { _s; }
+
+#endif//ERROR_TRACE
+
+//-----------------------------------------------------------------------------
+// Info trace macros
+//-----------------------------------------------------------------------------
+//
+#ifdef INFO_TRACE
+
+    /**
+    * Info log message definitions.
+    */
+    #ifdef TRACE_INTO_FILE
+
+        #define TRACES( aMsg )\
+            {\
+            RFileLogger::Write( KDir, KFile, EFileLoggingModeAppend, \
+                _PREFIX_INFO( aMsg ) );\
+            }
+        #define TRACES1( aMsg, aP1 )\
+            {\
+            RFileLogger::WriteFormat( KDir, KFile, EFileLoggingModeAppend, \
+                _PREFIX_INFO( aMsg ), aP1 );\
+            }
+        #define TRACES2( aMsg, aP1, aP2 )\
+            {\
+            RFileLogger::WriteFormat( KDir, KFile, EFileLoggingModeAppend, \
+                _PREFIX_INFO( aMsg ), aP1, aP2 );\
+            }
+        #define TRACES3( aMsg, aP1, aP2, aP3 )\
+            {\
+            RFileLogger::WriteFormat( KDir, KFile, EFileLoggingModeAppend, \
+                _PREFIX_INFO( aMsg ), aP1, aP2, aP3 );\
+            }
+        #define TRACES4( aMsg, aP1, aP2, aP3, aP4 )\
+            {\
+            RFileLogger::WriteFormat( KDir, KFile, EFileLoggingModeAppend, \
+                _PREFIX_INFO( aMsg ), aP1, aP2, aP3, aP4 );\
+            }
+        #define TRACES5( aMsg, aP1, aP2, aP3, aP4, aP5 )\
+            {\
+            RFileLogger::WriteFormat( KDir, KFile, EFileLoggingModeAppend, \
+                _PREFIX_INFO( aMsg ), aP1, aP2, aP3, aP4, aP5 );\
+            }
+
+    #else//TRACE_INTO_FILE not defined
+
+        #define TRACES( aMsg )\
+            {\
+            RDebug::Print( _PREFIX_INFO( aMsg ) );\
+            }
+        #define TRACES1( aMsg, aP1 )\
+            {\
+            RDebug::Print( _PREFIX_INFO( aMsg ), aP1 );\
+            }
+        #define TRACES2( aMsg, aP1, aP2 )\
+            {\
+            RDebug::Print( _PREFIX_INFO( aMsg ), aP1, aP2 );\
+            }
+        #define TRACES3( aMsg, aP1, aP2, aP3 )\
+            {\
+            RDebug::Print( _PREFIX_INFO( aMsg ), aP1, aP2, aP3 );\
+            }
+        #define TRACES4( aMsg, aP1, aP2, aP3, aP4 )\
+            {\
+            RDebug::Print( _PREFIX_INFO( aMsg ), aP1, aP2, aP3, aP4 );\
+            }
+        #define TRACES5( aMsg, aP1, aP2, aP3, aP4, aP5 )\
+            {\
+            RDebug::Print( _PREFIX_INFO( aMsg ), aP1, aP2, aP3, aP4, aP5 );\
+            }
+
+    #endif//TRACE_INTO_FILE
+
+    #define TRACES_PARAM( aParam ) aParam
+
+#else//INFO_TRACE not defined
+
+    #define TRACES( aMsg )
+    #define TRACES1( aMsg, aP1 )
+    #define TRACES2( aMsg, aP1, aP2 )
+    #define TRACES3( aMsg, aP1, aP2, aP3 )
+    #define TRACES4( aMsg, aP1, aP2, aP3, aP4 )
+    #define TRACES5( aMsg, aP1, aP2, aP3, aP4, aP5 )
+    #define TRACES_PARAM( aParam )
+
+#endif//INFO_TRACE
+
+//-----------------------------------------------------------------------------
+// Trace current client thread name and process id
+//-----------------------------------------------------------------------------
+//
+#ifdef CLIENT_TRACE
+
+    #define CLIENT( aMessage )\
+        {\
+        RThread thread;\
+        TInt err = aMessage.Client( thread );\
+        if( err == KErrNone )\
+            {\
+            RProcess process;\
+            err = thread.Process( process );\
+            if( err == KErrNone )\
+                {\
+                TPtrC thredName( thread.Name() );\
+                TUid processUid( process.SecureId() );\
+                TRACES2( "Current client process UID: [%x], thread name: [%S]",\
+                    processUid,\
+                    &thredName );\
+                }\
+            process.Close();\
+            }\
+        thread.Close();\
+        }
+
+#else
+
+    #define CLIENT( aMessage )
+
+#endif
+
+//-----------------------------------------------------------------------------
+// Function trace macros
+//-----------------------------------------------------------------------------
+//
+#ifdef FUNC_TRACE
+
+    #include <e32base.h> // TCleanupItem
+
+    /**
+    * Function logging definitions.
+    */
+    #ifdef TRACE_INTO_FILE
+
+        #define FUNC( aMsg, aP1 )\
+            {\
+            TPtrC8 trace( _S8( aMsg ) );\
+            RFileLogger::WriteFormat( KDir, KFile, EFileLoggingModeAppend, trace, aP1 );\
+            }\
+
+    #else//TRACE_INTO_FILE not defined
+
+        #define FUNC( aMsg, aP1 )\
+            {\
+            RDebug::Printf( aMsg, aP1 );\
+            }\
+
+    #endif//TRACE_INTO_FILE
+
+    /**
+    * Function trace helper class.
+    *
+    * NOTE:
+    * LC -methods cannot be trapped. Therefore if LC -method leaves
+    * END trace is used instead of LEAVE trace.
+    * If you have an idea how to round this problem please tell.
+    */
+    _LIT8( KFuncNameTerminator, "(" );
+    _LIT8( KFuncLeavePatternL, "L" );
+    class TFuncLog
+        {
+        public:
+            static void Cleanup( TAny* aPtr )
+                {
+                TFuncLog* self = static_cast< TFuncLog* >( aPtr );
+                self->iLeft = ETrue;
+                FUNC( _PREFIX_CHAR("%S-LEAVE"), &self->iFunc ); // Leave detected
+                }
+            inline TFuncLog( const char* aFunc ) :
+                    iFunc( aFunc ? _S8( aFunc ) : _S8("") ),
+                    iLeft( EFalse ),
+                    iCleanupItem( Cleanup, this ),
+                    iCanLeave( EFalse )
+                {
+                TInt pos( iFunc.Find( KFuncNameTerminator ) );
+                if( pos != KErrNotFound )
+                    {
+                    iFunc.Set( iFunc.Left( pos ) );
+                    iCanLeave = !iFunc.Right(
+                        KFuncLeavePatternL().Length() ).Compare( KFuncLeavePatternL );
+                    if ( iCanLeave )
+                        {
+                        CleanupStack::PushL( iCleanupItem ); // Ignore warnings
+                        }
+                    }
+                FUNC( _PREFIX_CHAR("%S-START"), &iFunc );
+                }
+
+            inline ~TFuncLog()
+                {
+                if ( !iLeft )
+                    {
+                    if ( iCanLeave )
+                        {
+                        CleanupStack::Pop( this ); // Pop the cleanup item
+                        }
+                    FUNC( _PREFIX_CHAR("%S-END"), &iFunc ); // Normally finished
+                    }
+                }
+
+        private: // Data
+            TPtrC8 iFunc;
+            TBool iLeft;
+            TCleanupItem iCleanupItem;
+            TBool iCanLeave;
+        };
+    #define FUNC_LOG TFuncLog _fl( __PRETTY_FUNCTION__ );
+
+#else//FUNC_TRACE not defined
+
+    #define FUNC_LOG
+
+#endif//FUNC_TRACE
+
+//-----------------------------------------------------------------------------
+// Timestamp trace macros
+//-----------------------------------------------------------------------------
+//
+#ifdef TIMESTAMP_TRACE
+
+    #define PREFIX_TIMESTAMP( aCaption ) _PREFIX_TRACE_2("[TIMESTAMP] (%d:%02d:%02d.%06d us) ",aCaption)
+    #define CURRENT_TIME( aDt ) TDateTime aDt; { TTime t; t.HomeTime(); aDt = t.DateTime(); }
+    #define EXTRACT_TIME( aDt ) aDt.Hour(), aDt.Minute(), aDt.Second(), aDt.MicroSecond()
+
+    #ifdef TRACE_INTO_FILE
+
+        #define TIMESTAMP( aCaption )\
+            {\
+            CURRENT_TIME( dt );\
+            RFileLogger::WriteFormat( KDir, KFile, EFileLoggingModeAppend,\
+                PREFIX_TIMESTAMP(aCaption),EXTRACT_TIME( dt ) );\
+            }
+
+        #define TIMESTAMP_1( aCaption, aP1 )\
+            {\
+            CURRENT_TIME( dt );\
+            RFileLogger::WriteFormat( KDir, KFile, EFileLoggingModeAppend,\
+                PREFIX_TIMESTAMP(aCaption),EXTRACT_TIME( dt ),aP1 );\
+            }
+
+        #define TIMESTAMP_2( aCaption, aP1, aP2 )\
+            {\
+            CURRENT_TIME( dt );\
+            RFileLogger::WriteFormat( KDir, KFile, EFileLoggingModeAppend,\
+                PREFIX_TIMESTAMP(aCaption),EXTRACT_TIME( dt ),aP1,aP2 );\
+            }
+
+        #define TIMESTAMP_3( aCaption, aP1, aP2, aP3 )\
+            {\
+            CURRENT_TIME( dt );\
+            RFileLogger::WriteFormat( KDir, KFile, EFileLoggingModeAppend,\
+                PREFIX_TIMESTAMP(aCaption),EXTRACT_TIME( dt ),aP1,aP2,aP3 );\
+            }
+
+    #else//TRACE_INTO_FILE not defined
+
+        #define TIMESTAMP( aCaption )\
+            {\
+            CURRENT_TIME( dt );\
+            RDebug::Print( PREFIX_TIMESTAMP(aCaption),EXTRACT_TIME( dt ) );\
+            }
+
+        #define TIMESTAMP_1( aCaption, aP1 )\
+            {\
+            CURRENT_TIME( dt );\
+            RDebug::Print( PREFIX_TIMESTAMP(aCaption),EXTRACT_TIME( dt ),aP1 );\
+            }
+
+        #define TIMESTAMP_2( aCaption, aP1, aP2 )\
+            {\
+            CURRENT_TIME( dt );\
+            RDebug::Print( PREFIX_TIMESTAMP(aCaption),EXTRACT_TIME( dt ),aP1,aP2 );\
+            }
+
+        #define TIMESTAMP_3( aCaption, aP1, aP2, aP3 )\
+            {\
+            CURRENT_TIME( dt );\
+            RDebug::Print( PREFIX_TIMESTAMP(aCaption),EXTRACT_TIME( dt ),aP1,aP2,aP3 );\
+            }
+
+    #endif//TRACE_INTO_FILE
+
+#else//TIMESTAMP_TRACE not defined
+
+    #define TIMESTAMP( aCaption )
+    #define TIMESTAMP_1( aCaption, aP1 )
+    #define TIMESTAMP_2( aCaption, aP1, aP2 )
+    #define TIMESTAMP_3( aCaption, aP1, aP2, aP3 )
+
+#endif//TIMESTAMP_TRACE
+
+#ifdef _DEBUG
+
+    #include <e32debug.h> // RDebug
+
+    static void Panic( const TDesC8& aFileName, const TInt aLineNum )
+        {
+        TPath name;
+        name.Copy( aFileName );
+        RDebug::Print( _L( "Assertion failed in file=%S, line=%d" ), &name, aLineNum );
+        User::Invariant();
+        }
+
+    #define ASSERT_ALWAYS_TRACE Panic( _L8(__FILE__), __LINE__ );
+    #define ASSERT_TRACE( _s ) if ( !( _s ) ) { ASSERT_ALWAYS_TRACE; }
+
+#else // _DEBUG
+
+    #define ASSERT_ALWAYS_TRACE
+    #define ASSERT_TRACE( _s )
+
+#endif // _DEBUG
+
+#define TRACE_MATRIX( aMsg, aMatrix ) \
+    TRACES( aMsg ); \
+    TRACES( "------------------------------------------------" ); \
+    TRACES3( "       [%f %f %f]", (TReal)(aMatrix)[0], (TReal)(aMatrix)[1], (TReal)(aMatrix)[2] ); \
+    TRACES3( "Matrix [%f %f %f]", (TReal)(aMatrix)[3], (TReal)(aMatrix)[4], (TReal)(aMatrix)[5] ); \
+    TRACES3( "       [%f %f %f]", (TReal)(aMatrix)[6], (TReal)(aMatrix)[7], (TReal)(aMatrix)[8] ); \
+    TRACES( "------------------------------------------------" );
+
+#endif      // OOMTRACES_H
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/inc/oomaction.h	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,81 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Classes for executing OOM actions (e.g. closing applications and running plugins).
+*
+*/
+
+
+#ifndef OOMACTION_H_
+#define OOMACTION_H_
+
+#include <e32base.h>
+
+class MOomActionObserver;
+
+/*
+ * The base class for all OOM actions (i.e. close application or run OOM plug-in).
+ * 
+ * A base class is used because both types of action have common aspects, specifically:
+ *  - They are prioritised according to application idle time
+ *  - They need to be prioritised against each other
+ *  - For each action it is possible to either continue immediately or to wait for completion
+ *  
+ * @lib oommonitor.lib
+ * @since S60 v5.0
+ */
+NONSHARABLE_CLASS(COomAction) : public CBase
+    {
+public:
+
+    virtual ~COomAction();
+    
+    /**
+     * Activate the OOM action
+     *
+     * @since S60 5.0
+     * @param aBytesRequested ?description
+     */ 
+    virtual void FreeMemory(TInt aBytesRequested, TBool aIsDataPaged) = 0;
+    
+    /**
+     * @since S60 5.0
+     * @return ETrue if the action is currently freeing memory, else EFalse
+     */ 
+    virtual TBool IsRunning() = 0;
+    
+protected:
+    // 
+    /**
+     * To be called by the derived class after the memory has been freed (or if it fails)
+     * 
+     * @since S60 5.0
+     * @param aError KErrNone if memory has successfully been freed, otherwise any system wide error code
+     */ 
+    void MemoryFreed(TInt aError);
+    
+    COomAction(MOomActionObserver& aStateChangeObserver);
+    
+private: //data
+    
+    enum TOomActionState
+        {
+        EOomIdle,
+        EOomFreeingMemory
+        };  
+    TOomActionState iState;
+    
+    MOomActionObserver& iStateChangeObserver;
+    };
+
+#endif /*OOMACTION_H_*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/inc/oomactionconfig.h	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,82 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Configuration representation classes for Out of Memory Monitor.
+*
+*/
+
+
+#ifndef OOMACTIONCONFIG_
+#define OOMACTIONCONFIG_
+
+#include <e32cmn.h>
+#include <e32std.h>
+#include <w32std.h>
+
+class MOomRuleConfig;
+class COomWindowGroupList;
+
+enum TOomSyncMode
+    {
+    EContinue,					// Continue with the next action regardless of anything else (exluding max_batch_size)
+    EEstimate,					// Continue with the next action if we estimate that we need to free more memory
+    ECheckRam,					// Wait for this action to complete, then check the free RAM before continuing
+    EContinueIgnoreMaxBatchSize // Continue with the next action regardless of anything else (including max_batch_size)
+    };
+
+/*
+ * The base class for the configuration of all OOM actions
+ * 
+ * @lib oommonitor.lib
+ * @since S60 v5.0
+ */
+NONSHARABLE_CLASS(COomActionConfig) : public CBase
+    {
+public:
+    // Add a rule
+    // This class takes ownership of the given rule
+    void AddRuleL(MOomRuleConfig* aRule);    // Add the configuration for a rule (e.g. an idle time rule)
+            
+    virtual ~COomActionConfig();
+    
+    // Set the priority of this action
+    // This priority will be applied if none of the attached rules can be applied
+    inline void SetDefaultPriority(TUint aPriority);
+    
+protected:
+    
+    // Return the priority for this action for the idle time of the target app
+    TUint Priority(const COomWindowGroupList& aWindowGroupList, TInt aAppIndexInWindowGroup) const;
+    
+    void ConstructL();
+
+    COomActionConfig(TInt32 aId);
+    
+public:
+    
+    TOomSyncMode iSyncMode;
+    
+    TInt iRamEstimate;    // The estimated RAM saving after performing this action
+    
+    TInt32 iId;        // The ID of the affected component (e.g. an application ID for app closure, or a plugin ID for a plugin event)
+    
+    TUint iDefaultPriority;
+    
+protected:    
+    
+    RPointerArray<MOomRuleConfig> iRules;
+    };
+
+#include "oomactionconfig.inl"
+
+#endif /*OOMACTIONCONFIG_*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/inc/oomactionconfig.inl	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,30 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Configuration representation classes for Out of Memory Monitor.
+*
+*/
+
+
+#ifndef OOMACTIONCONFIGINL_H_
+#define OOMACTIONCONFIGINL_H_
+
+// Set the priority of this action
+// This priority will be applied if none of the attached rules can be applied
+inline void COomActionConfig::SetDefaultPriority(TUint aPriority)
+    {
+    iDefaultPriority = aPriority;
+    }
+
+
+#endif /*OOMACTIONCONFIGINL_H_*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/inc/oomactionlist.h	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,240 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Classes for executing OOM actions (e.g. closing applications and running plugins).
+*
+*/
+
+
+#ifndef OOMACTIONLIST_H_
+#define OOMACTIONLIST_H_
+
+#include <e32def.h>
+#include <e32base.h>
+
+#include "oommonitorplugin.h"
+
+class COomWindowGroupList;
+class CMemoryMonitorServer;
+class COomCloseApp;
+class TActionRef;
+class COomRunPlugin;
+class COomConfig;
+
+/*
+ * Interface for reporting a change of state in an OOM action
+ * e.g. that the action has changed from a freeing-memory state to an idle state
+ * 
+ * @lib oommonitor.lib
+ * @since S60 v5.0
+ */
+class MOomActionObserver
+    {
+public:
+    virtual void StateChanged() = 0;
+    };
+
+
+template <class T> 
+/**
+ *  A class for getting instances of all of the OOM ECom plugins
+ *  This class is templated because we actually need two types of list
+ *  One list for V1 plugins
+ *  One list for V2 plugins
+ *  The functionality of each list is nearly identical, hence the templated class
+ *  
+ * @lib oommonitor.lib
+ * @since S60 v5.0
+ */
+NONSHARABLE_CLASS(COomPluginList) : public CBase
+    {
+public:
+    
+    /** 
+     * Two-phased constructor.
+     * @param aInterfaceUid The interface of the plugin (either V1 or V2) depending on the templated type
+     */
+    static COomPluginList* NewL(TInt aInterfaceUid);
+    inline TInt Count();
+    inline T& Implementation(TInt aIndex);
+    inline TInt32 Uid(TInt aIndex);
+    
+    ~COomPluginList();
+    
+private:
+    COomPluginList();
+    void ConstructL(TInt aInterfaceUid);
+    
+private: // data
+    
+    struct TPlugin
+        {
+        TPlugin();
+        T* iImpl;
+        TUid iDtorUid;
+        TInt32 iUid;
+        };
+    
+    RArray<TPlugin> iPlugins;
+    };
+
+/*
+ * The list of possible OOM actions to be run.
+ * 
+ * This class is responsible for identifying the best action(s) to execute at a given time.
+ * This decision is based on the properties of each action and idle time of the target apps.
+ *
+ *  @lib oommonitor.lib
+ *  @since S60 v5.0
+ */
+NONSHARABLE_CLASS(COomActionList) : public CBase, public MOomActionObserver
+    {
+public:
+
+    /**
+     * Two-phased constructor.
+     * @param aMonitor the owning Memory Monitor
+     * @param aServer 
+     * @param aWs a handle to a window server session, opened by the Memory Monitor
+     * @param aConfig
+     */
+    static COomActionList* NewL(CMemoryMonitor& aMonitor, CMemoryMonitorServer& aServer, RWsSession& aWs, COomConfig& aConfig);
+
+    ~COomActionList();
+    
+    /**
+     * Creates a list of actions based on the contents of the config and the current window group list
+     * Any old actions will be replaced.
+     * 
+     * @since S60 5.0
+     * @param aWindowGroupList
+     * @param aConfig
+     */
+    void BuildActionListL(COomWindowGroupList& aWindowGroupList, COomConfig& aConfig);    
+    
+    template <class T>
+    void BuildPluginActionsL(COomPluginList<T>& aPluginList, COomWindowGroupList& aWindowGroupList, COomConfig& aConfig, TInt& aActionsIndex);
+    
+    /**
+     * Execute the OOM actions according to their priority
+     * Actions are run in batches according to their sync mode
+     * 
+     * @since S60 5.0
+     * @param aMaxPriority The maximum priority of actions to run 
+     */     
+    void FreeMemory(TInt aMaxPriority);
+    
+    /**
+     * Sets the target; the maximum prioirity up to which actions are run when an OomMonitor event 
+     * occurs
+     * 
+     * @since S60 5.0
+     * @param aCurrentRamTarget the desired amount of free unpaged memory
+	 * @param aCurrentSwapTarget the desired amount of free paged memory
+     */    
+    inline void SetCurrentTargets(TUint aCurrentRamTarget, TUint aCurrentSwapTarget);
+    
+    /**
+     * Switch all plugins to Off (Memory Good) state
+     * Should be called when the memory situation is good, i.e. the actions run have released enough memory 
+     * so that the device is above the current target.
+     * It is also always called after an optional RAM request has been processed, even if insufficient
+     * memory could be freed to successfully complete the request.
+     * 
+     * @since S60 5.0
+     */     
+    void SwitchOffPlugins();
+        
+    /**
+     * Compares priorites of two actions, hard-coded rules are used to determine the order 
+     * of actions with equal priority:
+     * - application plugins are run in preference to system plugins
+     * - appliction plugins where the target app is not running are run first
+     * - Z order of the target app determines order of the rest of the application plugins (furthest back first)
+     * - system plugins are run before app close actions
+     * - Z order determines the prioirty of app close actions (furthest back first)
+     * 
+     * @since S60 5.0
+     */    
+    static TInt ComparePriorities(const TActionRef& aPos1, const TActionRef& aPos2 );
+
+    /**
+     * A callback from the UI framework that an applications has failed to respond to the close event.
+     * Allows us to cleanup the related app close action object and move on the next available action.
+     * 
+     * @since S60 5.0
+     * @param aWgId the window group ID of the application that has not closed.
+     */    
+    void AppNotExiting(TInt aWgId);
+    
+// from MOomActionObserver
+
+    /**
+     * 
+     * from MOomActionObserver
+     * 
+     * An action has changed state (possibly it has completed freeing memory)
+     */
+    void StateChanged();    
+    
+private:
+    
+    COomActionList(CMemoryMonitor& aMonitor, CMemoryMonitorServer& aServer, RWsSession& aWs);
+    
+    void ConstructL(COomConfig& aConfig);
+    
+private: //data    
+    
+    RWsSession& iWs;
+    
+    RPointerArray<COomCloseApp> iCloseAppActions;
+    RPointerArray<COomRunPlugin> iRunPluginActions;
+    RArray<TActionRef> iActionRefs;
+    
+    TInt iCurrentActionIndex;
+        
+    TUint iCurrentRamTarget;
+    TBool iSwapUsageMonitored;
+    TUint iCurrentSwapTarget;
+
+    /*
+     * Flag specifying that a OomMonitor event is in progress.
+     */
+    TBool iFreeingMemory;
+    
+    CMemoryMonitor& iMonitor;
+
+    /**
+     * The list of V1 plugins
+     * Own
+     */
+    COomPluginList<COomMonitorPlugin>* iPluginList;
+    
+    /**
+     * The list of V2 plugins
+     * Own
+     */
+    COomPluginList<COomMonitorPluginV2>* iPluginListV2;
+    
+    /**
+     * The maximum priority of actions that should be run by an OomMonitor Event
+     */
+    TInt iMaxPriority; 
+    
+    CMemoryMonitorServer& iServer;
+    
+    };
+
+#include "oomactionlist.inl"
+
+#endif /*OOMACTIONLIST_H_*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/inc/oomactionlist.inl	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,47 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Classes for executing OOM actions (e.g. closing applications and running plugins).
+*
+*/
+
+
+#ifndef OOMACTIONLISTINL_H_
+#define OOMACTIONLISTINL_H_
+
+template <class T>
+inline TInt COomPluginList<T>::Count()
+    {
+    return iPlugins.Count();
+    }
+    
+template <class T>
+inline T& COomPluginList<T>::Implementation(TInt aIndex)
+    {
+    return *(iPlugins[aIndex].iImpl);
+    }
+
+template <class T>
+inline TInt32 COomPluginList<T>::Uid(TInt aIndex)
+    {
+    return iPlugins[aIndex].iUid;
+    }
+    
+inline void COomActionList::SetCurrentTargets(TUint aCurrentRamTarget, TUint aCurrentSwapTarget)
+    {
+    iCurrentRamTarget = aCurrentRamTarget;
+    iCurrentSwapTarget = aCurrentSwapTarget;
+    }
+
+
+#endif /*OOMACTIONLISTINL_H_*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/inc/oomactionref.h	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,73 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Classes for executing OOM actions (e.g. closing applications and running plugins).
+*
+*/
+
+
+#ifndef OOMACTIONREF_H_
+#define OOMACTIONREF_H_
+
+#include <e32base.h>
+#include "oomactionconfig.h"
+
+class COomRunPlugin;
+
+/**
+ *  Encapsulates a reference to an action. 
+ *  
+ *  Objects of this T-class are instantiated at memory freeing time in preference to the  
+ *  COomAction derived objects, so that we do not instantiate anything on the heap at a time
+ *  when the device is, by-definition, low on memory.
+ *
+ *  @lib oommonitor.lib
+ *  @since S60 v5.0
+ */
+class TActionRef
+    {
+public:
+    
+    enum TActionType
+        {
+        EAppPlugin,
+        ESystemPlugin,
+        EAppClose
+        };
+
+    //constructor for Plugin actions
+    TActionRef(TActionType aType, TInt aPriority, TOomSyncMode aSyncMode, TInt aRamEstimate, COomRunPlugin& aRunPlugin, TUint aWgIndexOfTargetApp);
+
+    //constructor for AppClose actions
+    TActionRef(TActionType aType, TInt aPriority, TOomSyncMode aSyncMode, TInt aRamEstimate, TInt aWgId, TUint aWgIndex);
+    
+    TActionType Type() const;
+    TUint Priority() const;
+    TOomSyncMode SyncMode() const;
+    TInt RamEstimate() const;
+    TInt WgId() const;
+    TInt WgIndex() const;
+    COomRunPlugin& RunPlugin();
+
+private: //data
+    
+    TActionType iType;
+    TUint iPriority;
+    TOomSyncMode iSyncMode; //needed as we don't have reference to the config 
+    TInt iRamEstimate; //needed as we don't have reference to the config 
+    TInt iWgId; //For AppClose
+    TInt iWgIndex;
+    COomRunPlugin* iRunPlugin; //For Plugins. Not owned
+    };
+
+#endif /*OOMACTIONREF_H_*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/inc/oomappclosetimer.h	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,53 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Timer class which implements a timeout for an application close action.
+*
+*/
+
+
+#ifndef OOMAPPCLOSETIMER_H_
+#define OOMAPPCLOSETIMER_H_
+
+#include <e32base.h>
+
+class COomCloseApp;
+
+/**
+ *  A simple timer class which implements a timeout for an application close action.
+ *
+ *  If the application has not been closed within the period this timer is started with, 
+ *  then we complete the action as if he had been successful, allowing us to move on to the 
+ *  action or set of actions.
+ *
+ *  @lib oommonitor.lib
+ *  @since S60 v5.0
+ */
+NONSHARABLE_CLASS(COomAppCloseTimer) : public CTimer
+    {
+public:
+    static COomAppCloseTimer* NewL(COomCloseApp& aMonitor);
+private:
+    COomAppCloseTimer(COomCloseApp& aMonitor);
+    void RunL();
+    
+private: //data
+	
+    /**
+     * A reference to the owning close app action
+     */
+    COomCloseApp& iMonitor;
+    
+    };
+
+#endif /*OOMAPPCLOSETIMER_H_*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/inc/oomappclosewatcher.h	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,64 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  An active object which watches for app close actions successfully completing.
+*
+*/
+
+
+#ifndef OOMAPPCLOSEWATCHER_H_
+#define OOMAPPCLOSEWATCHER_H_
+
+#include <e32base.h>
+
+class COomCloseApp;
+class TApaTask;
+
+/**
+ *  This class implements an active object which watches for app close actions successfully completing.
+ *  
+ *  This watcher object logs-on to the thread of the application being closed and completes 
+ *  the app close action when the thread dies.  
+ *
+ *  @lib oommonitor.lib
+ *  @since S60 v5.0
+ */
+NONSHARABLE_CLASS(COomAppCloseWatcher) : public CActive
+    {
+public:
+    COomAppCloseWatcher(COomCloseApp& aMonitor);
+    ~COomAppCloseWatcher();
+    void Start(const TApaTask& aTask);
+private:
+    void DoCancel();
+    void RunL();
+    
+private: //data
+
+    /**
+     * A reference to the owning close app action
+     */
+	COomCloseApp& iMonitor;
+
+    /**
+     * A handle to the main thread of the application to be closed.
+     */
+    RThread iThread;
+    
+    /**
+     * A backup of the orginal priority of the application's process
+     */
+    TProcessPriority iOriginalProcessPriority;
+    };
+
+#endif /*OOMAPPCLOSEWATCHER_H_*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/inc/oomapplicationconfig.h	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,92 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Configuration representation classes for Out of Memory Monitor.
+*
+*/
+
+
+#ifndef OOMAPPLICATIONCONFIG_
+#define OOMAPPLICATIONCONFIG_
+
+#include <e32base.h>
+
+class COomCloseAppConfig;
+class MOomRuleConfig;
+
+/*
+ * A list of action configurations for a particular target application.
+ *
+ * All configured actions in this list must be for the same target application.
+ * Actions may be configured to close the application or to run an OOM plugin.
+ *  
+ *  @lib oommonitor.lib
+ *  @since S60 v5.0
+ */
+NONSHARABLE_CLASS(COomApplicationConfig) : public CBase
+    {
+public:
+    
+    /**
+     * Two-phased constructor
+     * @param aApplicationId the UID of the application
+     */
+	static COomApplicationConfig* NewL(TUint aApplicationId);
+    
+// Functions for getting configuration  
+    
+    /**
+     * Return a pointer to the close app config, this may be NULL if no app close config has been configured
+     * Ownership is NOT passed to the caller
+     */
+    inline COomCloseAppConfig* GetAppCloseConfig();
+        
+    inline TUint Id();
+    
+// Functions for setting configuration  
+
+    inline void SetAppCloseConfig(COomCloseAppConfig* aActionConfig);
+    
+    /**
+     * Add a rule
+     * 
+     * This class takes ownership of the given rule
+     * The rule would will apply to the "application close" event
+     */
+    void AddRuleL(MOomRuleConfig* aRule);
+    
+    ~COomApplicationConfig();
+
+public:
+    
+    TUint iGoodRamThreshold;
+    TUint iLowRamThreshold; 
+    TUint iGoodSwapThreshold;
+    TUint iLowSwapThreshold; 
+    
+private:
+    
+    void ConstructL();
+    
+    COomApplicationConfig(TUint aApplicationId);
+    
+    COomCloseAppConfig* iCloseAppConfig;
+    
+    TInt iIndex;
+    
+    TUint iApplicationId;
+    };
+
+#include "oomapplicationconfig.inl"
+
+#endif /*OOMAPPLICATIONCONFIG_*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/inc/oomapplicationconfig.inl	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,42 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Configuration representation classes for Out of Memory Monitor.
+*
+*/
+
+
+#ifndef OOMAPPLICATIONCONFIGINL_H_
+#define OOMAPPLICATIONCONFIGINL_H_
+
+#include "oompanic.h"
+
+inline COomCloseAppConfig* COomApplicationConfig::GetAppCloseConfig()
+    {
+    return iCloseAppConfig;
+    }
+
+inline void COomApplicationConfig::SetAppCloseConfig(COomCloseAppConfig* aActionConfig)
+    {
+    __ASSERT_ALWAYS(iCloseAppConfig == NULL, OomMonitorPanic(KSameAppClosureConfiguredTwice));
+    
+    iCloseAppConfig = aActionConfig;
+    }
+
+
+inline TUint COomApplicationConfig::Id()
+    {
+    return iApplicationId;
+    }
+
+#endif /*OOMAPPLICATIONCONFIGINL_H_*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/inc/oomclientrequestqueue.h	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,134 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  COomClientRequestQueue.cpp.
+*
+*/
+
+
+#ifndef COOMCLIENTREQUESTQUEUE_H
+#define COOMCLIENTREQUESTQUEUE_H
+
+#include <e32std.h>
+#include <e32base.h>
+#include <e32property.h>
+
+#include "oommemorymonitor.h"
+
+class COomClientRequestQueue;
+class CMemoryMonitor;
+class CSubscribeHelper;
+
+class TClientRequest
+    {
+public:
+    TClientRequest(TActionTriggerType aClientRequestType, TInt aBytesRequested);    
+    TClientRequest(TActionTriggerType aClientRequestType, const RMessage2& aRequestFreeRam);    
+public:    
+    TActionTriggerType iClientRequestType;
+    TInt iBytesRequested;
+    RMessage2 iRequestFreeRamMessage;
+    TSglQueLink iLink;
+    };
+
+/*
+ *  If two client requests are queued, the COomClientRequestTimer is used to wait after the first request 
+ *  has been completed, to allow the first client time to allocate the memory it requested.
+ *
+ *  @lib oommonitor.lib
+ *  @since S60 v5.0
+ */
+NONSHARABLE_CLASS(COomClientRequestTimer) : public CTimer
+    {
+public:
+    static COomClientRequestTimer* NewL(COomClientRequestQueue& aQueue);
+private:
+    COomClientRequestTimer(COomClientRequestQueue& aQueue);
+    void RunL();    
+    
+private: //data
+    COomClientRequestQueue& iClientRequestQueue;
+    };
+
+/**
+ *  Queues client requests so that the actual RAM level of the device is in a state where it can be more 
+ *  accurately determined whether more actions need to be run
+ *
+ *  @lib oommonitor.lib
+ *  @since S60 v5.0 
+ */
+NONSHARABLE_CLASS(COomClientRequestQueue) : public CBase
+    {
+public:
+ 
+    // Constructors and destructor
+
+    /**
+     * Destructor.
+     */
+    ~COomClientRequestQueue();
+
+    /**
+     * Two-phased constructor.
+     */
+    static COomClientRequestQueue* NewL(CMemoryMonitor& aMonitor);
+   
+    CMemoryMonitor& Monitor();
+    
+    void RequestFreeMemoryL(const RMessage2& aMessage);
+    void RequestOptionalRamL(const RMessage2& aMessage);
+    void ActionsCompleted(TInt aBytesFree, TBool aMemoryGood);
+    void RequestTimerCallbackL();
+    
+private:
+
+    /**
+     * Constructor for performing 1st stage construction
+     */
+    COomClientRequestQueue(CMemoryMonitor& aMonitor);
+
+    /**
+     * EPOC default constructor for performing 2nd stage construction
+     */
+    void ConstructL();
+    
+    static TInt WatchdogStatusStatusChanged(TAny* aPtr);
+    void HandleWatchdogStatusCallBack();
+    void AddClientRequestL(TClientRequest& request);
+    void StartClientRequestL();    
+    
+    // parameters for P&S watcher.
+
+    /**
+     * The handle to the P&S property that can be used to initiate OOM Monitor actions
+     */    
+    RProperty iWatchdogStatusProperty;
+    
+    /**
+     * The active object which monitors the P&S property that can be used to initiate OOM Monitor actions
+     * Own.       
+     */    
+    CSubscribeHelper* iWatchdogStatusSubscriber;
+    
+    TSglQue<TClientRequest> iQueue;
+    
+    TBool iClientRequestActive;
+    
+    CMemoryMonitor& iMonitor;
+
+    COomClientRequestTimer* iClientRequestTimer;
+
+    TTime iLastClientCompletedTime;
+    };
+
+#endif // COOMCLIENTREQUESTQUEUE_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/inc/oomcloseapp.h	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,100 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Classes for executing OOM actions (e.g. closing applications and running plugins).
+*
+*/
+
+
+#ifndef OOMCLOSEAPP_H_
+#define OOMCLOSEAPP_H_
+
+
+#include <apgtask.h>
+
+#include "oomaction.h"
+
+class COomAppCloseTimer;
+class COomAppCloseWatcher;
+class TApaTask;
+class TActionRef;
+
+/*
+ * The OOM action of closing an application in order to free up memory.
+ *
+ *  @lib oommonitor.lib
+ *  @since S60 v5.0
+ */
+NONSHARABLE_CLASS(COomCloseApp) : public COomAction
+    {
+public:
+    /**
+     * Two-phased constructor.
+     * @param aStateChangeObserver an observer to the state of the application
+     * @param aWs a connected handle to a window server session
+     */
+    static COomCloseApp* NewL(MOomActionObserver& aStateChangeObserver, RWsSession& aWs);
+        
+    //from COomAction
+    
+    /**
+     * Close the application in order to free memory
+     * Call the COomAction::MemoryFreed when it is done
+     * @param aBytesRequested not used for clsoe app actions
+     */
+    virtual void FreeMemory(TInt aBytesRequested, TBool aIsDataPaged);
+    
+    ~COomCloseApp();
+    
+    /**
+     * Callback from COomAppCloseWatcher and COomAppCloseTimer
+     */
+    void CloseAppEvent();
+    
+    inline TBool IsRunning();
+
+    /**
+     * Configure, or reconfigure the COomCloseApp object
+     * Action objects are reused to minimize any memory allocation when memory is low
+     */
+    void Reconfigure(const TActionRef& aRef);
+
+    inline TUint WgId() const;
+    
+private:
+    
+    COomCloseApp(MOomActionObserver& aStateChangeObserver, RWsSession& aWs);
+    
+    void ConstructL();
+    
+    TUint iWgId;
+        
+    TBool iAppCloserRunning;
+    TApaTask iCurrentTask;
+
+    /**
+     * A timeout for an app close action
+     * Own
+     */
+    COomAppCloseTimer* iAppCloseTimer;
+
+    /**
+     * A watcher for the application closing
+     * Own
+     */
+    COomAppCloseWatcher* iAppCloseWatcher; 
+    };
+
+#include "oomcloseapp.inl"
+
+#endif /*OOMCLOSEAPP_H_*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/inc/oomcloseapp.inl	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,32 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Classes for executing OOM actions (e.g. closing applications and running plugins).
+*
+*/
+
+
+#ifndef OOMCLOSEAPPINL_H_
+#define OOMCLOSEAPPINL_H_
+
+inline TBool COomCloseApp::IsRunning()
+    {
+    return iAppCloserRunning;
+    }
+
+inline TUint COomCloseApp::WgId() const
+    {
+    return iWgId;
+    }
+
+#endif /*OOMCLOSEAPPINL_H_*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/inc/oomcloseappconfig.h	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,59 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Configuration representation classes for Out of Memory Monitor.
+*
+*/
+
+
+#ifndef OOMCLOSEAPPCONFIG_
+#define OOMCLOSEAPPCONFIG_
+
+#include "oomactionconfig.h"
+
+/*
+ * 
+ */
+/**
+ *  The OOM action of closing an application in order to free up memory.
+ *
+ *  @lib oommonitor.lib
+ *  @since S60 v5.0
+ */
+NONSHARABLE_CLASS(COomCloseAppConfig) : public COomActionConfig
+    {
+public:
+    /**
+     * Two-phased constructor.
+     * @param aId The Uid of the applicaton
+     */
+    static COomCloseAppConfig* NewL(TInt32 aId);
+    
+    ~COomCloseAppConfig();
+
+    /**
+     * Calculates the priority of a close app action, based on its position on the window group list
+     * 
+     * @param aWindowGroupList a fully constructed, collapsed window group list
+     * @param aAppIndexInWindowGroup the position in the window group list
+     */
+    inline TUint CalculateCloseAppPriority(const COomWindowGroupList& aWindowGroupList, TUint aAppIndexInWindowGroup);
+    
+private:
+    
+    COomCloseAppConfig(TInt32 aId);
+    };
+
+#include "oomcloseappconfig.inl"
+
+#endif /*OOMCLOSEAPPCONFIG_*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/inc/oomcloseappconfig.inl	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,28 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Configuration representation classes for Out of Memory Monitor.
+*
+*/
+
+
+#ifndef OOMCLOSEAPPCONFIGINL_H_
+#define OOMCLOSEAPPCONFIGINL_H_
+
+inline TUint COomCloseAppConfig::CalculateCloseAppPriority(const COomWindowGroupList& aWindowGroupList, TUint aAppIndexInWindowGroup)
+    {
+    // Calculating the priority for application closures is simple, we just get the base class to apply the rules
+    return Priority(aWindowGroupList, aAppIndexInWindowGroup);
+    }
+
+#endif /*OOMCLOSEAPPCONFIGINL_H_*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/inc/oomconfig.h	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,105 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Configuration representation classes for Out of Memory Monitor.
+*
+*/
+
+
+#ifndef OOMCONFIG_
+#define OOMCONFIG_
+
+#include <e32base.h>
+
+#include "oomglobalconfig.h"
+
+class COomCloseAppConfig;
+class COomRunPluginConfig;
+class MOomRuleConfig;
+class COomApplicationConfig;
+
+/*
+ * A class representing the entire configuration.
+ *
+ *  @lib oommonitor.lib
+ *  @since S60 v5.0
+ */
+NONSHARABLE_CLASS(COomConfig) : public CBase
+    {
+public:
+    
+    static COomConfig* NewL();
+    
+// Functions for setting configuration  
+    
+    // Add the configuration for an application closure.
+    // This class takes ownership of this configuration object.
+    void SetAppCloseConfigL(COomCloseAppConfig* aActionConfig);
+    
+    // Add the configuration for a plugin action.
+    // This class takes ownership of the configuration object.
+    void AddPluginConfigL(COomRunPluginConfig* aPluginConfig);
+    
+    // Add a rule for an application
+    // This class takes ownership of the given rule
+    // This rule applies to the specified application (and not a plugin associated with this application)
+    // The rule would usually apply to an "application close" event
+    void AddApplicationRuleL(TUint aTargetAppId, MOomRuleConfig* aRule);
+    
+    // Add a rule for a plugin
+    // This class takes ownership of the given rule
+    // This rule is applied to the plugin with the specified ID
+    void AddPluginRuleL(TUint aPluginId, MOomRuleConfig* aRule);    
+    
+    // Add this application config - this class takes ownership of it
+    // Application config includes settings for a particular application, e.g. whether or not it can be closed
+    void AddApplicationConfigL(COomApplicationConfig* aApplicationConfig);
+    
+// Functions for getting configuration  
+    
+    // Get the application configuration for the given app id
+    // If no specific actions have been configured for this application then the default application configuration is returned
+    COomApplicationConfig& GetApplicationConfig(TInt32 aAppId);
+    
+    // Get the plugin configuration for the given plugin id
+    // If no specific actions have been configured for this plugin then the default plugin configuration is returned
+    COomRunPluginConfig& GetPluginConfig(TInt32 aPluginId);
+        
+// Functions for setting global configuration   
+    
+    ~COomConfig();
+    
+    inline COomGlobalConfig& GlobalConfig();
+    
+    inline void SetDefaultLowRamThreshold(TInt aLowRamThreshold);
+    inline void SetDefaultGoodRamThreshold(TInt aGoodRamThreshold);
+    inline void SetSwapUsageMonitored(TBool aMonitored);
+    inline void SetDefaultLowSwapThreshold(TInt aLowSwapThreshold);
+    inline void SetDefaultGoodSwapThreshold(TInt aGoodSwapThreshold);
+    inline void SetMaxCloseAppBatch(TUint MaxCloseAppBatch);
+    inline void SetDefaultWaitAfterPlugin(TInt aMilliseconds);
+    inline void SetMaxAppExitTime(TInt aMilliseconds);
+    
+private:
+    void ConstructL();
+    
+    RHashMap<TInt32, COomApplicationConfig*> iApplicationToConfigMapping; // A hash-map of application configs, keyed on the application ID
+    
+    RHashMap<TInt32, COomRunPluginConfig*> iPluginToConfigMapping; // A hash-map of plug-in configs, keyed on the plugin ID
+
+    COomGlobalConfig iGlobalConfig;
+    };
+
+#include "oomconfig.inl"
+
+#endif /*OOMCONFIG_*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/inc/oomconfig.inl	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,66 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Configuration representation classes for Out of Memory Monitor.
+*
+*/
+
+
+#ifndef OOMCONFIGINL_H_
+#define OOMCONFIGINL_H_
+
+inline COomGlobalConfig& COomConfig::GlobalConfig()
+    {
+    return iGlobalConfig;
+    }
+
+void COomConfig::SetDefaultLowRamThreshold(TInt aLowRamThreshold)
+    {
+    iGlobalConfig.iLowRamThreshold = aLowRamThreshold;
+    }
+
+void COomConfig::SetDefaultGoodRamThreshold(TInt aGoodRamThreshold)
+    {
+    iGlobalConfig.iGoodRamThreshold = aGoodRamThreshold;
+    }
+
+void COomConfig::SetSwapUsageMonitored(TBool aMonitored)
+    {
+    iGlobalConfig.iSwapUsageMonitored = aMonitored;
+    }
+
+void COomConfig::SetDefaultLowSwapThreshold(TInt aLowSwapThreshold)
+    {
+    iGlobalConfig.iLowSwapThreshold = aLowSwapThreshold;
+    }
+
+void COomConfig::SetDefaultGoodSwapThreshold(TInt aGoodSwapThreshold)
+    {
+    iGlobalConfig.iGoodSwapThreshold = aGoodSwapThreshold;
+    }
+
+void COomConfig::SetMaxCloseAppBatch(TUint aMaxCloseAppBatch)
+    {
+    iGlobalConfig.iMaxCloseAppBatch = aMaxCloseAppBatch;
+    }
+void COomConfig::SetDefaultWaitAfterPlugin(TInt aMilliseconds)
+    {
+    iGlobalConfig.iDefaultWaitAfterPlugin = aMilliseconds;
+    }
+
+void COomConfig::SetMaxAppExitTime(TInt aMilliseconds)
+    {
+    iGlobalConfig.iMaxAppExitTime = aMilliseconds;
+    }
+
+#endif /*OOMCONFIGINL_H_*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/inc/oomconfigparser.h	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,123 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  The parser for the OOM configuration file.
+*
+*/
+
+
+#ifndef OOMCONFIGPARSER_H_
+#define OOMCONFIGPARSER_H_
+
+#include <xml/contenthandler.h>
+
+using namespace Xml;
+
+class COomConfig;
+class COomRunPluginConfig;
+
+/**
+ *  Parser for the Oom Monitor configuration file
+ *
+ *  @lib oommonitor.lib
+ *  @since S60 v5.0
+ */
+NONSHARABLE_CLASS(COomConfigParser) : public CBase, public MContentHandler 
+    {
+public:
+    COomConfigParser(COomConfig& aConfig, RFs& aFs);
+    
+    void ParseL();
+
+    
+    // From MContent handler
+    virtual void OnStartDocumentL(const RDocumentParameters& aDocParam, TInt aErrorCode);
+    virtual void OnEndDocumentL(TInt aErrorCode);
+    virtual void OnStartElementL(const RTagInfo& aElement, const RAttributeArray& aAttributes, 
+                                 TInt aErrorCode);
+    virtual void OnEndElementL(const RTagInfo& aElement, TInt aErrorCode);
+    virtual void OnContentL(const TDesC8& aBytes, TInt aErrorCode);
+    virtual void OnStartPrefixMappingL(const RString& aPrefix, const RString& aUri, 
+                                       TInt aErrorCode);
+    virtual void OnEndPrefixMappingL(const RString& aPrefix, TInt aErrorCode);
+    virtual void OnIgnorableWhiteSpaceL(const TDesC8& aBytes, TInt aErrorCode);
+    virtual void OnSkippedEntityL(const RString& aName, TInt aErrorCode);
+    virtual void OnProcessingInstructionL(const TDesC8& aTarget, const TDesC8& aData, 
+                                          TInt aErrorCode);
+    virtual void OnError(TInt aErrorCode);
+    virtual TAny* GetExtendedInterface(const TInt32 aUid);
+    
+    
+    
+private:
+    
+    void ConfigError(TInt aError);
+    
+    
+    
+    void StartElementL(const TDesC8& aLocalName, 
+                          const RAttributeArray& aAttributes);
+    
+    void SetGlobalSettings(const RAttributeArray& aAttributes);
+    void SetForceCheckConfigL(const RAttributeArray& aAttributes);
+    void SetAppConfigL(const RAttributeArray& aAttributes);
+    void SetCloseAppConfigL(const RAttributeArray& aAttributes);
+    void SetAppCloseIdlePriorityConfigL(const RAttributeArray& aAttributes);
+    void SetForegroundAppPriorityL(const RAttributeArray& aAttributes);
+    
+    void SetSystemPluginConfigL(const RAttributeArray& aAttributes);
+    void SetAppPluginConfigL(const RAttributeArray& aAttributes);
+    void SetPluginIdlePriorityL(const RAttributeArray& aAttributes);
+    void SetPluginForegroundAppPriorityL(const RAttributeArray& aAttributes);
+    
+    TInt GetValueFromAttributeList(const RAttributeArray& aAttributes, const TDesC8& aName, TPtrC8& aValue);
+    TInt GetValueFromHexAttributeList(const RAttributeArray& aAttributes, const TDesC8& aName, TUint& aValue);
+    TInt GetValueFromDecimalAttributeList(const RAttributeArray& aAttributes, const TDesC8& aName, TUint& aValue);
+    TInt GetValueFromDecimalAttributeList(const RAttributeArray& aAttributes, const TDesC8& aName, TInt& aValue);
+    TInt GetValueFromBooleanAttributeList(const RAttributeArray& aAttributes, const TDesC8& aName, TBool& aValue);
+    
+    void SetPluginSyncMode(const RAttributeArray& aAttributes, COomRunPluginConfig& aRunPluginConfig);
+
+    enum TOomParsingState
+        {
+        EOomParsingStateNone,
+        EOomParsingStateRoot,
+        EOomParsingStateGlobalSettings,
+        EOomParsingStateAppSettings,
+        EOomParsingStateAppCloseSettings,
+        EOomParsingStateSystemPluginSettings,
+        EOomParsingStateAppPluginSettings
+        };    
+    
+    // Check that the current state is as expected
+    // If not then the specified config error is generated
+    void CheckState(TOomParsingState aExpectedState, TInt aError);
+    
+    // Check that the current state is as expected
+    // If not then the specified config error is generated
+    // This version checks to ensure that the current state matches either of the passed in states
+    void CheckState(TOomParsingState aExpectedState1, TOomParsingState aExpectedState2, TInt aError);
+    
+    COomConfig& iConfig;
+    
+    RFs& iFs;
+    
+    void ChangeState(TOomParsingState aState);    
+    
+    TOomParsingState iState;
+    
+    TUint iParentUid;
+    TUint iParentTargetApp;
+    };
+
+#endif /*OOMCONFIGPARSER_H_*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/inc/oomconstants.hrh	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,39 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Out of Memory Monitor Constants.
+*
+*/
+
+
+#ifndef OOMCONSTANTS_HRH_
+#define OOMCONSTANTS_HRH_
+
+const TInt KAppNotInWindowGroupList = -1;
+
+const TInt KOomDefaultAppId = 0;
+const TInt KOomDefaultPluginId = 0;
+const TInt KOomThresholdUnset = 0;
+
+const TInt KOomBusyAppId = 0x10286A84;
+const TInt KOomHighPriorityAppId = 0x10286A85;
+
+const TInt KOomPriorityInfinate = 1024;
+
+// same as Akncapserver since fast swap is contained in it
+const TUid  KUidFastSwap = { 0x10207218 };
+const TUid  KUidPenInputServer = { 0x10281855 };
+
+const TInt KMicrosecondsInMillisecond = 1000;
+
+#endif /*OOMCONSTANTS_HRH_*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/inc/oomforegroundrule.h	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,48 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Configuration representation classes for Out of Memory Monitor.
+*
+*/
+
+
+#ifndef OOMFOREGROUNDRULE_
+#define OOMFOREGROUNDRULE_
+
+#include <e32base.h>
+#include "oomruleconfig.h"
+
+/**
+ *  A rule to modify the priority if a particular application is in the foreground
+ *
+ *  @lib oommonitor.lib
+ *  @since S60 v5.0
+ */
+NONSHARABLE_CLASS(COomForegroundRule) : public CBase, public MOomRuleConfig
+    {
+public:
+    // If the specified target app is in the foreground then apply the specified priority
+    COomForegroundRule(TInt aTargetAppId, TInt aPriority);
+    
+    TBool RuleIsApplicable(const COomWindowGroupList& aWindowGroupList, TInt aAppIndexInWindowGroup) const;
+
+    inline TUint Priority() const;
+        
+private:
+    TInt iTargetAppId;
+    TInt iPriority; // The priority to apply if the specified app is in the foreground
+    };
+
+#include "oomforegroundrule.inl"
+
+#endif /*OOMFOREGROUNDRULE_*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/inc/oomforegroundrule.inl	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,28 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Configuration representation classes for Out of Memory Monitor.
+*
+*/
+
+
+#ifndef OOMFOREGROUNDRULEINL_H_
+#define OOMFOREGROUNDRULEINL_H_
+
+
+inline TUint COomForegroundRule::Priority() const
+    {
+    return iPriority;
+    }
+
+#endif /*OOMFOREGROUNDRULEINL_H_*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/inc/oomglobalconfig.h	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,57 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Configuration representation classes for Out of Memory Monitor.
+*
+*/
+
+
+#ifndef OOMGLOBALCONFIG_
+#define OOMGLOBALCONFIG_
+
+#include <e32base.h>
+#include <e32hashtab.h>
+
+/**
+ *  Class presenting the parts of the configuration that are global defaults rather than specific
+ *  to the current state of the device
+ *
+ *  @lib oommonitor.lib
+ *  @since S60 v5.0
+ */
+NONSHARABLE_CLASS(COomGlobalConfig) : public CBase
+    {
+public:
+    ~COomGlobalConfig();
+    
+    inline void AddForceCheckPriorityL(TUint aPriority);
+    
+    // Return ETrue if a force check has been added for this priority, return EFalse otherwise
+    inline TBool ForceCheckAtPriority(TUint aPriority) const;
+    
+public:
+    TInt iLowRamThreshold;
+    TInt iGoodRamThreshold;
+    TBool iSwapUsageMonitored;
+    TInt iLowSwapThreshold;
+    TInt iGoodSwapThreshold;
+    TUint iMaxCloseAppBatch;
+    TInt iDefaultWaitAfterPlugin;
+    TInt iMaxAppExitTime;
+    
+    RHashSet<TUint> iForceCheckPriorities;
+    };
+
+#include "oomglobalconfig.inl"
+
+#endif /*OOMGLOBALCONFIG_*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/inc/oomglobalconfig.inl	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,33 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Configuration representation classes for Out of Memory Monitor.
+*
+*/
+
+
+#ifndef OOMGLOBALCONFIGINL_H_
+#define OOMGLOBALCONFIGINL_H_
+
+void COomGlobalConfig::AddForceCheckPriorityL(TUint aPriority)
+    {
+    iForceCheckPriorities.InsertL(aPriority);
+    }
+
+// Return ETrue if a force check has been added for this priority, return EFalse otherwise
+TBool COomGlobalConfig::ForceCheckAtPriority(TUint aPriority) const
+    {
+    return (iForceCheckPriorities.Find(aPriority) != NULL);
+    }
+
+#endif /*OOMGLOBALCONFIGINL_H_*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/inc/oomidletimerule.h	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,53 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Configuration representation classes for Out of Memory Monitor.
+*
+*/
+
+
+#ifndef OOMIDLETIMERULE_
+#define OOMIDLETIMERULE_
+
+#include <e32base.h>
+
+#include "oomruleconfig.h"
+
+/**
+ *  A rule to modify the priority of an app close action if it has been idle for a period of time
+ *
+ *  @lib oommonitor.lib
+ *  @since S60 v5.0
+ */
+NONSHARABLE_CLASS(COomIdleTimeRule) : public CBase, public MOomRuleConfig
+    {
+public:
+    static COomIdleTimeRule* NewL(TTimeIntervalSeconds aIdleTime, TInt aPriority);
+    
+    TBool RuleIsApplicable(const COomWindowGroupList& aWindowGroupList, TInt aAppIndexInWindowGroup) const;
+
+    inline TUint Priority() const;
+    
+    ~COomIdleTimeRule();
+    
+private:
+    COomIdleTimeRule(TTimeIntervalSeconds aIdleTime, TInt aPriority);
+    
+private:
+    TTimeIntervalSeconds iIdleTime; // The idle time after which to apply the given priority
+    TInt iPriority; // The priority to apply after the given idle time
+    };
+
+#include "oomidletimerule.inl"
+
+#endif /*OOMIDLETIMERULE_*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/inc/oomidletimerule.inl	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,27 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Configuration representation classes for Out of Memory Monitor.
+*
+*/
+
+
+#ifndef OOMIDLETIMERULEINL_H_
+#define OOMIDLETIMERULEINL_H_
+
+inline TUint COomIdleTimeRule::Priority() const
+    {
+    return iPriority;
+    }
+
+#endif /*OOMIDLETIMERULEINL_H_*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/inc/oomlog.h	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,85 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Logging functionality for OOM monitor profiling.
+*
+*/
+
+
+#ifndef OOMLOG_H_
+#define OOMLOG_H_
+
+#ifdef _DEBUG
+
+#include <apgwgnam.h>
+
+#include "oomwindowgrouplist.h"
+
+const TUint KTimeBetweenMemorySamples = 100000; // In microseconds
+const TUint KSamplingDurationUint = 3000000;
+
+const TUint KMaxBytesOfLoggingPerSample = 20;
+
+NONSHARABLE_CLASS(COomLogger) : public CTimer
+    {
+public:
+    static COomLogger* NewL(RWsSession& aWs, RFs& aFs);
+    
+    // Start logging the available memory every n micro seconds
+    // Firstly a list of the app IDs is written to the log (foreground app first)
+    // Note that the log is created in memory (to a pre-allocated buffer) and flushed out after it is complete
+    // the samples are saved in CSV format so that they can easily be cut and pasted to plot graphs etc.
+    void StartL();
+    
+// From CTimer / CActice
+    void RunL();
+    void DoCancel();
+    
+    ~COomLogger();
+    
+    void Write(const TDesC8& aBuffer);
+    
+protected:
+    void LogApplicationIds();
+    void LogFreeMemory();
+    
+    COomLogger(RWsSession& aWs, RFs& aFs);
+    void ConstructL();
+    
+    // Duplicated functionality from OomMonitor
+    // Duplicated because it was messy to reuse it and to minimise changes to OOM monitor during development of new features
+    void ColapseWindowGroupTree();
+    
+    TUid GetUidFromWindowGroupId(TInt aWgId);
+
+    RWsSession& iWs;    
+    
+    // Used to get a list of open applications
+    RArray<RWsSession::TWindowGroupChainInfo> iWgIds;
+    CApaWindowGroupName* iWgName;
+    HBufC* iWgNameBuf;              // owned by iWgName
+    
+    RFs& iFs;
+    
+    RFile iFile;
+    TBool iIsOpen;
+    
+    // The time when the logging was started
+    TTime iStartTime;
+    
+    TBuf8<(KSamplingDurationUint / KTimeBetweenMemorySamples) * KMaxBytesOfLoggingPerSample> iWriteBuffer;
+    };
+
+#endif //_DEBUG
+
+#endif /*OOMLOG_H_*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/inc/oommemorymonitor.h	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,205 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Main classes for Out of Memory Monitor.
+*
+*/
+
+
+#ifndef OOMMEMORYMONITOR_H
+#define OOMMEMORYMONITOR_H
+
+#include <e32property.h>
+#include <e32svr.h>
+#include <w32std.h>
+#include "oomglobalconfig.h"
+#include "oomwindowgrouplist.h"
+#include "oommonitorsession.h"
+
+enum TActionTriggerType
+    {
+    ERamRotation,
+    EClientServerRequestOptionalRam,
+    EClientServerRequestFreeMemory,
+    EPublishAndSubscribe        
+    };
+
+// ---------------------------------------------------------
+// CMemoryMonitor
+// ---------------------------------------------------------
+//
+class COutOfMemoryWatcher;
+class CSubscribeHelper;
+class COomMonitorPlugin;
+class CMemoryMonitorServer;
+class CWservEventReceiver;
+class COomActionList;
+class COomLogger;
+class COomConfig;
+class COomClientRequestQueue;
+
+/**
+ *  The main manager class for Oom Monitor. It has the following responsibility: 
+ *  
+ *  - initiates building the static configuration at boot time and owns the object which holds this. 
+ *  - owns and drives the action list which runs actions
+ *  - owns the internal representation of the window group list and an active object to monitor window group changes
+ *  - owns the public API via the server and client request queue.
+ *  - has an active object which monitors low RAM events
+ *
+ *  @lib oommonitor.lib
+ *  @since S60 v5.0
+ */
+NONSHARABLE_CLASS(CMemoryMonitor) : public CBase
+    {
+public:
+    static CMemoryMonitor* NewL();
+    ~CMemoryMonitor();
+
+public: // event handlers
+    void FreeMemThresholdCrossedL();
+    void AppNotExiting(TInt aWgId);
+    void StartFreeSomeRamL(TInt aFreeRamTarget, TInt aFreeSwapSpaceTarget);
+    void StartFreeSomeRamL(TInt aFreeRamTarget, TInt aFreeSwapSpaceTarget, TInt aMaxPriority);
+    void FreeOptionalRamL(TInt aBytesRequested, TInt aPluginId, TBool aDataPaged); // The ID of the plugin that will clear up the allocation, used to determine the priority of the allocation
+    void HandleFocusedWgChangeL();
+    static const COomGlobalConfig& GlobalConfig();
+    void SetPriorityBusy(TInt aWgId);
+    void SetPriorityNormal(TInt aWgId);
+    void SetPriorityHigh(TInt aWgId);
+    void ResetTargets();
+    void RequestTimerCallbackL();
+    void GetFreeMemory(TInt& aCurrentFreeMemory);
+    void GetFreeSwapSpace(TInt& aCurrentFreeSwapSpace);
+    TActionTriggerType ActionTrigger() const;
+#ifdef CLIENT_REQUEST_QUEUE
+    void ActionsCompleted(TInt aBytesFree, TBool aMemoryGood);
+    TInt GoodRamThreshold() const;
+    TInt LowRamThreshold() const;
+#endif
+    void RequestFreeMemoryL(TInt aBytesRequested, TBool aDataPaged);
+    void RequestFreeMemoryPandSL(TInt aBytesRequested);
+    
+    /*
+     * Sets the RProperty associated with KOomMemoryMonitorStatusPropertyKey
+     * It checks if the value is going to be changed. 
+     * If the new value is the same as the old one then the property is not updated
+     * If the new value is different from the previously set one then the property is update
+     * 
+     * @param aNewValue one of TMemoryMonitorStatusPropertyValues 
+     */
+    void SetMemoryMonitorStatusProperty(const TMemoryMonitorStatusPropertyValues aValue);
+   
+private:
+    CMemoryMonitor();
+    void ConstructL();
+#ifndef CLIENT_REQUEST_QUEUE
+    static TInt WatchdogStatusStatusChanged(TAny* aPtr);
+    void HandleWatchdogStatusCallBack();
+    TBool FreeMemoryAboveThreshold(TInt& aCurrentFreeMemory);    void CloseNextApp();
+#endif
+    void RefreshThresholds();
+    
+public:
+    // All members are owned
+    // generally useful sessions
+    RFs iFs;
+    RWsSession iWs;
+
+    TBool iDataPaged;
+    
+private: //data
+
+    // parameters for OOM watcher.
+    TInt iLowRamThreshold;
+    TInt iGoodRamThreshold;
+    TInt iLowSwapThreshold;
+    TInt iGoodSwapThreshold;
+    TInt iCurrentRamTarget;
+    TInt iCurrentSwapTarget;
+    
+   
+    
+#ifdef CLIENT_REQUEST_QUEUE
+    TInt iClientBytesRequested;
+#endif        
+    // event receivers
+    
+    /**
+     * The active object which monitors the kernel change notifier for changes in the low and good thresholds
+     * Own
+     */    
+    COutOfMemoryWatcher* iOOMWatcher;
+    
+    
+    CWservEventReceiver* iWservEventReceiver;
+
+#ifndef CLIENT_REQUEST_QUEUE
+    // parameters for P&S watcher.
+    /**
+    * The handle to the P&S property that can be used to initiate OOM Monitor actions
+    */    
+    RProperty iWatchdogStatusProperty;
+
+    /**
+     * The active object which monitors the P&S property that can be used to initiate OOM Monitor actions
+     * Own.       
+     */    
+    CSubscribeHelper* iWatchdogStatusSubscriber;
+#endif
+    
+    /**
+     * The Memory Monitor Server
+     * Own.       
+     */
+    CMemoryMonitorServer* iServer;
+    
+#ifdef CLIENT_REQUEST_QUEUE
+    COomClientRequestQueue* iQueue;
+#endif
+    
+#ifdef _DEBUG    
+    /**
+     * Oom logging tool - samples free memory for profiling
+     * Own.       
+     */
+    COomLogger* iLogger;
+#endif
+    
+    /**
+     * A list of window group Ids, with child window groups removed such that there is one Id per application
+     * Own.       
+     */    
+    COomWindowGroupList* iOomWindowGroupList;
+    
+    /**
+     * The object responsible for identifying the best actions to run, and running them 
+     * Own.       
+     */
+    COomActionList* iOomActionList;
+    
+    /**
+     * The entire Oom Monitor configuration
+     * Own.       
+     */
+    COomConfig* iConfig;
+
+    /**
+     * The most recent value the memory monitor status property was set to 
+     */
+    TInt iLastMemoryMonitorStatusProperty;
+    
+    TActionTriggerType iActionTrigger;
+    };
+
+#endif /*OOMMEMORYMONITOR_H*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/inc/oommemorymonitorserver.h	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,63 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Main classes for Out of Memory Monitor.
+*
+*/
+
+
+#ifndef OOMMEMORYMONITORSERVER_H
+#define OOMMEMORYMONITORSERVER_H
+
+#include <e32base.h>
+
+class CMemoryMonitor;
+class COomClientRequestQueue;
+
+NONSHARABLE_CLASS(CMemoryMonitorServer) : public CServer2
+    {
+public:
+#ifdef CLIENT_REQUEST_QUEUE
+    static CMemoryMonitorServer* NewL(COomClientRequestQueue& aQueue);
+#else
+    static CMemoryMonitorServer* NewL(CMemoryMonitor& aMonitor);
+#endif    
+    ~CMemoryMonitorServer();
+
+    CMemoryMonitor& Monitor();
+#ifndef CLIENT_REQUEST_QUEUE
+    void CloseAppsFinished(TInt aBytesFree, TBool aMemoryGood);
+#endif
+#ifdef CLIENT_REQUEST_QUEUE
+    COomClientRequestQueue& ClientRequestQueue();
+#endif
+    
+private:
+#ifdef CLIENT_REQUEST_QUEUE
+    CMemoryMonitorServer(COomClientRequestQueue& aQueue);
+#else
+    CMemoryMonitorServer(CMemoryMonitor& aMonitor);
+#endif
+    void ConstructL();
+    CSession2* NewSessionL(const TVersion& aVersion,const RMessage2& aMessage) const;
+    TInt RunError(TInt aError);
+
+private:
+#ifdef CLIENT_REQUEST_QUEUE
+    COomClientRequestQueue& iQueue;
+#else
+    CMemoryMonitor& iMonitor;
+#endif
+    };
+
+#endif /*OOMMEMORYMONITORSERVER_H*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/inc/oommemorymonitorsession.h	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,53 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Main classes for Out of Memory Monitor.
+*
+*/
+
+
+#ifndef OOMMEMORYMONITORSESSION_H
+#define OOMMEMORYMONITORSESSION_H
+
+#include <e32base.h>
+
+class CMemoryMonitorServer;
+class CMemoryMonitor;
+class COomClientRequestQueue;
+
+NONSHARABLE_CLASS(CMemoryMonitorSession) : public CSession2
+    {
+public:
+    CMemoryMonitorSession();
+#ifndef CLIENT_REQUEST_QUEUE
+    void CloseAppsFinished(TInt aBytesFree, TBool aMemoryGood);
+    TBool IsDataPaged(const RMessage2& aMessage);
+#endif
+    
+private:
+    ~CMemoryMonitorSession();
+    CMemoryMonitorServer& Server();
+#ifdef CLIENT_REQUEST_QUEUE
+    COomClientRequestQueue& ClientRequestQueue();
+#endif
+    CMemoryMonitor& Monitor();
+    void ServiceL(const RMessage2& aMessage);
+private:
+    RMessagePtr2 iRequestFreeRam;
+#ifndef CLIENT_REQUEST_QUEUE
+    TInt iFunction;
+#endif    
+    TInt iMinimumMemoryRequested;
+    };
+
+#endif /*OOMMEMORYMONITORSESSION_H*/
--- a/sysresmonitoring/oommonitor/inc/oommonitorclientserver.h	Tue Jun 15 16:07:48 2010 +0100
+++ b/sysresmonitoring/oommonitor/inc/oommonitorclientserver.h	Thu Jul 22 16:35:22 2010 +0100
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2006 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 "Eclipse Public License v1.0"
@@ -11,7 +11,7 @@
 *
 * Contributors:
 *
-* Description:  Command definitions for OOM Monitor client/server interface.
+* Description:  The client / server classes allowing clients to make requests to OOM monitor.
 *
 */
 
@@ -22,20 +22,24 @@
 #include <e32std.h>
 
 enum TOomMonitorClientPanic
-	{
-	EPanicIllegalFunction,
-	EPanicRequestActive
-	};
+    {
+    EPanicIllegalFunction,
+    EPanicRequestActive
+    };
 
 void PanicClient(const RMessagePtr2& aMessage,TOomMonitorClientPanic aPanic);
 
 _LIT(KMemoryMonitorServerName, "OomMonitorServer");
 
 enum TOomMonitorCmd
-	{
-	EOomMonitorRequestFreeMemory,
-	EOomMonitorCancelRequestFreeMemory,
-	EOomMonitorThisAppIsNotExiting
-	};
+    {
+    EOomMonitorRequestFreeMemory,
+    EOomMonitorCancelRequestFreeMemory,
+    EOomMonitorThisAppIsNotExiting,
+    EOomMonitorRequestOptionalRam,
+    EOomMonitorSetPriorityBusy,
+    EOomMonitorSetPriorityNormal,
+    EOomMonitorSetPriorityHigh
+    };
 
 #endif // OOMMONITORCLIENTSERVER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/inc/oomoutofmemorywatcher.h	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,60 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Main classes for Out of Memory Monitor.
+*
+*/
+
+
+#ifndef OOMOUTOFMEMORYWATCHER_H
+#define OOMOUTOFMEMORYWATCHER_H
+
+#include <e32base.h>
+
+class CMemoryMonitor;
+
+/**
+ *  This class is an active object which monitors a kernel change notifer for changes in the 
+ *  low and good memory thresholds. 
+ *  
+ *  @lib oommonitor.lib
+ *  @since S60 v5.0
+ */
+NONSHARABLE_CLASS(COutOfMemoryWatcher) : public CActive
+    {
+public:
+    static COutOfMemoryWatcher* NewL(CMemoryMonitor& aMonitor, TInt aLowRamThreshold, TInt aGoodRamThreshold,
+        TBool aSwapUsageMonitored, TInt aLowSwapThreshold, TInt aGoodSwapThreshold);
+    ~COutOfMemoryWatcher();
+    void Start();
+    
+    /**
+     * Set the Low and Good thresholds that we are listening for.
+     * These values can change from the global default values when certain applications are in the foreground.
+     * @param aLowThreshold If Ram Level drops below the low threshold Oom Monitor actions are started.
+     * @param aGoodThreshold When memory returns above the Good threshold then Oom Monitor stops freeing memory.
+     */
+    void UpdateThresholds(TInt aLowRamThreshold, TInt aGoodRamThreshold, TInt aLowSwapThreshold, TInt aGoodSwapThreshold);
+private:
+    COutOfMemoryWatcher(CMemoryMonitor& aMonitor, TBool aSwapUsageMonitored);
+    void ConstructL(TInt aLowRamThreshold, TInt aGoodRamThreshold, TInt aLowSwapThreshold, TInt aGoodSwapThreshold);
+private: // from CActive
+    void DoCancel();
+    void RunL();
+private: // data
+    RChangeNotifier iChangeNotifier;
+    CMemoryMonitor& iMemoryMonitor;
+    TBool iSwapUsageMonitored;
+    };
+
+#endif /*OOMOUTOFMEMORYWATCHER_H*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/inc/oompanic.h	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,52 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Panic codes for OOM monitor.
+*
+*/
+
+
+#ifndef OOMPANIC_
+#define OOMPANIC_
+
+#include <e32def.h>
+
+enum TOomMonitorPanic
+    {
+    KRuleConfiguredBeforeApplication,
+    KCloseAppActionIsResued,
+    KAppConfigAddedTwice,
+    KSameAppClosureConfiguredTwice,
+    KOomDefaultAppCloseNotConfigured,
+    KPluginConfigAddedTwice,
+    KRuleConfiguredBeforePlugin,
+    KOomDefaultAppNotConfigured,
+    KOomDefaultPluginNotConfigured,
+    KNoCoeEnvFound,
+    KInvalidWgName,
+    KOomInvalidPriority,
+    KAppCloseActionEqualPriorities,
+    KClientQueueNotEmpty,
+    KClientRequestTimerActive,
+    KInvalidClientRequestType,
+    KPluginArrayIndexOutOfBounds,
+    KWindowGroupArrayIndexOutOfBounds,
+    KStartingActiveCloseAppTimer,
+    KStartingActiveAppCloseWatcher,
+    KStartingActivePluginWaiter
+    };
+
+void OomMonitorPanic(TOomMonitorPanic aReason);
+void OomConfigParserPanic(TInt aReason);
+
+#endif /*OOMPANIC_*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/inc/oompluginwaiter.h	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,53 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Classes for executing OOM actions (e.g. closing applications and running plugins).
+*
+*/
+
+
+#ifndef OOMPLUGINWAITER_H_
+#define OOMPLUGINWAITER_H_
+
+#include <e32base.h>
+
+class COomRunPlugin;
+
+
+/*
+ *  A class used for waiting for a pre-determined period before completing the plugin operation
+ *  It is intended to be used to force a delay between the call to the plugin and the memory check,
+ *  thus allowing the plugin to free some memory first.
+ * 
+ *  @lib oommonitor.lib
+ *  @since S60 v5.0
+ */
+NONSHARABLE_CLASS(COomPluginWaiter) : public CTimer
+    {
+public:
+    static COomPluginWaiter* NewL(TInt aMillisecondsToWait, COomRunPlugin& aCallbackClass);
+    
+    // Start the timer, it will call the plugin back when it expires
+    void Start();
+    
+protected:
+    void RunL();
+    
+    COomPluginWaiter(TInt aMillisecondsToWait, COomRunPlugin& aCallbackClass);
+    
+private:
+    TInt iMillisecondsToWait;
+    COomRunPlugin& iCallbackClass;
+    };
+
+#endif /*OOMPLUGINWAITER_H_*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/inc/oomruleconfig.h	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,33 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Configuration representation classes for Out of Memory Monitor.
+*
+*/
+
+
+#ifndef OOMRULECONFIG_
+#define OOMRULECONFIG_
+
+#include <e32std.h>
+
+class COomWindowGroupList;
+
+NONSHARABLE_CLASS(MOomRuleConfig)
+    {
+public:
+    virtual TBool RuleIsApplicable(const COomWindowGroupList& aWindowGroupList, TInt aAppIndexInWindowGroup) const = 0;
+    virtual TUint Priority() const = 0;
+    };
+
+#endif /*OOMRULECONFIG_*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/inc/oomrunplugin.h	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,85 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Classes for executing OOM actions (e.g. closing applications and running plugins).
+*
+*/
+
+
+#ifndef OOMRUNPLUGIN_H_
+#define OOMRUNPLUGIN_H_
+
+#include "oomaction.h"
+
+class COomRunPlugin;
+class COomRunPluginConfig;
+class MOomActionObserver;
+class COomPluginWaiter;
+class COomMonitorPlugin;
+class COomMonitorPluginV2;
+class COomActionConfig;
+
+/*
+ * The OOM action of running an OOM plug-in to free up memory.
+ * 
+ *  @lib oommonitor.lib
+ *  @since S60 v5.0
+ */
+NONSHARABLE_CLASS(COomRunPlugin) : public COomAction
+    {
+public:
+    static COomRunPlugin* NewL(TUint aPluginId, COomRunPluginConfig& aConfig, MOomActionObserver& aStateChangeObserver, COomMonitorPlugin& aPlugin, COomMonitorPluginV2* aV2Plugin = NULL);
+
+    ~COomRunPlugin();   
+    
+    // Run the OOM plugin in order to free memory
+    // Call the COomAction::MemoryFreed when it is done
+    virtual void FreeMemory(TInt aBytesRequested, TBool aIsDataPaged);
+    
+    // Call the memory good function on the plugin but...
+    // only if there is an outstanding FreeMemory request
+    void MemoryGood();
+        
+    inline TBool IsRunning();
+    
+    // To be called by the COomPluginWaiter
+    inline void WaitCompleted();
+    
+protected:
+    
+    void ConstructL(COomRunPluginConfig& aPluginConfig);    
+    
+    inline COomActionConfig& GetConfig();   
+    
+private:
+    
+    COomRunPlugin(TUint aPluginId, COomRunPluginConfig& aConfig, MOomActionObserver& aStateChangeObserver, COomMonitorPlugin& aPlugin, COomMonitorPluginV2* aV2Plugin);
+    
+    TUint iPluginId;
+    
+    COomMonitorPlugin& iPlugin;
+    
+    COomRunPluginConfig& iConfig;
+    
+    COomPluginWaiter* iPluginWaiter;
+    
+    // Note that this shouldn't be deleted
+    // If it is pointing to a V2 plugin then it is a cast to the same instance as iPlugin
+    COomMonitorPluginV2* iV2Plugin;
+    
+    TBool iFreeMemoryCalled; // True if FreeMemory has been called since the last call to MemoryGood
+    };
+
+#include "oomrunplugin.inl"
+
+#endif /*OOMRUNPLUGIN_H_*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/inc/oomrunplugin.inl	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,43 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Classes for executing OOM actions (e.g. closing applications and running plugins).
+*
+*/
+
+
+#ifndef OOMRUNPLUGININL_H_
+#define OOMRUNPLUGININL_H_
+
+#include "oomactionconfig.h"
+#include "oompluginwaiter.h"
+#include "oomrunpluginconfig.h"
+
+inline COomActionConfig& COomRunPlugin::GetConfig()
+    {
+    return iConfig;
+    }
+
+
+inline TBool COomRunPlugin::IsRunning()
+    {
+    return iPluginWaiter->IsActive();
+    }
+
+inline void COomRunPlugin::WaitCompleted()
+    {
+    MemoryFreed(KErrNone);
+    }
+
+
+#endif /*OOMRUNPLUGININL_H_*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/inc/oomrunpluginconfig.h	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,81 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Configuration representation classes for Out of Memory Monitor.
+*
+*/
+
+
+#ifndef OOMRUNPLUGINCONFIG_
+#define OOMRUNPLUGINCONFIG_
+
+#include "oomactionconfig.h"
+
+enum TOomPluginType
+    {
+    EOomAppPlugin,
+    EOomSystemPlugin
+    };
+
+/*
+ * The OOM action of running an OOM plug-in to free up memory.
+ */
+NONSHARABLE_CLASS(COomRunPluginConfig) : public COomActionConfig
+    {
+public:
+    static COomRunPluginConfig* NewL(TUint aPluginId, TOomPluginType aPluginType);
+    
+    TUint CalculatePluginPriority(const COomWindowGroupList& aWindowGroupList);
+    
+    inline TUint Id();
+    
+    inline void SetTargetApp(TUint aTargetAppId);
+    
+    inline TUint TargetApp() const;
+    
+    ~COomRunPluginConfig();
+    
+    // Returns ETrue if a wait period has been explicitly configured for this plugin
+    inline TBool WaitAfterPluginDefined() const;
+    
+    // Returns the configured wait after the plugin has been called
+    inline TInt WaitAfterPlugin() const;
+    
+    inline TBool CallIfTargetAppNotRunning() const;
+    
+    // Set the time to wait 
+    inline void SetWaitAfterPlugin(TInt aMillisecondsToWait);
+    
+    inline void SetCallIfTargetAppNotRunning(TBool aCallIfTargetAppNotRunning);
+    
+    inline TOomPluginType PluginType();
+    
+private:
+    COomRunPluginConfig(TUint aPluginId, TOomPluginType aPluginType);
+    
+    TUint iPluginId;
+    
+    TUint iTargetAppId;
+        
+    TBool iWaitAfterPluginDefined;
+    
+    TInt iWaitAfterPlugin; // The period to wait after a plugin has been called
+    
+    TBool iCallIfTargetAppNotRunning; 
+    
+    TOomPluginType iPluginType;
+    };
+
+#include "oomrunpluginconfig.inl"
+
+#endif /*OOMRUNPLUGINCONFIG_*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/inc/oomrunpluginconfig.inl	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,72 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Configuration representation classes for Out of Memory Monitor.
+*
+*/
+
+
+#ifndef OOMRUNPLUGINCONFIGINL_H_
+#define OOMRUNPLUGINCONFIGINL_H_
+
+
+// Returns ETrue if a wait period has been explicitly configured for this plugin
+inline TBool COomRunPluginConfig::WaitAfterPluginDefined() const
+    {
+    return iWaitAfterPluginDefined;
+    }
+
+// Returns the configured wait after the plugin has been called
+inline TInt COomRunPluginConfig::WaitAfterPlugin() const
+    {
+    return iWaitAfterPlugin;
+    }
+
+inline TBool COomRunPluginConfig::CallIfTargetAppNotRunning() const
+    {
+    return iCallIfTargetAppNotRunning;
+    }
+
+// Set the time to wait 
+inline void COomRunPluginConfig::SetWaitAfterPlugin(TInt aMillisecondsToWait)
+    {
+    iWaitAfterPluginDefined = ETrue;
+    iWaitAfterPlugin = aMillisecondsToWait;
+    }
+
+inline void COomRunPluginConfig::SetCallIfTargetAppNotRunning(TBool aCallIfTargetAppNotRunning)
+    {
+    iCallIfTargetAppNotRunning = aCallIfTargetAppNotRunning;
+    }
+
+inline void COomRunPluginConfig::SetTargetApp(TUint aTargetAppId)
+    {
+    iTargetAppId = aTargetAppId;
+    }
+
+inline TUint COomRunPluginConfig::Id()
+    {
+    return  iPluginId;
+    }
+
+inline TOomPluginType COomRunPluginConfig::PluginType()
+    {
+    return iPluginType;
+    }
+
+inline TUint COomRunPluginConfig::TargetApp() const
+    {
+    return iTargetAppId;
+    }
+
+#endif /*OOMRUNPLUGINCONFIGINL_H_*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/inc/oomsubscribehelper.h	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,52 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Main classes for Out of Memory Monitor.
+*
+*/
+
+
+#ifndef OOMSUBSCRIBEHELPER_H
+#define OOMSUBSCRIBEHELPER_H
+
+#include <e32base.h>
+
+class RProperty;
+
+/**
+ *  This class is a simple active object which monitors the publish subscribe key method of calling the 
+ *  requesting that the OOM Monitor starts to free memory
+ *  
+ *  @lib oommonitor.lib
+ *  @since S60 v5.0
+ */
+NONSHARABLE_CLASS(CSubscribeHelper) : public CActive
+    {
+public:
+    CSubscribeHelper(TCallBack aCallBack, RProperty& aProperty);
+    ~CSubscribeHelper();
+
+public: // New functions
+    void Subscribe();
+    void StopSubscribe();
+
+private: // from CActive
+    void RunL();
+    void DoCancel();
+
+private:
+    TCallBack   iCallBack;
+    RProperty&  iProperty;
+    };
+
+#endif /*OOMSUBSCRIBEHELPER_H*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/inc/oomwindowgrouplist.h	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,119 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  A wrapper for the window group list, adding additional functionality required by OOM Monitor v2.
+*
+*/
+
+
+#ifndef OOMWINDOWGROUPLIST_H_
+#define OOMWINDOWGROUPLIST_H_
+
+#include <e32base.h>
+#include <e32hashtab.h>
+#include <w32std.h>
+
+class CApaWindowGroupName;
+
+/**
+ *  This class holds a snapshot of the window group tree. 
+ *  
+ *  The window group tree is collapsed (see CollapseWindowGroupTree) to remove child windows as we are only 
+ *  interested in a single window group Id per application.
+ *
+ *  @lib oommonitor.lib
+ *  @since S60 v5.0
+ */
+NONSHARABLE_CLASS(COomWindowGroupList) : public CBase
+    {
+public:
+    
+    static COomWindowGroupList* NewL(RWsSession& aWs);
+    
+    // Update the list of window groups
+    void RefreshL();
+    
+    // Update the list of window groups, non-leaving version
+    void Refresh();
+    
+    // Return the number of application instances in this list
+    inline TUint Count() const;
+    
+    TUint AppId(TInt aIndex, TBool aResolveFromThread = EFalse) const;
+    
+    inline const RWsSession::TWindowGroupChainInfo& WgId(TInt aIndex) const;
+    
+    TTimeIntervalSeconds IdleTime(TInt aIndex) const;
+  
+    ~COomWindowGroupList();
+    
+    void SetPriorityBusy(TInt aWgId);
+    
+    void SetPriorityNormal(TInt aWgId);
+    
+    void SetPriorityHigh(TInt aWgId);
+    
+    TBool IsBusy(TInt wgIndex);
+    
+    // Returns ETrue if an application has registered itself as high priority at runtime
+    TBool IsDynamicHighPriority(TInt wgIndex);
+    
+    CApaWindowGroupName* WgName() const;
+    
+    // Find the specificed application in the window group list and return the index
+    TInt GetIndexFromAppId(TUint aAppId) const;
+    
+private:    
+
+    void CollapseWindowGroupTree();
+    
+    void RemovePropertiesForClosedWindowsL();
+
+    TInt FindParentIdL(TInt aWgId);
+
+private:
+    
+    COomWindowGroupList(RWsSession& aWs);
+    
+    void ConstructL();
+    
+    RArray<RWsSession::TWindowGroupChainInfo> iWgIds;
+    RArray<RWsSession::TWindowGroupChainInfo> iUncollapsedWgIds;
+    
+    enum TOomPriority
+        {
+        EOomPriorityNormal,
+        EOomPriorityHigh,
+        EOomPriorityBusy
+        };
+    
+    class TOomWindowGroupProperties
+        {
+    public:
+        TOomWindowGroupProperties();
+        TUint32 iIdleTickTime;
+        TOomPriority iDynamicPriority;
+        };
+        
+    RHashMap<TInt, TOomWindowGroupProperties> iWgToPropertiesMapping; // A mapping between window group IDs and the properties such as idle time and the high-priority flag
+    RHashSet<TInt> iExistingWindowIds; // Used locally in RemoveIdleTimesForClosedWindows(), declared globally because we need to reserve space    
+    
+    RWsSession& iWs;    
+        
+    CApaWindowGroupName* iWgName;
+    HBufC* iWgNameBuf;              // owned by iWgName
+    };
+
+#include "oomwindowgrouplist.inl"
+
+#endif /*OOMWINDOWGROUPLIST_H_*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/inc/oomwindowgrouplist.inl	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,33 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Classes for executing OOM actions (e.g. closing applications and running plugins).
+*
+*/
+
+
+#ifndef OOMWINDOWGROUPLISTINL_H_
+#define OOMWINDOWGROUPLISTINL_H_
+
+// Return the number of application instances in this list
+inline TUint COomWindowGroupList::Count() const 
+    {
+    return iWgIds.Count();    
+    }
+
+inline const RWsSession::TWindowGroupChainInfo& COomWindowGroupList::WgId(TInt aIndex) const
+    {
+    return iWgIds[aIndex];
+    }
+    
+#endif /*OOMWINDOWGROUPLISTINL_H_*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/inc/oomwserveventreceiver.h	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,41 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Main classes for Out of Memory Monitor.
+*
+*/
+
+
+#ifndef OOMWSERVEVENTRECEIVER_H
+#define OOMWSERVEVENTRECEIVER_H
+
+#include <w32std.h>
+class CMemoryMonitor;
+
+NONSHARABLE_CLASS(CWservEventReceiver) : public CActive
+    {
+public:
+    CWservEventReceiver(CMemoryMonitor& aMonitor, RWsSession& aWs);
+    ~CWservEventReceiver();
+    void ConstructL();
+private:
+    void Queue();
+    void DoCancel();
+    void RunL();
+private:
+    CMemoryMonitor& iMonitor;
+    RWsSession& iWs;
+    RWindowGroup iWg;
+    };
+
+#endif /*OOMWSERVEVENTRECEIVER_H*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/inc/traceconfiguration.hrh	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,84 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Tracing flags configuration.
+*
+*/
+
+
+#ifndef TRACECONFIGURATION_HRH
+#define TRACECONFIGURATION_HRH
+
+//-----------------------------------------------------------------------------
+// Trace definitions
+//-----------------------------------------------------------------------------
+//
+
+/**
+* Error trace enabled
+*/
+#ifdef _DEBUG
+    #define ERROR_TRACE
+#else
+    #undef ERROR_TRACE
+#endif
+
+/**
+* Info trace enabled
+*/
+#define __OOM_INFO_TRACE__
+#if defined _DEBUG && defined __OOM_INFO_TRACE__
+    #define INFO_TRACE
+    #define TIMESTAMP_TRACE
+#else
+    #undef INFO_TRACE
+    #undef TIMESTAMP_TRACE
+#endif
+
+/**
+* Function trace enabled
+*/
+#if defined _DEBUG && defined __OOM_FUNC_TRACE__
+    #define FUNC_TRACE
+#else
+    #undef FUNC_TRACE
+#endif
+
+/**
+* Timestamp tracing on
+*/
+#if defined _DEBUG && defined __OOM_TIMESTAMP_TRACE__
+    #define TIMESTAMP_TRACE
+#else
+    #undef TIMESTAMP_TRACE
+#endif
+
+/**
+* Tracing current client process and thread
+*/
+#ifdef _DEBUG
+    #define CLIENT_TRACE
+#else
+    #undef CLIENT_TRACE
+#endif
+
+/**
+* Tracing into file enabled, default RDebug
+*/
+#ifdef __OOM_TRACE_INTO_FILE__
+    #define TRACE_INTO_FILE
+#else
+    #undef TRACE_INTO_FILE
+#endif
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/inc/tracedefs.h	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,39 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Definitions for tracing.
+*
+*/
+
+
+#ifndef TRACEDEFS_H
+#define TRACEDEFS_H
+
+//-----------------------------------------------------------------------------
+// Constants
+//-----------------------------------------------------------------------------
+//
+
+/**
+* Prefix trace macro to complete tracing with component name.
+* Returns TDesC which can be used directly with RDebug or RFileLogger.
+*/
+#define _PREFIX_TRACE( aMsg ) TPtrC( (const TText*)L"[OOM]: " L##aMsg )
+#define _PREFIX_TRACE_2( aMsg1, aMsg2 ) TPtrC( (const TText*)L"[OOM]: " L##aMsg1 L##aMsg2 )
+
+/**
+* Prefix macro for strings
+*/
+#define _PREFIX_CHAR( aMsg ) (const char*)"[OOM]: " ##aMsg
+
+#endif // TRACEDEFS_H
--- a/sysresmonitoring/oommonitor/rom/oommonitor.iby	Tue Jun 15 16:07:48 2010 +0100
+++ b/sysresmonitoring/oommonitor/rom/oommonitor.iby	Thu Jul 22 16:35:22 2010 +0100
@@ -22,6 +22,7 @@
 #include <data_caging_paths_for_iby.hrh>
 
 file=ABI_DIR\BUILD_DIR\oommonitor.dll   SHARED_LIB_DIR\oommonitor.dll
+data=ZSYSTEM\..\private\10207218\oomconfig.xml  private\10207218\oomconfig.xml
 
 #endif // OOMMONITOR_IBY
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/src/oomIdletimerule.cpp	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,51 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Configuration representation classes for Out of Memory Monitor.
+*
+*/
+
+#include "oomidletimerule.h"
+#include "oomwindowgrouplist.h"
+#include "OomTraces.h"
+
+COomIdleTimeRule* COomIdleTimeRule::NewL(TTimeIntervalSeconds aIdleTime, TInt aPriority)
+    {
+    FUNC_LOG;
+
+    COomIdleTimeRule* self = new (ELeave) COomIdleTimeRule(aIdleTime, aPriority);
+    return self;
+    }
+
+TBool COomIdleTimeRule::RuleIsApplicable(const COomWindowGroupList& aWindowGroupList, TInt aAppIndexInWindowGroup) const
+    {
+    FUNC_LOG;
+
+    TBool applicable = EFalse;
+    if (aAppIndexInWindowGroup >= 0)
+        {
+        applicable = (aWindowGroupList.IdleTime(aAppIndexInWindowGroup) >= iIdleTime);
+        }
+    return applicable;
+    }
+
+COomIdleTimeRule::~COomIdleTimeRule()
+    {
+    FUNC_LOG;
+    }
+
+COomIdleTimeRule::COomIdleTimeRule(TTimeIntervalSeconds aIdleTime, TInt aPriority) : iIdleTime(aIdleTime), iPriority(aPriority)
+    {
+    FUNC_LOG;
+    }
+    
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/src/oomaction.cpp	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,40 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Classes for executing OOM actions (e.g. closing applications and running plugins).
+*
+*/
+
+
+#include "oomaction.h"
+#include "oomactionlist.h"
+#include "OomTraces.h"
+
+COomAction::~COomAction()
+    {
+    FUNC_LOG;
+    }
+
+// To be called by the derived class after the memory has been freed (or if it fails)
+void COomAction::MemoryFreed(TInt)
+    {
+    FUNC_LOG;
+    
+    iState = EOomIdle;
+    iStateChangeObserver.StateChanged();
+    }
+
+COomAction::COomAction(MOomActionObserver& aStateChangeObserver) : iStateChangeObserver(aStateChangeObserver)
+    {
+    FUNC_LOG;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/src/oomactionconfig.cpp	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,77 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Configuration representation classes for Out of Memory Monitor.
+*
+*/
+
+
+
+#include "oomactionconfig.h"
+#include "oomruleconfig.h"
+#include "OomTraces.h"
+
+// Add a rule
+// This class takes ownership of the given rule
+void COomActionConfig::AddRuleL(MOomRuleConfig* aRule)    // Add the configuration for a rule (e.g. an idle time rule)
+    {
+    FUNC_LOG;
+    
+    iRules.AppendL(aRule);
+    }
+	
+COomActionConfig::~COomActionConfig()
+    {
+    FUNC_LOG;
+    
+    iRules.ResetAndDestroy();
+    iRules.Close();
+    }
+
+// Utility function to return the priority for this action for the given rule
+TUint COomActionConfig::Priority(const COomWindowGroupList& aWindowGroupList, TInt aAppIndexInWindowGroup) const
+    {
+    FUNC_LOG;
+    
+    TUint priority = iDefaultPriority;
+    
+    // See if any rules apply
+    TInt index = 0;
+    while (index < iRules.Count())
+        {
+        if (iRules[index]->RuleIsApplicable(aWindowGroupList, aAppIndexInWindowGroup))
+            {
+            // If an applicable rule has been found, then apply the new priority
+            // The last applicable rule in the config file should be used
+            // This is ensured because the last rule in the list will be the last rule from the file
+            if (iRules[index]->Priority())
+                priority = iRules[index]->Priority();
+            }
+        
+        index++;
+        }
+        
+    return priority;
+    }
+    
+void COomActionConfig::ConstructL()
+    {
+    FUNC_LOG;
+    }
+	
+COomActionConfig::COomActionConfig(TInt32 aId) : iId(aId)
+    {
+    FUNC_LOG;
+    }
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/src/oomactionlist.cpp	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,712 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Classes for executing OOM actions (e.g. closing applications and running plugins).
+*
+*/
+
+
+
+#include <hal.h>
+#include <u32hal.h>
+#include <apgwgnam.h>
+
+#include "oommonitorplugin.h"
+#include "oommonitorplugin.hrh"
+#include "oomactionlist.h"
+#include "oomwindowgrouplist.h"
+#include "oompanic.h"
+#include "OomTraces.h"
+#include "oomconstants.hrh"
+#include "oommemorymonitor.h"
+#include "oommemorymonitorserver.h"
+#include "oomrunplugin.h"
+#include "oomcloseapp.h"
+#include "oomconfig.h"
+#include "oomactionref.h"
+#include "oomapplicationconfig.h"
+#include "oomcloseappconfig.h"
+#include "oomrunpluginconfig.h"
+
+const TUid  KUidMatrixMenuApp = { 0x101F4CD2 };
+
+template <class T>
+COomPluginList<T>::COomPluginList()
+    {
+    FUNC_LOG;
+    }
+
+template <class T>
+COomPluginList<T>::~COomPluginList()
+    {
+    FUNC_LOG;
+    
+    TInt count = iPlugins.Count();
+    for (TInt ii=0; ii<count; ii++)
+        {
+        TPlugin& plugin = iPlugins[ii];
+        if (plugin.iImpl)    // only if successfully added
+            REComSession::DestroyedImplementation(plugin.iDtorUid);
+        }
+    iPlugins.Close();
+    }
+
+template <class T>
+void COomPluginList<T>::ConstructL(TInt aInterfaceUid)
+    {
+    FUNC_LOG;
+    
+    RImplInfoPtrArray implArray;
+    CleanupClosePushL(implArray);
+    REComSession::ListImplementationsL(TUid::Uid(aInterfaceUid), implArray);
+
+    TInt count = implArray.Count();
+    iPlugins.ReserveL(count);
+
+    for (TInt ii=0; ii<count; ii++)
+        {
+        iPlugins.AppendL(TPlugin());
+        TPlugin& plugin = iPlugins[ii];
+        TUid uid(implArray[ii]->ImplementationUid());
+        plugin.iImpl = static_cast<T*>(REComSession::CreateImplementationL(uid, plugin.iDtorUid, NULL));
+        plugin.iUid = uid.iUid;
+        }
+    
+    CleanupStack::PopAndDestroy(&implArray);
+    }
+
+template <class T>
+COomPluginList<T>::TPlugin::TPlugin()
+: iImpl(0)
+    {
+    FUNC_LOG;
+   }
+
+template <class T>
+COomPluginList<T>* COomPluginList<T>::NewL(TInt aInterfaceUid)
+    {
+    FUNC_LOG;
+    
+    COomPluginList* self = new (ELeave) COomPluginList();
+    CleanupStack::PushL(self);
+    self->ConstructL(aInterfaceUid);
+    CleanupStack::Pop(self);
+    return self;
+    }
+    
+COomActionList* COomActionList::NewL(CMemoryMonitor& aMonitor, CMemoryMonitorServer& aServer, RWsSession& aWs, COomConfig& aConfig)
+    {
+    FUNC_LOG;
+    
+    COomActionList* self = new (ELeave) COomActionList(aMonitor, aServer, aWs);
+    CleanupStack::PushL(self);
+    self->ConstructL(aConfig);
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+COomActionList::~COomActionList()
+    {
+    FUNC_LOG;
+    
+    iCloseAppActions.ResetAndDestroy(); 
+    iCloseAppActions.Close();
+    iRunPluginActions.ResetAndDestroy(); 
+    iRunPluginActions.Close();
+
+    iActionRefs.Close();
+    
+    delete iPluginList;
+    delete iPluginListV2;
+    }
+
+
+
+// Creates a list of actions based on the contents of the config and the current window group list
+// Any old actions will be replaced.
+// This function may leave, however enough memory should be reserved for this process so that at least
+// some actions have been created for freeing memory, these can then be run by calling FreeMemory.
+// Note that this function will only leave in extreme circumstances, in normal usage we should have
+// enough reserved memory to build the complete action list.
+void COomActionList::BuildActionListL(COomWindowGroupList& aWindowGroupList, COomConfig& aConfig)
+    {
+    FUNC_LOG;
+    
+    if (iFreeingMemory)
+        {
+        TRACES("COomActionList::BuildActionListL Memory is currently being freed, do not build action list");
+        return;
+        }
+
+    iActionRefs.Reset();
+    iCurrentActionIndex = 0;
+    
+    aWindowGroupList.RefreshL();
+    
+    TInt actionsIndex = 0;
+    
+    // we rely on the two pluginlists not having changed since construction
+    BuildPluginActionsL(*iPluginList, aWindowGroupList, aConfig, actionsIndex);
+    BuildPluginActionsL(*iPluginListV2, aWindowGroupList, aConfig, actionsIndex);
+    
+    // Go through each item in the wglist, create an app close action for this application
+    TUint wgIndex = aWindowGroupList.Count() - 1;
+    
+    // Fix for when fast swap has focus, or pen input server has put itself into the foreground:
+    // the wg at index 1 should be considered as the foreground app.
+    // stopIndex is calculated to take this into account. 
+    TUint stopIndex = 0;
+    TUid foregroundUid = TUid::Uid(aWindowGroupList.AppId(0));
+    if ( KUidFastSwap == foregroundUid || KUidPenInputServer == foregroundUid)
+        {
+        stopIndex = 1;
+        }
+    
+    while (wgIndex > stopIndex) // Don't go down to entry stopIndex because this is the foreground window
+        {
+        COomCloseAppConfig* appCloseConfig = NULL;
+
+        CApaWindowGroupName* wgName = aWindowGroupList.WgName();
+        __ASSERT_DEBUG(wgName, OomMonitorPanic(KInvalidWgName));    
+        
+        // Get the app ID for the wglist item
+        // This sets the window group name
+        TInt32 appId = aWindowGroupList.AppId(wgIndex);    
+
+        if ( !appId || wgName->IsSystem() || wgName->Hidden() )
+            {
+            //If the UID is NULL at this point, we assume the process is not an application
+            //and therefore is not a suitable candidate for closure. 
+            //We also do not close system or hidden apps.
+      
+            //Matrix Menu is temporarily hardcoded here as a system app that can be closed
+            TUid appUid = TUid::Uid(aWindowGroupList.AppId(wgIndex, ETrue));
+            if ( KUidMatrixMenuApp == appUid)
+                {   
+                TRACES2("BuildActionListL: System App is Matrix Menu; UID = %x, wgIndex = %d", aWindowGroupList.AppId(wgIndex, ETrue),wgIndex);
+                // Find the app close config for Menu App
+                appCloseConfig = aConfig.GetApplicationConfig(appId).GetAppCloseConfig();
+                }
+            else
+                {
+                TRACES2("BuildActionListL: Not adding process to action list; UID = %x, wgIndex = %d", aWindowGroupList.AppId(wgIndex, ETrue),wgIndex);                
+                TRACES2("BuildActionListL: IsSystem = %d, Hidden = %d", wgName->IsSystem() ? 1 : 0, wgName->Hidden() ? 1 : 0);                
+                wgIndex--;
+                continue;
+                }
+            }
+        if (aWindowGroupList.IsBusy(wgIndex) || wgName->IsBusy())
+            // If the application has been flagged as busy then look up the configuration for busy apps in the config file
+            {
+            // Find the app close config for this app ID
+            appCloseConfig = aConfig.GetApplicationConfig(KOomBusyAppId).GetAppCloseConfig();
+            }
+        else if (aWindowGroupList.IsDynamicHighPriority(wgIndex))
+            // If the application has been flagged as busy then look up the configuration for busy apps in the config file
+            {
+            // Find the app close config for this app ID
+            appCloseConfig = aConfig.GetApplicationConfig(KOomHighPriorityAppId).GetAppCloseConfig();
+            }
+        else
+            // If the application hasn't been flagged as busy or high priority then look up the priority according to the config
+            {            
+            // Find the app close config for this app ID
+            appCloseConfig = aConfig.GetApplicationConfig(appId).GetAppCloseConfig();        
+            }
+
+        //If the app close config is NULL it is because there is an app specific threshold for this 
+        //app but no specific close config. Use the default app close config
+        if (!appCloseConfig)
+            {
+            appCloseConfig = aConfig.GetApplicationConfig(KOomDefaultAppId).GetAppCloseConfig();                    
+            }
+        
+        TUint priority = appCloseConfig->CalculateCloseAppPriority(aWindowGroupList, wgIndex);
+        TInt wgId = aWindowGroupList.WgId(wgIndex).iId;
+        TOomSyncMode syncMode = appCloseConfig->iSyncMode;
+        TInt ramEstimate = appCloseConfig->iRamEstimate;
+        TActionRef ref = TActionRef(TActionRef::EAppClose, priority, syncMode, ramEstimate, wgId, wgIndex);
+
+        //AppClose Actions should always have a unique prioirity determined by the application's z order.
+        TInt err = iActionRefs.InsertInOrder(ref, ComparePriorities);
+        if ((err != KErrNone) && (err != KErrAlreadyExists))
+            {
+            User::Leave(err);
+            }
+        TRACES3("BuildActionListL: Adding app to action list, Uid = %x, wgId = %d, wgIndex = %d", appId, wgId, wgIndex);                
+
+        wgIndex--;
+        }
+    
+    TRACES1("BuildActionListL: Action list built with %d items",iActionRefs.Count());    
+    }
+
+template <class T>
+void COomActionList::BuildPluginActionsL(COomPluginList<T>& aPluginList, COomWindowGroupList& aWindowGroupList, COomConfig& aConfig, TInt& aActionsIndex)
+    {
+    TInt pluginIndex = aPluginList.Count();
+
+    while (pluginIndex--)
+        {
+        // Get the config for this plugin
+        COomRunPluginConfig& pluginConfig = aConfig.GetPluginConfig(aPluginList.Uid(pluginIndex));
+        
+        TActionRef::TActionType actionType;
+        
+        if (pluginConfig.PluginType() == EOomAppPlugin)
+            {
+            if (pluginConfig.CallIfTargetAppNotRunning() == EFalse)
+                {
+                //loop through wg group and if find can't find the target app, don't add this plugin
+                TInt index = aWindowGroupList.Count() - 1;
+                TUint targetApp = pluginConfig.TargetApp();
+                TBool targetAppFound = EFalse;
+                while (index >= 0)
+                    {
+                    if (aWindowGroupList.AppId(index) == targetApp)
+                        {
+                        targetAppFound = ETrue;
+                        break;
+                        }
+                    index--;
+                    }
+                if (targetAppFound == EFalse)
+                    {
+                    aActionsIndex++;
+                    continue;
+                    }
+                }
+            actionType = TActionRef::EAppPlugin;
+            }
+        else
+            {
+            actionType = TActionRef::ESystemPlugin;
+            }
+
+        TInt priority = pluginConfig.CalculatePluginPriority(aWindowGroupList);
+        TOomSyncMode syncMode = pluginConfig.iSyncMode;
+        TInt ramEstimate = pluginConfig.iRamEstimate;
+        
+        __ASSERT_DEBUG(aActionsIndex < iRunPluginActions.Count(), OomMonitorPanic(KPluginArrayIndexOutOfBounds));    
+        TActionRef ref = TActionRef(actionType, priority, syncMode, ramEstimate, *(iRunPluginActions[aActionsIndex]), aWindowGroupList.GetIndexFromAppId(pluginConfig.TargetApp()));
+
+        //It is valid to have plugins with equal priority
+        User::LeaveIfError(iActionRefs.InsertInOrderAllowRepeats(ref, ComparePriorities));
+        
+        aActionsIndex++;
+        }
+    }
+
+
+// Execute the OOM actions according to their priority
+// Run batches of OOM actions according to their sync mode
+void COomActionList::FreeMemory(TInt aMaxPriority)
+    {
+    FUNC_LOG;
+    if (iFreeingMemory)
+        {
+        TRACES("COomActionList::FreeMemory Memory is currently being freed, do not start any more actions");
+        return;
+        }
+    
+    iMaxPriority = aMaxPriority;
+        
+    TBool memoryFreeingActionRun = EFalse;
+    
+    // Get the configured maximum number of applications that can be closed at one time
+    const COomGlobalConfig& globalConfig = CMemoryMonitor::GlobalConfig();
+    TInt maxBatchSize = globalConfig.iMaxCloseAppBatch;
+    TInt numberOfRunningActions = 0;
+    
+    TInt freeRamEstimate = 0; // The amount of free memory we expect to be free after the currently initiated operations
+    HAL::Get(HALData::EMemoryRAMFree, freeRamEstimate);
+    TUint64 freeSwapEstimate = 0;
+    if (iSwapUsageMonitored)
+        {
+        SVMSwapInfo swapInfo;
+        UserSvr::HalFunction(EHalGroupVM, EVMHalGetSwapInfo, &swapInfo, 0);
+        freeSwapEstimate = swapInfo.iSwapFree;
+        }
+        
+    while (iCurrentActionIndex < iActionRefs.Count() 
+            && iActionRefs[iCurrentActionIndex].Priority() <= aMaxPriority)
+        {
+        TActionRef ref = iActionRefs[iCurrentActionIndex];
+        COomAction* action = NULL;
+        if (ref.Type() == TActionRef::EAppClose)
+            {
+            action = iCloseAppActions[numberOfRunningActions];
+            static_cast<COomCloseApp*>(action)->Reconfigure(ref);
+            }
+        else 
+            {
+            action = &(ref.RunPlugin());
+            }
+        
+        iFreeingMemory = ETrue;
+        TRACES2("COomActionList::FreeMemory: Running action %d which has priority %d", iCurrentActionIndex,ref.Priority());
+        
+        iMonitor.SetMemoryMonitorStatusProperty(EFreeingMemory);
+        
+        // At the moment the actions don't make any difference between freeing
+        // RAM and freeing swap. So we try to free the biggest of the two.
+        // Until the plugins are updated to make a distinction between swap and RAM this is the best
+        // we can do. For application close actions the amount to try to free is ignored anyway.
+        TUint amountToTryToFree = 0;
+		if (iCurrentRamTarget > freeRamEstimate)
+			{
+			amountToTryToFree = iCurrentRamTarget - freeRamEstimate;
+			}
+        if (iSwapUsageMonitored && (iCurrentSwapTarget > freeSwapEstimate) && ((iCurrentSwapTarget - freeSwapEstimate) > amountToTryToFree))
+            {
+            amountToTryToFree = iCurrentSwapTarget - freeSwapEstimate;
+            }
+        action->FreeMemory(amountToTryToFree, iMonitor.iDataPaged);
+        memoryFreeingActionRun = ETrue;
+                
+        // Actions with EContinueIgnoreMaxBatchSize don't add to the tally of running actions
+        if (ref.SyncMode() != EContinueIgnoreMaxBatchSize)
+            numberOfRunningActions++;
+        
+        // Update our estimate of how much RAM we think we'll have after this operation
+        freeRamEstimate += ref.RamEstimate();
+         
+        // Do we estimate that we are freeing enough memory (only applies if the sync mode is "esimtate" for this action)
+        TBool estimatedEnoughMemoryFreed = EFalse;
+        if ((ref.SyncMode() == EEstimate)
+            && (freeRamEstimate >= iCurrentRamTarget))
+            {
+            estimatedEnoughMemoryFreed = ETrue;
+            }
+        
+        if ((ref.SyncMode() == ECheckRam)
+                || (numberOfRunningActions >= maxBatchSize)
+                || estimatedEnoughMemoryFreed
+                || globalConfig.ForceCheckAtPriority(iActionRefs[iCurrentActionIndex].Priority()))
+            // If this actions requires a RAM check then wait for it to complete
+            // Also force a check if we've reached the maximum number of concurrent operations
+            // Also check if we estimate that we have already freed enough memory (assuming that the sync mode is "estimate"
+            {
+            // Return from the loop - we will be called back (in COomActionList::StateChanged()) when the running actions complete
+            TRACES("COomActionList::FreeMemory: Exiting run action loop");
+            return;
+            }
+        // ... otherwise continue running actions, don't wait for any existing ones to complete
+        iCurrentActionIndex++;
+        }
+
+    
+    if (!memoryFreeingActionRun)
+        {
+        // No usable memory freeing action has been found, so we give up
+        TRACES("COomActionList::FreeMemory: No usable memory freeing action has been found");
+        iMonitor.ResetTargets();
+        TInt freeMemory = 0;
+        iMonitor.GetFreeMemory(freeMemory);
+        TInt freeSwap = 0;
+        if (iSwapUsageMonitored)
+            {
+            iMonitor.GetFreeSwapSpace(freeSwap);
+            }
+        if ((freeMemory >= iCurrentRamTarget) &&
+            ((!iSwapUsageMonitored) || (freeSwap >= iCurrentSwapTarget)))
+            {
+            SwitchOffPlugins();
+            iMonitor.SetMemoryMonitorStatusProperty(EAboveTreshHold);
+            }
+        else
+            {
+            if (iMonitor.ActionTrigger() == EClientServerRequestOptionalRam)
+                {
+                //We always switch off the plugins after an optional RAM request
+                SwitchOffPlugins();
+                }
+            iMonitor.SetMemoryMonitorStatusProperty(EBelowTreshHold);
+            }
+#ifdef CLIENT_REQUEST_QUEUE        
+        iMonitor.ActionsCompleted(freeMemory, EFalse);
+#else
+        iServer.CloseAppsFinished(freeMemory, EFalse);
+#endif
+        }
+    }
+
+void COomActionList::SwitchOffPlugins()
+    {
+    FUNC_LOG;
+    
+    TInt actionRefIndex = iActionRefs.Count();
+    
+    // Go through each of the action references, if it's a plugin action then call MemoryGood on it
+    // Note that this only results in a call to the plugin if FreeMemory has been called on this plugin since that last call to MemoryGood
+    while (actionRefIndex--)
+        {
+        if ((iActionRefs[actionRefIndex].Type() == TActionRef::EAppPlugin)
+                || (iActionRefs[actionRefIndex].Type() == TActionRef::ESystemPlugin))
+            {
+            iActionRefs[actionRefIndex].RunPlugin().MemoryGood();
+            }
+        }
+    }
+
+TInt COomActionList::ComparePriorities(const TActionRef& aPos1, const TActionRef& aPos2 )
+    {
+    FUNC_LOG;
+    
+    if (aPos1.Priority()< aPos2.Priority())
+        {
+        return -1;
+        }
+    if (aPos1.Priority() > aPos2.Priority())
+        {
+        return 1;
+        }
+    
+    // If priorities are equal then we use hardcoded rules to determine which one is run...
+
+    // All other actions are run in preference to application closures
+	if ((aPos1.Type() != TActionRef::EAppClose)
+			&& ((aPos2.Type() == TActionRef::EAppClose)))
+		{
+		return -1;
+		}
+	if ((aPos1.Type() == TActionRef::EAppClose)
+			&& ((aPos2.Type() != TActionRef::EAppClose)))
+		{
+		return 1;
+		}
+	// If both actions are application closures then the Z order is used to determine which one to run (furthest back application will be closed first)
+	if ((aPos1.Type() == TActionRef::EAppClose)
+			&& ((aPos2.Type() == TActionRef::EAppClose)))
+		{
+		if (aPos1.WgIndex() < aPos2.WgIndex())
+			{
+			return 1;
+			}
+		else
+			{
+			return -1;
+			}
+		//Two Apps should not have equal window group indexes, we panic below if this is the case.
+		}	
+	
+	// Application plugins will be run in preference to system plugins
+	if ((aPos1.Type() == TActionRef::EAppPlugin)
+			&& ((aPos2.Type() == TActionRef::ESystemPlugin)))
+		{
+		return -1;
+		}	
+	if ((aPos1.Type() == TActionRef::ESystemPlugin)
+			&& ((aPos2.Type() == TActionRef::EAppPlugin)))
+		{
+		return 1;
+		}
+		
+	// If both actions are application plugins then the Z order of the target app is used to determine which one to run (the one with the furthest back target app will be closed first)
+	// If the target app is not running then the plugin is run in preference to target apps where the target app is running
+	if ((aPos1.Type() == TActionRef::EAppPlugin)
+			&& ((aPos2.Type() == TActionRef::EAppPlugin)))
+		{
+		// When the target app is not running then the plugin will be run ahead of plugins where the target app is running
+		if ((aPos1.WgIndex() == KAppNotInWindowGroupList) && (aPos2.WgIndex() != KAppNotInWindowGroupList))
+			{
+			return -1;
+			}
+		if ((aPos1.WgIndex() != KAppNotInWindowGroupList) && (aPos2.WgIndex() == KAppNotInWindowGroupList))
+			{
+			return 1;
+			}
+		// If the target apps for both plugins are running then compare the Z order
+		if ((aPos1.WgIndex() != KAppNotInWindowGroupList) && (aPos2.WgIndex() != KAppNotInWindowGroupList))
+			{
+			if (aPos1.WgIndex() < aPos2.WgIndex())
+				{
+				return 1;
+				}
+			else
+				{
+				return -1;
+				}
+			}
+		// If the target app for neither plugin is running then they are of equal priority
+		}
+    //App Close Actions must have a unique priority.
+    __ASSERT_DEBUG((aPos1.Type() != TActionRef::EAppClose) && (aPos2.Type() != TActionRef::EAppClose), OomMonitorPanic(KAppCloseActionEqualPriorities));    
+    return 0;        
+    }
+
+void COomActionList::AppNotExiting(TInt aWgId)
+    {
+    FUNC_LOG;
+    
+    TInt index = iCloseAppActions.Count();
+    while (index--)
+        {
+        COomCloseApp* action = iCloseAppActions[index];
+        if ( (action->WgId() == aWgId) && (action->IsRunning()) )
+            {
+            TRACES1("COomCloseApp::AppNotExiting: App with window group id %d has not responded to the close event", aWgId);
+            action->CloseAppEvent();            
+            }
+        }
+    }
+
+// From MOomActionObserver
+// An action has changed state (possibly it has completed freeing memory)
+void COomActionList::StateChanged()
+    {
+    FUNC_LOG;
+    
+    TBool allActionsComplete = ETrue;
+    
+    // Note that the actions themselves are responsible for timing out if necessary.
+    TInt index = iCloseAppActions.Count();
+    while ((index--) && (allActionsComplete))
+        {
+        if (iCloseAppActions[index]->IsRunning())
+            {
+            allActionsComplete = EFalse;
+            }
+        }
+
+    index = iRunPluginActions.Count();
+    while ((index--) && (allActionsComplete))
+        {
+        if (iRunPluginActions[index]->IsRunning())
+            {
+            allActionsComplete = EFalse;
+            }
+        }
+    
+    if (allActionsComplete)
+        {
+        //All immediate actions are complete and iFreeingMemory is being set to false but
+        //SetMemoryMonitorStatusProperty will not change here because it is possible for the freeing actions to recommence
+        //in essence, all immediate actions have been completed but not all possible actions have been processed 
+        //and therefore we are still in a memory freeing state
+        iFreeingMemory = EFalse;
+        // If all of the actions are complete then check memory and run more if necessary
+        TInt freeMemory = 0;
+        iMonitor.GetFreeMemory(freeMemory);
+        TInt freeSwap = 0;
+        if (iSwapUsageMonitored)
+            {
+            iMonitor.GetFreeSwapSpace(freeSwap);
+            }
+        if ((freeMemory < iCurrentRamTarget) ||
+            (iSwapUsageMonitored && (freeSwap < iCurrentSwapTarget)))
+            // If we are still below the good-memory-threshold then continue running actions
+            {
+            iCurrentActionIndex++;
+            
+            if (iCurrentActionIndex >= iActionRefs.Count())
+                {
+                // There are no more actions to try, so we give up
+                TRACES1("COomActionList::StateChanged: All current actions complete, below good threshold with no more actions available. freeMemory=%d", freeMemory);
+                iMonitor.ResetTargets();
+                if ((freeMemory >= iCurrentRamTarget) &&
+                    ((!iSwapUsageMonitored) || (freeSwap >= iCurrentSwapTarget)))
+                    {
+                    SwitchOffPlugins();
+                    iMonitor.SetMemoryMonitorStatusProperty(EAboveTreshHold);
+                    }
+                else
+                    {
+                    if (iMonitor.ActionTrigger() == EClientServerRequestOptionalRam)
+                        {
+                        //We always switch off the plugins after an optional RAM request
+                        SwitchOffPlugins();
+                        }
+                    iMonitor.SetMemoryMonitorStatusProperty(EBelowTreshHold);
+                    }
+#ifdef CLIENT_REQUEST_QUEUE        
+                iMonitor.ActionsCompleted(freeMemory, EFalse);
+#else
+                iServer.CloseAppsFinished(freeMemory, EFalse);
+#endif
+                }
+            else
+                {
+                // There are still more actions to try, so we continue
+                TRACES1("COomActionList::StateChanged: All current actions complete, running more actions. freeMemory=%d", freeMemory);
+                FreeMemory(iMaxPriority);
+                }
+            }
+        else
+            {
+            TRACES1("COomActionList::StateChanged: All current actions complete, memory good. freeMemory=%d", freeMemory);
+            iMonitor.ResetTargets();
+            SwitchOffPlugins();
+            iMonitor.SetMemoryMonitorStatusProperty(EAboveTreshHold);
+#ifdef CLIENT_REQUEST_QUEUE        
+            iMonitor.ActionsCompleted(freeMemory, ETrue);
+#else
+            iServer.CloseAppsFinished(freeMemory, ETrue);
+#endif
+            }
+        }
+    
+    // If some actions are not yet in the idle state then we must continue to wait for them (they will notify us of a state change via a callback)
+    }
+
+COomActionList::COomActionList(CMemoryMonitor& aMonitor, CMemoryMonitorServer& aServer, RWsSession& aWs) 
+    : iWs(aWs), iMonitor(aMonitor), iServer(aServer)
+    {
+    FUNC_LOG;
+    }
+
+void COomActionList::ConstructL(COomConfig& aConfig)
+    {
+    FUNC_LOG;
+    
+    iCurrentActionIndex = 0;
+    iSwapUsageMonitored = aConfig.GlobalConfig().iSwapUsageMonitored;
+    iFreeingMemory = EFalse;
+    
+    // Get the list of V1 and V2 plugins available to the system
+    iPluginList = COomPluginList<COomMonitorPlugin>::NewL(KOomPluginInterfaceUidValue);
+    iPluginListV2 = COomPluginList<COomMonitorPluginV2>::NewL(KOomPluginInterfaceV2UidValue);
+    // Go through each plugin in the plugin list, create a run-plugin action for each one
+    TInt pluginIndex = iPluginList->Count();
+    while (pluginIndex--)
+        {
+        // Get the config for this plugin
+        COomRunPluginConfig& pluginConfig = aConfig.GetPluginConfig(iPluginList->Uid(pluginIndex));
+        
+        // Create an action acording to the config
+        COomRunPlugin* action = COomRunPlugin::NewL(iPluginList->Uid(pluginIndex), pluginConfig, *this, iPluginList->Implementation(pluginIndex));
+        
+        iRunPluginActions.AppendL(action);
+        }
+    
+    // Go through each V2 in the V2 plugin list, create a run-plugin action for each one
+    pluginIndex = iPluginListV2->Count();
+    while (pluginIndex--)
+        {
+        // Get the config for this plugin
+        COomRunPluginConfig& pluginConfig = aConfig.GetPluginConfig(iPluginListV2->Uid(pluginIndex));
+        
+        // Create an action acording to the config
+        COomRunPlugin* action = COomRunPlugin::NewL(iPluginList->Uid(pluginIndex), pluginConfig, *this, iPluginListV2->Implementation(pluginIndex), &(iPluginListV2->Implementation(pluginIndex)));
+        
+        iRunPluginActions.AppendL(action);
+        }
+
+    //allocate empty COomCloseApp objects
+    TInt appCloseIndex = aConfig.GlobalConfig().iMaxCloseAppBatch;
+    while (appCloseIndex--)        
+        {
+        COomCloseApp* action = COomCloseApp::NewL(*this, iWs);
+        iCloseAppActions.AppendL(action);
+        }
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/src/oomactionref.cpp	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,66 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Classes for executing OOM actions (e.g. closing applications and running plugins).
+*
+*/
+
+
+
+#include "oomactionref.h"
+
+TActionRef::TActionRef(TActionType aType, TInt aPriority, TOomSyncMode aSyncMode, TInt aRamEstimate, COomRunPlugin& aRunPlugin, TUint aWgIndexOfTargetApp)
+    : iType(aType), iPriority(aPriority), iSyncMode(aSyncMode), iRamEstimate(aRamEstimate), iWgIndex(aWgIndexOfTargetApp), iRunPlugin(&aRunPlugin)
+    {   
+    }
+
+TActionRef::TActionRef(TActionType aType, TInt aPriority, TOomSyncMode aSyncMode, TInt aRamEstimate, TInt aWgId, TUint aWgIndex)
+: iType(aType), iPriority(aPriority), iSyncMode(aSyncMode), iRamEstimate(aRamEstimate), iWgId(aWgId), iWgIndex(aWgIndex), iRunPlugin(NULL)
+    {   
+    }
+
+    
+TActionRef::TActionType TActionRef::Type() const
+    {
+    return iType;
+    }
+
+TUint TActionRef::Priority() const
+    {
+    return iPriority;
+    }
+
+TOomSyncMode TActionRef::SyncMode() const
+    {
+    return iSyncMode;
+    }
+    
+TInt TActionRef::RamEstimate() const
+    {
+    return iRamEstimate;
+    }
+
+TInt TActionRef::WgId() const
+    {
+    return iWgId;
+    }
+
+TInt TActionRef::WgIndex() const
+    {
+    return iWgIndex;
+    }
+
+COomRunPlugin& TActionRef::RunPlugin()
+    {
+    return *iRunPlugin;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/src/oomappclosetimer.cpp	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,47 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Timer class which implements a timeout for an application close action.
+*
+*/
+
+
+#include "oomappclosetimer.h"
+#include "oomcloseapp.h"
+#include "OomTraces.h"
+
+COomAppCloseTimer* COomAppCloseTimer::NewL(COomCloseApp& aMonitor)
+    {
+    FUNC_LOG;
+
+    COomAppCloseTimer* self = new (ELeave) COomAppCloseTimer(aMonitor);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+COomAppCloseTimer::COomAppCloseTimer(COomCloseApp& aMonitor)
+: CTimer(CActive::EPriorityStandard), iMonitor(aMonitor)
+    {
+    FUNC_LOG;
+
+    CActiveScheduler::Add(this);
+    }
+
+void COomAppCloseTimer::RunL()
+    {
+    FUNC_LOG;
+
+    iMonitor.CloseAppEvent();
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/src/oomappclosewatcher.cpp	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,84 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  An active object which watches for app close actions successfully completing.
+*
+*/
+
+
+
+#include "oomappclosewatcher.h"
+#include "oomcloseapp.h"
+#include "OomTraces.h"
+
+COomAppCloseWatcher::COomAppCloseWatcher(COomCloseApp& aMonitor) : CActive(CActive::EPriorityStandard), iMonitor(aMonitor)
+    {
+    FUNC_LOG;
+
+    CActiveScheduler::Add(this);
+    }
+
+COomAppCloseWatcher::~COomAppCloseWatcher()
+    {
+    FUNC_LOG;
+
+    Cancel();
+    }
+
+void COomAppCloseWatcher::Start(const TApaTask& aTask)
+    {
+    FUNC_LOG;
+
+    if (!IsActive())
+        {
+        TInt err = iThread.Open(aTask.ThreadId());
+        if (err == KErrNone)
+            {
+            iOriginalProcessPriority = iThread.ProcessPriority();
+            iThread.SetProcessPriority(EPriorityForeground);
+            iThread.Logon(iStatus);
+            SetActive();
+            }
+        else
+            {
+            TRequestStatus* s = &iStatus;
+            User::RequestComplete(s, err);
+            SetActive();
+            }
+        }
+    }
+
+void COomAppCloseWatcher::DoCancel()
+    {
+    FUNC_LOG;
+
+    iThread.LogonCancel(iStatus);
+    iThread.SetProcessPriority(iOriginalProcessPriority);
+    iThread.Close();
+    }
+
+void COomAppCloseWatcher::RunL()
+    {
+    FUNC_LOG;
+
+    if (iThread.Handle())
+        iThread.SetProcessPriority(iOriginalProcessPriority);
+    iThread.Close();
+    // Experimentation shows that memory may take up to 40ms
+    // to be released back to the system after app thread close.
+    // Using this delay should minimise the number of apps that
+    // need to be closed to recover the necessary memory.
+    const TInt KAppTidyUpDelay = 40000;
+    User::After(KAppTidyUpDelay);
+    iMonitor.CloseAppEvent();
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/src/oomapplicationconfig.cpp	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,69 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Configuration representation classes for Out of Memory Monitor.
+*
+*/
+
+
+
+#include "oomapplicationconfig.h"
+#include "oomconstants.hrh"
+#include "oomcloseappconfig.h"
+#include "OomTraces.h"
+
+COomApplicationConfig* COomApplicationConfig::NewL(TUint aApplicationId)
+    {
+    FUNC_LOG;
+
+    COomApplicationConfig* self = new (ELeave) COomApplicationConfig(aApplicationId);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+// Add a rule
+// This class takes ownership of the given rule
+// This rule applies to this application itself (and not a plugin associated with this application)
+// The rule would usually apply to an "application close" event
+void COomApplicationConfig::AddRuleL(MOomRuleConfig* aRule)
+    {   
+    FUNC_LOG;
+
+   __ASSERT_ALWAYS(iCloseAppConfig, OomMonitorPanic(KRuleConfiguredBeforeApplication));
+    
+    iCloseAppConfig->AddRuleL(aRule);
+    }
+
+COomApplicationConfig::~COomApplicationConfig()
+    {
+    FUNC_LOG;
+
+    delete iCloseAppConfig;
+    }
+
+void COomApplicationConfig::ConstructL()
+    {
+    FUNC_LOG;
+
+    iGoodRamThreshold = KOomThresholdUnset;
+    iLowRamThreshold = KOomThresholdUnset;  
+    iGoodSwapThreshold = KOomThresholdUnset;
+    iLowSwapThreshold = KOomThresholdUnset;  
+    }
+
+COomApplicationConfig::COomApplicationConfig(TUint aApplicationId) : iApplicationId(aApplicationId)
+    {
+    FUNC_LOG;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/src/oomclientrequestqueue.cpp	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,359 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  COomClientRequestQueue.cpp.
+*
+*/
+
+
+
+#include "oomclientrequestqueue.h"
+#include "OomTraces.h"
+#include "oomsubscribehelper.h"
+#include "oompanic.h"
+#include "oommemorymonitor.h"
+#include <UikonInternalPSKeys.h>
+
+const TInt KOomWatchDogStatusIdle = -1;
+const TInt KClientTimeToFreeMemory = 500000; //microseconds
+
+COomClientRequestQueue::COomClientRequestQueue(CMemoryMonitor& aMonitor)
+    :iQueue(_FOFF(TClientRequest,iLink)),
+    iMonitor(aMonitor)
+    {
+    FUNC_LOG;
+    }
+
+COomClientRequestQueue::~COomClientRequestQueue()
+    {
+    FUNC_LOG;
+    
+    if (iWatchdogStatusSubscriber)
+        {
+        iWatchdogStatusSubscriber->StopSubscribe();
+        }
+    iWatchdogStatusProperty.Close();
+    delete iWatchdogStatusSubscriber;
+
+    if (iClientRequestTimer)
+        {
+        iClientRequestTimer->Cancel();
+        }
+    delete iClientRequestTimer;
+    
+    TClientRequest* request;
+    TSglQueIter<TClientRequest> iter(iQueue);
+    iter.SetToFirst(); 
+    while (iter)
+        {
+        request = iter++;
+        iQueue.Remove(*request);
+        delete request;
+        };
+    }
+
+COomClientRequestQueue* COomClientRequestQueue::NewL(CMemoryMonitor& aMonitor)
+    {
+    FUNC_LOG;
+    
+    COomClientRequestQueue* self = new (ELeave) COomClientRequestQueue(aMonitor);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self); 
+    return self;
+    }
+
+void COomClientRequestQueue::ConstructL()
+    {
+    FUNC_LOG;
+    
+    TInt err = iWatchdogStatusProperty.Attach(KPSUidUikon, KUikOOMWatchdogStatus);
+
+    TRACES1("COomClientRequestQueue::ConstructL: KUikOOMWatchdogStatus err = %d", err);
+    
+    err = iWatchdogStatusProperty.Set(KOomWatchDogStatusIdle);
+    
+    iWatchdogStatusSubscriber = new (ELeave) CSubscribeHelper(TCallBack(WatchdogStatusStatusChanged, this), iWatchdogStatusProperty);
+    iWatchdogStatusSubscriber->Subscribe();
+
+    
+    iClientRequestTimer = COomClientRequestTimer::NewL(*this);    
+    }
+
+void COomClientRequestQueue::RequestFreeMemoryL(const RMessage2& aMessage)
+    {
+    FUNC_LOG;
+    
+    TClientRequest* request = new (ELeave) TClientRequest(EClientServerRequestFreeMemory, aMessage);
+    CleanupStack::PushL(request);
+    AddClientRequestL(*request);
+    CleanupStack::Pop(request);
+    }
+
+void COomClientRequestQueue::RequestOptionalRamL(const RMessage2& aMessage)
+    {
+    FUNC_LOG;
+    
+    TClientRequest* request = new (ELeave) TClientRequest(EClientServerRequestOptionalRam, aMessage);
+    CleanupStack::PushL(request);
+    AddClientRequestL(*request);
+    CleanupStack::Pop(request);
+    }
+
+TInt COomClientRequestQueue::WatchdogStatusStatusChanged(TAny* aPtr)
+    {
+    FUNC_LOG;
+
+    COomClientRequestQueue* self = static_cast<COomClientRequestQueue*>(aPtr);
+    if (self)
+        {
+        self->HandleWatchdogStatusCallBack();
+        }
+    return KErrNone;
+    }
+
+void COomClientRequestQueue::HandleWatchdogStatusCallBack()
+    {
+    FUNC_LOG;
+
+    // Someone has set the key to request some free memory.
+    TInt memoryRequested = 0;
+    iWatchdogStatusProperty.Get(memoryRequested);
+
+    // Try to free the RAM.
+    if (memoryRequested >= 1)
+        {
+        TClientRequest request = TClientRequest(EPublishAndSubscribe, memoryRequested);
+        TRAP_IGNORE(AddClientRequestL(request));
+        }
+    // Set the key back to KOomWatchDogStatusIdle to indicate we're done.
+    iWatchdogStatusProperty.Set(KOomWatchDogStatusIdle);
+    }
+
+// The new request is added to the queue, then we have the following conditions: 
+// 1. A client request is currently being processed
+// 2. The last client request completed less than KClientTimeToFreeMemory microseconds ago -> start the timer
+// 3. The timer has already been started
+// 4. none of the above -> process this request
+void COomClientRequestQueue::AddClientRequestL(TClientRequest& request)
+    {
+    FUNC_LOG;
+    
+    iQueue.AddLast(request);
+ 
+    if ( !iClientRequestActive && !iClientRequestTimer->IsActive() )
+        {
+        TTime now;
+        now.UniversalTime();
+        TInt64 interval64 = (now.MicroSecondsFrom(iLastClientCompletedTime)).Int64();
+        TRACES3("COomClientRequestQueue::AddClientRequestL: now = %Ld, iLastClientCompletedTime = %Ld, interval64 = %Ld",
+                now.Int64(), iLastClientCompletedTime.Int64(), interval64);
+               
+        if ( interval64 < 0)        
+            {
+            //If the system time is moved backwards we lose the information about when the last request was 
+            //made, so we wait for KClientTimeToFreeMemory microseconds
+            iClientRequestTimer->After(TTimeIntervalMicroSeconds32(KClientTimeToFreeMemory));            
+            }
+        else if ( interval64 < KClientTimeToFreeMemory)
+            {            
+            //The last completed client is given KClientTimeToFreeMemory microseconds to allocate the memory 
+            //it requested
+            iClientRequestTimer->After(TTimeIntervalMicroSeconds32(interval64));
+            }
+        else 
+            {
+            StartClientRequestL();
+            }        
+        }
+    }
+
+void COomClientRequestQueue::StartClientRequestL()
+    {    
+    FUNC_LOG;
+    
+    iClientRequestActive = ETrue;
+
+    TClientRequest* request = iQueue.First();
+    
+    RThread clientThread;
+    TInt err =  (request->iRequestFreeRamMessage).Client(clientThread);
+    TBool dataPaged = EFalse;
+    if(err == KErrNone)
+        {
+        RProcess processName;
+        err = clientThread.Process(processName);
+        dataPaged = processName.DefaultDataPaged();
+        }
+    else
+        {
+        OomMonitorPanic(KInvalidClientRequestType);
+        }
+    
+    
+    switch (request->iClientRequestType)
+        {
+        case EClientServerRequestOptionalRam:
+            {
+            TInt pluginId = request->iRequestFreeRamMessage.Int2();
+            iMonitor.FreeOptionalRamL(request->iBytesRequested, pluginId, dataPaged);
+            break;
+            }
+        case EClientServerRequestFreeMemory:
+            iMonitor.RequestFreeMemoryL(request->iBytesRequested, dataPaged);
+            break;
+        case EPublishAndSubscribe:
+            iMonitor.RequestFreeMemoryPandSL(request->iBytesRequested);
+            break;
+        default:
+            OomMonitorPanic(KInvalidClientRequestType);
+            break;
+        }
+    }
+
+CMemoryMonitor& COomClientRequestQueue::Monitor()
+    {
+    FUNC_LOG;
+    
+    return iMonitor;
+    }
+
+TClientRequest::TClientRequest(TActionTriggerType aClientRequestType, TInt aBytesRequested)    
+    : iClientRequestType(aClientRequestType), iBytesRequested(aBytesRequested)   
+    {
+    FUNC_LOG;
+    }
+
+TClientRequest::TClientRequest(TActionTriggerType aClientRequestType, const RMessage2& aRequestFreeRam)    
+    : iClientRequestType(aClientRequestType), iRequestFreeRamMessage(aRequestFreeRam)
+    {
+    FUNC_LOG;
+    
+    iBytesRequested = aRequestFreeRam.Int0();
+    }
+
+void COomClientRequestQueue::ActionsCompleted(TInt aBytesFree, TBool aMemoryGood)
+    {
+    FUNC_LOG;
+    
+    if (iClientRequestActive)
+        {
+#ifdef _DEBUG
+        TSglQueIter<TClientRequest> iter(iQueue);
+        iter.SetToFirst();
+        TClientRequest* req;
+        while (iter)
+            {
+            req = iter++;
+            TActionTriggerType crt = req->iClientRequestType;
+            TInt bytes = req->iBytesRequested;
+            TRACES2("COomClientRequestQueue::ActionsCompleted Printing Queue: Type = %d, Bytes Requested = %d", crt, bytes);
+            };
+#endif 
+
+        __ASSERT_DEBUG(!iQueue.IsEmpty(), OomMonitorPanic(KClientQueueNotEmpty));        
+        __ASSERT_DEBUG(!iClientRequestTimer->IsActive(), OomMonitorPanic(KClientRequestTimerActive));        
+
+        TClientRequest* request = iQueue.First();
+        RMessage2 message;
+        
+        switch (request->iClientRequestType)
+            {
+            case EClientServerRequestOptionalRam:
+                message = request->iRequestFreeRamMessage;
+                if (!message.IsNull())
+                    {
+                    TInt memoryAvailable = aBytesFree - iMonitor.GoodRamThreshold();
+                    TInt minimumNeeded = message.Int1();
+                    if (memoryAvailable >= minimumNeeded)
+                        {
+                        message.Complete(memoryAvailable);
+                        }
+                    else
+                        {
+                        message.Complete(KErrNoMemory);
+                        }
+                    }
+                break;
+            case EClientServerRequestFreeMemory:
+                message = request->iRequestFreeRamMessage;
+                if (!message.IsNull())
+                    {
+                    // If memory available is greater than the requested RAM then complete with the amount of free memory, otherwise complete with KErrNoMemory
+                    message.Complete(aMemoryGood ? KErrNone : KErrNoMemory);        
+                    }
+                break;
+            case EPublishAndSubscribe:
+                // No action required for P&S key
+                break; 
+            default:
+                OomMonitorPanic(KInvalidClientRequestType);
+                break;
+            }
+            
+        iClientRequestActive = EFalse;
+        iQueue.Remove(*request);
+        delete request;
+
+        iLastClientCompletedTime.UniversalTime();
+        
+        if (!iQueue.IsEmpty())
+            {
+            //We give the client KClientTimeToFreeMemory microseconds to free the memory it requested before 
+            //processing the next request
+            iClientRequestTimer->After(TTimeIntervalMicroSeconds32(KClientTimeToFreeMemory));
+            }
+        }    
+    }
+
+void COomClientRequestQueue::RequestTimerCallbackL()
+    {
+    FUNC_LOG;
+    
+    __ASSERT_DEBUG(!iQueue.IsEmpty(), OomMonitorPanic(KClientQueueNotEmpty));        
+    
+    StartClientRequestL();
+    }
+
+COomClientRequestTimer* COomClientRequestTimer::NewL(COomClientRequestQueue& aQueue)
+    {
+    FUNC_LOG;
+
+    COomClientRequestTimer* self = new (ELeave) COomClientRequestTimer(aQueue);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+COomClientRequestTimer::COomClientRequestTimer(COomClientRequestQueue& aQueue)
+: CTimer(CActive::EPriorityStandard), iClientRequestQueue(aQueue)
+    {
+    FUNC_LOG;
+    
+    CActiveScheduler::Add(this);
+    }
+
+
+void COomClientRequestTimer::RunL()
+    {
+    FUNC_LOG;
+    
+    iClientRequestQueue.RequestTimerCallbackL();
+    }
+
+
+
+
+    
+    
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/src/oomcloseapp.cpp	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,123 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Classes for executing OOM actions (e.g. closing applications and running plugins).
+*
+*/
+
+
+#include <apgtask.h>
+
+#include "oomcloseapp.h"
+#include "OomTraces.h"
+#include "oomappclosetimer.h"
+#include "oomappclosewatcher.h"
+#include "oomactionref.h"
+#include "oommemorymonitor.h"
+#include "oomconstants.hrh"
+#include "oompanic.h"
+
+COomCloseApp* COomCloseApp::NewL(MOomActionObserver& aStateChangeObserver, RWsSession& aWs)
+    {
+    FUNC_LOG;
+
+    COomCloseApp* self = new (ELeave) COomCloseApp(aStateChangeObserver, aWs);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+// Close the application in order to free memory
+// Call the COomAction::MemoryFreed when it is done
+void COomCloseApp::FreeMemory(TInt, TBool aIsDataPaged)
+    {
+    FUNC_LOG;
+
+    iAppCloserRunning = ETrue;
+    
+    // Set the TApaTask to the app
+    iCurrentTask.SetWgId(iWgId);
+    
+    __ASSERT_DEBUG(!iAppCloseTimer->IsActive(), OomMonitorPanic(KStartingActiveCloseAppTimer));    
+    __ASSERT_DEBUG(!iAppCloseWatcher->IsActive(), OomMonitorPanic(KStartingActiveAppCloseWatcher));    
+    // Start a timer and the thread watcher 
+    iAppCloseTimer->After(CMemoryMonitor::GlobalConfig().iMaxAppExitTime * KMicrosecondsInMillisecond);
+    iAppCloseWatcher->Start(iCurrentTask);
+    // Tell the app to close
+    TRACES1("COomCloseApp::FreeMemory: Closing app with window group id %d",iWgId);
+    
+    RThread thread;
+    TInt err=thread.Open(iCurrentTask.ThreadId());
+    if (!err)
+        {
+        RProcess process;
+        thread.Process(process);
+        TBool isDataPaged = process.DefaultDataPaged();
+        if((aIsDataPaged && isDataPaged) || (!aIsDataPaged && !isDataPaged ))
+            {
+            iCurrentTask.EndTask();
+            }
+        }
+    }
+
+COomCloseApp::~COomCloseApp()
+    {
+    FUNC_LOG;
+
+    if (iAppCloseTimer)
+        iAppCloseTimer->Cancel();
+    
+    if (iAppCloseWatcher)
+        iAppCloseWatcher->Cancel();
+    
+    delete iAppCloseTimer;    
+    delete iAppCloseWatcher;
+    }
+
+// Callback from COomAppCloseWatcher and COomAppCloseTimer
+void COomCloseApp::CloseAppEvent()
+    {
+    FUNC_LOG;
+
+    // The application has closed (or we have a timeout)
+    iAppCloserRunning = EFalse;
+    
+    if (iAppCloseTimer)
+        iAppCloseTimer->Cancel();
+    if (iAppCloseWatcher)
+        iAppCloseWatcher->Cancel(); 
+    
+    MemoryFreed(KErrNone);
+    }
+
+void COomCloseApp::Reconfigure(const TActionRef& aRef)
+    {
+    FUNC_LOG;
+
+    iWgId = aRef.WgId();    
+    }
+
+void COomCloseApp::ConstructL()
+    {
+    FUNC_LOG;
+
+    iAppCloseTimer = COomAppCloseTimer::NewL(*this);
+    iAppCloseWatcher = new(ELeave) COomAppCloseWatcher(*this);
+    }
+        
+COomCloseApp::COomCloseApp(MOomActionObserver& aStateChangeObserver, RWsSession& aWs)
+                                : COomAction(aStateChangeObserver), iCurrentTask(aWs)
+    {
+    FUNC_LOG;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/src/oomcloseappconfig.cpp	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,42 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Configuration representation classes for Out of Memory Monitor.
+*
+*/
+
+
+
+#include "oomcloseappconfig.h"
+#include "OomTraces.h"
+
+COomCloseAppConfig* COomCloseAppConfig::NewL(TInt32 aId)
+    {
+    FUNC_LOG;
+
+    COomCloseAppConfig* self = new (ELeave) COomCloseAppConfig(aId);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+COomCloseAppConfig::~COomCloseAppConfig()
+    {
+    FUNC_LOG;
+    }
+
+COomCloseAppConfig::COomCloseAppConfig(TInt32 aId) : COomActionConfig(aId)
+    {
+    FUNC_LOG;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/src/oomconfig.cpp	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,195 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Configuration representation classes for Out of Memory Monitor.
+*
+*/
+
+
+
+#include <e32hashtab.h>
+
+#include "oomconfig.h"
+#include "oomconstants.hrh"
+#include "oomapplicationconfig.h"
+#include "oomrunpluginconfig.h"
+#include "oomcloseappconfig.h"
+#include "OomTraces.h"
+
+COomConfig* COomConfig::NewL()
+    {
+    FUNC_LOG;
+
+    COomConfig* self = new (ELeave) COomConfig;
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+
+// Add the configuration for an application closure.
+// This class takes ownership of this action.
+void COomConfig::SetAppCloseConfigL(COomCloseAppConfig* aActionConfig)
+    {
+    FUNC_LOG;
+
+    // Find the right application config (if there is one) for the app
+    // The map actually contains pointers for values, so we get pointers to pointers here...
+    COomApplicationConfig** applicationConfigPointer = iApplicationToConfigMapping.Find(aActionConfig->iId);
+    
+    // Used to de-reference the pointer-to-pointer, hopefully making the code more readable
+    COomApplicationConfig* applicationConfig = NULL;
+    
+    // Create a new COomApplicationConfig if there isn't one for this app
+    if (!applicationConfigPointer)
+        {
+        applicationConfig = COomApplicationConfig::NewL(aActionConfig->iId);
+        iApplicationToConfigMapping.InsertL(aActionConfig->iId, applicationConfig);
+        }
+    else
+        {
+        applicationConfig = *applicationConfigPointer;
+        }
+    
+    // Append the action config to the appropriate list (the list for the relevant application)
+    applicationConfig->SetAppCloseConfig(aActionConfig);    
+    }
+
+// Add the configuration for a plugin action.
+// This class takes ownership of the configuration object.
+void COomConfig::AddPluginConfigL(COomRunPluginConfig* aPluginConfig)
+    {
+    FUNC_LOG;
+
+    // Check if the plugin has already been added, if so then this is an error in configuration (something is trying to add the same plugin twice)
+    COomRunPluginConfig** runPluginConfig = iPluginToConfigMapping.Find(aPluginConfig->Id());
+    if (runPluginConfig)
+        {
+        OomMonitorPanic(KPluginConfigAddedTwice);
+        }
+    
+    iPluginToConfigMapping.InsertL(aPluginConfig->Id(), aPluginConfig);
+    
+    }
+
+// Add a rule
+// This class takes ownership of the given rule
+// This rule applies to the specified application (and not a plugin associated with this application)
+// The rule would usually apply to an "application close" event
+void COomConfig::AddApplicationRuleL(TUint aTargetAppId, MOomRuleConfig* aRule)
+    {
+    FUNC_LOG;
+
+    COomApplicationConfig** applicationConfig = iApplicationToConfigMapping.Find(aTargetAppId);
+    
+    if (applicationConfig)
+        {
+        (*applicationConfig)->AddRuleL(aRule);
+        }
+    else
+        {
+        OomMonitorPanic(KRuleConfiguredBeforeApplication);
+        }
+    }
+
+// Add a rule for a plugin
+// This class takes ownership of the given rule
+// This rule is applied to the plugin with the specified ID
+void COomConfig::AddPluginRuleL(TUint aPluginId, MOomRuleConfig* aRule)
+    {
+    FUNC_LOG;
+
+    COomRunPluginConfig** runPluginConfig = iPluginToConfigMapping.Find(aPluginId);
+    
+    if (runPluginConfig)
+        {
+        (*runPluginConfig)->AddRuleL(aRule);
+        }
+    else
+        {
+        OomMonitorPanic(KRuleConfiguredBeforePlugin);
+        }   
+    }
+
+// Add this application config - this class takes ownership of it
+// Application config includes settings for a particular application, e.g. whether or not it can be closed
+void COomConfig::AddApplicationConfigL(COomApplicationConfig* aApplicationConfig)
+    {
+    FUNC_LOG;
+
+    // Check if the application has already been added, if so then this is an error in configuration (something is trying to add the same app twice)
+    COomApplicationConfig** applicationConfig = iApplicationToConfigMapping.Find(aApplicationConfig->Id());
+    if (applicationConfig)
+        {
+        OomMonitorPanic(KAppConfigAddedTwice);
+        }
+    
+    iApplicationToConfigMapping.InsertL(aApplicationConfig->Id(), aApplicationConfig);
+    }
+
+// Get the list of configured actions for the given app id
+// If no specific actions have been configured for this application then the default action is returned
+COomApplicationConfig& COomConfig::GetApplicationConfig(TInt32 aAppId)
+    {
+    FUNC_LOG;
+
+    COomApplicationConfig** applicationConfig = iApplicationToConfigMapping.Find(aAppId);
+    
+    if (!applicationConfig)
+        applicationConfig = iApplicationToConfigMapping.Find(KOomDefaultAppId);
+    
+    // The default app configuration should always exist
+    __ASSERT_ALWAYS(applicationConfig, OomMonitorPanic(KOomDefaultAppNotConfigured));
+    
+    return *(*applicationConfig);
+    }
+
+// Get the plugin configuration for the given plugin id
+// If no specific actions have been configured for this plugin then the default plugin configuration is returned
+COomRunPluginConfig& COomConfig::GetPluginConfig(TInt32 aPluginId)
+    {
+    FUNC_LOG;
+
+    COomRunPluginConfig** runPluginConfig = iPluginToConfigMapping.Find(aPluginId);
+    
+    if (!runPluginConfig)
+        runPluginConfig = iPluginToConfigMapping.Find(KOomDefaultPluginId);
+    
+    // The default app configuration should always exist
+    __ASSERT_ALWAYS(runPluginConfig, OomMonitorPanic(KOomDefaultPluginNotConfigured));
+    
+    return *(*runPluginConfig);
+    }
+
+COomConfig::~COomConfig()
+    {
+    FUNC_LOG;
+
+    // Iterate through the hash map deleting all of the items
+    RHashMap<TInt32, COomApplicationConfig*>::TIter iterator(iApplicationToConfigMapping);
+    while (iterator.NextValue())
+        delete iterator.CurrentValue();
+    
+    // Iterate through the plugiun hash map deleting all of the items
+    RHashMap<TInt32, COomRunPluginConfig*>::TIter pluginIterator(iPluginToConfigMapping);
+    while (pluginIterator.NextValue())
+        delete pluginIterator.CurrentValue();
+    
+    iApplicationToConfigMapping.Close();
+    }
+
+void COomConfig::ConstructL()
+    {
+    FUNC_LOG;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/src/oomconfigparser.cpp	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,1149 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  The parser for the OOM configuration file.
+*
+*/
+#include <e32base.h>
+#include <xml/parser.h>
+
+#include "oomconfigparser.h"
+#include "oompanic.h"
+#include "OomTraces.h"
+#include "oomidletimerule.h"
+#include "oomforegroundrule.h"
+#include "oomconstants.hrh"
+#include "oomapplicationconfig.h"
+#include "oomcloseappconfig.h"
+#include "oomconfig.h"
+#include "oomrunpluginconfig.h"
+
+enum TOomConfigParserPanic
+{
+KOomErrMoreThanOneOomConfig = 0,
+KOomErrGlobalSettingsMustComeAfterRoot,
+KOomErrAppSettingsMustComeAfterGlobalSettings,
+KOomErrCloseAppSettingsMustComeAfterAppSettings,
+KOomErrAppIdleSettingsMustComeAfterAppCloseSettings,
+KOomErrLowRamErrorInGlobalSettings,
+KOomErrGoodRamErrorInGlobalSettings,
+KOomErrSwapUsageMonitoredErrorInGlobalSettings,
+KOomErrLowSwapErrorInGlobalSettings,
+KOomErrGoodSwapErrorInGlobalSettings,
+KOomErrMaxCloseErrorInGlobalSettings,
+KOomErrDefaultPriorityErrorInGlobalSettings,
+KOomErrMissingUidFromAppCloseConfig,
+KOomErrMissingPriorityFromAppCloseConfig,
+KOomErrMissingSyncModeFromAppCloseConfig,
+KOomErrMissingEstimateFromAppCloseConfig,
+KOomErrInvalidSyncMode,
+KOomErrMissingSyncModeInAppCloseConfig,
+KOomErrBadOrMissingPriorityInAppIdleRule,
+KOomErrBadOrMissingIdleTimeInAppIdleRule,
+KOomErrBadOrMissingUidInAppIdleRule,
+KOomErrBadNeverCloseValue,
+KOomErrBadOrMissingUidInAppConfig,
+KOomErrBadOrMissingPriorityInAppCloseConfig,
+KOomErrBadLowThresholdValueForAppConfig,
+KOomErrBadGoodThresholdValueForAppConfig,
+KOomErrSystemPluginSettingsMustComeAfterAppCloseSettings,
+KOomErrAppPluginSettingsMustComeAfterSystemPluginSettings,
+KOomErrAppPluginIdleTimeRulesMustComeAfterAppPluginSettings,
+KOomErrBadOrMissingUidInAppCloseConfig,
+KOomErrBadOrMissingUidInSystemPluginConfig,
+KOomErrBadOrMissingPriorityInSystemPluginConfig,
+KOomErrBadOrMissingTargetAppIdInAppPluginConfig,
+KOomErrBadOrMissingUidInAppPluginConfig,
+KOomErrBadOrMissingPriorityInAppPluginConfig,
+KOomErrBadOrMissingPriorityInPluginIdleRule,
+KOomErrBadOrMissingIdleTimeInPluginIdleRule,
+KOomErrBadOrMissingUidInPluginIdleRule,
+KOomErrBadOrMissingUidInForegroundAppRule,
+KOomErrBadOrMissingPriorityInForegroundAppRule,
+KOomErrBadOrMissingTargetAppIdInForegroundAppRule,
+KOomErrDefaultWaitAfterPluginInGlobalSettings,
+KOomErrBadOrMissingPriorityInForceCheck,
+KOomErrOomRulesMustComeLast,
+KOomErrBadPluginWaitTime,
+KOomErrBadXml,
+KOomErrAppCloseIdleRuleOutsideAppCloseElement,
+KOomErrForegroundAppRuleOutsideAppCloseElement,
+KOomErrPluginIdleRuleOutsideAppPluginElement,
+KOomErrPluginForegroundRuleOutsidePluginElement,
+KOomErrBadCallIfTargetAppNotRunning
+};
+
+const TInt KOomXmlFileBufferSize = 1024;
+const TInt KOomMaxAppExitTime = 2000;
+const TInt KBytesInMegabyte = 1024;
+#ifdef __WINS__
+const TInt KEmulatorTickDivisor = 5; // The tick is 5 times slower on the emulator than on the phone
+#endif
+using namespace Xml;
+
+// Mime type of the parsed document
+_LIT8(KXmlMimeType, "text/xml");
+
+_LIT(KOomConfigFilePath, ":\\private\\10207218\\oomconfig.xml");
+_LIT(KRomDrive, "z");
+
+// Element strings
+// Root
+_LIT8(KOomConfigOomConfig, "oom_config");
+
+// Global settings
+_LIT8(KOomConfigGlobalSettings, "global_settings");
+_LIT8(KOomConfigForceCheckAtPriority, "force_check");
+
+// App settings
+_LIT8(KOomConfigAppSettings, "app_specific_thresholds");
+_LIT8(KOomConfigApp, "app");
+
+// App close settings
+_LIT8(KOomConfigAppCloseSettings, "app_close_settings");
+_LIT8(KOomConfigCloseApp, "close_app");
+
+// App close idle time
+_LIT8(KOomConfigAppCloseIdlePriority, "app_close_idle_priority");
+
+_LIT8(KOomConfigForegroundAppPriority, "foreground_app_priority");
+
+// Global settings attribute names
+_LIT8(KOomAttributeLowRamThreshold, "low_ram_threshold");
+_LIT8(KOomAttributeGoodRamThreshold, "good_ram_threshold");
+_LIT8(KOomAttributeSwapUsageMonitored, "swap_usage_monitored");
+_LIT8(KOomAttributeLowSwapThreshold, "low_swap_threshold");
+_LIT8(KOomAttributeGoodSwapThreshold, "good_swap_threshold");
+_LIT8(KOomAttributeMaxAppCloseBatch, "max_app_close_batch");
+_LIT8(KOomAttributeDefaultWaitAfterPlugin, "default_wait_after_plugin");
+_LIT8(KOomAttributeMaxAppExitTime , "max_app_exit_time");
+
+// System plugins 
+
+_LIT8(KOomAttributeSystemPluginSettings, "system_plugin_settings");
+_LIT8(KOomAttributeSystemPlugin, "system_plugin");
+
+// Application plugins
+
+_LIT8(KOomAttributeAppPluginSettings, "app_plugin_settings");
+_LIT8(KOomAttributeAppPlugin, "app_plugin");
+
+// Plugin idle time rules
+
+_LIT8(KOomAttributePluginIdlePriority, "plugin_idle_priority");
+
+// Plugin foreground app rules
+_LIT8(KOomAttributePluginForegroundAppPriority, "plugin_foreground_app_priority");
+
+// Atribute names
+_LIT8(KOomAttibuteUid, "uid");
+_LIT8(KOomAttibuteSyncMode, "sync_mode");
+_LIT8(KOomAttibutePriority, "priority");
+_LIT8(KOomAttibuteRamEstimate, "ram_estimate");
+
+_LIT8(KOomConfigSyncModeContinue, "continue");
+_LIT8(KOomConfigSyncModeCheck, "check");
+_LIT8(KOomConfigSyncModeEstimate, "estimate");
+
+_LIT8(KOomAttibuteIdleTime, "idle_time");
+_LIT8(KOomAttibuteIdlePriority, "priority");
+
+_LIT8(KOomAttibuteNeverClose, "NEVER_CLOSE");
+
+_LIT8(KOomAttributeTargetAppId, "target_app_id");
+
+_LIT8(KOomAttributeWait, "wait");
+
+_LIT8(KOomAttributeIfForegroundAppId, "if_foreground_app_id");
+
+_LIT8(KOomAttributeCallIfTargetAppNotRunning, "call_if_target_app_not_running");
+_LIT8(KOomAttributeTrue, "true");
+_LIT8(KOomAttributeFalse, "false");
+_LIT8(KOomAttribute0, "0");
+_LIT8(KOomAttribute1, "1");
+
+
+_LIT8(KOomConfigDefaultAppUid, "DEFAULT_APP");
+_LIT8(KOomConfigDefaultPluginUid, "DEFAULT_PLUGIN");
+_LIT8(KOomConfigTargetAppValue, "TARGET_APP");
+
+_LIT8(KOomConfigBusyAppUid, "BUSY_APP");
+_LIT8(KOomConfigHighPriorityAppUid, "HIGH_PRIORITY_APP");
+
+COomConfigParser::COomConfigParser(COomConfig& aConfig, RFs& aFs) : iConfig(aConfig), iFs(aFs), iState(EOomParsingStateNone)
+    {
+    }
+
+void COomConfigParser::ParseL()
+    {
+    FUNC_LOG;
+
+    TRACES("COomConfigParser::ParseL: Parsing Config File");
+    
+    CParser* parser = CParser::NewLC(KXmlMimeType, *this);
+    
+    RFile configFile;
+    TFileName configFileName;
+    TChar driveChar = iFs.GetSystemDriveChar();
+    configFileName.Append(driveChar);
+    configFileName.Append(KOomConfigFilePath);
+    if (configFile.Open(iFs, configFileName, EFileShareExclusive) != KErrNone)
+        {
+        configFileName.Replace(0,1,KRomDrive); //replace 'c' with 'z'
+        User::LeaveIfError(configFile.Open(iFs, configFileName, EFileShareExclusive));
+        }
+    CleanupClosePushL(configFile);
+    
+    TBuf8<KOomXmlFileBufferSize> fileBuffer;
+    TInt bytesRead;
+    do
+        {
+        User::LeaveIfError(configFile.Read(fileBuffer));
+        bytesRead = fileBuffer.Size();
+        
+        parser->ParseL(fileBuffer);
+        
+        } while (bytesRead != 0);
+    
+    CleanupStack::PopAndDestroy(2, parser); // config file - automatically closes it
+                                            // parser
+            
+    TRACES("COomConfigParser::ParseL: Finished Parsing Config File");    
+    }
+
+void COomConfigParser::OnStartDocumentL(const RDocumentParameters&, TInt)
+    {
+    FUNC_LOG;
+    }
+
+void COomConfigParser::OnEndDocumentL(TInt)
+    {
+    FUNC_LOG;
+    }
+
+
+void COomConfigParser::OnEndElementL(const RTagInfo&, TInt)
+    {
+    }
+
+void COomConfigParser::OnContentL(const TDesC8&, TInt)
+    {
+    }
+
+void COomConfigParser::OnStartPrefixMappingL(const RString&, const RString&, 
+                                   TInt)
+    {
+    }
+
+void COomConfigParser::OnEndPrefixMappingL(const RString&, TInt)
+    {
+    }
+
+void COomConfigParser::OnIgnorableWhiteSpaceL(const TDesC8&, TInt)
+    {
+    }
+
+void COomConfigParser::OnSkippedEntityL(const RString&, TInt)
+    {
+    }
+
+void COomConfigParser::OnProcessingInstructionL(const TDesC8&, const TDesC8&, 
+                                      TInt)
+    {
+    }
+
+void COomConfigParser::OnError(TInt)
+    {
+    }
+
+TAny* COomConfigParser::GetExtendedInterface(const TInt32)
+    {
+    return 0;
+    }
+
+void COomConfigParser::OnStartElementL(const RTagInfo& aElement, const RAttributeArray& aAttributes, 
+                             TInt aErrorCode)
+    {
+    if (aErrorCode != KErrNone)
+        ConfigError(KOomErrBadXml);
+    
+    StartElementL(aElement.LocalName().DesC(), aAttributes);
+    }
+
+void COomConfigParser::StartElementL(const TDesC8& aLocalName,
+                                        const RAttributeArray& aAttributes)
+    {
+    // Root
+    if (aLocalName == KOomConfigOomConfig)
+        {
+        if (iState != EOomParsingStateNone)
+            ConfigError(KOomErrMoreThanOneOomConfig);
+        
+        ChangeState(EOomParsingStateRoot);
+        }
+    // Parse main elements
+    else if (aLocalName == KOomConfigGlobalSettings)
+        {
+        if (iState != EOomParsingStateRoot)
+            ConfigError(KOomErrGlobalSettingsMustComeAfterRoot);
+        
+        SetGlobalSettings(aAttributes);
+        
+        ChangeState(EOomParsingStateGlobalSettings);
+        }
+    else if (aLocalName == KOomConfigAppSettings)
+        {
+        ChangeState(EOomParsingStateAppSettings);
+        }
+    else if (aLocalName == KOomConfigAppCloseSettings)
+        {
+        ChangeState(EOomParsingStateAppCloseSettings);
+        }
+    else if (aLocalName == KOomAttributeSystemPluginSettings)
+        {
+        ChangeState(EOomParsingStateSystemPluginSettings);
+        }
+    else if (aLocalName == KOomAttributeAppPluginSettings)
+        {
+        ChangeState(EOomParsingStateAppPluginSettings);
+        }
+    // Parse actual configuration elements
+    else if (aLocalName == KOomConfigForceCheckAtPriority)
+        {
+        SetForceCheckConfigL(aAttributes);
+        }
+    else if (aLocalName == KOomConfigApp)
+        {
+        SetAppConfigL(aAttributes);
+        }
+    else if (aLocalName == KOomConfigCloseApp)
+        {
+        SetCloseAppConfigL(aAttributes);
+        }
+    else if (aLocalName == KOomConfigAppCloseIdlePriority)
+        {
+        CheckState(EOomParsingStateAppCloseSettings, KOomErrAppCloseIdleRuleOutsideAppCloseElement);
+        SetAppCloseIdlePriorityConfigL(aAttributes);
+        }
+    else if (aLocalName == KOomConfigForegroundAppPriority)
+        {
+        CheckState(EOomParsingStateAppCloseSettings, KOomErrForegroundAppRuleOutsideAppCloseElement);
+        SetForegroundAppPriorityL(aAttributes);
+        }
+    else if (aLocalName == KOomAttributeSystemPlugin)
+        {
+        SetSystemPluginConfigL(aAttributes);
+        }
+    else if (aLocalName == KOomAttributeAppPlugin)
+        {
+        SetAppPluginConfigL(aAttributes);
+        }
+    else if (aLocalName == KOomAttributePluginIdlePriority)
+        {
+        CheckState(EOomParsingStateAppPluginSettings, KOomErrPluginIdleRuleOutsideAppPluginElement);
+        SetPluginIdlePriorityL(aAttributes);
+        }
+    else if (aLocalName == KOomAttributePluginForegroundAppPriority)
+        {
+        CheckState(EOomParsingStateAppPluginSettings, EOomParsingStateSystemPluginSettings, KOomErrPluginForegroundRuleOutsidePluginElement);
+        SetPluginForegroundAppPriorityL(aAttributes);
+        }
+    
+    }
+
+void COomConfigParser::ConfigError(TInt aError)
+    {
+    OomConfigParserPanic(aError);
+    }
+
+void COomConfigParser::SetGlobalSettings(const RAttributeArray& aAttributes)
+    {
+    TInt defaultLowMemoryThreshold;    
+    TInt err = GetValueFromDecimalAttributeList(aAttributes, KOomAttributeLowRamThreshold, defaultLowMemoryThreshold);
+
+    if (err == KErrNone)
+        iConfig.SetDefaultLowRamThreshold(defaultLowMemoryThreshold * KBytesInMegabyte);
+    else
+        ConfigError(KOomErrLowRamErrorInGlobalSettings);
+    
+    if (err == KErrNone)
+        {
+        TInt defaultGoodMemoryThreshold;    
+        TInt err = GetValueFromDecimalAttributeList(aAttributes, KOomAttributeGoodRamThreshold, defaultGoodMemoryThreshold);
+
+        if (err == KErrNone)
+            iConfig.SetDefaultGoodRamThreshold(defaultGoodMemoryThreshold * KBytesInMegabyte);
+        else
+            ConfigError(KOomErrGoodRamErrorInGlobalSettings);
+        }
+
+    if (err == KErrNone)
+        {
+        TInt swapUsageMonitored;
+        TInt err = GetValueFromBooleanAttributeList(aAttributes, KOomAttributeSwapUsageMonitored, swapUsageMonitored);
+        
+        if (err == KErrNone)
+            iConfig.SetSwapUsageMonitored(swapUsageMonitored);
+        else
+            ConfigError(KOomErrSwapUsageMonitoredErrorInGlobalSettings);
+        }
+    
+    if (err == KErrNone)
+        {
+        TInt defaultLowSwapThreshold;    
+        TInt err = GetValueFromDecimalAttributeList(aAttributes, KOomAttributeLowSwapThreshold, defaultLowSwapThreshold);
+
+        if (err == KErrNone)
+            iConfig.SetDefaultLowSwapThreshold(defaultLowSwapThreshold * KBytesInMegabyte);
+        else
+            ConfigError(KOomErrLowSwapErrorInGlobalSettings);
+        }
+
+    if (err == KErrNone)
+        {
+        TInt defaultGoodSwapThreshold;    
+        TInt err = GetValueFromDecimalAttributeList(aAttributes, KOomAttributeGoodSwapThreshold, defaultGoodSwapThreshold);
+
+        if (err == KErrNone)
+            iConfig.SetDefaultGoodSwapThreshold(defaultGoodSwapThreshold * KBytesInMegabyte);
+        else
+            ConfigError(KOomErrGoodSwapErrorInGlobalSettings);
+        }
+    
+    if (err == KErrNone)
+        {
+        TInt defaultMaxCloseAppBatch;    
+        TInt err = GetValueFromDecimalAttributeList(aAttributes, KOomAttributeMaxAppCloseBatch, defaultMaxCloseAppBatch);
+
+        if (err == KErrNone)
+            iConfig.SetMaxCloseAppBatch(defaultMaxCloseAppBatch);
+        else
+            ConfigError(KOomErrMaxCloseErrorInGlobalSettings);
+        }
+    
+    if (err == KErrNone)
+        {
+        TInt defaultWaitAfterPlugin;    
+        TInt err = GetValueFromDecimalAttributeList(aAttributes, KOomAttributeDefaultWaitAfterPlugin, defaultWaitAfterPlugin);
+
+        if (err == KErrNone)
+            iConfig.SetDefaultWaitAfterPlugin(defaultWaitAfterPlugin);
+        else
+            ConfigError(KOomErrDefaultWaitAfterPluginInGlobalSettings);
+        }
+    
+    if (err == KErrNone)
+        {
+        TInt maxAppExitTime;    
+        TInt err = GetValueFromDecimalAttributeList(aAttributes, KOomAttributeMaxAppExitTime, maxAppExitTime);
+
+        if (err == KErrNone)
+            iConfig.SetMaxAppExitTime(maxAppExitTime);
+        else
+            iConfig.SetMaxAppExitTime(KOomMaxAppExitTime);
+        }
+    }
+
+void COomConfigParser::SetForceCheckConfigL(const RAttributeArray& aAttributes)
+    {
+    TUint priority;
+    TInt err = GetValueFromDecimalAttributeList(aAttributes, KOomAttibutePriority, priority);
+    if (err == KErrNone)
+        {
+        iConfig.GlobalConfig().AddForceCheckPriorityL(priority);
+        }
+    else
+        {
+        ConfigError(KOomErrBadOrMissingPriorityInForceCheck);    
+        }
+    }
+
+void COomConfigParser::SetAppConfigL(const RAttributeArray& aAttributes)
+    {
+    TUint uid;
+    COomApplicationConfig* appConfig = NULL;
+    
+    TInt err = GetValueFromHexAttributeList(aAttributes, KOomAttibuteUid, uid);
+    
+    if (err != KErrNone)
+        {
+        ConfigError(KOomErrBadOrMissingUidInAppConfig);
+        }
+    else
+        iParentUid = uid;
+
+    appConfig = COomApplicationConfig::NewL(uid);
+    CleanupStack::PushL(appConfig);    
+        
+    // Set the app specific memory thresholds (if they exist)
+    // Get the app specific low threshold
+    if (err == KErrNone)
+        {
+        TUint lowThreshold;
+        err = GetValueFromDecimalAttributeList(aAttributes, KOomAttributeLowRamThreshold, lowThreshold);
+        if (err == KErrNone)
+            {
+            appConfig->iLowRamThreshold = lowThreshold * KBytesInMegabyte;
+            }
+        else if (err == KErrNotFound)
+            err = KErrNone;
+        
+        if (err != KErrNone)
+            ConfigError(KOomErrBadLowThresholdValueForAppConfig);
+        }
+
+    // Get the app specific good threshold
+    if (err == KErrNone)
+        {
+        TUint goodThreshold;
+        err = GetValueFromDecimalAttributeList(aAttributes, KOomAttributeGoodRamThreshold, goodThreshold);
+        if (err == KErrNone)
+            {
+            appConfig->iGoodRamThreshold = goodThreshold * KBytesInMegabyte;
+            }
+        else if (err == KErrNotFound)
+            err = KErrNone;
+        
+        if (err != KErrNone)
+            ConfigError(KOomErrBadGoodThresholdValueForAppConfig);
+        }
+    
+    // Set the app specific swap thresholds (if they exist)
+    // Get the app specific low swap threshold
+    if (err == KErrNone)
+        {
+        TUint lowThreshold;
+        err = GetValueFromDecimalAttributeList(aAttributes, KOomAttributeLowSwapThreshold, lowThreshold);
+        if (err == KErrNone)
+            {
+            appConfig->iLowSwapThreshold = lowThreshold * KBytesInMegabyte;
+            }
+        else if (err == KErrNotFound)
+            err = KErrNone;
+            
+        if (err != KErrNone)
+            ConfigError(KOomErrBadLowThresholdValueForAppConfig);
+        }
+
+    // Get the app specific good swapthreshold
+    if (err == KErrNone)
+        {
+        TUint goodThreshold;
+        err = GetValueFromDecimalAttributeList(aAttributes, KOomAttributeGoodSwapThreshold, goodThreshold);
+        if (err == KErrNone)
+            {
+            appConfig->iGoodSwapThreshold = goodThreshold * KBytesInMegabyte;
+            }
+        else if (err == KErrNotFound)
+            err = KErrNone;
+            
+        if (err != KErrNone)
+            ConfigError(KOomErrBadGoodThresholdValueForAppConfig);
+        }  
+        
+    // Add the applciation config to the main config
+    if ((err == KErrNone) && (appConfig))
+        {
+        iConfig.AddApplicationConfigL(appConfig);
+        }
+    
+    if (appConfig)
+        CleanupStack::Pop(appConfig);
+    }
+
+void COomConfigParser::SetCloseAppConfigL(const RAttributeArray& aAttributes)
+    {
+    // Get and convert uid attribute to TInt
+    TInt err = KErrNone;
+    
+    TUint uid;
+    err = GetValueFromHexAttributeList(aAttributes, KOomAttibuteUid, uid);
+
+    if (err != KErrNone)
+        {
+        ConfigError(KOomErrBadOrMissingUidInAppCloseConfig);    
+        return;
+        }
+    else
+        iParentUid = uid;
+    
+    COomCloseAppConfig* closeAppConfig = COomCloseAppConfig::NewL(uid); // Radio UID
+    CleanupStack::PushL(closeAppConfig);
+
+     if (err == KErrNone)
+        {
+        // Check that we have a priority for the added app_close event
+        // Specifying a priority is mandatory
+        TUint priority;
+        err = GetValueFromDecimalAttributeList(aAttributes, KOomAttibutePriority, priority);
+        if (err == KErrNone)
+            {
+            closeAppConfig->SetDefaultPriority(priority);
+            }
+        else
+            {
+            ConfigError(KOomErrBadOrMissingPriorityInAppCloseConfig);    
+            }
+        }
+    
+    if (err == KErrNone)
+        {
+        TPtrC8 syncModeString;
+        err = GetValueFromAttributeList(aAttributes, KOomAttibuteSyncMode, syncModeString);
+        
+        if (err == KErrNone)
+            {
+            TOomSyncMode syncMode = EContinue;
+            
+            if (syncModeString == KOomConfigSyncModeContinue)
+                syncMode = EContinue;
+            else if (syncModeString == KOomConfigSyncModeCheck)
+                syncMode = ECheckRam;
+            else if (syncModeString == KOomConfigSyncModeEstimate)
+                syncMode = EEstimate;
+            else
+                ConfigError(KOomErrInvalidSyncMode);
+            
+            if (err == KErrNone)
+                {
+                closeAppConfig->iSyncMode = syncMode;
+                }
+            }
+        else
+            {
+            ConfigError(KOomErrMissingSyncModeInAppCloseConfig);
+            }
+        }
+    
+    
+    if (err == KErrNone)
+        {
+        // If we have a default priority attribute then add it, otherwise use the global default priority
+        TInt ramEstimate;
+        err = GetValueFromDecimalAttributeList(aAttributes, KOomAttibuteRamEstimate, ramEstimate);
+        if ((err == KErrNotFound) && (closeAppConfig->iSyncMode != EEstimate))
+            {
+            err = KErrNone;
+            }
+        
+        if (err != KErrNone)
+            ConfigError(KOomErrMissingEstimateFromAppCloseConfig);
+        else
+            closeAppConfig->iRamEstimate = ramEstimate * KBytesInMegabyte;
+           }
+
+    if (err == KErrNone)
+        iConfig.SetAppCloseConfigL(closeAppConfig);
+    
+    CleanupStack::Pop(closeAppConfig);
+    }
+
+void COomConfigParser::SetAppCloseIdlePriorityConfigL(const RAttributeArray& aAttributes)
+    {
+    TUint uid;
+    TInt idleTime;
+    TUint priority;
+
+    // Use the UID from the parent scope
+    uid = iParentUid;
+
+    TInt err = KErrNone;
+    
+    err = GetValueFromDecimalAttributeList(aAttributes, KOomAttibuteIdleTime, idleTime);
+    
+#ifdef __WINS__
+    // The tick is 5 times slower on the emulator than on the phone
+    idleTime = idleTime / KEmulatorTickDivisor;
+#endif
+    
+    if (err != KErrNone)
+        {
+        ConfigError(KOomErrBadOrMissingIdleTimeInAppIdleRule);
+        }
+    
+    if (err == KErrNone)
+        {
+        err = GetValueFromDecimalAttributeList(aAttributes, KOomAttibuteIdlePriority, priority);
+        
+        if (err != KErrNone)
+            {
+            ConfigError(KOomErrBadOrMissingPriorityInAppIdleRule);
+            }
+        }
+    
+    if (err == KErrNone)
+        {
+        COomIdleTimeRule* idleRule = COomIdleTimeRule::NewL(idleTime, priority);
+        CleanupStack::PushL(idleRule);
+        iConfig.AddApplicationRuleL(uid, idleRule);
+        CleanupStack::Pop(idleRule);
+        }
+    }
+
+void COomConfigParser::SetForegroundAppPriorityL(const RAttributeArray& aAttributes)
+    {
+    TUint appUid;
+    TUint targetAppId;
+    TUint priority;
+
+    TInt err = KErrNone;
+    
+    // Use the UID from the parent scope
+    appUid = iParentUid;
+
+    // Check that we have a priority for the added system plugin action
+    // Specifying a priority is mandatory
+    err = GetValueFromHexAttributeList(aAttributes, KOomAttributeIfForegroundAppId, targetAppId);
+    if (err != KErrNone)
+        {
+        ConfigError(KOomErrBadOrMissingTargetAppIdInForegroundAppRule);    
+        }
+    
+    if (err == KErrNone)
+        {
+        err = GetValueFromDecimalAttributeList(aAttributes, KOomAttibuteIdlePriority, priority);
+        
+        if (err != KErrNone)
+            {
+            ConfigError(KOomErrBadOrMissingPriorityInForegroundAppRule);
+            }
+        }
+    
+    if (err == KErrNone)
+        {
+        COomForegroundRule* foregroundRule = new (ELeave) COomForegroundRule(targetAppId, priority);
+        CleanupStack::PushL(foregroundRule);
+        iConfig.AddApplicationRuleL(appUid, foregroundRule);
+        CleanupStack::Pop(foregroundRule);
+        }
+
+    }
+
+void COomConfigParser::SetSystemPluginConfigL(const RAttributeArray& aAttributes)
+    {
+    // Get and convert uid attribute to TInt
+    TInt err = KErrNone;
+    
+    TUint uid;
+    err = GetValueFromHexAttributeList(aAttributes, KOomAttibuteUid, uid);
+
+    if (err != KErrNone)
+        {
+        ConfigError(KOomErrBadOrMissingUidInSystemPluginConfig);    
+        return;
+        }
+    else
+        iParentUid = uid;
+    
+    COomRunPluginConfig* pluginConfig = COomRunPluginConfig::NewL(uid, EOomSystemPlugin);
+    CleanupStack::PushL(pluginConfig);
+
+     if (err == KErrNone)
+        {
+        // Check that we have a priority for the added system plugin action
+        // Specifying a priority is mandatory
+        TUint priority;
+        err = GetValueFromDecimalAttributeList(aAttributes, KOomAttibutePriority, priority);
+        if (err == KErrNone)
+            {
+            pluginConfig->SetDefaultPriority(priority);
+            }
+        else
+            {
+            ConfigError(KOomErrBadOrMissingPriorityInSystemPluginConfig);    
+            }
+        }
+     
+     if (err == KErrNone)
+        {
+        TInt wait;
+        err = GetValueFromDecimalAttributeList(aAttributes, KOomAttributeWait, wait);
+        if (err == KErrNone)
+            {
+            pluginConfig->SetWaitAfterPlugin(wait);
+            }
+        else if (err == KErrNotFound)
+            {
+            // If this attribute isn't present then just don't set it, and clear the error
+            err = KErrNone;
+            }
+        else
+            ConfigError(KOomErrBadPluginWaitTime);
+        }
+     
+     if (err == KErrNone)
+         {
+         // Get the config for the sync mode for this plugin (if one is specified) and set it
+         SetPluginSyncMode(aAttributes, *pluginConfig);
+         }
+
+     iConfig.AddPluginConfigL(pluginConfig);
+     
+     CleanupStack::Pop(pluginConfig);
+    }
+
+void COomConfigParser::SetAppPluginConfigL(const RAttributeArray& aAttributes)
+    {
+    // Get and convert uid attribute to TInt
+    TInt err = KErrNone;
+    
+    TUint uid;
+    err = GetValueFromHexAttributeList(aAttributes, KOomAttibuteUid, uid);
+
+    if (err != KErrNone)
+        {
+        ConfigError(KOomErrBadOrMissingUidInAppPluginConfig);    
+        return;
+        }
+    else
+        iParentUid = uid;
+    
+    COomRunPluginConfig* pluginConfig = COomRunPluginConfig::NewL(uid, EOomAppPlugin);
+    CleanupStack::PushL(pluginConfig);
+
+    if (err == KErrNone)
+       {
+       // Check that we have a priority for the added system plugin action
+       // Specifying a priority is mandatory
+        TUint priority;
+        err = GetValueFromDecimalAttributeList(aAttributes, KOomAttibutePriority, priority);
+        if (err == KErrNone)
+            {
+            pluginConfig->SetDefaultPriority(priority);
+            }
+        else
+            {
+            ConfigError(KOomErrBadOrMissingPriorityInAppPluginConfig);    
+            }
+       }
+
+    if (err == KErrNone)
+       {
+       // Check that we have a priority for the added system plugin action
+       // Specifying a priority is mandatory
+        TUint targetAppId;
+        err = GetValueFromHexAttributeList(aAttributes, KOomAttributeTargetAppId, targetAppId);
+        if (err == KErrNone)
+            {
+            pluginConfig->SetTargetApp(targetAppId);
+            iParentTargetApp = targetAppId;
+            }
+        else
+            {
+            ConfigError(KOomErrBadOrMissingTargetAppIdInAppPluginConfig);    
+            }
+       }
+    
+    if (err == KErrNone)
+       {
+       TInt wait;
+        err = GetValueFromDecimalAttributeList(aAttributes, KOomAttributeWait, wait);
+        if (err == KErrNone)
+            {
+            pluginConfig->SetWaitAfterPlugin(wait);
+            }
+        else if (err == KErrNotFound)
+            {
+            // If this attribute isn't present then just don't set it, and clear the error
+            err = KErrNone;
+            }
+        else
+            ConfigError(KOomErrBadPluginWaitTime);
+       }    
+    
+    if (err == KErrNone)
+        {
+        // Get the config for the sync mode for this plugin (if one is specified) and set it
+        SetPluginSyncMode(aAttributes, *pluginConfig);
+        
+        TBool targetAppNotRunning;
+        err = GetValueFromBooleanAttributeList(aAttributes, KOomAttributeCallIfTargetAppNotRunning, targetAppNotRunning);
+        if (err == KErrNone)
+            {
+            pluginConfig->SetCallIfTargetAppNotRunning(targetAppNotRunning);
+            }
+        else if (err == KErrNotFound)
+            {
+            // If this attribute isn't present then just don't set it, and clear the error
+            err = KErrNone;
+            }
+        else
+            {
+            ConfigError(KOomErrBadCallIfTargetAppNotRunning);
+            }
+        }
+
+     iConfig.AddPluginConfigL(pluginConfig);
+     
+     CleanupStack::Pop(pluginConfig);
+
+    }
+
+void COomConfigParser::SetPluginIdlePriorityL(const RAttributeArray& aAttributes)
+    {
+    TUint uid;
+    TInt idleTime;
+    TUint priority;
+
+    TInt err = KErrNone;
+    
+    // Use the UID from the parent scope
+    uid = iParentUid;
+
+    err = GetValueFromDecimalAttributeList(aAttributes, KOomAttibuteIdleTime, idleTime);
+    
+#ifdef __WINS__
+    // The tick is 5 times slower on the emulator than on the phone
+    idleTime = idleTime / KEmulatorTickDivisor;
+#endif
+    
+    if (err != KErrNone)
+        {
+        ConfigError(KOomErrBadOrMissingIdleTimeInPluginIdleRule);
+        }
+    
+    if (err == KErrNone)
+        {
+        err = GetValueFromDecimalAttributeList(aAttributes, KOomAttibuteIdlePriority, priority);
+        
+        if (err != KErrNone)
+            {
+            ConfigError(KOomErrBadOrMissingPriorityInPluginIdleRule);
+            }
+        }
+    
+    if (err == KErrNone)
+        {
+        COomIdleTimeRule* idleRule = COomIdleTimeRule::NewL(idleTime, priority);
+        CleanupStack::PushL(idleRule);
+        iConfig.AddPluginRuleL(uid, idleRule);
+        CleanupStack::Pop(idleRule);
+        }
+    }
+
+void COomConfigParser::SetPluginForegroundAppPriorityL(const RAttributeArray& aAttributes)
+    {
+    TUint uid;
+    TUint targetAppId;
+    TUint priority;
+
+    TInt err = KErrNone;
+    
+    // Use the UID from the parent scope
+    uid = iParentUid;
+
+        // Check that we have a priority for the added system plugin action
+        // Specifying a priority is mandatory
+        
+    TPtrC8 targetAppString;
+    err = GetValueFromAttributeList(aAttributes, KOomAttributeTargetAppId, targetAppString);
+    if ((err == KErrNone)
+            && (targetAppString == KOomConfigTargetAppValue)
+            && (iState == EOomParsingStateAppPluginSettings))
+        // If the target app is specified as "TARGET_APP" then we use the target app from the parent entry
+        {
+        targetAppId = iParentTargetApp;
+        }
+    else
+        {
+        err = GetValueFromHexAttributeList(aAttributes, KOomAttributeTargetAppId, targetAppId);
+        if (err != KErrNone)
+            {
+            ConfigError(KOomErrBadOrMissingTargetAppIdInForegroundAppRule);    
+            }
+        }
+     
+    if (err == KErrNone)
+        {
+        err = GetValueFromDecimalAttributeList(aAttributes, KOomAttibuteIdlePriority, priority);
+        
+        if (err != KErrNone)
+            {
+            ConfigError(KOomErrBadOrMissingPriorityInForegroundAppRule);
+            }
+        }
+    
+    if (err == KErrNone)
+        {
+        COomForegroundRule* foregroundRule = new (ELeave) COomForegroundRule(targetAppId, priority);
+        CleanupStack::PushL(foregroundRule);
+        iConfig.AddPluginRuleL(uid, foregroundRule);
+        CleanupStack::Pop(foregroundRule);
+        }
+    }
+
+// Finds an attribute of the given name and gets its value
+// A value is only valid as long as AAtrributes is valid (and unmodified)
+// Returns KErrNone if the attribute is present in the list, KErrNotFound otherwise
+TInt COomConfigParser::GetValueFromAttributeList(const RAttributeArray& aAttributes, const TDesC8& aName, TPtrC8& aValue)
+    {
+    TInt index = aAttributes.Count();
+    TBool attributeFound = EFalse;
+    while ((index--) && (!attributeFound))
+        {
+        if (aAttributes[index].Attribute().LocalName().DesC() == aName)
+            {
+            attributeFound = ETrue;
+            aValue.Set(aAttributes[index].Value().DesC());
+            }
+        }
+    
+    TInt err = KErrNone;
+    
+    if (!attributeFound)
+        err = KErrNotFound;
+    
+    return err;
+    }
+
+// Finds an attribute of the given name and gets its value (coverting the string hex value to a UInt)
+// Returns KErrNone if the attribute is present in the list, KErrNotFound otherwise
+// Returns KErrCorrupt if the string is not a valid hex number
+TInt COomConfigParser::GetValueFromHexAttributeList(const RAttributeArray& aAttributes, const TDesC8& aName, TUint& aValue)
+    {
+    TPtrC8 hexString;
+    TInt err = GetValueFromAttributeList(aAttributes, aName, hexString);
+
+    if (hexString == KOomConfigDefaultAppUid)
+        {
+        // This is a special case
+        // When we hit this value in a hex field then we return the default app UID
+        aValue = KOomDefaultAppId;
+        }
+    else if (hexString == KOomConfigDefaultPluginUid)
+        {
+        // This is a special case
+        // When we hit this value in a hex field then we return the default app UID
+        aValue = KOomDefaultPluginId;
+        }
+    else if (hexString == KOomConfigBusyAppUid)
+        {
+        aValue = KOomBusyAppId;
+        }
+    else if (hexString == KOomConfigHighPriorityAppUid)
+        {
+        aValue = KOomHighPriorityAppId;
+        }
+    else if (err == KErrNone)
+        {
+        TLex8 hexLex(hexString);
+        err = hexLex.Val(aValue, EHex);
+        if (err != KErrNone)
+            err = KErrCorrupt;
+        }
+    
+    return err;
+    }
+
+// Finds an attribute of the given name and gets its value (coverting the string decimal value to a UInt)
+// Returns KErrNone if the attribute is present in the list, KErrNotFound otherwise
+// Returns KErrCorrupt if the string is not a valid decimal number
+TInt COomConfigParser::GetValueFromDecimalAttributeList(const RAttributeArray& aAttributes, const TDesC8& aName, TUint& aValue)
+    {
+    TPtrC8 decimalString;
+    TInt err = GetValueFromAttributeList(aAttributes, aName, decimalString);
+
+    if (err == KErrNone)
+        {
+        if (decimalString == KOomAttibuteNeverClose)
+            aValue = KOomPriorityInfinate;
+        else
+            {
+            TLex8 decimalLex(decimalString);
+            err = decimalLex.Val(aValue, EDecimal);
+            if (err != KErrNone)
+                err = KErrCorrupt;
+            }
+        }
+    
+    return err;
+    }
+
+TInt COomConfigParser::GetValueFromDecimalAttributeList(const RAttributeArray& aAttributes, const TDesC8& aName, TInt& aValue)
+    {
+    TUint uintValue;
+    TInt err = GetValueFromDecimalAttributeList(aAttributes, aName, uintValue);
+    aValue = uintValue;
+    return err;
+    }
+
+TInt COomConfigParser::GetValueFromBooleanAttributeList(const RAttributeArray& aAttributes, const TDesC8& aName, TBool& aValue)
+    {
+    TPtrC8 ptrValue;
+    TInt err = GetValueFromAttributeList(aAttributes, aName, ptrValue);
+    if (err == KErrNone)
+        {
+        if (ptrValue == KOomAttributeTrue || ptrValue == KOomAttribute1)
+            {
+            aValue = ETrue;
+            }
+        else if (ptrValue == KOomAttributeFalse || ptrValue == KOomAttribute0)
+            {
+            aValue = EFalse;
+            }
+        else
+            {
+            err = KErrCorrupt;
+            }
+        }
+    return err;
+    }
+
+void COomConfigParser::SetPluginSyncMode(const RAttributeArray& aAttributes, COomRunPluginConfig& aRunPluginConfig)
+    {
+    TPtrC8 syncModeString;
+    TInt err = GetValueFromAttributeList(aAttributes, KOomAttibuteSyncMode, syncModeString);
+    
+    if (err == KErrNone)
+        // If there is no specified sync mode then leave it as the default
+        {
+        TOomSyncMode syncMode = EContinue;
+        
+        if (syncModeString == KOomConfigSyncModeContinue)
+            syncMode = EContinueIgnoreMaxBatchSize;
+        else if (syncModeString == KOomConfigSyncModeCheck)
+            syncMode = ECheckRam;
+        else if (syncModeString == KOomConfigSyncModeEstimate)
+            syncMode = EEstimate;
+        else
+            ConfigError(KOomErrInvalidSyncMode);
+        
+        if (err == KErrNone)
+            {
+            aRunPluginConfig.iSyncMode = syncMode;
+            }
+        }
+    }
+
+// Check that the current state is as expected
+// If not then the specified config error is generated
+void COomConfigParser::CheckState(TOomParsingState aExpectedState, TInt aError)
+    {
+    if (iState != aExpectedState)
+        ConfigError(aError);
+    }
+
+// Check that the current state is as expected
+// If not then the specified config error is generated
+// This version checks to ensure that the current state matches either of the passed in states
+void COomConfigParser::CheckState(TOomParsingState aExpectedState1, TOomParsingState aExpectedState2, TInt aError)
+    {
+    if ((iState != aExpectedState1)
+            && (iState != aExpectedState2))
+        ConfigError(aError);
+    }
+
+void COomConfigParser::ChangeState(TOomParsingState aState)
+    {
+    iState = aState;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/src/oomforegroundrule.cpp	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,43 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Configuration representation classes for Out of Memory Monitor.
+*
+*/
+
+
+#include "oomforegroundrule.h"
+#include "oomwindowgrouplist.h"
+#include "OomTraces.h"
+
+// If the specified target app is in the foreground then apply the specified priority
+COomForegroundRule::COomForegroundRule(TInt aTargetAppId, TInt aPriority) : iTargetAppId(aTargetAppId), iPriority(aPriority)
+    {
+    FUNC_LOG;
+    }
+
+TBool COomForegroundRule::RuleIsApplicable(const COomWindowGroupList& aWindowGroupList, TInt /*aAppIndexInWindowGroup*/) const
+    {
+    FUNC_LOG;
+
+    TBool ruleIsApplicable = EFalse;
+    if (aWindowGroupList.Count() > 0)
+        {
+        // If the target app is in the foreground then this rule is applicable
+        TUint foregroundAppId = aWindowGroupList.AppId(0, ETrue);
+        if (foregroundAppId == iTargetAppId)
+            ruleIsApplicable = ETrue;
+        }
+    
+    return ruleIsApplicable;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/src/oomglobalconfig.cpp	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,28 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Configuration representation classes for Out of Memory Monitor.
+*
+*/
+
+
+
+#include "oomglobalconfig.h"
+#include "OomTraces.h"
+
+COomGlobalConfig::~COomGlobalConfig()
+    {
+    FUNC_LOG;
+
+    iForceCheckPriorities.Close();
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/src/oomlog.cpp	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,307 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Logging functionality for OOM monitor profiling.
+*
+*/
+
+
+
+#ifdef _DEBUG
+
+#include <hal.h>
+#include <w32std.h>
+#include <e32std.h>
+#include <e32hal.h>
+#include <apgwgnam.h>
+#include <flogger.h>
+
+#include "oomlog.h"
+#include "oompanic.h"
+
+_LIT8(KMemorySampleLoggingString, "%d");
+_LIT8(KMemorySampleLoggingSeparator, ", ");
+
+_LIT8(KCrLf, "\r\n");
+
+_LIT8(KOomLogCancel, "Sampling triggered before previous sampling has completed. Results so far: ");
+
+_LIT(KOomLogFile, ":\\logs\\OOM\\liveoommonitor.txt");
+_LIT(KOomOldLogFile, ":\\logs\\OOM\\oommonitor.txt");
+
+const TInt KMaxTimeStampSize = 30;
+_LIT(KTimeStampFormat, "%F    %H:%T:%S");
+
+_LIT(KDummyWgName, "20");
+
+_LIT8(KUidPreamble, "App UIDs:");
+_LIT8(KUidFormat, " 0x%x");
+
+const TInt KPreallocatedSpaceForAppList = 50;
+
+const TInt KMaxUidBufferSize = 1024;
+
+COomLogger* COomLogger::NewL(RWsSession& aWs, RFs& aFs)
+    {
+    COomLogger* self = new (ELeave) COomLogger(aWs, aFs);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+    
+// Start logging the available memory every n micro seconds
+// Firstly a list of the app IDs is written to the log (foreground app first)
+// Note that the log is created in memory (to a pre-allocated buffer) and flushed out after it is complete
+// the samples are saved in CSV format so that they can easily be cut and pasted to plot graphs etc.
+void COomLogger::StartL()
+    {
+    // If the log file doesn't exist then don't attempt to sample anything
+    if (!iIsOpen)
+        return;
+    
+    // If we are already active then cancel first
+    if (IsActive())
+        Cancel();
+    
+    iWriteBuffer.Zero();
+    
+    iStartTime.HomeTime();
+    
+    // Log the timestamp
+    TBuf16<KMaxTimeStampSize> timeStamp;
+    iStartTime.FormatL(timeStamp, KTimeStampFormat);
+    TBuf8<KMaxTimeStampSize> timeStamp8;
+    timeStamp8.Copy(timeStamp);
+    Write(timeStamp8);
+    
+    // Log all of the application IDs (foreground app first, then the other apps moving towards the back)
+    LogApplicationIds();
+
+    // Then, record the free memory
+    // Note that this is done to a buffer so as not to affect the timing too much
+    LogFreeMemory();
+    
+    // Finally, set a timer to record the memory every n microseconds
+    HighRes(KTimeBetweenMemorySamples);
+    }
+
+// From CTimer / CActice
+void COomLogger::RunL()
+    {
+    TTime currentTime;
+    currentTime.HomeTime();
+    TTimeIntervalMicroSeconds loggingDuration = currentTime.MicroSecondsFrom(iStartTime);
+    TTimeIntervalMicroSeconds samplingDuration = KSamplingDurationUint;
+    if (loggingDuration > samplingDuration)
+        // If we have passed the desired logging duration then write the data we have collected
+        {
+        Write(iWriteBuffer);
+        }
+    else
+        {
+        // If we haven't passed the desired logging duration then record the free memory
+        // Note that this is recorded into a buffer and then logged later
+        iWriteBuffer.Append(KMemorySampleLoggingSeparator);
+        LogFreeMemory();
+        
+        // Wait before taking another memory sample
+        HighRes(KTimeBetweenMemorySamples);
+        }
+    }
+
+void COomLogger::DoCancel()
+    {
+    CTimer::DoCancel();
+    
+    Write(KOomLogCancel);
+    Write(iWriteBuffer);
+    }
+
+COomLogger::~COomLogger()
+    {
+    iWgIds.Close();
+ // delete iWgName; // Not owned
+    if (iIsOpen)
+        iFile.Close();
+
+    }
+
+void COomLogger::Write(const TDesC8& aBuffer)
+    {
+    if (iIsOpen)
+        {
+        iFile.Write(aBuffer);
+    
+        // Add the line break
+        iFile.Write(KCrLf);
+        }
+    }
+
+void COomLogger::LogApplicationIds()
+    {
+    // get all window groups, with info about parents
+    TInt numGroups = iWs.NumWindowGroups(0);
+    TRAPD(err, iWgIds.ReserveL(numGroups));
+    
+    if (err != KErrNone)
+        return;
+    
+    if (iWs.WindowGroupList(0, &iWgIds) != KErrNone)
+        return;
+
+    // Remove all child window groups, promote parents to foremost child position
+    ColapseWindowGroupTree();
+    
+    // Go through each window group ID in the list, get the Uid of each app then log it
+    // Start with the foreground application
+    TInt index = 0;
+    
+    TUid uid;
+    
+    TBuf8<KMaxUidBufferSize> uidBuffer;
+    
+    uidBuffer = KUidPreamble;
+    
+    while (index < numGroups)
+        {
+        __ASSERT_DEBUG(index < iWgIds.Count(), OomMonitorPanic(KWindowGroupArrayIndexOutOfBounds));    
+        uid = GetUidFromWindowGroupId(iWgIds[index].iId);
+        
+        uidBuffer.AppendFormat(KUidFormat, uid.iUid);
+        
+        index++;
+        }
+    
+    Write(uidBuffer);
+    }
+
+void COomLogger::LogFreeMemory()
+    {
+    TMemoryInfoV1Buf meminfo;
+    UserHal::MemoryInfo(meminfo);
+    TInt freeMem = meminfo().iFreeRamInBytes;
+
+    // Save the free memory to a descriptor which will be written later
+    iWriteBuffer.AppendFormat(KMemorySampleLoggingString(), freeMem);
+    }
+
+COomLogger::COomLogger(RWsSession& aWs, RFs& aFs) : CTimer(EPriorityStandard), iWs(aWs), iFs(aFs)
+    {
+    }
+
+void COomLogger::ConstructL()
+    {
+    CActiveScheduler::Add(this);
+    
+    CTimer::ConstructL();
+    
+    TFileName oldLogFileName;
+    TFileName newLogFileName;
+    TChar driveChar = iFs.GetSystemDriveChar();
+    oldLogFileName.Append(driveChar);
+    oldLogFileName.Append(KOomOldLogFile);
+    newLogFileName.Append(driveChar);
+    newLogFileName.Append(KOomLogFile);
+    // If there is an existing log then copy it, this will be the log that can be sent to the PC
+    // Without this feature then you can't get the logs off of the device because the "live" log will always be is use.
+    CFileMan* fileMan = CFileMan::NewL(iFs);
+    CleanupStack::PushL(fileMan);
+    fileMan->Copy(newLogFileName, oldLogFileName);
+    CleanupStack::PopAndDestroy(fileMan);
+    
+    // Create the log file, or open it if is already exists (note that the directory must already be present
+    TInt err = iFile.Create(iFs, KOomLogFile, EFileShareAny | EFileWrite);
+    if (KErrNone != err)
+        {
+        err = iFile.Open(iFs, KOomLogFile, EFileShareAny | EFileWrite);
+        }
+    
+    if (KErrNone == err)
+        {
+        iIsOpen = ETrue;
+        
+        // Append all new data to the end of the file
+        TInt offset = 0;
+        iFile.Seek(ESeekEnd, offset);
+        }
+    
+    // Reserve enough space to build an app list later.
+    iWgIds.ReserveL(KPreallocatedSpaceForAppList);
+    // Reserve enough space for CApaWindowGroupName.
+    iWgName = CApaWindowGroupName::NewL(iWs);
+    iWgNameBuf = HBufC::NewL(CApaWindowGroupName::EMaxLength);
+    (*iWgNameBuf) = KDummyWgName;
+    iWgName->SetWindowGroupName(iWgNameBuf);    // iWgName takes ownership of iWgNameBuf*/
+
+    }
+
+void COomLogger::ColapseWindowGroupTree()
+    {
+    // start from the front, wg count can reduce as loop runs
+    for (TInt ii=0; ii<iWgIds.Count();)
+        {
+        RWsSession::TWindowGroupChainInfo& info = iWgIds[ii];
+        if (info.iParentId > 0)        // wg has a parent
+            {
+            // Look for the parent position
+            TInt parentPos = ii;        // use child pos as not-found signal
+            TInt count = iWgIds.Count();
+            for (TInt jj=0; jj<count; jj++)
+                {
+                if (iWgIds[jj].iId == info.iParentId)
+                    {
+                    parentPos = jj;
+                    break;
+                    }
+                }
+
+            if (parentPos > ii)  // parent should be moved forward
+                {
+                iWgIds[ii] = iWgIds[parentPos];
+                iWgIds.Remove(parentPos);
+                }
+            else if (parentPos < ii)  // parent is already ahead of child, remove child
+                iWgIds.Remove(ii);
+            else                    // parent not found, skip
+                ii++;
+            }
+        else    // wg does not have a parent, skip
+            ii++;
+        }
+    }
+
+TUid COomLogger::GetUidFromWindowGroupId(TInt aWgId)
+    {
+    // get the app's details
+    TPtr wgPtr(iWgNameBuf->Des());
+    
+    TUid uid;
+    
+    TInt err = iWs.GetWindowGroupNameFromIdentifier(aWgId, wgPtr);
+    
+    if (KErrNone != err)
+        // If there is an error then set the UID to 0;
+        {
+        uid.iUid = 0;
+        }
+    else
+        {
+        iWgName->SetWindowGroupName(iWgNameBuf);
+        uid = iWgName->AppUid(); // This UID comes from the app, not the mmp!
+        }
+    
+    return uid;
+    }
+
+#endif //_DEBUG
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/src/oommemorymonitor.cpp	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,523 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Main classes for Out of Memory Monitor.
+*
+*/
+
+
+#include <hal.h>
+#include <u32hal.h>
+
+#include <UikonInternalPSKeys.h>
+
+#include "oommemorymonitor.h"
+#include "oommonitorplugin.h"
+#include "oomsubscribehelper.h"
+#include "oomconfig.h"
+#include "oommemorymonitorserver.h"
+#include "oomconfigparser.h"
+#include "oomactionlist.h"
+#include "oomlog.h"
+#include "OomTraces.h"
+#include "oomoutofmemorywatcher.h"
+#include "oomwserveventreceiver.h"
+#include "oomconstants.hrh"
+#include "oomrunpluginconfig.h"
+#include "oomapplicationconfig.h"
+#include "oomclientrequestqueue.h"
+
+#ifndef CLIENT_REQUEST_QUEUE
+const TInt KOomWatchDogStatusIdle = -1;
+#endif
+
+// ======================================================================
+// class CMemoryMonitor
+// ======================================================================
+
+// ---------------------------------------------------------
+//
+// ---------------------------------------------------------
+//
+CMemoryMonitor* CMemoryMonitor::NewL()
+    { // static
+    FUNC_LOG;
+
+    CMemoryMonitor* self = new(ELeave) CMemoryMonitor();
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+CMemoryMonitor::CMemoryMonitor()
+    {
+    FUNC_LOG;
+
+    SetMemoryMonitorTls(this);
+    }
+
+// ---------------------------------------------------------
+//
+// ---------------------------------------------------------
+//
+CMemoryMonitor::~CMemoryMonitor()
+    {
+    FUNC_LOG;
+
+#ifndef CLIENT_REQUEST_QUEUE
+    if (iWatchdogStatusSubscriber)
+        {
+        iWatchdogStatusSubscriber->StopSubscribe();
+        }
+    iWatchdogStatusProperty.Close();
+    delete iWatchdogStatusSubscriber;
+#endif
+    
+    delete iServer;
+    delete iWservEventReceiver;
+    delete iOOMWatcher;
+    iFs.Close();
+    iWs.Close();
+    
+    delete iOomWindowGroupList;
+    delete iOomActionList;
+    delete iConfig;
+#ifdef CLIENT_REQUEST_QUEUE
+    delete iQueue;
+#endif
+    
+#ifdef _DEBUG    
+    delete iLogger;
+#endif
+    }
+
+// ---------------------------------------------------------
+//
+// ---------------------------------------------------------
+//
+void CMemoryMonitor::ConstructL()
+    {
+    FUNC_LOG;
+
+    User::LeaveIfError(iWs.Connect());
+    
+    iOomWindowGroupList = COomWindowGroupList::NewL(iWs);
+    
+    iConfig = COomConfig::NewL(); 
+    
+#ifdef CLIENT_REQUEST_QUEUE
+    iQueue = COomClientRequestQueue::NewL(*this);
+    
+    iServer = CMemoryMonitorServer::NewL(*iQueue);
+#else
+    iServer = CMemoryMonitorServer::NewL(*this);    
+#endif
+    
+   // Load up threshold & OOM app lists from resource.
+    User::LeaveIfError(iFs.Connect());    
+    
+    COomConfigParser* oomConfigParser = new (ELeave) COomConfigParser(*iConfig, iFs);
+    CleanupStack::PushL(oomConfigParser);
+    oomConfigParser->ParseL();
+    CleanupStack::PopAndDestroy(oomConfigParser);
+
+    iOomActionList = COomActionList::NewL(*this, *iServer, iWs, *iConfig);
+    
+#ifdef _DEBUG    
+    iLogger = COomLogger::NewL(iWs, iFs);
+#endif
+    
+    // Get the thresholds based on the current foreground app and the config
+    RefreshThresholds();
+    
+    _LIT_SECURITY_POLICY_S0(KOomMemoryMonitorPolicyWrite, KOomMemoryMonitorStatusPropertyCategory.iUid);
+    _LIT_SECURITY_POLICY_PASS(KOomMemoryMonitorPolicyRead);
+
+    // Define MemoryMonitorStatusProperty. set to "above treshhold".
+    TInt err = RProperty::Define(KOomMemoryMonitorStatusPropertyCategory, KOomMemoryMonitorStatusPropertyKey, RProperty::EInt, KOomMemoryMonitorPolicyRead, KOomMemoryMonitorPolicyWrite);
+    TRACES1("CMemoryMonitor::ConstructL: KOomMemoryMonitorStatusProperty: Define err = %d", err);
+    
+    err = RProperty::Set(KOomMemoryMonitorStatusPropertyCategory, KOomMemoryMonitorStatusPropertyKey, EAboveTreshHold);
+    TRACES1("CMemoryMonitor::ConstructL:  KOomMemoryMonitorStatusProperty: Set err = %d", err);            
+
+#ifndef CLIENT_REQUEST_QUEUE
+    err = iWatchdogStatusProperty.Attach(KPSUidUikon, KUikOOMWatchdogStatus);
+    
+    TRACES1("CMemoryMonitor::ConstructL: KUikOOMWatchdogStatus err = %d", err);
+        
+    err = iWatchdogStatusProperty.Set(KOomWatchDogStatusIdle);
+    
+    iWatchdogStatusSubscriber = new (ELeave) CSubscribeHelper(TCallBack(WatchdogStatusStatusChanged, this), iWatchdogStatusProperty);
+    iWatchdogStatusSubscriber->Subscribe();
+#endif
+    
+    
+    iOOMWatcher = COutOfMemoryWatcher::NewL(*this, iLowRamThreshold, iGoodRamThreshold, iConfig->GlobalConfig().iSwapUsageMonitored, iLowSwapThreshold, iGoodSwapThreshold);
+    iOOMWatcher->Start();
+
+    iWservEventReceiver = new(ELeave) CWservEventReceiver(*this, iWs);
+    iWservEventReceiver->ConstructL();
+    }
+
+const COomGlobalConfig& CMemoryMonitor::GlobalConfig()
+    {
+    CMemoryMonitor* globalMemoryMonitor = static_cast<CMemoryMonitor*>(Dll::Tls());
+    return globalMemoryMonitor->iConfig->GlobalConfig();
+    }
+
+
+// ---------------------------------------------------------
+//
+// ---------------------------------------------------------
+//
+void CMemoryMonitor::FreeMemThresholdCrossedL()
+    {
+    FUNC_LOG;
+
+    iActionTrigger = ERamRotation;
+    StartFreeSomeRamL(iGoodRamThreshold, iGoodSwapThreshold);
+    }
+
+void CMemoryMonitor::HandleFocusedWgChangeL()
+    {
+    FUNC_LOG;
+
+    TInt oldGoodRamThreshold = iGoodRamThreshold;
+    TInt oldLowRamThreshold = iLowRamThreshold;
+    TInt oldGoodSwapThreshold = iGoodSwapThreshold;
+    TInt oldLowSwapThreshold = iLowSwapThreshold;
+        
+    // Refresh the low and good memory thresholds as they may have changed due to the new foreground application
+    RefreshThresholds();
+       
+    if ((oldGoodRamThreshold != iGoodRamThreshold)
+            || (oldLowRamThreshold != iLowRamThreshold)
+            || (oldGoodSwapThreshold != iGoodSwapThreshold)
+            || (oldLowSwapThreshold != iLowSwapThreshold))
+        // If the thresholds have changed then update the memory watched
+        {
+        iOOMWatcher->UpdateThresholds(iLowRamThreshold, iGoodRamThreshold, iLowSwapThreshold, iGoodSwapThreshold);
+        }
+    
+    // If the available memory is less than the low memory threshold then free some RAM
+    User::CompressAllHeaps();
+    TInt currentFreeRam = 0;
+    HAL::Get( HALData::EMemoryRAMFree, currentFreeRam );
+	TInt currentFreeSwap = 0;
+	if (iConfig->GlobalConfig().iSwapUsageMonitored)
+		{
+        SVMSwapInfo swapInfo;
+		UserSvr::HalFunction(EHalGroupVM, EVMHalGetSwapInfo, &swapInfo, 0);
+		currentFreeSwap = swapInfo.iSwapFree;
+		}
+    
+    if ((currentFreeRam < iLowRamThreshold) ||
+		(iConfig->GlobalConfig().iSwapUsageMonitored && (currentFreeSwap < iLowSwapThreshold)))
+        {
+        iActionTrigger = ERamRotation;
+        StartFreeSomeRamL(iGoodRamThreshold, iGoodSwapThreshold);
+        }
+    }
+
+void CMemoryMonitor::StartFreeSomeRamL(TInt aFreeRamTarget, TInt aFreeSwapTarget)
+    {
+    StartFreeSomeRamL(aFreeRamTarget, aFreeSwapTarget, KOomPriorityInfinate - 1);
+    }
+
+void CMemoryMonitor::StartFreeSomeRamL(TInt aFreeRamTarget, TInt aFreeSwapTarget, TInt aMaxPriority) // The maximum priority of action to run
+    {
+    FUNC_LOG;
+
+    TRACES4("MemoryMonitor::StartFreeSomeRamL: aFreeRamTarget = %d, iCurrentRamTarget = %d, aFreeSwapSpaceTarget = %d, iCurrentSwapTarget = %d", aFreeRamTarget, iCurrentRamTarget, aFreeSwapTarget, iCurrentSwapTarget);
+    
+    // Update the target if new target is higher. If the target is lower than the current target and memory 
+    // is currently being freed then we do not want to reduce the amount of memory this operation frees.
+    if (aFreeRamTarget > iCurrentRamTarget)
+        {
+        iCurrentRamTarget = aFreeRamTarget;
+        }
+    
+    if (aFreeSwapTarget > iCurrentSwapTarget)
+        {
+        iCurrentSwapTarget = aFreeSwapTarget;
+        }
+
+    // check if there is enough free memory already.
+    TInt freeMemory = 0;
+    GetFreeMemory(freeMemory);
+    TInt freeSwap = 0;
+    if (iConfig->GlobalConfig().iSwapUsageMonitored)
+        {
+        GetFreeSwapSpace(freeSwap);
+        }
+
+    TRACES2("MemoryMonitor::StartFreeSomeRamL, freeMemory = %d, freeSwap = %d", freeMemory, freeSwap);
+    
+    if ((freeMemory >= iCurrentRamTarget) &&
+        ((!iConfig->GlobalConfig().iSwapUsageMonitored) || (freeSwap >= iCurrentSwapTarget)))
+        {
+        if (iLastMemoryMonitorStatusProperty != EFreeingMemory)
+            {
+        ResetTargets();
+        iOomActionList->SwitchOffPlugins();
+        SetMemoryMonitorStatusProperty(EAboveTreshHold);
+#ifdef CLIENT_REQUEST_QUEUE        
+        iQueue->ActionsCompleted(freeMemory, ETrue);
+#else        
+        iServer->CloseAppsFinished(freeMemory, ETrue);
+#endif        
+            }
+        return;
+        }
+
+#ifdef _DEBUG    
+    iLogger->StartL();
+#endif
+	
+    // Build the list of memory freeing actions
+    iOomActionList->BuildActionListL(*iOomWindowGroupList, *iConfig);
+    
+	iOomActionList->SetCurrentTargets(iCurrentRamTarget, iCurrentSwapTarget);
+    
+    // Run the memory freeing actions
+    iOomActionList->FreeMemory(aMaxPriority);
+    }
+
+void CMemoryMonitor::RequestFreeMemoryPandSL(TInt aBytesRequested)
+    {
+    FUNC_LOG;
+    
+    iActionTrigger = EPublishAndSubscribe;
+    StartFreeSomeRamL(aBytesRequested + iLowRamThreshold, iLowSwapThreshold);
+    }
+
+void CMemoryMonitor::RequestFreeMemoryL(TInt aBytesRequested, TBool aDataPaged)
+    {
+    FUNC_LOG;
+    
+    iActionTrigger = EClientServerRequestFreeMemory;
+    iDataPaged = aDataPaged;
+    StartFreeSomeRamL(iLowRamThreshold, aBytesRequested + iLowSwapThreshold);
+    }
+
+void CMemoryMonitor::FreeOptionalRamL(TInt aBytesRequested, TInt aPluginId, TBool aDataPaged) // The ID of the plugin that will clear up the allocation, used to determine the priority of the allocation
+    {
+    FUNC_LOG;
+    
+    iActionTrigger = EClientServerRequestOptionalRam;
+
+    iDataPaged = aDataPaged;
+       
+    // Calculate the priority of the allocation (the priority of the plugin that will clear it up - 1)
+    TInt priorityOfAllocation = iConfig->GetPluginConfig(aPluginId).CalculatePluginPriority(*iOomWindowGroupList) - 1;
+   
+    StartFreeSomeRamL(aBytesRequested + iGoodRamThreshold, iLowSwapThreshold, priorityOfAllocation);
+    }
+
+void CMemoryMonitor::GetFreeMemory(TInt& aCurrentFreeMemory)
+    {
+    FUNC_LOG;
+
+    // may cause some extra load but allows more precise action
+    User::CompressAllHeaps();
+
+    HAL::Get( HALData::EMemoryRAMFree, aCurrentFreeMemory );
+
+    TRACES1("CMemoryMonitor::GetFreeMemory: Free RAM now %d", aCurrentFreeMemory);
+    }
+
+void CMemoryMonitor::GetFreeSwapSpace(TInt& aCurrentFreeSwapSpace)
+    {
+    FUNC_LOG;
+    
+    SVMSwapInfo swapInfo;
+    UserSvr::HalFunction(EHalGroupVM, EVMHalGetSwapInfo, &swapInfo, 0);
+    aCurrentFreeSwapSpace = swapInfo.iSwapFree;
+        
+    TRACES1("CMemoryMonitor::GetFreeSwapSpace: Free swap space now %d", aCurrentFreeSwapSpace);
+    }
+
+#ifndef CLIENT_REQUEST_QUEUE 
+TInt CMemoryMonitor::WatchdogStatusStatusChanged(TAny* aPtr)
+    {
+    FUNC_LOG;
+
+    CMemoryMonitor* self = STATIC_CAST(CMemoryMonitor*,aPtr);
+    if (self)
+        self->HandleWatchdogStatusCallBack();
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------
+//
+// ---------------------------------------------------------
+//
+void CMemoryMonitor::HandleWatchdogStatusCallBack()
+    {
+    FUNC_LOG;
+
+    // Someone has set the key to request some free memory.
+    TInt memoryRequested = 0;
+    iWatchdogStatusProperty.Get(memoryRequested);
+
+    // Try to free the RAM.
+    if (memoryRequested >= 1)
+        {
+        iOOMWatcher->Cancel();              // Pause memory notifys.
+        TRAP_IGNORE(RequestFreeMemoryPandSL(memoryRequested + iLowThreshold)); // This call could take a few seconds to do its stuff.
+        iOOMWatcher->Start();               // Restarts memory monitoring.
+        }
+    // Set the key back to KOomWatchDogStatusIdle to indicate we're done.
+    iWatchdogStatusProperty.Set(KOomWatchDogStatusIdle);
+    }
+#endif //CLIENT_REQUEST_QUEUE
+
+void CMemoryMonitor::AppNotExiting(TInt aWgId)
+    {
+    FUNC_LOG;
+
+    iOomActionList->AppNotExiting(aWgId);
+    }
+
+
+void CMemoryMonitor::RefreshThresholds()
+    {
+    FUNC_LOG;
+
+    iOomWindowGroupList->Refresh();
+    
+    // Calculate the desired good threshold, this could be the globally configured value...
+    iGoodRamThreshold = CMemoryMonitor::GlobalConfig().iGoodRamThreshold;
+    iLowRamThreshold = CMemoryMonitor::GlobalConfig().iLowRamThreshold;
+    iGoodSwapThreshold = CMemoryMonitor::GlobalConfig().iGoodSwapThreshold;
+    iLowSwapThreshold = CMemoryMonitor::GlobalConfig().iLowSwapThreshold;
+    TRACES4("CMemoryMonitor::RefreshThresholds: Global Good Ram Threshold = %d, Global Low Ram Threshold = %d, Global Good Swap Threshold = %d, Global Low Swap Threshold = %d", iGoodRamThreshold, iLowRamThreshold, iGoodSwapThreshold, iLowSwapThreshold);
+
+#ifdef _DEBUG
+    TRACES("CMemoryMonitor::RefreshThresholds: Dumping Window Group List");
+    TInt wgIndex = iOomWindowGroupList->Count() - 1;
+    while (wgIndex >= 0)        
+        {
+        TInt32 appId = iOomWindowGroupList->AppId(wgIndex, ETrue);    
+        TInt wgId = iOomWindowGroupList->WgId(wgIndex).iId;
+        TInt parentId = iOomWindowGroupList->WgId(wgIndex).iId;        
+        TRACES4("CMemoryMonitor::RefreshThresholds: wgIndex=%d, oom uid=%x, wgId(child)=%d, parentId=%d", wgIndex, appId, wgId, parentId);    
+        wgIndex--;
+        }
+#endif
+    
+    // The global value can be overridden by an app specific value
+    // Find the application config entry for the foreground application
+    if (iOomWindowGroupList->Count())
+        {
+        TUint foregroundAppId = iOomWindowGroupList->AppId(0, ETrue);
+        TUid foregroundAppUid = TUid::Uid(foregroundAppId);
+        
+        if ( (foregroundAppUid == KUidPenInputServer || foregroundAppUid == KUidFastSwap) &&
+             iOomWindowGroupList->Count() > 1 )
+            {
+            // pen input server puts itself to the foreground when the web browser is active
+            // fast swap should not reset the thresholds for the app behind it
+            foregroundAppId = iOomWindowGroupList->AppId(1, ETrue);
+            }
+
+        // If this application configuration overrides the good_ram_threshold then set it
+        if (iConfig->GetApplicationConfig(foregroundAppId).iGoodRamThreshold != KOomThresholdUnset)
+            {
+            iGoodRamThreshold = iConfig->GetApplicationConfig(foregroundAppId).iGoodRamThreshold;
+            TRACES2("CMemoryMonitor::RefreshThresholds: For foreground app %x, Good Ram Threshold = %d", foregroundAppId, iGoodRamThreshold);
+            }
+        // If this application configuration overrides the low_ram_threshold then set it
+        if (iConfig->GetApplicationConfig(foregroundAppId).iLowRamThreshold != KOomThresholdUnset)
+            {
+            iLowRamThreshold = iConfig->GetApplicationConfig(foregroundAppId).iLowRamThreshold;
+            TRACES2("CMemoryMonitor::RefreshThresholds: For foreground app %x, Low Ram Threshold = %d", foregroundAppId, iLowRamThreshold);
+            }
+
+        if (iConfig->GetApplicationConfig(foregroundAppId).iGoodSwapThreshold != KOomThresholdUnset)
+            {
+            iGoodSwapThreshold = iConfig->GetApplicationConfig(foregroundAppId).iGoodSwapThreshold;
+            TRACES2("CMemoryMonitor::RefreshThresholds: For foreground app %x, Good Swap Threshold = %d", foregroundAppId, iGoodSwapThreshold);
+            }
+        // If this application configuration overrides the low_swap_threshold then set it
+        if (iConfig->GetApplicationConfig(foregroundAppId).iLowSwapThreshold != KOomThresholdUnset)
+            {
+            iLowSwapThreshold = iConfig->GetApplicationConfig(foregroundAppId).iLowSwapThreshold;
+            TRACES2("CMemoryMonitor::RefreshThresholds: For foreground app %x, Low Swap Threshold = %d", foregroundAppId, iLowSwapThreshold);
+            }
+        }
+    }
+
+// SetMemoryMonitorStatusProperty - updates the property value only if it has changed
+void CMemoryMonitor::SetMemoryMonitorStatusProperty(const TMemoryMonitorStatusPropertyValues aValue)
+    {
+    if (iLastMemoryMonitorStatusProperty != aValue)
+        {
+        TInt err = RProperty::Set(KOomMemoryMonitorStatusPropertyCategory, KOomMemoryMonitorStatusPropertyKey, aValue);
+        TRACES1("CMemoryMonitor::SetMemoryMonitorStatusProperty: err = %d", err);
+        iLastMemoryMonitorStatusProperty = aValue;
+        }
+    }
+
+void CMemoryMonitor::ResetTargets()
+    {
+    FUNC_LOG;
+
+    //we reset the target when a memory free operation completes, to deal with the case 
+    //where the operation was initiated with a target larger than the current good threshold
+    iCurrentRamTarget = iGoodRamThreshold;
+    iCurrentSwapTarget = iGoodSwapThreshold;
+    iOomActionList->SetCurrentTargets(iCurrentRamTarget, iCurrentSwapTarget);
+    }
+
+void CMemoryMonitor::SetPriorityBusy(TInt aWgId)
+    {
+    FUNC_LOG;
+
+    iOomWindowGroupList->SetPriorityBusy(aWgId);
+    }
+
+void CMemoryMonitor::SetPriorityNormal(TInt aWgId)
+    {
+    FUNC_LOG;
+
+    iOomWindowGroupList->SetPriorityNormal(aWgId);
+    }
+
+void CMemoryMonitor::SetPriorityHigh(TInt aWgId)
+    {
+    iOomWindowGroupList->SetPriorityHigh(aWgId);
+    }
+
+TActionTriggerType CMemoryMonitor::ActionTrigger() const
+    {
+    return iActionTrigger;
+    }
+
+#ifdef CLIENT_REQUEST_QUEUE 
+TInt CMemoryMonitor::GoodRamThreshold() const
+    {
+    return iGoodRamThreshold;
+    }
+
+TInt CMemoryMonitor::LowRamThreshold() const
+    {
+    return iLowRamThreshold;
+    }
+
+void CMemoryMonitor::ActionsCompleted(TInt aBytesFree, TBool aMemoryGood)
+    {
+    iQueue->ActionsCompleted(aBytesFree, aMemoryGood);
+    }
+#endif //CLIENT_REQUEST_QUEUE
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/src/oommemorymonitorserver.cpp	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,114 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Main classes for Out of Memory Monitor.
+*
+*/
+
+
+
+#include "oommemorymonitorserver.h"
+#include "oommonitorclientserver.h"
+#include "oommemorymonitorsession.h"
+#include "oommemorymonitor.h"
+#include "OomTraces.h"
+
+#ifdef CLIENT_REQUEST_QUEUE        
+CMemoryMonitorServer* CMemoryMonitorServer::NewL(COomClientRequestQueue& aQueue)
+#else
+CMemoryMonitorServer* CMemoryMonitorServer::NewL(CMemoryMonitor& aMonitor)
+#endif
+    {
+    FUNC_LOG;
+
+#ifdef CLIENT_REQUEST_QUEUE        
+    CMemoryMonitorServer* self=new(ELeave) CMemoryMonitorServer(aQueue);
+#else
+    CMemoryMonitorServer* self=new(ELeave) CMemoryMonitorServer(aMonitor);
+#endif
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+CMemoryMonitorServer::~CMemoryMonitorServer()
+    {
+    FUNC_LOG;
+    }
+
+#ifdef CLIENT_REQUEST_QUEUE        
+CMemoryMonitorServer::CMemoryMonitorServer(COomClientRequestQueue& aQueue)
+    :CServer2(CActive::EPriorityStandard), iQueue(aQueue)
+#else
+CMemoryMonitorServer::CMemoryMonitorServer(CMemoryMonitor& aMonitor)
+    :CServer2(CActive::EPriorityStandard), iMonitor(aMonitor)    
+#endif
+    {
+    FUNC_LOG;
+    }
+
+void CMemoryMonitorServer::ConstructL()
+    {
+    FUNC_LOG;
+
+    StartL(KMemoryMonitorServerName);
+    }
+
+CSession2* CMemoryMonitorServer::NewSessionL(const TVersion& /*aVersion*/, const RMessage2& /*aMessage*/) const
+    {
+    FUNC_LOG;
+
+    return new(ELeave) CMemoryMonitorSession();
+    }
+
+TInt CMemoryMonitorServer::RunError(TInt aError)
+    {
+    FUNC_LOG;
+
+    Message().Complete(aError);
+    //
+    // The leave will result in an early return from CServer::RunL(), skipping
+    // the call to request another message. So do that now in order to keep the
+    // server running.
+    ReStart();
+    return KErrNone;    // handled the error fully
+    }
+
+#ifdef CLIENT_REQUEST_QUEUE        
+COomClientRequestQueue& CMemoryMonitorServer::ClientRequestQueue()
+    {
+    FUNC_LOG;
+
+    return iQueue;
+    }
+#else
+CMemoryMonitor& CMemoryMonitorServer::Monitor()
+    {
+    FUNC_LOG;
+
+    return iMonitor;
+    }
+#endif
+
+#ifndef CLIENT_REQUEST_QUEUE        
+void CMemoryMonitorServer::CloseAppsFinished(TInt aBytesFree, TBool aMemoryGood)
+    {
+    FUNC_LOG;
+
+    iSessionIter.SetToFirst();
+    CSession2* s;
+    while ((s = iSessionIter++) != 0)
+        static_cast<CMemoryMonitorSession*>(s)->CloseAppsFinished(aBytesFree, aMemoryGood);
+    }
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/src/oommemorymonitorsession.cpp	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,184 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Main classes for Out of Memory Monitor.
+*
+*/
+
+
+#include "oommonitorclientserver.h"
+#include "oommemorymonitorsession.h"
+#include "oommemorymonitor.h"
+#include "oommemorymonitorserver.h"
+#include "OomTraces.h"
+#include "oomclientrequestqueue.h"
+
+CMemoryMonitorSession::CMemoryMonitorSession()
+    {
+    FUNC_LOG;
+    }
+
+
+CMemoryMonitorSession::~CMemoryMonitorSession()
+    {
+    FUNC_LOG;
+    }
+
+CMemoryMonitorServer& CMemoryMonitorSession::Server()
+    {
+    FUNC_LOG;
+
+    return *static_cast<CMemoryMonitorServer*>(const_cast<CServer2*>(CSession2::Server()));
+    }
+
+#ifdef CLIENT_REQUEST_QUEUE
+COomClientRequestQueue& CMemoryMonitorSession::ClientRequestQueue()
+    {
+    FUNC_LOG;
+
+    return Server().ClientRequestQueue();
+    }
+#endif
+
+CMemoryMonitor& CMemoryMonitorSession::Monitor()
+    {
+    FUNC_LOG;
+
+#ifdef CLIENT_REQUEST_QUEUE
+    return ClientRequestQueue().Monitor();
+#else
+    return Server().Monitor();    
+#endif
+    }
+#ifndef CLIENT_REQUEST_QUEUE
+TBool CMemoryMonitorSession::IsDataPaged(const RMessage2& aMessage)
+    {
+    RThread clientThread;
+    TInt err = aMessage.Client(clientThread);
+    TBool dataPaged = EFalse;
+    if(err == KErrNone)
+        {
+        RProcess processName;
+        err = clientThread.Process(processName);
+        if(err == KErrNone)
+            {
+            dataPaged = processName.DefaultDataPaged();
+            }
+        else
+            {
+            PanicClient(aMessage, EPanicIllegalFunction);
+            }
+        }
+    else
+        {
+        PanicClient(aMessage, EPanicIllegalFunction);
+        }
+    return dataPaged;            
+    }
+#endif
+
+void CMemoryMonitorSession::ServiceL(const RMessage2& aMessage)
+    {
+    FUNC_LOG;
+        
+#ifndef CLIENT_REQUEST_QUEUE
+    iFunction = aMessage.Function();
+#endif 
+    
+    switch (aMessage.Function())
+        {
+        case EOomMonitorRequestFreeMemory:
+            if (!iRequestFreeRam.IsNull())
+                PanicClient(aMessage, EPanicRequestActive);
+            // message will be completed when CloseAppsFinished() is called.  
+            
+#ifdef CLIENT_REQUEST_QUEUE
+            ClientRequestQueue().RequestFreeMemoryL(aMessage);
+#else
+            iRequestFreeRam = aMessage;
+            Monitor().RequestFreeMemoryL(aMessage.Int0(), IsDataPaged(aMessage));
+#endif
+            break;
+
+        case EOomMonitorCancelRequestFreeMemory:
+            if (!iRequestFreeRam.IsNull())
+                iRequestFreeRam.Complete(KErrCancel);
+            aMessage.Complete(KErrNone);
+            break;
+
+        case EOomMonitorThisAppIsNotExiting:
+            Monitor().AppNotExiting(aMessage.Int0());
+            aMessage.Complete(KErrNone);
+            break;
+
+        case EOomMonitorRequestOptionalRam:
+            if (!iRequestFreeRam.IsNull())
+                PanicClient(aMessage, EPanicRequestActive);
+            // message will be completed when CloseAppsFinished() is called.
+            
+#ifdef CLIENT_REQUEST_QUEUE
+            ClientRequestQueue().RequestOptionalRamL(aMessage);
+#else
+            iRequestFreeRam = aMessage;
+            iMinimumMemoryRequested = aMessage.Int1();
+            Monitor().FreeOptionalRamL(aMessage.Int0(), aMessage.Int2(), IsDataPaged(aMessage));
+#endif            
+            break;
+            
+        case EOomMonitorSetPriorityBusy:
+            Monitor().SetPriorityBusy(aMessage.Int0());
+            aMessage.Complete(KErrNone);
+            break;
+            
+        case EOomMonitorSetPriorityNormal:
+               Monitor().SetPriorityNormal(aMessage.Int0());
+            aMessage.Complete(KErrNone);
+            break;
+
+        case EOomMonitorSetPriorityHigh:
+               Monitor().SetPriorityHigh(aMessage.Int0());
+            aMessage.Complete(KErrNone);
+            break;
+
+        default:
+            PanicClient(aMessage, EPanicIllegalFunction);
+            break;
+        }
+    }
+
+#ifndef CLIENT_REQUEST_QUEUE
+void CMemoryMonitorSession::CloseAppsFinished(TInt aBytesFree, TBool aMemoryGood)
+    {
+    FUNC_LOG;
+
+    if (!iRequestFreeRam.IsNull())
+        {
+        if (iFunction == EOomMonitorRequestOptionalRam)
+            {
+            TInt memoryAvailable = aBytesFree - CMemoryMonitor::GlobalConfig().iGoodRamThreshold;
+            
+            // If memory available is greater than the requested RAM then complete with the amount of free memory, otherwise complete with KErrNoMemory
+            if (memoryAvailable >= iMinimumMemoryRequested)
+                {
+                iRequestFreeRam.Complete(memoryAvailable);
+                }
+            else
+                {
+                iRequestFreeRam.Complete(KErrNoMemory);
+                }
+               }
+        else 
+            iRequestFreeRam.Complete(aMemoryGood ? KErrNone : KErrNoMemory);
+        }
+    }
+#endif
--- a/sysresmonitoring/oommonitor/src/oommonitor.cpp	Tue Jun 15 16:07:48 2010 +0100
+++ b/sysresmonitoring/oommonitor/src/oommonitor.cpp	Thu Jul 22 16:35:22 2010 +0100
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2006 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 "Eclipse Public License v1.0"
@@ -16,41 +16,20 @@
 */
 
 
-#include <hal.h>
-#include <s32file.h>
-#include <w32std.h>
-#include <akneiksrvc.h>
-#include <LafMemoryWatcher.rsg>
-#include <bautils.h>
-#include <apgwgnam.h>
-#include <apgtask.h>
-#include <barsc.h>
-#include <barsread2.h>
 
-#include <e32property.h>
-#include <UikonInternalPSKeys.h>
-#include <UiklafInternalCRKeys.h>
-
-#include <data_caging_path_literals.hrh>
 
 #include "oommonitor.h"
-#include "oommonitorplugin.h"
-#include "oommonitorplugin.hrh"
+#include "oommemorymonitor.h"
 #include "oommonitorclientserver.h"
-
-#define OOM_WATCHDOG_STATUS_IDLE -1
+#include "OomTraces.h"
 
-const TInt KPreallocatedSpaceForAppList = 50;
-const TInt KPluginFreeMemoryTime = 100000;       // 100 milliseconds for plugins to free memory, overridden by LafMemoryWatcher.rss
+const TInt KStackSize = 0x2000;
 
-_LIT(KDriveZ, "z:");
-_LIT(KOOMWatcherResourceFileName, "lafmemorywatcher.rsc");
 _LIT(KOOMWatcherThreadName, "OOM FW");
-_LIT(KDummyWgName, "20");
 
 
 // Implements just Error() to avoid panic
-class CSimpleScheduler : public CActiveScheduler
+NONSHARABLE_CLASS(CSimpleScheduler) : public CActiveScheduler
     {
     void Error( TInt ) const{} // From CActiveScheduler
     };
@@ -58,6 +37,8 @@
 // thread function for OOM watcher
 GLDEF_C TInt WatcherThreadFunction( TAny* )
     {
+    FUNC_LOG;
+
     TInt err( KErrNone );
 
     CTrapCleanup* cleanup = CTrapCleanup::New();
@@ -95,12 +76,14 @@
 // Creates thread for OOM watchers
 EXPORT_C void CreateOOMWatcherThreadL()
     {
+    FUNC_LOG;
+
     RThread thread;
     TInt ret = thread.Create( KOOMWatcherThreadName,
                               WatcherThreadFunction,
-                              0x2000, // stack size
+                              KStackSize, // stack size
                               NULL, // uses caller thread's heap
-                              (TAny*)NULL );
+                              NULL );
 
     if ( ret == KErrNone )
         {
@@ -111,941 +94,10 @@
     User::LeaveIfError( ret );
     }
 
-
-// ======================================================================
-// class CMemoryMonitor
-// ======================================================================
-
-// ---------------------------------------------------------
-//
-// ---------------------------------------------------------
-//
-CMemoryMonitor* CMemoryMonitor::NewL()
-    { // static
-    CMemoryMonitor* self = new(ELeave) CMemoryMonitor();
-    CleanupStack::PushL(self);
-    self->ConstructL();
-    CleanupStack::Pop(self);
-    return self;
-    }
-
-CMemoryMonitor::CMemoryMonitor()
-: iRamPluginRunTime(KPluginFreeMemoryTime), iCurrentTask(iWs), 
-  iMemoryAboveThreshold(ETrue), iPluginMemoryGood(ETrue)
-    {
-    SetMemoryMonitorTls(this);
-    }
-
-// ---------------------------------------------------------
-//
-// ---------------------------------------------------------
-//
-CMemoryMonitor::~CMemoryMonitor()
-    {
-    if (iWatchdogStatusSubscriber)
-    {
-        iWatchdogStatusSubscriber->StopSubscribe();
-    }
-    iWatchdogStatusProperty.Close();
-    delete iWatchdogStatusSubscriber;
-
-    delete iServer;
-    delete iWservEventReceiver;
-    delete iAppCloseTimer;
-    delete iAppCloseWatcher;
-    delete iOOMWatcher;
-    delete iPlugins;
-    iAppCloseOrderMap.Close();
-    iWgIds.Close();
-    delete iWgName;
-    iFs.Close();
-    iWs.Close();
-    }
-
-// ---------------------------------------------------------
-//
-// ---------------------------------------------------------
-//
-void CMemoryMonitor::ConstructL()
-    {
-    User::LeaveIfError(iWs.Connect());
-
-    // Reserve enough space to build an app list later.
-    iWgIds.ReserveL(KPreallocatedSpaceForAppList);
-    // Reserve enough space for CApaWindowGroupName.
-    iWgName = CApaWindowGroupName::NewL(iWs);
-    iWgNameBuf = HBufC::NewL(CApaWindowGroupName::EMaxLength);
-    (*iWgNameBuf) = KDummyWgName;
-    iWgName->SetWindowGroupName(iWgNameBuf);    // iWgName takes ownership of iWgNameBuf
-
-   // Load up threshold & OOM app lists from resource.
-    User::LeaveIfError(iFs.Connect());
-
-    RResourceFile resFile;
-    TFileName filename(KDriveZ);
-    filename.Append(KDC_RESOURCE_FILES_DIR);
-    filename.Append(KOOMWatcherResourceFileName);
-    BaflUtils::NearestLanguageFile(iFs, filename);
-    resFile.OpenL(iFs, filename);
-    CleanupClosePushL(resFile);
-
-    HBufC8* thresholds = resFile.AllocReadLC(R_APP_OOM_THRESHOLDS);
-    RResourceReader theReader;
-    theReader.OpenLC(*thresholds);
-
-    iLowThreshold = theReader.ReadInt32L();
-    iGoodThreshold = theReader.ReadInt32L();
-    iMaxExitTime = theReader.ReadInt32L();
-    TRAP_IGNORE(iRamPluginRunTime = theReader.ReadInt32L());    // trapped in case lafmemorywatcher.rss does not define this value
-
-    CleanupStack::PopAndDestroy(&theReader);
-    CleanupStack::PopAndDestroy(thresholds);
-
-    // apps to close first, first app in list gets closed first
-    ReadAppResourceArrayL(resFile, R_APP_OOM_EXIT_CANDIDATES, ECloseFirst, +1);	// +1 means apps later in the list are closed later
-    // apps to never close, all apps get order ENeverClose
-    ReadAppResourceArrayL(resFile, R_APP_OOM_EXIT_NEVER, ENeverClose, 0);	// 0 means that all apps get ENeverClose
-    // apps to close last, first app in list gets closed last
-    ReadAppResourceArrayL(resFile, R_APP_OOM_EXIT_LAST, ECloseLast, -1);	// -1 means apps later in the list are closed earlier
-    
-    CleanupStack::PopAndDestroy(); // resFile.Close();
-
-    iPlugins = new(ELeave) COomPlugins;
-    iPlugins->ConstructL();
-
-    TInt err = iWatchdogStatusProperty.Attach(KPSUidUikon, KUikOOMWatchdogStatus);
-#ifdef _DEBUG
-    RDebug::Print(_L("xxxx KUikOOMWatchdogStatus err=%d"), err);
-#endif
-    err = iWatchdogStatusProperty.Set(OOM_WATCHDOG_STATUS_IDLE);
-
-    iWatchdogStatusSubscriber = new (ELeave) CSubscribeHelper(TCallBack(WatchdogStatusStatusChanged, this), iWatchdogStatusProperty);
-    iWatchdogStatusSubscriber->SubscribeL();
-
-    iOOMWatcher = COutOfMemoryWatcher::NewL(*this, iLowThreshold, iGoodThreshold);
-    iOOMWatcher->Start();
-
-    iAppCloseTimer = CAppCloseTimer::NewL(*this);
-    iAppCloseWatcher = new(ELeave) CAppCloseWatcher(*this);
-    
-    iWservEventReceiver = new(ELeave) CWservEventReceiver(*this, iWs);
-    iWservEventReceiver->ConstructL();
-
-    iServer = CMemoryMonitorServer::NewL(*this);
-    }
-
-void CMemoryMonitor::ReadAppResourceArrayL(RResourceFile& aResFile, TInt aResId, TInt aOrderBase, TInt aOrderInc)
-    {
-    // apps in this list will be ordered starting from aOrderBase
-    TInt order = aOrderBase;
-    // get the resource and set up the resource reader
-    HBufC8* apps = aResFile.AllocReadLC(aResId);
-    TResourceReader theReader;
-    theReader.SetBuffer(apps);
-    // go through all apps in the list
-    TInt appsCount = theReader.ReadUint16();
-    for (TInt ii = 0; ii < appsCount; ii++)
-        {
-        TInt appUid = theReader.ReadInt32();
-        // insert the app UID with the appropriate order
-        iAppCloseOrderMap.Insert(appUid, order);
-        // change the order number as appropriate for this list
-        order += aOrderInc;
-        }
-    CleanupStack::PopAndDestroy(apps);
-    }
-
-void CMemoryMonitor::CancelAppCloseWatchers()
-    {
-    iAppCloserRunning = EFalse;
-    iCurrentTask.SetWgId(0);
-    if (iAppCloseTimer)
-        iAppCloseTimer->Cancel();
-    if (iAppCloseWatcher)
-        iAppCloseWatcher->Cancel();
-    }
-
-// ---------------------------------------------------------
-//
-// ---------------------------------------------------------
-//
-void CMemoryMonitor::FreeMemThresholdCrossedL()
-    {
-    StartFreeSomeRamL(iGoodThreshold);
-    }
-
-void CMemoryMonitor::HandleFocusedWgChangeL()
-    {
-    // The focused window group has changed.
-    if (iAppCloserRunning)
-        {
-        // if the app closer is currently running, restart it
-        RestartAppCloser();
-        }
-    else if (!iMemoryAboveThreshold)
-    	{
-	    // If memory is low, rescan for free memory
-    	StartFreeSomeRamL(iGoodThreshold);
-    	}
-    }
-
-void CMemoryMonitor::RestartAppCloser()
-	{
-    CancelAppCloseWatchers();
-    // StartFreeSomeRamL is trapped so that clients waiting
-    // for completion will definitely receive it.
-	TRAPD(err, StartFreeSomeRamL(iCurrentTarget))
-	if (err != KErrNone)
-        CloseAppsFinished(FreeMemoryAboveThreshold());
-	}
-
-// ---------------------------------------------------------
-// This function attempts to free enough RAM to leave the target amount of space free.
-// This function could take a substantial time to return as it may have to close a number
-// of applications, and each will be given a timeout of KAPPEXITTIMEOUT.
-// ---------------------------------------------------------
-//
-void CMemoryMonitor::StartFreeSomeRamL(TInt aTargetFree)
-    {
-    // update the target if new target is higher
-    if (aTargetFree > iCurrentTarget)
-        iCurrentTarget = aTargetFree;
-
-    // do nothing more if app closer is already running
-    if (iAppCloserRunning)
-        return;
-
-       iCurrentTarget = aTargetFree;
-
-    // check if there is enough free memory already.
-    if (FreeMemoryAboveThreshold())
-        {
-        CloseAppsFinished(ETrue);
-        return;
-        }
-
-    // Tell plugins to free memory
-    bool pluginsToldToFreeMemory = iPluginMemoryGood;
-    SetPluginMemoryGood(EFalse);
-
-    // get the list of apps to free
-    GetWgsToCloseL();
-
-    if (pluginsToldToFreeMemory)
-        {
-        // Give the plugins a short time to free memory.
-        // App close timer will kick off the app closer.
-        iAppCloseTimer->After(iRamPluginRunTime);
-        }
-    else
-        {
-        // start closing apps
-        CloseNextApp();
-        }
-    }
-
-void CMemoryMonitor::CloseNextApp()
-    {
-    if(iNextAppToClose >= 0)
-        {
-        // close an app, if there's an app to be closed
-#ifdef _DEBUG
-        RDebug::Print(_L("OOM WATCHER: Target not achieved; continuing... Target:%d"),iCurrentTarget);
-#endif
-		// CloseNextApp() may have been called by one of the event
-		// watchers, cancel them all to prevent more events from the
-		// last app before restarting the watchers for the new app to close
-        CancelAppCloseWatchers();
-        iAppCloserRunning = ETrue;
-        // Set the TApaTask to the app
-        iCurrentTask.SetWgId(iWgIds[iNextAppToClose].iId);
-        // Start a timer and the thread watcher
-        iAppCloseTimer->After(iMaxExitTime);
-        iAppCloseWatcher->Start(iCurrentTask);
-        // Tell the app to close
-        iCurrentTask.EndTask();
-        iNextAppToClose--;
-        }
-    else
-        {
-        // stop if we have no more apps
-        CloseAppsFinished(EFalse);
-        }
-    }
-
-// handle an app closed event
-void CMemoryMonitor::CloseAppEvent()
-    {
-    if (FreeMemoryAboveThreshold())
-        {
-        // stop if we have enough memory
-        CloseAppsFinished(ETrue);
-        }
-    else
-        {
-        // otherwise try to close another app
-        CloseNextApp();
-        }
-    }
-
-// The app closer is finished
-void CMemoryMonitor::CloseAppsFinished(TBool aMemoryGood)
-    {
-    CancelAppCloseWatchers();
-#ifdef _DEBUG
-    RDebug::Print(_L("OOM WATCHER: Final result: Target:%d Good?:%d"),iCurrentTarget,aMemoryGood);
-#endif
-    iServer->CloseAppsFinished(aMemoryGood);
-    // plugins can start using memory if result is good
-    SetPluginMemoryGood(aMemoryGood);
-    }
-
-TBool CMemoryMonitor::FreeMemoryAboveThreshold()
-    {
-    // may cause some extra load but allows more precise action
-    User::CompressAllHeaps();
-
-    TInt current = 0;
-    HAL::Get( HALData::EMemoryRAMFree, current );
-
-#ifdef _DEBUG
-    RDebug::Print(_L("OOM WATCHER: Free RAM now:%d "),current);
-#endif
-
-	iMemoryAboveThreshold = (current >= iCurrentTarget);
-    return iMemoryAboveThreshold;
-    }
-
-void CMemoryMonitor::GetWgsToCloseL()
-    {
-    // get all window groups, with info about parents
-    TInt numGroups = iWs.NumWindowGroups(0);
-    iWgIds.ReserveL(numGroups);
-    User::LeaveIfError(iWs.WindowGroupList(0, &iWgIds));
-
-    // Remove all child window groups, promote parents to foremost child position
-    ColapseWindowGroupTree();
-    
-    // now rearange the list so that it only contains apps to close
-    // first remove the foreground window group
-    iWgIds.Remove(0);
-
-    // go through the list from start to end.
-    // this divides the list into two sections. Apps that never
-    // close move towards the end of the list, apps that will close
-    // go towards the start.
-    // apps to close first will be placed further back in the close list.
-    TInt numAppsToClose = 0;		// numAppsToClose marks the boundary between closing and non-closing apps
-    TInt count = iWgIds.Count();
-    for (TInt ii=0; ii<count; ii++)
-        {
-        ASSERT(ii >= numAppsToClose);	// we are always looking at apps after the sorted section
-        // get the next window group
-        RWsSession::TWindowGroupChainInfo info = iWgIds[ii];
-        // get the close order for the window group
-        TInt closeOrder = AppCloseOrder(ii, info.iId);
-        if (closeOrder == ENeverClose)
-            {
-            // leave apps which should not be closed in place,
-            // after the last app to close.
-            continue;
-            }
-        else
-            {
-            // We no longer need the parent id. Use it to store the close order, to avoid the need to allocate more array space
-            info.iParentId = closeOrder;
-               // remove the app from it's current position
-            iWgIds.Remove(ii);
-            // find the right place to insert the app (lower orders are put further back)
-            TInt insertPos;
-            for (insertPos = 0; insertPos < numAppsToClose; insertPos++)
-                {
-                // compare this close order with window groups already in the list,
-                // whose close order is stored in iParentId
-                if (closeOrder > iWgIds[insertPos].iParentId)
-                    break;
-                }
-            // Insert the app in the correct place
-            ASSERT(insertPos <= ii && insertPos <= numAppsToClose);	// apps to close are always moved to front, before the close boundary
-            iWgIds.Insert(info, insertPos);
-            numAppsToClose++;
-            }
-        }
-    
-    // start closing apps from the end of the list of apps to close
-    iNextAppToClose = numAppsToClose - 1;
-    }
-
-// Calculate the order number in which this app should be closed
-// This is based on the app's UID and its window group Z-order
-// Apps given a lower order will be closed before those with a
-// higher order.
-TInt CMemoryMonitor::AppCloseOrder(TInt aWgIndex, TInt aWgId)
-    {
-    // get the app's details
-    TPtr wgPtr(iWgNameBuf->Des());
-    if (iWs.GetWindowGroupNameFromIdentifier(aWgId, wgPtr) != KErrNone)
-        return ENeverClose;
-    iWgName->SetWindowGroupName(iWgNameBuf);
-    TUid uid = iWgName->AppUid(); // This UID comes from the app, not the mmp!
-    TInt* order = iAppCloseOrderMap.Find(uid.iUid);
-
-    // The default app close order is normal with further 
-    // back apps getting a lower order
-    TInt closeOrder = ECloseNormal - aWgIndex;
-    if (order)
-        {
-        // Apps with a defined close order get that order.
-        closeOrder = *order;
-        }
-    else if (uid.iUid == 0 || iWgName->IsSystem() || iWgName->Hidden() || iWgName->IsBusy())
-        {
-        // Apps that should never close get the ENeverClose rank
-        closeOrder = ENeverClose;
-        }
-
-    return closeOrder;
-    }
-
-void CMemoryMonitor::SetPluginMemoryGood(TBool aSetToGood)
-    {
-    if (aSetToGood && !iPluginMemoryGood)
-        iPlugins->MemoryGood();
-    else if (!aSetToGood && iPluginMemoryGood)
-        iPlugins->FreeRam();
-    iPluginMemoryGood = aSetToGood;
-    }
-
-
-// ---------------------------------------------------------
-//
-// ---------------------------------------------------------
-//
-TInt CMemoryMonitor::WatchdogStatusStatusChanged(TAny* aPtr)
-    {
-    CMemoryMonitor* self = STATIC_CAST(CMemoryMonitor*,aPtr);
-    if (self)
-        self->HandleWatchdogStatusCallBackL();
-    return KErrNone;
-    }
-
-// ---------------------------------------------------------
-//
-// ---------------------------------------------------------
-//
-void CMemoryMonitor::HandleWatchdogStatusCallBackL()
-    {
-    // Someone has set the key to request some free memory.
-    TInt target = 0;
-    iWatchdogStatusProperty.Get(target);
-
-    // Try to free the RAM.
-    if (target >= 1)
-        {
-        iOOMWatcher->Cancel();              // Pause memory notifys.
-        TRAP_IGNORE(StartFreeSomeRamL(target)); // This call could take a few seconds to do its stuff.
-        iOOMWatcher->Start();               // Restarts memory monitoring.
-        }
-    // Set the key back to OOM_WATCHDOG_STATUS_IDLE to indicate we're done.
-    iWatchdogStatusProperty.Set(OOM_WATCHDOG_STATUS_IDLE);
-    }
-
-// ---------------------------------------------------------
-// Remove child window groups. Promote parent window groups forward to child position
-// ---------------------------------------------------------
-//
-void CMemoryMonitor::ColapseWindowGroupTree()
-    {
-    // start from the front, wg count can reduce as loop runs
-    for (TInt ii=0; ii<iWgIds.Count();)
-        {
-        RWsSession::TWindowGroupChainInfo& info = iWgIds[ii];
-        if (info.iParentId > 0)        // wg has a parent
-            {
-            // Look for the parent position
-            TInt parentPos = ii;        // use child pos as not-found signal
-            TInt count = iWgIds.Count();
-            for (TInt jj=0; jj<count; jj++)
-                {
-                if (iWgIds[jj].iId == info.iParentId)
-                    {
-                    parentPos = jj;
-                    break;
-                    }
-                }
-
-            if (parentPos > ii)  // parent should be moved forward
-                {
-                iWgIds[ii] = iWgIds[parentPos];
-                iWgIds.Remove(parentPos);
-                }
-            else if (parentPos < ii)  // parent is already ahead of child, remove child
-                iWgIds.Remove(ii);
-            else                    // parent not found, skip
-                ii++;
-            }
-        else    // wg does not have a parent, skip
-            ii++;
-        }
-    }
-
-void CMemoryMonitor::AppNotExiting(TInt aWgId)
-    {
-    if (aWgId == iCurrentTask.WgId())
-        CloseAppEvent();
-    }
-
-
-// ======================================================================
-// class COutOfMemoryWatcher
-// - notifies when free memory crosses preset thresholds
-// ======================================================================
-
-// ---------------------------------------------------------
-//
-// ---------------------------------------------------------
-//
-COutOfMemoryWatcher* COutOfMemoryWatcher::NewL(CMemoryMonitor& aMonitor, TInt aLowThreshold, TInt aGoodThreshold)
-    {
-    COutOfMemoryWatcher* self = new (ELeave) COutOfMemoryWatcher(aMonitor);
-    CleanupStack::PushL(self);
-    self->ConstructL(aLowThreshold, aGoodThreshold);
-    CleanupStack::Pop(self);
-    return self;
-    }
-
-// ---------------------------------------------------------
-//
-// ---------------------------------------------------------
-//
-COutOfMemoryWatcher::~COutOfMemoryWatcher()
-    {
-    Cancel();
-    }
-
-// ---------------------------------------------------------
-//
-// ---------------------------------------------------------
-//
-COutOfMemoryWatcher::COutOfMemoryWatcher(CMemoryMonitor& aMonitor)
-:   CActive(CActive::EPriorityStandard),
-    iLafShutdown(aMonitor)
-    {
-    CActiveScheduler::Add(this);
-    }
-
-// ---------------------------------------------------------
-//
-// ---------------------------------------------------------
-//
-void COutOfMemoryWatcher::ConstructL(TInt aLowThreshold, TInt aGoodThreshold)
-    {
-    UserSvr::SetMemoryThresholds(aLowThreshold,aGoodThreshold);
-    User::LeaveIfError(iChangeNotifier.Create());
-    }
-
-// ---------------------------------------------------------
-//
-// ---------------------------------------------------------
-//
-void COutOfMemoryWatcher::Start()
-    {
-    if (!IsActive())
-        {
-        iChangeNotifier.Logon(iStatus);
-        SetActive();
-        }
-    }
-
-// ---------------------------------------------------------
-//
-// ---------------------------------------------------------
-//
-void COutOfMemoryWatcher::DoCancel()
-    {
-    iChangeNotifier.LogonCancel();
-    }
-
-// ---------------------------------------------------------
-//
-// ---------------------------------------------------------
-//
-void COutOfMemoryWatcher::RunL()
-    {
-    TInt status = iStatus.Int();
-
-    if (status < 0)
-        {
-        User::Leave(status);
-        }
-
-    // Check for memory status change.
-    if (status & EChangesFreeMemory)
-        {
-        iLafShutdown.FreeMemThresholdCrossedL();
-        }
-
-    // We are not active until FreeMemThresholdCrossedL returns.
-    Start();
-    }
-
-// ---------------------------------------------------------
-//
-// ---------------------------------------------------------
-//
-CSubscribeHelper::CSubscribeHelper(TCallBack aCallBack, RProperty& aProperty)
-    : CActive(EPriorityNormal), iCallBack(aCallBack), iProperty(aProperty)
-    {
-    CActiveScheduler::Add(this);
-    }
-
-// ---------------------------------------------------------
-//
-// ---------------------------------------------------------
-//
-CSubscribeHelper::~CSubscribeHelper()
-    {
-    Cancel();
-    }
-
-// ---------------------------------------------------------
-//
-// ---------------------------------------------------------
-//
-void CSubscribeHelper::SubscribeL()
-    {
-    if (!IsActive())
-        {
-        iProperty.Subscribe(iStatus);
-        SetActive();
-        }
-    }
-
-// ---------------------------------------------------------
-//
-// ---------------------------------------------------------
-//
-void CSubscribeHelper::StopSubscribe()
-    {
-    Cancel();
-    }
-
-// ---------------------------------------------------------
-//
-// ---------------------------------------------------------
-//
-void CSubscribeHelper::RunL()
-    {
-    if (iStatus.Int() == KErrNone)
-        {
-        iCallBack.CallBack();
-        SubscribeL();
-        }
-    }
-
-// ---------------------------------------------------------
-//
-// ---------------------------------------------------------
-//
-void CSubscribeHelper::DoCancel()
-    {
-    iProperty.Cancel();
-    }
-
-
-COomPlugins::COomPlugins()
-    {
-    }
-
-COomPlugins::~COomPlugins()
-    {
-    TInt count = iPlugins.Count();
-    for (TInt ii=0; ii<count; ii++)
-        {
-        TPlugin& plugin = iPlugins[ii];
-        if (plugin.iImpl)    // only if successfully added
-            REComSession::DestroyedImplementation(plugin.iDtorUid);
-        }
-    iPlugins.Close();
-    }
-
-void COomPlugins::ConstructL()
-    {
-    RImplInfoPtrArray implArray;
-    CleanupClosePushL(implArray);
-    REComSession::ListImplementationsL(KOomPluginInterfaceUid, implArray);
-
-    TInt count = implArray.Count();
-    iPlugins.ReserveL(count);
-
-    for (TInt ii=0; ii<count; ii++)
-        {
-        iPlugins.AppendL(TPlugin());
-        TPlugin& plugin = iPlugins[ii];
-        TUid uid(implArray[ii]->ImplementationUid());
-        plugin.iImpl = static_cast<COomMonitorPlugin*>(REComSession::CreateImplementationL(uid, plugin.iDtorUid, NULL));
-        }
-    
-    CleanupStack::PopAndDestroy(&implArray);
-    }
-
-void COomPlugins::FreeRam()
-    {
-    TInt count = iPlugins.Count();
-    for (TInt ii=0; ii<count; ii++)
-        {
-        TPlugin& plugin = iPlugins[ii];
-        plugin.iImpl->FreeRam();
-        }
-    }
-
-void COomPlugins::MemoryGood()
-    {
-    TInt count = iPlugins.Count();
-    for (TInt ii=0; ii<count; ii++)
-        {
-        TPlugin& plugin = iPlugins[ii];
-        plugin.iImpl->MemoryGood();
-        }
-    }
-
-COomPlugins::TPlugin::TPlugin()
-: iImpl(0)
-    {
-    }
-
-
-CAppCloseTimer* CAppCloseTimer::NewL(CMemoryMonitor& aMonitor)
-    {
-    CAppCloseTimer* self = new(ELeave)CAppCloseTimer(aMonitor);
-    CleanupStack::PushL(self);
-    self->ConstructL();
-    CleanupStack::Pop(self);
-    return self;
-    }
-
-CAppCloseTimer::CAppCloseTimer(CMemoryMonitor& aMonitor)
-: CTimer(CActive::EPriorityStandard), iMonitor(aMonitor)
-    {
-    CActiveScheduler::Add(this);
-    }
-
-void CAppCloseTimer::RunL()
-    {
-    iMonitor.CloseAppEvent();
-    }
-
-
-
-CAppCloseWatcher::CAppCloseWatcher(CMemoryMonitor& aMonitor)
-: CActive(CActive::EPriorityStandard), iMonitor(aMonitor)
-    {
-    CActiveScheduler::Add(this);
-    }
-
-CAppCloseWatcher::~CAppCloseWatcher()
-    {
-    Cancel();
-    }
-
-void CAppCloseWatcher::Start(const TApaTask& aTask)
-    {
-    TInt err = iThread.Open(aTask.ThreadId());
-    if (err == KErrNone)
-        {
-        iOriginalProcessPriority = iThread.ProcessPriority();
-        iThread.SetProcessPriority(EPriorityForeground);
-        iThread.Logon(iStatus);
-        SetActive();
-        }
-    else
-        {
-        iStatus = KRequestPending;
-        TRequestStatus* s = &iStatus;
-        User::RequestComplete(s, err);
-        SetActive();
-        }
-    }
-
-void CAppCloseWatcher::DoCancel()
-    {
-    iThread.LogonCancel(iStatus);
-    iThread.SetProcessPriority(iOriginalProcessPriority);
-    iThread.Close();
-    }
-
-void CAppCloseWatcher::RunL()
-    {
-    if (iThread.Handle())
-        iThread.SetProcessPriority(iOriginalProcessPriority);
-    iThread.Close();
-    // Experimentation shows that memory may take up to 40ms
-    // to be released back to the system after app thread close.
-    // Using this delay should minimise the number of apps that
-    // need to be closed to recover the necessary memory.
-    const TInt KAppTidyUpDelay = 40000;
-    User::After(KAppTidyUpDelay);
-    iMonitor.CloseAppEvent();
-    }
-
-
-
-CWservEventReceiver::CWservEventReceiver(CMemoryMonitor& aMonitor, RWsSession& aWs)
-: CActive(CActive::EPriorityStandard), iMonitor(aMonitor), iWs(aWs), iWg(aWs)
-    {
-    CActiveScheduler::Add(this);
-    }
-
-CWservEventReceiver::~CWservEventReceiver()
-    {
-    Cancel();
-    iWg.Close();
-    }
-
-void CWservEventReceiver::ConstructL()
-    {
-    User::LeaveIfError(iWg.Construct((TUint32)this, EFalse));
-    iWg.SetOrdinalPosition(0, ECoeWinPriorityNeverAtFront);
-    iWg.EnableFocusChangeEvents();
-    Queue();
-    }
-
-void CWservEventReceiver::Queue()
-    {
-    iWs.EventReady(&iStatus);
-    SetActive();
-    }
-
-void CWservEventReceiver::DoCancel()
-    {
-    iWs.EventReadyCancel();
-    }
-
-void CWservEventReceiver::RunL()
-    {
-    TWsEvent event;
-    iWs.GetEvent(event);
-    if (event.Type() == EEventFocusGroupChanged)
-        iMonitor.HandleFocusedWgChangeL();
-    Queue();
-    }
-
-
-
-CMemoryMonitorServer* CMemoryMonitorServer::NewL(CMemoryMonitor& aMonitor)
-    {
-    CMemoryMonitorServer* self=new(ELeave) CMemoryMonitorServer(aMonitor);
-    CleanupStack::PushL(self);
-    self->ConstructL();
-    CleanupStack::Pop(self);
-    return self;
-    }
-
-CMemoryMonitorServer::~CMemoryMonitorServer()
-    {
-    }
-
-CMemoryMonitorServer::CMemoryMonitorServer(CMemoryMonitor& aMonitor)
-:CServer2(CActive::EPriorityStandard), iMonitor(aMonitor)
-    {
-    }
-
-void CMemoryMonitorServer::ConstructL()
-    {
-    StartL(KMemoryMonitorServerName);
-    }
-
-CSession2* CMemoryMonitorServer::NewSessionL(const TVersion& /*aVersion*/, const RMessage2& /*aMessage*/) const
-    {
-    return new(ELeave) CMemoryMonitorSession();
-    }
-
-TInt CMemoryMonitorServer::RunError(TInt aError)
-    {
-    Message().Complete(aError);
-    //
-    // The leave will result in an early return from CServer::RunL(), skipping
-    // the call to request another message. So do that now in order to keep the
-    // server running.
-    ReStart();
-    return KErrNone;    // handled the error fully
-    }
-
-CMemoryMonitor& CMemoryMonitorServer::Monitor()
-    {
-    return iMonitor;
-    }
-
-void CMemoryMonitorServer::CloseAppsFinished(TBool aMemoryGood)
-    {
-    iSessionIter.SetToFirst();
-    CSession2* s;
-    while ((s = iSessionIter++) != 0)
-        static_cast<CMemoryMonitorSession*>(s)->CloseAppsFinished(aMemoryGood);
-    }
-
-
-CMemoryMonitorSession::CMemoryMonitorSession()
-    {
-    }
-
-void CMemoryMonitorSession::CreateL()
-    {
-    }
-
-CMemoryMonitorSession::~CMemoryMonitorSession()
-    {
-    }
-
-CMemoryMonitorServer& CMemoryMonitorSession::Server()
-    {
-    return *static_cast<CMemoryMonitorServer*>(const_cast<CServer2*>(CSession2::Server()));
-    }
-
-CMemoryMonitor& CMemoryMonitorSession::Monitor()
-    {
-    return Server().Monitor();
-    }
-
-void CMemoryMonitorSession::ServiceL(const RMessage2& aMessage)
-    {
-    aMessage.HasCapabilityL(ECapabilityWriteDeviceData); //Leaves if client has not correct capability
-    switch (aMessage.Function())
-        {
-        case EOomMonitorRequestFreeMemory:
-            if (!iRequestFreeRam.IsNull())
-                PanicClient(aMessage, EPanicRequestActive);
-            // message will be completed when CloseAppsFinished() is called.
-            iRequestFreeRam = aMessage;
-            Monitor().StartFreeSomeRamL(aMessage.Int0());
-            break;
-
-        case EOomMonitorCancelRequestFreeMemory:
-            if (!iRequestFreeRam.IsNull())
-                iRequestFreeRam.Complete(KErrCancel);
-            aMessage.Complete(KErrNone);
-            break;
-
-        case EOomMonitorThisAppIsNotExiting:
-            Monitor().AppNotExiting(aMessage.Int0());
-            aMessage.Complete(KErrNone);
-            break;
-
-        default:
-            PanicClient(aMessage, EPanicIllegalFunction);
-            break;
-        }
-    }
-
-void CMemoryMonitorSession::CloseAppsFinished(TBool aMemoryGood)
-    {
-    if (!iRequestFreeRam.IsNull())
-        iRequestFreeRam.Complete(aMemoryGood ? KErrNone : KErrNoMemory);
-    }
-
-
 void PanicClient(const RMessagePtr2& aMessage,TOomMonitorClientPanic aPanic)
     {
+    FUNC_LOG;
+
     aMessage.Panic(KMemoryMonitorServerName, aPanic);
     }
 
--- a/sysresmonitoring/oommonitor/src/oommonitorplugin.cpp	Tue Jun 15 16:07:48 2010 +0100
+++ b/sysresmonitoring/oommonitor/src/oommonitorplugin.cpp	Thu Jul 22 16:35:22 2010 +0100
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2006 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 "Eclipse Public License v1.0"
@@ -16,26 +16,33 @@
 */
 
 
+#include <apgwgnam.h>
 #include "oommonitorplugin.h"
-#include "oommonitor.h"
-#include <apgwgnam.h>
+#include "oommemorymonitor.h"
+#include "OomTraces.h"
 
 // TLS is used to store the CMemoryMonitor pointer, CMemoryMonitor
 // being the main object in the OOM monitor thread. This allows
 // plugins to access the CMemoryMonitor object easily.
 EXPORT_C void SetMemoryMonitorTls(CMemoryMonitor* aMonitor)
     {
+    FUNC_LOG;
+
     Dll::SetTls(aMonitor);
     }
 
 CMemoryMonitor* MemoryMonitorTls()
     {
+    FUNC_LOG;
+
     return static_cast<CMemoryMonitor*>(Dll::Tls());
     }
 
 
 void OomMonitorPluginPanic(TOomMonitorPluginPanic aReason)
     {
+    FUNC_LOG;
+
     _LIT(KCat, "OomMonitorPlugin");
     User::Panic(KCat, aReason);
     }
@@ -43,34 +50,53 @@
 
 EXPORT_C COomMonitorPlugin::COomMonitorPlugin()
 : iMemoryMonitor(MemoryMonitorTls())
-	{
-	__ASSERT_ALWAYS(iMemoryMonitor, OomMonitorPluginPanic(EOomMonitorPluginPanic_PluginConstructedOutsideOomMonitorThread));
-	}
+    {
+    FUNC_LOG;
+
+    __ASSERT_ALWAYS(iMemoryMonitor, OomMonitorPluginPanic(EOomMonitorPluginPanic_PluginConstructedOutsideOomMonitorThread));
+    }
 
 EXPORT_C COomMonitorPlugin::~COomMonitorPlugin()
-	{
-	}
+    {
+    FUNC_LOG;
+    }
 
 EXPORT_C void COomMonitorPlugin::ConstructL()
-	{
-	// CAppOomMonitorPlugin assumes ConstructL is empty
-	}
+    {
+    FUNC_LOG;
+
+    // CAppOomMonitorPlugin assumes ConstructL is empty
+    }
 
 EXPORT_C void COomMonitorPlugin::ExtensionInterface(TUid /*aInterfaceId*/, TAny*& /*aImplementaion*/)
-	{
-	}
+    {
+    FUNC_LOG;
+    }
 
 EXPORT_C RFs& COomMonitorPlugin::FsSession()
     {
+    FUNC_LOG;
+
     return iMemoryMonitor->iFs;
     }
 
 EXPORT_C RWsSession& COomMonitorPlugin::WsSession()
     {
+    FUNC_LOG;
+
     return iMemoryMonitor->iWs;
     }
 
 
+
+EXPORT_C void COomMonitorPluginV2::FreeRam()
+    {
+    // Note that OomMonitorV2 will not call this version of the function
+    // so it does not need to be implemented in derived classes.
+    }
+
+
+
 EXPORT_C CAppOomMonitorPlugin* CAppOomMonitorPlugin::NewL(TUid aAppUid)
     {
     CAppOomMonitorPlugin* self = new(ELeave) CAppOomMonitorPlugin(aAppUid);
@@ -96,18 +122,18 @@
 void CAppOomMonitorPlugin::SendMessageToApp(TInt aMessage)
     {
     RWsSession& ws = WsSession();
-	TInt wgId = 0;
+    TInt wgId = 0;
 
     do 
         {
-		CApaWindowGroupName::FindByAppUid(iAppUid, ws, wgId);
-		if (wgId>0)
-			{
-        	TWsEvent event;
-        	event.SetType(aMessage);
-        	event.SetTimeNow();
-			ws.SendEventToWindowGroup(wgId, event);
-			}
+        CApaWindowGroupName::FindByAppUid(iAppUid, ws, wgId);
+        if (wgId>0)
+            {
+            TWsEvent event;
+            event.SetType(aMessage);
+            event.SetTimeNow();
+            ws.SendEventToWindowGroup(wgId, event);
+            }
         }
-	while (wgId>0);
+    while (wgId>0);
     }
--- a/sysresmonitoring/oommonitor/src/oommonitorsession.cpp	Tue Jun 15 16:07:48 2010 +0100
+++ b/sysresmonitoring/oommonitor/src/oommonitorsession.cpp	Thu Jul 22 16:35:22 2010 +0100
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2006 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 "Eclipse Public License v1.0"
@@ -16,33 +16,104 @@
 */
 
 
-#include "oommonitorsession.h"
+#include <coemain.h>
+#include <oommonitorsession.h>
 #include "oommonitorclientserver.h"
+#include "oompanic.h"
+#include "OomTraces.h"
 
 EXPORT_C TInt ROomMonitorSession::Connect()
-	{
-	return CreateSession(KMemoryMonitorServerName, TVersion(0,0,0));
-	}
+    {
+    FUNC_LOG;
+
+    return CreateSession(KMemoryMonitorServerName, TVersion(0,0,0));
+    }
 
 EXPORT_C TInt ROomMonitorSession::RequestFreeMemory(TInt aBytesRequested)
-	{
-	TIpcArgs p(aBytesRequested);
-	return SendReceive(EOomMonitorRequestFreeMemory, p);
-	}
+    {
+    FUNC_LOG;
+
+    TIpcArgs p(aBytesRequested);
+    return SendReceive(EOomMonitorRequestFreeMemory, p);
+    }
+
+EXPORT_C TInt ROomMonitorSession::RequestOptionalRam(TInt aBytesRequested, TInt aMinimumBytesNeeded, TInt aPluginId, TInt& aBytesAvailable)
+    {
+    FUNC_LOG;
+
+    TIpcArgs p(aBytesRequested, aMinimumBytesNeeded, aPluginId, aBytesAvailable);
+    TInt ret = SendReceive(EOomMonitorRequestOptionalRam, p);
+    if (ret >= 0)
+        {
+        aBytesAvailable = ret;
+        ret = KErrNone;
+        }
+    
+    return ret;
+    }
+
+
+
+EXPORT_C void ROomMonitorSession::RequestOptionalRam(TInt aBytesRequested, TInt aMinimumBytesNeeded, TInt aPluginId, TRequestStatus& aStatus)
+    {
+    FUNC_LOG;
+
+    TIpcArgs p(aBytesRequested, aMinimumBytesNeeded, aPluginId);
+    SendReceive(EOomMonitorRequestOptionalRam, p, aStatus);
+    }
 
 EXPORT_C void ROomMonitorSession::RequestFreeMemory(TInt aBytesRequested, TRequestStatus& aStatus)
-	{
-	TIpcArgs p(aBytesRequested);
-	SendReceive(EOomMonitorRequestFreeMemory, p, aStatus);
-	}
+    {
+    FUNC_LOG;
+
+    TIpcArgs p(aBytesRequested);
+    SendReceive(EOomMonitorRequestFreeMemory, p, aStatus);
+    }
 
 EXPORT_C void ROomMonitorSession::CancelRequestFreeMemory()
-	{
-	SendReceive(EOomMonitorCancelRequestFreeMemory, TIpcArgs());
-	}
+    {
+    FUNC_LOG;
+
+    SendReceive(EOomMonitorCancelRequestFreeMemory, TIpcArgs());
+    }
 
 EXPORT_C void ROomMonitorSession::ThisAppIsNotExiting(TInt aWgId)
-	{
-	TIpcArgs p(aWgId);
-	SendReceive(EOomMonitorThisAppIsNotExiting, p);
-	}
+    {
+    FUNC_LOG;
+
+    TIpcArgs p(aWgId);
+    SendReceive(EOomMonitorThisAppIsNotExiting, p);
+    }
+
+
+EXPORT_C void ROomMonitorSession::SetOomPriority(TOomPriority aPriority)
+    {
+    FUNC_LOG;
+
+    CCoeEnv* coeEnv = CCoeEnv::Static();
+
+    __ASSERT_DEBUG(coeEnv, OomMonitorPanic(KNoCoeEnvFound));    
+
+    if (coeEnv)
+        {
+        TInt wgId = coeEnv->RootWin().Identifier();
+        TIpcArgs p(wgId);
+        switch (aPriority)
+            {
+            case EOomPriorityNormal:
+                SendReceive(EOomMonitorSetPriorityNormal, p);
+                break;
+            case EOomPriorityHigh:
+                SendReceive(EOomMonitorSetPriorityHigh, p);
+                break;
+            case EOomPriorityBusy:
+                SendReceive(EOomMonitorSetPriorityBusy, p);
+                break;
+            default:
+                OomMonitorPanic(KOomInvalidPriority);
+                break;
+            }
+        }
+    }
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/src/oomoutofmemorywatcher.cpp	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,152 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Main classes for Out of Memory Monitor.
+*
+*/
+
+
+
+#include "oomoutofmemorywatcher.h"
+#include "oommemorymonitor.h"
+#include "OomTraces.h"
+#include <u32hal.h>
+
+// ======================================================================
+// class COutOfMemoryWatcher
+// - notifies when free memory crosses preset thresholds
+// ======================================================================
+
+// ---------------------------------------------------------
+//
+// ---------------------------------------------------------
+//
+COutOfMemoryWatcher* COutOfMemoryWatcher::NewL(CMemoryMonitor& aMonitor, TInt aLowRamThreshold, TInt aGoodRamThreshold, TBool aSwapUsageMonitored, TInt aLowSwapThreshold, TInt aGoodSwapThreshold)
+    {
+    FUNC_LOG;
+
+    COutOfMemoryWatcher* self = new (ELeave) COutOfMemoryWatcher(aMonitor, aSwapUsageMonitored);
+    CleanupStack::PushL(self);
+    self->ConstructL(aLowRamThreshold, aGoodRamThreshold, aLowSwapThreshold, aGoodSwapThreshold);
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+// ---------------------------------------------------------
+//
+// ---------------------------------------------------------
+//
+COutOfMemoryWatcher::~COutOfMemoryWatcher()
+    {
+    FUNC_LOG;
+
+    Cancel();
+    }
+
+// ---------------------------------------------------------
+//
+// ---------------------------------------------------------
+//
+COutOfMemoryWatcher::COutOfMemoryWatcher(CMemoryMonitor& aMonitor, TBool aSwapUsageMonitored)
+:   CActive(CActive::EPriorityStandard),
+    iMemoryMonitor(aMonitor),
+    iSwapUsageMonitored(aSwapUsageMonitored)
+    {
+    FUNC_LOG;
+
+    CActiveScheduler::Add(this);
+    }
+
+// ---------------------------------------------------------
+//
+// ---------------------------------------------------------
+//
+void COutOfMemoryWatcher::ConstructL(TInt aLowRamThreshold, TInt aGoodRamThreshold, TInt aLowSwapThreshold, TInt aGoodSwapThreshold)
+    {
+    FUNC_LOG;
+
+    UserSvr::SetMemoryThresholds(aLowRamThreshold,aGoodRamThreshold);
+    if (iSwapUsageMonitored)
+        {
+        SVMSwapThresholds thresholds;
+        thresholds.iLowThreshold = aLowSwapThreshold;
+        thresholds.iGoodThreshold = aGoodSwapThreshold;
+        UserSvr::HalFunction(EHalGroupVM, EVMHalSetSwapThresholds, &thresholds, 0);
+        }
+    User::LeaveIfError(iChangeNotifier.Create());
+    }
+
+void COutOfMemoryWatcher::UpdateThresholds(TInt aLowRamThreshold, TInt aGoodRamThreshold, TInt aLowSwapThreshold, TInt aGoodSwapThreshold)
+    {
+    FUNC_LOG;
+
+    UserSvr::SetMemoryThresholds(aLowRamThreshold,aGoodRamThreshold);
+    if (iSwapUsageMonitored)
+        {
+        SVMSwapThresholds thresholds;
+        thresholds.iLowThreshold = aLowSwapThreshold;
+        thresholds.iGoodThreshold = aGoodSwapThreshold;
+        UserSvr::HalFunction(EHalGroupVM, EVMHalSetSwapThresholds, &thresholds, 0);
+        }
+    }
+
+// ---------------------------------------------------------
+//
+// ---------------------------------------------------------
+//
+void COutOfMemoryWatcher::Start()
+    {
+    FUNC_LOG;
+
+    if (!IsActive())
+        {
+        iChangeNotifier.Logon(iStatus);
+        SetActive();
+        }
+    }
+
+// ---------------------------------------------------------
+//
+// ---------------------------------------------------------
+//
+void COutOfMemoryWatcher::DoCancel()
+    {
+    FUNC_LOG;
+
+    iChangeNotifier.LogonCancel();
+    }
+
+// ---------------------------------------------------------
+//
+// ---------------------------------------------------------
+//
+void COutOfMemoryWatcher::RunL()
+    {
+    FUNC_LOG;
+
+    TInt status = iStatus.Int();
+
+    if (status < 0)
+        {
+        User::Leave(status);
+        }
+
+    // Check for memory status change.
+    if (status & EChangesFreeMemory)
+        {
+        iMemoryMonitor.FreeMemThresholdCrossedL();
+        }
+
+    // We are not active until FreeMemThresholdCrossedL returns.
+    Start();
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/src/oompanic.cpp	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,32 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Panic codes for OOM monitor.
+*
+*/
+
+#include "oompanic.h"
+
+#include <e32std.h>
+
+void OomMonitorPanic(TOomMonitorPanic aReason)
+    {
+    _LIT(KCat, "OomMonitor");
+    User::Panic(KCat, aReason);
+    }
+
+void OomConfigParserPanic(TInt aReason)
+    {
+    _LIT(KParserCat, "OomParser");
+    User::Panic(KParserCat, aReason);
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/src/oompluginwaiter.cpp	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,55 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Classes for executing OOM actions (e.g. closing applications and running plugins).
+*
+*/
+
+
+#include "oompluginwaiter.h"
+#include "oomrunplugin.h"
+#include "OomTraces.h"
+#include "oomconstants.hrh"
+
+COomPluginWaiter* COomPluginWaiter::NewL(TInt aMillisecondsToWait, COomRunPlugin& aCallbackClass)
+    {
+    FUNC_LOG;
+
+    COomPluginWaiter* self = new (ELeave) COomPluginWaiter(aMillisecondsToWait, aCallbackClass);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+COomPluginWaiter::COomPluginWaiter(TInt aMillisecondsToWait, COomRunPlugin& aCallbackClass) : CTimer(EPriorityStandard), iMillisecondsToWait(aMillisecondsToWait), iCallbackClass(aCallbackClass)
+    {
+    FUNC_LOG;
+
+    CActiveScheduler::Add(this);
+    }
+
+// Start the timer, it will call the plugin back when it expires
+void COomPluginWaiter::Start()
+    {
+    FUNC_LOG;
+
+    HighRes(iMillisecondsToWait * KMicrosecondsInMillisecond);
+    }
+    
+void COomPluginWaiter::RunL()
+    {
+    FUNC_LOG;
+
+    iCallbackClass.WaitCompleted();
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/src/oomrunplugin.cpp	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,96 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Classes for executing OOM actions (e.g. closing applications and running plugins).
+*
+*/
+
+#include "oomrunplugin.h"
+#include "OomTraces.h"
+#include "oommemorymonitor.h"
+#include "oommonitorplugin.h"
+#include "oompanic.h"
+
+COomRunPlugin* COomRunPlugin::NewL(TUint aPluginId, COomRunPluginConfig& aConfig, MOomActionObserver& aStateChangeObserver, COomMonitorPlugin& aPlugin, COomMonitorPluginV2* aV2Plugin)
+    {
+    FUNC_LOG;
+
+    COomRunPlugin* self = new (ELeave) COomRunPlugin(aPluginId, aConfig, aStateChangeObserver, aPlugin, aV2Plugin);
+    CleanupStack::PushL(self);
+    self->ConstructL(aConfig);
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+// Run the OOM plugin in order to free memory
+// Call the COomAction::MemoryFreed when it is done
+void COomRunPlugin::FreeMemory(TInt aBytesRequested, TBool)
+    {
+    FUNC_LOG;
+    TRACES1("COomRunPlugin::FreeMemory: iPluginId = %x", iPluginId);        
+
+    // Ask the plugin to free some memory
+
+    // Do we have a V2 plugin, if so then use it
+    if (iV2Plugin)
+        iV2Plugin->FreeRam(aBytesRequested);
+    else
+        // If we only have a V1 plugin then use that
+        iPlugin.FreeRam();
+    
+    iFreeMemoryCalled = ETrue;
+    
+    // Wait for the required time before we signal completion.
+    __ASSERT_DEBUG(!iPluginWaiter->IsActive(), OomMonitorPanic(KStartingActivePluginWaiter));    
+    iPluginWaiter->Start();
+    }
+
+// Call the memory good function on the plugin but...
+// only if there is an outstanding FreeMemory request
+void COomRunPlugin::MemoryGood()
+    {
+    FUNC_LOG;
+
+    if (iFreeMemoryCalled)
+        {
+        iPlugin.MemoryGood();
+        iFreeMemoryCalled = EFalse;
+        }
+    }
+
+COomRunPlugin::~COomRunPlugin()
+    {
+    FUNC_LOG;
+
+    delete iPluginWaiter;
+    }
+
+COomRunPlugin::COomRunPlugin(TUint aPluginId, COomRunPluginConfig& aConfig, MOomActionObserver& aStateChangeObserver, COomMonitorPlugin& aPlugin, COomMonitorPluginV2* aV2Plugin) : COomAction(aStateChangeObserver), iPluginId(aPluginId), iPlugin(aPlugin), iConfig(aConfig), iV2Plugin(aV2Plugin)
+    {
+    FUNC_LOG;
+    }
+
+void COomRunPlugin::ConstructL(COomRunPluginConfig& aPluginConfig)
+    {
+    FUNC_LOG;
+
+    TInt waitDuration = CMemoryMonitor::GlobalConfig().iDefaultWaitAfterPlugin;
+    
+    if (aPluginConfig.WaitAfterPluginDefined())
+        {
+        // If the wait duration for this plugin is overridden then use the overridden value
+        waitDuration = aPluginConfig.WaitAfterPlugin();
+        }
+    
+    iPluginWaiter = COomPluginWaiter::NewL(waitDuration, *this);
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/src/oomrunpluginconfig.cpp	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,54 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Configuration representation classes for Out of Memory Monitor.
+*
+*/
+
+
+#include "oomrunpluginconfig.h"
+#include "oomwindowgrouplist.h"
+#include "OomTraces.h"
+
+COomRunPluginConfig* COomRunPluginConfig::NewL(TUint aPluginId, TOomPluginType aPluginType)
+    {
+    FUNC_LOG;
+
+    COomRunPluginConfig* self = new (ELeave) COomRunPluginConfig(aPluginId, aPluginType);
+    return self;
+    }
+
+TUint COomRunPluginConfig::CalculatePluginPriority(const COomWindowGroupList& aWindowGroupList)
+    {
+    FUNC_LOG;
+
+    // Call the Priority function on the CActionConfig base class
+    // This function will check if any rules match the current system state and then adjust the priority if they do
+    // Rules may apply to system plugins or application plugins
+    return Priority(aWindowGroupList, aWindowGroupList.GetIndexFromAppId(iTargetAppId));
+    }
+
+
+COomRunPluginConfig::~COomRunPluginConfig()
+    {
+    FUNC_LOG;
+    }
+    
+
+COomRunPluginConfig::COomRunPluginConfig(TUint aPluginId, TOomPluginType aPluginType) : COomActionConfig(aPluginId), iPluginId(aPluginId), iPluginType(aPluginType)
+    {
+    FUNC_LOG;
+
+    iSyncMode = EContinueIgnoreMaxBatchSize;
+    iCallIfTargetAppNotRunning = ETrue;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/src/oomsubscribehelper.cpp	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,96 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Main classes for Out of Memory Monitor.
+*
+*/
+
+#include <e32property.h>
+#include "oomsubscribehelper.h"
+#include "OomTraces.h"
+
+// ---------------------------------------------------------
+//
+// ---------------------------------------------------------
+//
+CSubscribeHelper::CSubscribeHelper(TCallBack aCallBack, RProperty& aProperty)
+    : CActive(EPriorityNormal), iCallBack(aCallBack), iProperty(aProperty)
+    {
+    FUNC_LOG;
+
+    CActiveScheduler::Add(this);
+    }
+
+// ---------------------------------------------------------
+//
+// ---------------------------------------------------------
+//
+CSubscribeHelper::~CSubscribeHelper()
+    {
+    FUNC_LOG;
+
+    Cancel();
+    }
+
+// ---------------------------------------------------------
+//
+// ---------------------------------------------------------
+//
+void CSubscribeHelper::Subscribe()
+    {
+    FUNC_LOG;
+
+    if (!IsActive())
+        {
+        iProperty.Subscribe(iStatus);
+        SetActive();
+        }
+    }
+
+// ---------------------------------------------------------
+//
+// ---------------------------------------------------------
+//
+void CSubscribeHelper::StopSubscribe()
+    {
+    FUNC_LOG;
+
+    Cancel();
+    }
+
+// ---------------------------------------------------------
+//
+// ---------------------------------------------------------
+//
+void CSubscribeHelper::RunL()
+    {
+    FUNC_LOG;
+
+    if (iStatus.Int() == KErrNone)
+        {
+        iCallBack.CallBack();
+        Subscribe();
+        }
+    }
+
+// ---------------------------------------------------------
+//
+// ---------------------------------------------------------
+//
+void CSubscribeHelper::DoCancel()
+    {
+    FUNC_LOG;
+
+    iProperty.Cancel();
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/src/oomwindowgrouplist.cpp	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,480 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  A wrapper for the window group list, adding additional functionality required by OOM Monitor v2.
+*
+*/
+
+#include <w32std.h>
+#include <e32std.h>
+#include <apgtask.h>
+#include <apgwgnam.h>
+
+#include "oomwindowgrouplist.h"
+#include "OomTraces.h"
+#include "oomconstants.hrh"
+#include "oompanic.h"
+
+_LIT(KDummyWgName, "20");
+const TInt KPreallocatedSpaceForAppList = 50;
+
+const TUint KOomTicksPerSecond = 1000;
+
+COomWindowGroupList::TOomWindowGroupProperties::TOomWindowGroupProperties() :  iIdleTickTime(0), iDynamicPriority(EOomPriorityNormal)
+    {
+    FUNC_LOG;
+    }
+
+// Update the list of window groups
+void COomWindowGroupList::Refresh()
+    {
+    FUNC_LOG;
+    
+#ifdef _DEBUG
+    TRAPD(err, RefreshL());
+    if (err)
+        {
+        TRACES1("COomWindowGroupList::Refresh(): RefreshL leave %d", err);
+        }
+#else
+    TRAP_IGNORE(RefreshL());
+    // Ignore any error
+    // Errors are very unlikely, the only possibility is OOM errors (which should be very unlikely due to pre-created, re-reserved lists)
+    // The outcome of any error is that the most foreground operations will be missing from the list
+    // meaning that they will not be considered candidates for closing
+#endif    
+    }
+
+// Update the list of window groups
+// Should be called whenever the 
+void COomWindowGroupList::RefreshL()
+    {
+    FUNC_LOG;
+
+    // Refresh window group list
+    // get all window groups, with info about parents
+    TInt numGroups = iWs.NumWindowGroups(0);
+    iWgIds.ReserveL(numGroups);
+    User::LeaveIfError(iWs.WindowGroupList(0, &iWgIds));
+    
+    // Remove all child window groups, promote parents to foremost child position
+    CollapseWindowGroupTree();
+    
+    // Note the current foreground window ID (if there is one)
+    TBool oldForegroundWindowExists = EFalse;
+
+    TInt oldForegroundWindowId;
+    if (iWgIds.Count() > 0)
+        {
+        oldForegroundWindowId = iWgIds[0].iId;
+        oldForegroundWindowExists = ETrue;
+        }    
+    
+    // Cleanup the idletime hash map to remove idle times for any windows that have closed
+    RemovePropertiesForClosedWindowsL();
+    
+    // Update the idle tick on the old foreground application (which might now be in the background)
+    // This will be set to the current system tick count and will be used later to determine the idle time
+    if (oldForegroundWindowExists)
+        {
+        TOomWindowGroupProperties* wgProperties = iWgToPropertiesMapping.Find(oldForegroundWindowId);
+        if (wgProperties)
+            {
+            wgProperties->iIdleTickTime = User::NTickCount();
+            }
+        
+        // If there is no idle tick entry for this window ID then it will be created in the next step...
+        }
+    
+    TInt index = iWgIds.Count();
+    
+    while (index--)
+        {
+        // See if there is a tick count entry for each window in the list
+        TOomWindowGroupProperties* wgProperties = iWgToPropertiesMapping.Find(iWgIds[index].iId);
+        
+        if (!wgProperties)
+            {
+            TOomWindowGroupProperties wgProperties;
+            wgProperties.iIdleTickTime = User::NTickCount();
+            // If there is no idle tick entry for this window then add one
+            iWgToPropertiesMapping.InsertL(iWgIds[index].iId, wgProperties);
+            }
+        }
+    }
+
+
+
+void COomWindowGroupList::RemovePropertiesForClosedWindowsL()
+    {
+    FUNC_LOG;
+    
+    // First, clear the existing set of window IDs (it would be quicker to delete it BUT we have reserved memory for it and don't want to be allocating in low memory conditions)
+    RHashSet<TInt>::TIter windowIdSetIter(iExistingWindowIds);
+    while (windowIdSetIter.Next())
+        {
+        windowIdSetIter.RemoveCurrent();
+        }
+    
+    // Create the set of existing window IDs (this saves expensive/repeated searching later on)
+    TInt index = iWgIds.Count();
+    while (index--)
+        {
+        iExistingWindowIds.InsertL(iWgIds[index].iId);
+        }
+    
+    // Iterate the idle-time hash map - remove any items where the window no longer exists
+    RHashMap<TInt, TOomWindowGroupProperties>::TIter wgToIdleIterator(iWgToPropertiesMapping);
+    while (wgToIdleIterator.NextKey())
+        {
+        // If the current key (window ID) does not exist in the set then remove the idle-time as it is no longer relevant
+        if (!iExistingWindowIds.Find(*(wgToIdleIterator.CurrentKey())))
+                wgToIdleIterator.RemoveCurrent();
+        }
+    }
+
+
+TUint COomWindowGroupList::AppId(TInt aIndex, TBool aResolveFromThread) const
+    {
+    FUNC_LOG;
+
+    // get the app's details
+    TPtr wgPtr(iWgNameBuf->Des());
+    
+    TUid uid;
+    
+    __ASSERT_DEBUG(aIndex < iWgIds.Count(), OomMonitorPanic(KWindowGroupArrayIndexOutOfBounds));    
+    TInt wgId = iWgIds[aIndex].iId;
+    
+    TInt err = iWs.GetWindowGroupNameFromIdentifier(wgId, wgPtr);
+    
+    if (KErrNone != err)
+        // If there is an error then set the UID to 0;
+        {
+        uid.iUid = 0;
+        }
+    else 
+        {
+        iWgName->SetWindowGroupName(iWgNameBuf); // iWgName takes ownership of iWgNameBuf
+        uid = iWgName->AppUid(); // This UID comes from the app, not the mmp!
+        if (aResolveFromThread && uid.iUid == 0)
+            {
+            TApaTask task(iWs);
+            task.SetWgId(wgId);
+            TThreadId threadId = task.ThreadId();
+            
+            TUint resolvedUid = 0;
+            RThread appThread;
+            TInt err = appThread.Open( threadId );
+            if ( err == KErrNone )
+                {
+                resolvedUid = appThread.SecureId().iId;
+                }
+            appThread.Close();
+            TRACES2("COomWindowGroupList::AppId: NULL wg UID, taking from thread; resolvedUid = %x aIndex = %d", resolvedUid, aIndex);            
+            return resolvedUid;               
+            }
+        }
+    
+    return uid.iUid;
+    }
+    
+
+TTimeIntervalSeconds COomWindowGroupList::IdleTime(TInt aIndex) const
+    {
+    FUNC_LOG;
+
+    TUint32 currentTickCount = User::NTickCount();
+        
+    __ASSERT_DEBUG(aIndex < iWgIds.Count(), OomMonitorPanic(KWindowGroupArrayIndexOutOfBounds));    
+    const TOomWindowGroupProperties* wgProperties = iWgToPropertiesMapping.Find(iWgIds[aIndex].iId);
+    
+    TTimeIntervalSeconds idleTime = 0;
+    
+    if (wgProperties)
+        {
+        // This should also handle the case where the current tick count has wrapped to a lower value than the idle tick time
+        // It will only work if it has wrapped once, but
+        TUint32 differenceBetweenTickCounts = currentTickCount - wgProperties->iIdleTickTime;
+        idleTime = differenceBetweenTickCounts / KOomTicksPerSecond;
+        }
+    
+    return idleTime;
+    }
+  
+
+
+void COomWindowGroupList::CollapseWindowGroupTree()
+    {
+    FUNC_LOG;
+
+    // start from the front, wg count can reduce as loop runs
+    for (TInt ii=0; ii<iWgIds.Count();)
+        {
+        RWsSession::TWindowGroupChainInfo& info = iWgIds[ii];
+        if (info.iParentId > 0)        // wg has a parent
+            {
+            // Look for the parent position
+            TInt parentPos = ii;        // use child pos as not-found signal
+            TInt count = iWgIds.Count();
+            for (TInt jj=0; jj<count; jj++)
+                {
+                if (iWgIds[jj].iId == info.iParentId)
+                    {
+                    parentPos = jj;
+                    break;
+                    }
+                }
+
+            if (parentPos > ii)  // parent should be moved forward
+                {
+                iWgIds[ii] = iWgIds[parentPos];
+                iWgIds.Remove(parentPos);
+                }
+            else if (parentPos < ii)  // parent is already ahead of child, remove child
+                iWgIds.Remove(ii);
+            else                    // parent not found, skip
+                ii++;
+            }
+        else    // wg does not have a parent, skip
+            ii++;
+        }    
+    }
+
+
+
+COomWindowGroupList::COomWindowGroupList(RWsSession& aWs) : iWs(aWs)
+    {
+    FUNC_LOG;
+    }
+
+
+
+void COomWindowGroupList::ConstructL()
+    {
+    FUNC_LOG;
+
+    // Reserve enough space to build an app list later.
+    iWgIds.ReserveL(KPreallocatedSpaceForAppList);
+    iUncollapsedWgIds.ReserveL(KPreallocatedSpaceForAppList);
+    
+    // Reserve enough space for the WG to idle tick mapping
+    iWgToPropertiesMapping.ReserveL(KPreallocatedSpaceForAppList);
+    
+    // Reserve enough space for CApaWindowGroupName.
+    iWgName = CApaWindowGroupName::NewL(iWs);
+    iWgNameBuf = HBufC::NewL(CApaWindowGroupName::EMaxLength);
+    (*iWgNameBuf) = KDummyWgName;
+    iWgName->SetWindowGroupName(iWgNameBuf);    // iWgName takes ownership of iWgNameBuf
+    
+    RefreshL();
+    }
+
+
+
+COomWindowGroupList* COomWindowGroupList::NewL(RWsSession& aWs)
+    {
+    FUNC_LOG;
+
+    COomWindowGroupList* self = new (ELeave) COomWindowGroupList(aWs);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+
+
+COomWindowGroupList::~COomWindowGroupList()
+    {
+    FUNC_LOG;
+
+    iWgIds.Close();
+    iUncollapsedWgIds.Close();
+    iWgToPropertiesMapping.Close();
+    iExistingWindowIds.Close();
+    delete iWgName;
+    }
+
+
+void COomWindowGroupList::SetPriorityBusy(TInt aWgId)
+    {
+    FUNC_LOG;
+
+    Refresh();
+    
+    TInt parentId;
+    TRAPD(err, parentId = FindParentIdL(aWgId));
+    if (err)
+        {
+        parentId = aWgId;
+        }
+    
+    TOomWindowGroupProperties* wgProperties = iWgToPropertiesMapping.Find(parentId);
+    if (wgProperties)
+        {
+        wgProperties->iDynamicPriority = EOomPriorityBusy;
+        }
+    
+    // If we can't find the window group then ignore it
+    }
+
+
+TInt COomWindowGroupList::FindParentIdL(TInt aWgId)
+    {
+    TInt numGroups = iWs.NumWindowGroups(0);
+    iUncollapsedWgIds.ReserveL(numGroups);
+    User::LeaveIfError(iWs.WindowGroupList(0, &iUncollapsedWgIds));
+
+    TInt parentPos = KErrNotFound;
+   
+    //loop through the window group list
+    for (TInt i=0; i<numGroups; i++)
+        {
+        //find the index for the required aWgId
+        __ASSERT_DEBUG(i < iUncollapsedWgIds.Count(), OomMonitorPanic(KWindowGroupArrayIndexOutOfBounds));    
+        if (iUncollapsedWgIds[i].iId == aWgId)
+            {
+            parentPos = i;
+            break;
+            }
+        }
+
+    if (parentPos >=0 )
+        {
+        __ASSERT_DEBUG(parentPos < iUncollapsedWgIds.Count(), OomMonitorPanic(KWindowGroupArrayIndexOutOfBounds));    
+        while (iUncollapsedWgIds[parentPos].iParentId > 0)
+            {
+            // find the index for the parent
+            for (TInt j=0; j<numGroups; j++)
+                {
+                __ASSERT_DEBUG(j < iUncollapsedWgIds.Count(), OomMonitorPanic(KWindowGroupArrayIndexOutOfBounds));    
+                if (iUncollapsedWgIds[j].iId == iUncollapsedWgIds[parentPos].iParentId)
+                    {
+                    parentPos = j;
+                    __ASSERT_DEBUG(parentPos < iUncollapsedWgIds.Count(), OomMonitorPanic(KWindowGroupArrayIndexOutOfBounds));    
+                    break; // break out of inner loop
+                    }
+                }
+            }
+        __ASSERT_DEBUG(parentPos < iUncollapsedWgIds.Count(), OomMonitorPanic(KWindowGroupArrayIndexOutOfBounds));    
+        return iUncollapsedWgIds[parentPos].iId;
+        }
+    else 
+        {
+        return KErrNotFound;
+        }
+    }
+
+
+TBool COomWindowGroupList::IsBusy(TInt aWgIndex)
+    {
+    TBool isBusy = EFalse;
+    __ASSERT_DEBUG(aWgIndex < iWgIds.Count(), OomMonitorPanic(KWindowGroupArrayIndexOutOfBounds));    
+    TOomWindowGroupProperties* wgProperties = iWgToPropertiesMapping.Find(iWgIds[aWgIndex].iId);
+    if (wgProperties)
+        {
+        isBusy = (wgProperties->iDynamicPriority == EOomPriorityBusy);
+        }
+    
+    return isBusy;
+    }
+
+// Returns ETrue if an application has registered itself as high priority at runtime
+TBool COomWindowGroupList::IsDynamicHighPriority(TInt aWgIndex)
+    {
+    FUNC_LOG;
+
+    TBool isHighPriority = EFalse;
+    __ASSERT_DEBUG(aWgIndex < iWgIds.Count(), OomMonitorPanic(KWindowGroupArrayIndexOutOfBounds));    
+    TOomWindowGroupProperties* wgProperties = iWgToPropertiesMapping.Find(iWgIds[aWgIndex].iId);
+    if (wgProperties)
+        {
+        isHighPriority = (wgProperties->iDynamicPriority == EOomPriorityHigh);
+        }
+    
+    return isHighPriority;
+    }
+
+CApaWindowGroupName* COomWindowGroupList::WgName() const
+    {
+    return iWgName;
+    }
+
+void COomWindowGroupList::SetPriorityNormal(TInt aWgId)
+    {
+    FUNC_LOG;
+
+    Refresh();
+    
+    TInt parentId;
+    TRAPD(err, parentId = FindParentIdL(aWgId));
+    if (err)
+        {
+        parentId = aWgId;
+        }
+    
+    TOomWindowGroupProperties* wgProperties = iWgToPropertiesMapping.Find(parentId);
+    if (wgProperties)
+        {
+        wgProperties->iDynamicPriority = EOomPriorityNormal;
+        }
+    
+    // If we can't find the window group then ignore it
+    }
+
+
+void COomWindowGroupList::SetPriorityHigh(TInt aWgId)
+    {
+    FUNC_LOG;
+
+    Refresh();
+
+    TInt parentId;
+    TRAPD(err, parentId = FindParentIdL(aWgId));
+    if (err)
+        {
+        parentId = aWgId;
+        }
+    
+    TOomWindowGroupProperties* wgProperties = iWgToPropertiesMapping.Find(parentId);
+    if (wgProperties)
+        {
+        wgProperties->iDynamicPriority = EOomPriorityHigh;
+        }
+    
+    // If we can't find the window group then ignore it
+    }
+
+// Find the specificed application in the window group list and return the index
+TInt COomWindowGroupList::GetIndexFromAppId(TUint aAppId) const
+    {
+    FUNC_LOG;
+
+    TInt indexInGroupList = Count();
+    TBool appFoundInWindowGroupList = EFalse;
+    
+    while (indexInGroupList--)
+        {
+        if (AppId(indexInGroupList, ETrue) == aAppId)
+            {
+            appFoundInWindowGroupList = ETrue;
+            break;
+            }
+        }
+    
+    if (!appFoundInWindowGroupList)
+        indexInGroupList = KAppNotInWindowGroupList;
+
+    return indexInGroupList;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/src/oomwserveventreceiver.cpp	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,90 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Main classes for Out of Memory Monitor.
+*
+*/
+
+#include <akneiksrvc.h>
+#include <apgwgnam.h>
+#include "oomwserveventreceiver.h"
+#include "oommemorymonitor.h"
+#include "OomTraces.h"
+#include "oomconstants.hrh"
+
+#include "apgwgnam.h"
+
+CWservEventReceiver::CWservEventReceiver(CMemoryMonitor& aMonitor, RWsSession& aWs)
+: CActive(CActive::EPriorityStandard), iMonitor(aMonitor), iWs(aWs), iWg(aWs)
+    {
+    FUNC_LOG;
+
+    CActiveScheduler::Add(this);
+    }
+
+CWservEventReceiver::~CWservEventReceiver()
+    {
+    FUNC_LOG;
+
+    Cancel();
+    iWg.Close();
+    }
+
+void CWservEventReceiver::ConstructL()
+    {
+    FUNC_LOG;
+
+    User::LeaveIfError(iWg.Construct((TUint32)this, EFalse));
+    iWg.SetOrdinalPosition(0, ECoeWinPriorityNeverAtFront);
+    iWg.EnableFocusChangeEvents();
+    Queue();
+    }
+
+void CWservEventReceiver::Queue()
+    {
+    FUNC_LOG;
+
+    iWs.EventReady(&iStatus);
+    SetActive();
+    }
+
+void CWservEventReceiver::DoCancel()
+    {
+    FUNC_LOG;
+
+    iWs.EventReadyCancel();
+    }
+
+void CWservEventReceiver::RunL()
+    {
+    FUNC_LOG;
+
+    TWsEvent event;
+    iWs.GetEvent(event);
+    if (event.Type() == EEventFocusGroupChanged)
+        {
+        // The following is done in order to avoid changing application threshholds when fastswap is activated
+        // 1) get the new focused app's details
+        // 2) we check to see if the fastswap uid caused the change
+        // 3a) If it didn't we proceed as normal: handleFocusedWgChangeL is called
+        // 3b) If not, we skip handleFocusedWgChangeL
+        CApaWindowGroupName* wgName = CApaWindowGroupName::NewLC(iWs, iWs.GetFocusWindowGroup());
+        if(wgName->AppUid() != KUidFastSwap)
+            {
+            iMonitor.HandleFocusedWgChangeL();
+            }
+        CleanupStack::PopAndDestroy(wgName);
+        }
+    
+    Queue();
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/conf/oomtest.cfg	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,3 @@
+[StifSettings]
+CheckHeapBalance= on
+[EndStifSettings]
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/data/oomconfig.xml	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,89 @@
+<!--
+ Copyright (c) 2004-20010 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"
+ which accompanies this distribution, and is available
+ at the URL "http://www.eclipse.org/legal/epl-v10.html".
+
+ Initial Contributors:
+ Nokia Corporation - initial contribution.
+
+ Contributors:
+
+ Description:
+
+-->
+
+
+
+
+<oom_config>
+
+	<global_settings low_ram_threshold="4096" good_ram_threshold="5000" max_app_close_batch="4" default_wait_after_plugin="10" max_app_exit_time="5000">
+		<force_check priority="8"></force_check>
+	</global_settings>
+
+	<app_specific_thresholds>
+		<app uid="E6CFBA08" low_ram_threshold="8192" good_ram_threshold="10000"></app>
+	</app_specific_thresholds>
+
+	<app_close_settings>
+		<close_app uid="DEFAULT_APP" priority="9" sync_mode="check">
+			<app_close_idle_priority idle_time="30" priority="9"></app_close_idle_priority>
+		</close_app>
+
+		<close_app uid="BUSY_APP" priority="NEVER_CLOSE" sync_mode="check"></close_app>
+		<close_app uid="HIGH_PRIORITY_APP" priority="10" sync_mode="check"></close_app>
+
+		<close_app uid="E6CFBA03" priority="7" sync_mode="check">
+			<foreground_app_priority if_foreground_app_id="E6CFBA02" priority="9"></foreground_app_priority>
+		</close_app>
+
+		<close_app uid="E6CFBA02" priority="8" sync_mode="check"></close_app>
+
+		<close_app uid="E6CFBA01" priority="9" sync_mode="check">
+			<app_close_idle_priority idle_time="30" priority="2"></app_close_idle_priority>
+		</close_app>
+
+		<close_app uid="E6CFBA09" priority="7" sync_mode="continue"></close_app>
+		<close_app uid="E6CFBA04" priority="7" sync_mode="check"></close_app>
+		<close_app uid="E6CFBA05" priority="7" sync_mode="check"></close_app>
+		
+		<close_app uid="E6CFBA07" priority="NEVER_CLOSE" sync_mode="check"></close_app>
+		<close_app uid="E6CFBA06" priority="NEVER_CLOSE" sync_mode="check"></close_app>
+		<close_app uid="E6CFBA0A" priority="NEVER_CLOSE" sync_mode="check"></close_app>
+		<close_app uid="101f4cd5" priority="NEVER_CLOSE" sync_mode="check"></close_app><!-- log -->
+		<close_app uid="1028311d" priority="NEVER_CLOSE" sync_mode="check"></close_app><!-- test app 39 for  uishellservices_menucontentservice. related to content harvester panic -->
+		<close_app uid="101f4cd2" priority="NEVER_CLOSE" sync_mode="check"></close_app><!-- application shell menu	-->		
+	</app_close_settings>
+
+
+	<system_plugin_settings>
+		<system_plugin uid="DEFAULT_PLUGIN" priority="10"></system_plugin>
+		<system_plugin uid="10286A34" priority="5"></system_plugin>
+	
+		<system_plugin uid="10286A35" priority="6">
+			<plugin_foreground_app_priority target_app_id="E6CFBA07" priority="9"></plugin_foreground_app_priority>
+		</system_plugin>
+	
+		<system_plugin uid="10286A36" priority="7"></system_plugin>
+		<system_plugin uid="10286A37" priority="8" wait="1000" sync_mode="check"></system_plugin>
+		<system_plugin uid="10286A3C" priority="4"></system_plugin>
+		<system_plugin uid="10286A3D" priority="9"></system_plugin>
+	</system_plugin_settings>
+
+	<app_plugin_settings>
+		<app_plugin uid="10286A3A" target_app_id="E6CFBA02" priority="4" sync_mode="check" call_if_target_app_not_running="false"></app_plugin>
+		<app_plugin uid="10286A3B" target_app_id="E6CFBA03" priority="3" call_if_target_app_not_running="true"></app_plugin>
+		<app_plugin uid="10286A38" target_app_id="E6CFBA03" priority="9" call_if_target_app_not_running="false">
+			<plugin_idle_priority idle_time="30" priority="1"></plugin_idle_priority>
+		</app_plugin>
+
+		<app_plugin uid="10286A39" target_app_id="E6CFBA01" priority="10">
+			<plugin_foreground_app_priority target_app_id="TARGET_APP" priority="1"></plugin_foreground_app_priority>
+		</app_plugin>
+	
+	</app_plugin_settings>
+
+</oom_config>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/group/bld.inf	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,40 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_TESTEXPORTS
+../init/oomtest.ini    /epoc32/winscw/c/testframework/testframework.ini
+../conf/oomtest.cfg    /epoc32/winscw/c/testframework/oomtest.cfg
+../data/oomconfig.xml  /epoc32/release/winscw/udeb/z/private/10207218/oomconfig.xml
+../data/oomconfig.xml  /epoc32/release/winscw/urel/z/private/10207218/oomconfig.xml
+
+PRJ_TESTMMPFILES
+#include "../t_oomallocserver/group/bld.inf"
+#include "../t_oomdummyapp/group/bld.inf"
+#include "../t_oomdummyplugin/group/bld.inf"
+#include "../t_oomdummyplugin2/group/bld.inf"
+//#include "../t_oomharness/group/bld.inf"
+#include "../t_oomtestapp/group/bld.inf"
+#include "../t_oomharness_stif/group/bld.inf"
+
+//  End of File  
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/group/oomtest.pkg	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,68 @@
+;Languages
+&EN
+
+#{"t_oomharness_stif"},(0x101FB3E7),1,0,0,TYPE=SA
+
+;Localised Vendor name
+%{"t_oomharness_stif EN"}
+
+; Vendor name
+: "t_oomharness_stif"
+
+"\epoc32\release\armv5\urel\t_oomharness_stif.dll"-"c:\sys\bin\t_oomharness_stif.dll"
+"..\init\oomtest.ini"-"c:\testframework\oomtest.ini"
+"..\conf\oomtest.cfg"-"c:\testframework\oomtest.cfg"
+;"..\data\oomconfig.xml"-"c:\private\10207218\oomconfig.xml"
+
+"\epoc32\release\armv5\urel\t_oomclient.dll"-"c:\sys\bin\t_oomclient.dll"
+"\epoc32\release\armv5\urel\t_oomallocserver.exe"-"c:\sys\bin\t_oomallocserver.exe"
+
+"\epoc32\release\armv5\urel\t_oomdummyapp_0xE6CFBA00.exe"-"c:\sys\bin\t_oomdummyapp_0xE6CFBA00.exe"
+"\epoc32\data\z\resource\apps\t_oomdummyapp_0xE6CFBA00.rsc"-"c:\resource\apps\t_oomdummyapp_0xE6CFBA00.rsc"
+"\epoc32\data\z\private\10003a3f\apps\t_oomdummyapp_0xE6CFBA00_reg.rsc"-"c:\private\10003a3f\import\apps\t_oomdummyapp_0xE6CFBA00_reg.rsc"
+
+"\epoc32\release\armv5\urel\t_oomdummyplugin.dll"-"c:\sys\bin\t_oomdummyplugin.dll"
+"\epoc32\data\z\resource\plugins\t_oomdummyplugin.rsc"-"c:\resource\plugins\t_oomdummyplugin.rsc"
+
+"\epoc32\release\armv5\urel\t_oomdummyplugin2.dll"-"c:\sys\bin\t_oomdummyplugin2.dll"
+"\epoc32\data\z\resource\plugins\t_oomdummyplugin2.rsc"-"c:\resource\plugins\t_oomdummyplugin2.rsc"
+
+"\epoc32\release\armv5\urel\t_oomtestapp.exe"-"c:\sys\bin\t_oomtestapp.exe"
+"\epoc32\data\z\resource\apps\t_oomtestapp.rsc"-"c:\resource\apps\t_oomtestapp.rsc"
+"\epoc32\data\z\private\10003a3f\apps\t_oomtestapp_reg.rsc"-"c:\private\10003a3f\import\apps\t_oomtestapp_reg.rsc"
+
+"\epoc32\release\armv5\urel\t_oomtestapp2.exe"-"c:\sys\bin\t_oomtestapp2.exe"
+"\epoc32\data\z\resource\apps\t_oomtestapp2.rsc"-"c:\resource\apps\t_oomtestapp2.rsc"
+"\epoc32\data\z\private\10003a3f\apps\t_oomtestapp2_reg.rsc"-"c:\private\10003a3f\import\apps\t_oomtestapp2_reg.rsc"
+
+"\epoc32\release\armv5\urel\t_oomtestapp3.exe"-"c:\sys\bin\t_oomtestapp3.exe"
+"\epoc32\data\z\resource\apps\t_oomtestapp3.rsc"-"c:\resource\apps\t_oomtestapp3.rsc"
+"\epoc32\data\z\private\10003a3f\apps\t_oomtestapp3_reg.rsc"-"c:\private\10003a3f\import\apps\t_oomtestapp3_reg.rsc"
+
+"\epoc32\release\armv5\urel\t_oomtestapp4.exe"-"c:\sys\bin\t_oomtestapp4.exe"
+"\epoc32\data\z\resource\apps\t_oomtestapp4.rsc"-"c:\resource\apps\t_oomtestapp4.rsc"
+"\epoc32\data\z\private\10003a3f\apps\t_oomtestapp4_reg.rsc"-"c:\private\10003a3f\import\apps\t_oomtestapp4_reg.rsc"
+
+"\epoc32\release\armv5\urel\t_oomtestapp5.exe"-"c:\sys\bin\t_oomtestapp5.exe"
+"\epoc32\data\z\resource\apps\t_oomtestapp5.rsc"-"c:\resource\apps\t_oomtestapp5.rsc"
+"\epoc32\data\z\private\10003a3f\apps\t_oomtestapp5_reg.rsc"-"c:\private\10003a3f\import\apps\t_oomtestapp5_reg.rsc"
+
+"\epoc32\release\armv5\urel\t_oomtestapp6.exe"-"c:\sys\bin\t_oomtestapp6.exe"
+"\epoc32\data\z\resource\apps\t_oomtestapp6.rsc"-"c:\resource\apps\t_oomtestapp6.rsc"
+"\epoc32\data\z\private\10003a3f\apps\t_oomtestapp6_reg.rsc"-"c:\private\10003a3f\import\apps\t_oomtestapp6_reg.rsc"
+
+"\epoc32\release\armv5\urel\t_oomtestapp7.exe"-"c:\sys\bin\t_oomtestapp7.exe"
+"\epoc32\data\z\resource\apps\t_oomtestapp7.rsc"-"c:\resource\apps\t_oomtestapp7.rsc"
+"\epoc32\data\z\private\10003a3f\apps\t_oomtestapp7_reg.rsc"-"c:\private\10003a3f\import\apps\t_oomtestapp7_reg.rsc"
+
+"\epoc32\release\armv5\urel\t_oomtestapp8.exe"-"c:\sys\bin\t_oomtestapp8.exe"
+"\epoc32\data\z\resource\apps\t_oomtestapp8.rsc"-"c:\resource\apps\t_oomtestapp8.rsc"
+"\epoc32\data\z\private\10003a3f\apps\t_oomtestapp8_reg.rsc"-"c:\private\10003a3f\import\apps\t_oomtestapp8_reg.rsc"
+
+"\epoc32\release\armv5\urel\t_oomtestapp9.exe"-"c:\sys\bin\t_oomtestapp9.exe"
+"\epoc32\data\z\resource\apps\t_oomtestapp9.rsc"-"c:\resource\apps\t_oomtestapp9.rsc"
+"\epoc32\data\z\private\10003a3f\apps\t_oomtestapp9_reg.rsc"-"c:\private\10003a3f\import\apps\t_oomtestapp9_reg.rsc"
+
+"\epoc32\release\armv5\urel\t_oomtestapp10.exe"-"c:\sys\bin\t_oomtestapp10.exe"
+"\epoc32\data\z\resource\apps\t_oomtestapp10.rsc"-"c:\resource\apps\t_oomtestapp10.rsc"
+"\epoc32\data\z\private\10003a3f\apps\t_oomtestapp10_reg.rsc"-"c:\private\10003a3f\import\apps\t_oomtestapp10_reg.rsc"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/group/oomtest_manualtestrun.pkg	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,68 @@
+;Languages
+&EN
+
+#{"t_oomharness_stif"},(0x101FB3E7),1,0,0,TYPE=SA
+
+;Localised Vendor name
+%{"t_oomharness_stif EN"}
+
+; Vendor name
+: "t_oomharness_stif"
+
+"\epoc32\release\armv5\urel\t_oomharness_stif.dll"-"c:\sys\bin\t_oomharness_stif.dll"
+"..\init\oomtest.ini"-"c:\testframework\oomtest.ini"
+"..\conf\oomtest.cfg"-"c:\testframework\oomtest.cfg"
+"..\data\oomconfig.xml"-"c:\data\oomconfig.xml"
+
+"\epoc32\release\armv5\urel\t_oomclient.dll"-"c:\sys\bin\t_oomclient.dll"
+"\epoc32\release\armv5\urel\t_oomallocserver.exe"-"c:\sys\bin\t_oomallocserver.exe"
+
+"\epoc32\release\armv5\urel\t_oomdummyapp_0xE6CFBA00.exe"-"c:\sys\bin\t_oomdummyapp_0xE6CFBA00.exe"
+"\epoc32\data\z\resource\apps\t_oomdummyapp_0xE6CFBA00.rsc"-"c:\resource\apps\t_oomdummyapp_0xE6CFBA00.rsc"
+"\epoc32\data\z\private\10003a3f\apps\t_oomdummyapp_0xE6CFBA00_reg.rsc"-"c:\private\10003a3f\import\apps\t_oomdummyapp_0xE6CFBA00_reg.rsc"
+
+"\epoc32\release\armv5\urel\t_oomdummyplugin.dll"-"c:\sys\bin\t_oomdummyplugin.dll"
+"\epoc32\data\z\resource\plugins\t_oomdummyplugin.rsc"-"c:\resource\plugins\t_oomdummyplugin.rsc"
+
+"\epoc32\release\armv5\urel\t_oomdummyplugin2.dll"-"c:\sys\bin\t_oomdummyplugin2.dll"
+"\epoc32\data\z\resource\plugins\t_oomdummyplugin2.rsc"-"c:\resource\plugins\t_oomdummyplugin2.rsc"
+
+"\epoc32\release\armv5\urel\t_oomtestapp.exe"-"c:\sys\bin\t_oomtestapp.exe"
+"\epoc32\data\z\resource\apps\t_oomtestapp.rsc"-"c:\resource\apps\t_oomtestapp.rsc"
+"\epoc32\data\z\private\10003a3f\apps\t_oomtestapp_reg.rsc"-"c:\private\10003a3f\import\apps\t_oomtestapp_reg.rsc"
+
+"\epoc32\release\armv5\urel\t_oomtestapp2.exe"-"c:\sys\bin\t_oomtestapp2.exe"
+"\epoc32\data\z\resource\apps\t_oomtestapp2.rsc"-"c:\resource\apps\t_oomtestapp2.rsc"
+"\epoc32\data\z\private\10003a3f\apps\t_oomtestapp2_reg.rsc"-"c:\private\10003a3f\import\apps\t_oomtestapp2_reg.rsc"
+
+"\epoc32\release\armv5\urel\t_oomtestapp3.exe"-"c:\sys\bin\t_oomtestapp3.exe"
+"\epoc32\data\z\resource\apps\t_oomtestapp3.rsc"-"c:\resource\apps\t_oomtestapp3.rsc"
+"\epoc32\data\z\private\10003a3f\apps\t_oomtestapp3_reg.rsc"-"c:\private\10003a3f\import\apps\t_oomtestapp3_reg.rsc"
+
+"\epoc32\release\armv5\urel\t_oomtestapp4.exe"-"c:\sys\bin\t_oomtestapp4.exe"
+"\epoc32\data\z\resource\apps\t_oomtestapp4.rsc"-"c:\resource\apps\t_oomtestapp4.rsc"
+"\epoc32\data\z\private\10003a3f\apps\t_oomtestapp4_reg.rsc"-"c:\private\10003a3f\import\apps\t_oomtestapp4_reg.rsc"
+
+"\epoc32\release\armv5\urel\t_oomtestapp5.exe"-"c:\sys\bin\t_oomtestapp5.exe"
+"\epoc32\data\z\resource\apps\t_oomtestapp5.rsc"-"c:\resource\apps\t_oomtestapp5.rsc"
+"\epoc32\data\z\private\10003a3f\apps\t_oomtestapp5_reg.rsc"-"c:\private\10003a3f\import\apps\t_oomtestapp5_reg.rsc"
+
+"\epoc32\release\armv5\urel\t_oomtestapp6.exe"-"c:\sys\bin\t_oomtestapp6.exe"
+"\epoc32\data\z\resource\apps\t_oomtestapp6.rsc"-"c:\resource\apps\t_oomtestapp6.rsc"
+"\epoc32\data\z\private\10003a3f\apps\t_oomtestapp6_reg.rsc"-"c:\private\10003a3f\import\apps\t_oomtestapp6_reg.rsc"
+
+"\epoc32\release\armv5\urel\t_oomtestapp7.exe"-"c:\sys\bin\t_oomtestapp7.exe"
+"\epoc32\data\z\resource\apps\t_oomtestapp7.rsc"-"c:\resource\apps\t_oomtestapp7.rsc"
+"\epoc32\data\z\private\10003a3f\apps\t_oomtestapp7_reg.rsc"-"c:\private\10003a3f\import\apps\t_oomtestapp7_reg.rsc"
+
+"\epoc32\release\armv5\urel\t_oomtestapp8.exe"-"c:\sys\bin\t_oomtestapp8.exe"
+"\epoc32\data\z\resource\apps\t_oomtestapp8.rsc"-"c:\resource\apps\t_oomtestapp8.rsc"
+"\epoc32\data\z\private\10003a3f\apps\t_oomtestapp8_reg.rsc"-"c:\private\10003a3f\import\apps\t_oomtestapp8_reg.rsc"
+
+"\epoc32\release\armv5\urel\t_oomtestapp9.exe"-"c:\sys\bin\t_oomtestapp9.exe"
+"\epoc32\data\z\resource\apps\t_oomtestapp9.rsc"-"c:\resource\apps\t_oomtestapp9.rsc"
+"\epoc32\data\z\private\10003a3f\apps\t_oomtestapp9_reg.rsc"-"c:\private\10003a3f\import\apps\t_oomtestapp9_reg.rsc"
+
+"\epoc32\release\armv5\urel\t_oomtestapp10.exe"-"c:\sys\bin\t_oomtestapp10.exe"
+"\epoc32\data\z\resource\apps\t_oomtestapp10.rsc"-"c:\resource\apps\t_oomtestapp10.rsc"
+"\epoc32\data\z\private\10003a3f\apps\t_oomtestapp10_reg.rsc"-"c:\private\10003a3f\import\apps\t_oomtestapp10_reg.rsc"
Binary file sysresmonitoring/oommonitor/tsrc/oomtest/group/oomtest_manualtestrun.sis has changed
Binary file sysresmonitoring/oommonitor/tsrc/oomtest/group/oomtest_manualtestrun.sisx has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/group/readme.txt	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,13 @@
+To test in emulator:
+	1) bldmake bldfiles + abld test build 
+	2) start emulator
+	3) run "consoleui" from "eshell"
+
+To test (manually) in HW:
+    1) bldmake bldfiles + abld test build
+    2) create and sign sis from oomtest_manualtestrun.pkg (note that oomtest.pkg is for automated testing)
+    3) install sis into phone
+    4) select OOM test config xml from c:\data\ (use t_oomtestapp -> Options -> Select...)
+    5) reboot phone (config xml is taken in use)
+    6) rename oomtest.ini in c:\testframework to testframework.ini (use FileBrowse)
+    7) run "consoleui" from "eshell"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/init/oomtest.ini	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,173 @@
+#
+# This is STIFTestFramework initialization file
+# Comment lines start with '#'-character.
+# See STIF TestFramework users guide.doc for instructions
+
+# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+# Set following test engine settings:
+#	- Set Test Reporting mode. TestReportMode's possible values are:
+#		+ 'Summary': Summary of the tested test cases.
+#		+ 'Environment': Hardware and software info.
+#		+ 'TestCases': Test case report.
+#		+ 'FullReport': Set of all above ones.
+#		+ Example 'TestReportMode= Summary TestCases'
+#
+# 	- CreateTestReport setting controls report creation mode
+#		+ YES, Test report will created.
+#		+ NO, No Test report.
+#
+# 	- File path indicates the base path of the test report.
+# 	- File name indicates the name of the test report.
+#
+# 	- File format indicates the type of the test report.
+#		+ TXT, Test report file will be txt type, for example 'TestReport.txt'.
+#		+ HTML, Test report will be html type, for example 'TestReport.html'.
+#
+# 	- File output indicates output source of the test report.
+#		+ FILE, Test report logging to file.
+#		+ RDEBUG, Test report logging to using rdebug.
+#
+# 	- File Creation Mode indicates test report overwriting if file exist.
+#		+ OVERWRITE, Overwrites if the Test report file exist.
+#		+ APPEND, Continue logging after the old Test report information if 
+#                 report exist.
+
+[Engine_Defaults]
+
+TestReportMode= FullReport		# Possible values are: 
+					# 'Summary', 'Environment', 'TestCases' or 'FullReport'
+
+CreateTestReport= YES			# Possible values: YES or NO
+
+TestReportFilePath= C:\LOGS\TestFramework\
+TestReportFileName= TestReport
+
+TestReportFormat= TXT			# Possible values: TXT or HTML
+TestReportOutput= FILE			# Possible values: FILE or RDEBUG
+TestReportFileCreationMode= OVERWRITE	# Possible values: OVERWRITE or APPEND
+
+[End_Defaults]
+# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+
+
+
+# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+# Module configurations start
+# Modules are added between module tags
+# tags. Module name is specified after ModuleName= tag, like
+# ModuleName= XXXXXXXXX
+# Modules might have initialisation file, specified as
+# IniFile= YYYYYY
+# Modules might have several configuration files, like
+# TestCaseFile= NormalCases.txt
+# TestCaseFile= SmokeCases.txt
+# TestCaseFile= ManualCases.txt
+
+# (TestCaseFile is synonym for old term ConfigFile)
+
+# Following case specifies demo module settings. Demo module
+# does not read any settings from file, so tags 
+# IniFile and TestCaseFile are not used.
+# In the simplest case it is enough to specify only the
+# name of the test module when adding new test module
+
+[New_Module]
+ModuleName= t_oomharness_stif
+TestCaseFile= c:\testframework\oomtest.cfg
+[End_Module]
+
+
+#Load testmoduleXXX, optionally with initialization file and/or test case files
+#[New_Module]
+#ModuleName= testmodulexxx
+
+#TestModuleXXX used initialization file
+#IniFile= init.txt
+
+#TestModuleXXX used configuration file(s)
+#TestCaseFile= testcases1.cfg
+#TestCaseFile= testcases2.cfg
+#TestCaseFile= manualtestcases.cfg
+
+#[End_Module]
+# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+
+
+
+# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+# Set STIFTestFramework logging overwrite parameters for Logger.
+# 	Hardware and emulator environment logging path and styles can
+# 	be configured from here to overwrite the Logger's implemented values.
+#	
+#	Settings description:
+#	- Indicates option for creation log directory/directories. If log directory/directories
+#         is/are not created by user they will make by software.
+#		+ YES, Create log directory/directories if not allready exist.
+#		+ NO, Log directory/directories not created. Only created one is used.
+#
+#	- Overwrite emulator path setting.
+#		+ Example: If 'EmulatorBasePath= C:\LOGS\TestFramework\' and in code is defined 
+#		           Logger's path 'D:\\LOGS\\Module\\' with those definition the path
+#		           will be 'C:\LOGS\TestFramework\LOGS\Module\'
+#
+#	- Overwrite emulator's logging format.
+#		+ TXT, Log file(s) will be txt type(s), for example 'Module.txt'.
+#		+ HTML, Log file(s) will be html type(s), for example 'Module.html'.
+#
+#	- Overwrited emulator logging output source.
+#		+ FILE, Logging to file(s).
+#		+ RDEBUG, Logging to using rdebug(s).
+#
+#	- Overwrite hardware path setting (Same description as above in emulator path).
+#	- Overwrite hardware's logging format(Same description as above in emulator format).
+#	- Overwrite hardware's logging output source(Same description as above in emulator output).
+#
+#	- File Creation Mode indicates file overwriting if file exist.
+#		+ OVERWRITE, Overwrites if file(s) exist.
+#		+ APPEND, Continue logging after the old logging information if file(s) exist.
+#
+#	- Will thread id include to the log filename.
+#		+ YES, Thread id to log file(s) name, Example filename 'Module_b9.txt'.
+#		+ NO, No thread id to log file(s), Example filename 'Module.txt'.
+#
+#	- Will time stamps include the to log file.
+#		+ YES, Time stamp added to each line in log file(s). Time stamp is 
+#                 for example'12.Nov.2003 115958    LOGGING INFO'
+#		+ NO, No time stamp(s).
+#
+#	- Will line breaks include to the log file.
+#		+ YES, Each logging event includes line break and next log event is in own line.
+#		+ NO, No line break(s).
+#
+#	- Will event ranking include to the log file.
+#		+ YES, Event ranking number added to each line in log file(s). Ranking number 
+#                 depends on environment's tics, for example(includes time stamp also)
+#                 '012   12.Nov.2003 115958    LOGGING INFO'
+#		+ NO, No event ranking.
+#
+
+[Logger_Defaults]
+
+#NOTE: If you want to set Logger using next setting(s) remove comment(s)'#' 
+
+#CreateLogDirectories= YES		# Possible values: YES or NO
+
+#EmulatorBasePath= C:\LOGS\TestFramework\
+#EmulatorFormat= HTML			# Possible values: TXT or HTML
+#EmulatorOutput= FILE			# Possible values: FILE or RDEBUG
+
+#HardwareBasePath= D:\LOGS\TestFramework\
+#HardwareFormat= HTML			# Possible values: TXT or HTML
+#HardwareOutput= FILE			# Possible values: FILE or RDEBUG
+
+#FileCreationMode= OVERWRITE		# Possible values: OVERWRITE or APPEND
+
+#ThreadIdToLogFile= YES			# Possible values: YES or NO
+#WithTimeStamp= YES			# Possible values: YES or NO
+#WithLineBreak= YES			# Possible values: YES or NO
+#WithEventRanking= YES			# Possible values: YES or NO
+
+[End_Logger_Defaults]
+# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+
+# End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/stub/group/bld.inf	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,28 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_TESTEXPORTS
+../../data/oomconfig.xml  /epoc32/data/Z/private/10207218/oomconfig.xml
+
+PRJ_TESTMMPFILES
+
+//  End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomallocserver/bwins/t_oomclientu.def	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,9 @@
+EXPORTS
+	?Configure@ROOMAllocSession@@QAEHVTUid@@III@Z @ 1 NONAME ; int ROOMAllocSession::Configure(class TUid, unsigned int, unsigned int, unsigned int)
+	?Connect@ROOMAllocSession@@QAEHXZ @ 2 NONAME ; int ROOMAllocSession::Connect(void)
+	?MemoryGood@ROOMAllocSession@@QAEHVTUid@@@Z @ 3 NONAME ; int ROOMAllocSession::MemoryGood(class TUid)
+	?MemoryLow@ROOMAllocSession@@QAEHVTUid@@@Z @ 4 NONAME ; int ROOMAllocSession::MemoryLow(class TUid)
+	?Reset@ROOMAllocSession@@QAEHXZ @ 5 NONAME ; int ROOMAllocSession::Reset(void)
+	?StartAllocating@ROOMAllocSession@@QAEHXZ @ 6 NONAME ; int ROOMAllocSession::StartAllocating(void)
+	?StopAllocating@ROOMAllocSession@@QAEHXZ @ 7 NONAME ; int ROOMAllocSession::StopAllocating(void)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomallocserver/clisrc/client.cpp	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,101 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+#include "t_oomclient.h"
+#include "../inc/clientserver.h"
+
+const TInt KServerDefaultMessageSlots = 1; //Number of message slots available per session.
+const TInt KServerRetryCount = 2;
+
+static TInt StartServer()
+//
+// Start the server process. Simultaneous launching
+// of two such processes should be detected when the second one attempts to
+// create the server object, failing with KErrAlreadyExists.
+//
+	{
+	const TUidType serverUid(KNullUid,KNullUid,KServerUid3);
+	RProcess server;
+	TInt r=server.Create(KAllocServerImg,KNullDesC,serverUid);
+	if (r!=KErrNone)
+		return r;
+	TRequestStatus stat;
+	server.Rendezvous(stat);
+	if (stat!=KRequestPending)
+		server.Kill(0);		// abort startup
+	else
+		server.Resume();	// logon OK - start the server
+	User::WaitForRequest(stat);		// wait for start or death
+	// 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
+	r=(server.ExitType()==EExitPanic) ? KErrGeneral : stat.Int();
+	server.Close();
+	return r;
+	}
+
+EXPORT_C TInt ROOMAllocSession::Connect()
+//
+// Connect to the server, attempting to start it if necessary
+//
+	{
+	TInt retry=KServerRetryCount;
+	for (;;)
+		{
+		TInt r=CreateSession(KAllocServerName,TVersion(0,0,0),KServerDefaultMessageSlots);
+		if (r!=KErrNotFound && r!=KErrServerTerminated)
+			return r;
+		if (--retry==0)
+			return r;
+		r=StartServer();
+		if (r!=KErrNone && r!=KErrAlreadyExists)
+			return r;
+		}
+	}
+
+EXPORT_C TInt ROOMAllocSession::Reset()
+	{
+	return SendReceive(EAllocServReset);
+	}
+
+EXPORT_C TInt ROOMAllocSession::StartAllocating()
+	{
+	return SendReceive(EAllocServStart);
+	}
+
+EXPORT_C TInt ROOMAllocSession::StopAllocating()
+	{
+	return SendReceive(EAllocServStop);
+	}
+
+EXPORT_C TInt ROOMAllocSession::MemoryLow(TUid aPlugin)
+	{
+	return SendReceive(EAllocServMemoryLow, TIpcArgs(aPlugin.iUid));
+	}
+
+EXPORT_C TInt ROOMAllocSession::MemoryGood(TUid aPlugin)
+	{
+	return SendReceive(EAllocServMemoryGood, TIpcArgs(aPlugin.iUid));
+	}
+
+EXPORT_C TInt ROOMAllocSession::Configure(TUid aPlugin, TUint aAllocRate, TUint aAllocInitial, TUint aAllocLimit)
+	{
+	return SendReceive(EAllocServConfig,TIpcArgs(aPlugin.iUid, aAllocRate, aAllocInitial, aAllocLimit));
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomallocserver/eabi/t_oomclientu.def	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,9 @@
+EXPORTS
+	_ZN16ROOMAllocSession10MemoryGoodE4TUid @ 1 NONAME
+	_ZN16ROOMAllocSession14StopAllocatingEv @ 2 NONAME
+	_ZN16ROOMAllocSession15StartAllocatingEv @ 3 NONAME
+	_ZN16ROOMAllocSession5ResetEv @ 4 NONAME
+	_ZN16ROOMAllocSession7ConnectEv @ 5 NONAME
+	_ZN16ROOMAllocSession9ConfigureE4TUidjjj @ 6 NONAME
+	_ZN16ROOMAllocSession9MemoryLowE4TUid @ 7 NONAME
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomallocserver/group/bld.inf	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,29 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_TESTMMPFILES
+t_oomallocserver.mmp
+t_oomallocclient.mmp
+
+PRJ_TESTEXPORTS
+../inc/t_oomclient.h ../../inc/t_oomclient.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomallocserver/group/t_oomallocclient.mmp	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,40 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+#include <platform_paths.hrh>
+
+target t_oomclient.dll
+targettype dll
+
+capability ALL -TCB
+
+// This is a SYSTEMINCLUDE macro containing the middleware
+// layer specific include directories
+MW_LAYER_SYSTEMINCLUDE
+
+USERINCLUDE ../inc
+USERINCLUDE ../../inc
+
+//project server
+sourcepath ../clisrc/
+
+source client.cpp
+
+library euser.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomallocserver/group/t_oomallocserver.mmp	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,42 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+#include <platform_paths.hrh>
+
+TARGET		  t_oomallocserver.exe
+TARGETTYPE	  exe
+UID			 0 0x10286A3E
+
+// This is a SYSTEMINCLUDE macro containing the middleware
+// layer specific include directories
+MW_LAYER_SYSTEMINCLUDE
+
+USERINCLUDE ../inc
+USERINCLUDE ../../inc
+
+
+#ifdef ENABLE_ABIV2_MODE
+DEBUGGABLE_UDEBONLY
+#endif
+SOURCEPATH ../srvsrc
+SOURCE server.cpp
+SOURCE CAllocManager.cpp
+
+library euser.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomallocserver/inc/CAllocManager.h	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,131 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+
+#ifndef CALLOCMANAGER_H
+#define CALLOCMANAGER_H
+
+// INCLUDES
+#include <e32std.h>
+#include <e32base.h>
+
+// CLASS DECLARATION
+
+class CAllocSimulation : public CBase
+	{
+public:
+	// Constructors and destructor
+
+	/**
+	 * Destructor.
+	 */
+	~CAllocSimulation();
+
+	/**
+	 * Two-phased constructor.
+	 */
+	static CAllocSimulation* NewL(TInt aAllocLimit, TInt aAllocInitial,
+			TInt aAllocRate, TUint aUid);
+
+	/**
+	 * Two-phased constructor.
+	 */
+	static CAllocSimulation* NewLC(TInt aAllocLimit, TInt aAllocInitial,
+			TInt aAllocRate, TUint aUid);
+
+	void SimulationTick();
+	void SetPaused(TBool aPaused);
+	void FreeMemory();
+	
+	static TBool CompareTo(const TUint *aUid, const CAllocSimulation& aSelf);
+private:
+
+	/**
+	 * Constructor for performing 1st stage construction
+	 */
+	CAllocSimulation(TInt aAllocLimit, TInt aAllocInitial,
+			TInt aAllocRate, TUint aUid);
+
+	/**
+	 * EPOC default constructor for performing 2nd stage construction
+	 */
+	void ConstructL();
+
+	TInt iAllocLimit;
+	TInt iAllocInitial;
+	TInt iAllocRate;
+	TUint iUid;
+	RChunk iChunk;
+	TBool iPaused;
+	TUint iAllocCurrent;
+	};
+
+/**
+ *  CCAllocManager
+ * 
+ */
+class CAllocManager : public CBase
+	{
+public:
+	// Constructors and destructor
+
+	/**
+	 * Destructor.
+	 */
+	~CAllocManager();
+
+	/**
+	 * Two-phased constructor.
+	 */
+	static CAllocManager* NewL();
+
+	/**
+	 * Two-phased constructor.
+	 */
+	static CAllocManager* NewLC();
+
+	TInt Reset();
+	TInt StartAllocating();
+	TInt StopAllocating();
+	void ConfigureL(TUint aPlugin, TUint aAllocRate, TUint aAllocInitial, TUint aAllocLimit);
+	TInt MemoryLow(TUint aPlugin);
+	TInt MemoryGood(TUint aPlugin);
+private:
+
+	/**
+	 * Constructor for performing 1st stage construction
+	 */
+	CAllocManager();
+
+	/**
+	 * EPOC default constructor for performing 2nd stage construction
+	 */
+	void ConstructL();
+
+	static TInt SimulationTickStatic(TAny *aPtr);
+	void SimulationTick();
+
+	TInt FindSimulation(TUint aUid);
+	
+	CPeriodic *iAllocationTimer;
+	RPointerArray<CAllocSimulation> iSimulations;
+	};
+
+#endif // CALLOCMANAGER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomallocserver/inc/clientserver.h	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,52 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+#include <e32base.h>
+
+
+// server name
+
+_LIT(KAllocServerName,"t_oomAllocServer");
+_LIT(KAllocServerImg,"t_oomAllocServer");
+const TUid KServerUid3={0x10286A3E};
+
+// A version must be specifyed when creating a session with the server
+
+const TUint KCountServMajorVersionNumber=0;
+const TUint KCountServMinorVersionNumber=1;
+const TUint KCountServBuildVersionNumber=1;
+
+IMPORT_C TInt StartThread(RThread& aServerThread);
+
+
+// Function codes (opcodes) used in message passing between client and server
+enum TAllocServRqst
+    {
+    EAllocServReset,
+    EAllocServConfig,
+    EAllocServStart,
+    EAllocServStop,
+    EAllocServMemoryLow,
+    EAllocServMemoryGood
+    };
+
+enum TAllocServLeave
+{
+    ENonNumericString = 99
+};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomallocserver/inc/server.h	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,81 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+#include <e32base.h>
+#include "clientserver.h"
+#include "callocmanager.h"
+
+enum TMyPanic
+	{
+	EPanicBadDescriptor,
+	EPanicIllegalFunction,
+	EPanicAlreadyReceiving
+	};
+
+void PanicClient(const RMessagePtr2& aMessage,TMyPanic TMyPanic);
+
+class CShutdown : public CTimer
+	{
+	enum {KMyShutdownDelay=0x200000};	// approx 2s
+public:
+	inline CShutdown();
+	inline void ConstructL();
+	inline void Start();
+private:
+	void RunL();
+	};
+
+class CMyServer : public CServer2
+	{
+public:
+	static CServer2* NewLC();
+	void AddSession();
+	void DropSession();
+	void Send(const TDesC& aMessage);
+	CAllocManager& AllocManager();
+	~CMyServer();
+private:
+	CMyServer();
+	void ConstructL();
+	void DefinePropertiesL();
+	CSession2* NewSessionL(const TVersion& aVersion, const RMessage2& aMessage) const;
+private:
+	TInt iSessionCount;
+	CShutdown iShutdown;
+	CAllocManager *iAllocManager;
+	};
+
+class CMySession : public CSession2
+	{
+public:
+	CMySession();
+	void CreateL();
+	void Send(const TDesC& aMessage);
+private:
+	~CMySession();
+	inline CMyServer& Server();
+	void ServiceL(const RMessage2& aMessage);
+	void ServiceError(const RMessage2& aMessage,TInt aError);
+	inline TBool ReceivePending() const;
+private:
+	RMessagePtr2 iReceiveMsg;
+	TInt iReceiveLen;
+	};
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomallocserver/inc/t_oomclient.h	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,38 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+#ifndef __T_CLIENT_H__
+#define __T_CLIENT_H__
+
+#include <e32std.h>
+
+class ROOMAllocSession : public RSessionBase
+	{
+public:
+	IMPORT_C TInt Connect();
+	IMPORT_C TInt Reset();
+	IMPORT_C TInt StartAllocating();
+	IMPORT_C TInt StopAllocating();
+	IMPORT_C TInt Configure(TUid aPlugin, TUint aAllocRate, TUint aAllocInitial, TUint aAllocLimit);
+	IMPORT_C TInt MemoryLow(TUid aPlugin);
+	IMPORT_C TInt MemoryGood(TUid aPlugin);
+	};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomallocserver/srvsrc/CAllocManager.cpp	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,203 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+#include "CAllocManager.h"
+#include <e32property.h>
+#include "t_oomdummyplugin_properties.h"
+
+const TInt KOneSecond = 1000000;
+
+CAllocManager::CAllocManager()
+	{
+	// No implementation required
+	}
+
+CAllocManager::~CAllocManager()
+	{
+	delete iAllocationTimer;
+	iSimulations.ResetAndDestroy();
+	}
+
+CAllocManager* CAllocManager::NewLC()
+	{
+	CAllocManager* self = new (ELeave) CAllocManager();
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	return self;
+	}
+
+CAllocManager* CAllocManager::NewL()
+	{
+	CAllocManager* self = CAllocManager::NewLC();
+	CleanupStack::Pop(); // self;
+	return self;
+	}
+
+void CAllocManager::ConstructL()
+	{
+	iAllocationTimer = CPeriodic::NewL(CActive::EPriorityStandard);
+	}
+
+TInt CAllocManager::SimulationTickStatic(TAny *aPtr)
+	{
+	((CAllocManager*)aPtr)->SimulationTick();
+	return KErrNone;
+	}
+
+void CAllocManager::SimulationTick()
+	{
+	for(TInt i=iSimulations.Count()-1; i>=0; i--)
+		{
+		iSimulations[i]->SimulationTick();
+		}
+	}
+
+TInt CAllocManager::Reset()
+	{
+	StopAllocating();
+	iSimulations.ResetAndDestroy();
+	return KErrNone;
+	}
+
+TInt CAllocManager::StartAllocating()
+	{
+	iAllocationTimer->Cancel();
+	iAllocationTimer->Start(KOneSecond, KOneSecond, TCallBack(SimulationTickStatic, this));
+	return KErrNone;
+	}
+
+TInt CAllocManager::StopAllocating()
+	{
+	iAllocationTimer->Cancel();
+	return KErrNone;
+	}
+
+void CAllocManager::ConfigureL(TUint aPlugin, TUint aAllocRate, TUint aAllocInitial, TUint aAllocLimit)
+	{
+	TInt sim = FindSimulation(aPlugin);
+	if(sim>=0)
+		{
+		delete iSimulations[sim];
+		iSimulations.Remove(sim);
+		}
+	CAllocSimulation* newsim = CAllocSimulation::NewLC(aAllocLimit, aAllocInitial, aAllocRate, aPlugin);
+	iSimulations.AppendL(newsim);
+	CleanupStack::Pop(newsim);
+	}
+
+TInt CAllocManager::MemoryLow(TUint aPlugin)
+	{
+	TInt sim = FindSimulation(aPlugin);
+	if(sim>=0)
+		{
+		iSimulations[sim]->SetPaused(ETrue);
+		iSimulations[sim]->FreeMemory();
+		return KErrNone;
+		}
+	else return KErrNotFound;
+	}
+
+TInt CAllocManager::MemoryGood(TUint aPlugin)
+	{
+	TInt sim = FindSimulation(aPlugin);
+	if(sim>=0)
+		{
+		iSimulations[sim]->SetPaused(EFalse);
+		return KErrNone;
+		}
+	else return KErrNotFound;
+	}
+
+TInt CAllocManager::FindSimulation(TUint aUid)
+	{
+	return iSimulations.Find<TUint>(aUid, CAllocSimulation::CompareTo);
+	}
+
+CAllocSimulation::CAllocSimulation(TInt aAllocLimit, TInt aAllocInitial,
+		TInt aAllocRate, TUint aUid) : 
+		iAllocLimit(aAllocLimit),
+		iAllocInitial(aAllocInitial),
+		iAllocRate(aAllocRate),
+		iUid(aUid)
+	{
+	// No implementation required
+	}
+
+CAllocSimulation::~CAllocSimulation()
+	{
+	iChunk.Close();
+	}
+
+CAllocSimulation* CAllocSimulation::NewLC(TInt aAllocLimit, TInt aAllocInitial,
+		TInt aAllocRate, TUint aUid)
+	{
+	CAllocSimulation* self = new (ELeave) CAllocSimulation(aAllocLimit, aAllocInitial,
+			aAllocRate, aUid);
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	return self;
+	}
+
+CAllocSimulation* CAllocSimulation::NewL(TInt aAllocLimit, TInt aAllocInitial,
+		TInt aAllocRate, TUint aUid)
+	{
+	CAllocSimulation* self = CAllocSimulation::NewLC(aAllocLimit, aAllocInitial,
+			aAllocRate, aUid);
+	CleanupStack::Pop(); // self;
+	return self;
+	}
+
+void CAllocSimulation::ConstructL()
+	{
+	User::LeaveIfError(iChunk.CreateLocal(iAllocInitial, iAllocLimit));
+	}
+
+void CAllocSimulation::SimulationTick()
+	{
+	if(!iPaused)
+		{
+		TUint allocnext = iAllocCurrent + iAllocRate;
+		if(allocnext < iAllocInitial) allocnext = iAllocInitial;
+		else if(allocnext > iAllocLimit) allocnext = iAllocLimit;
+		if(iAllocCurrent != allocnext && KErrNone == iChunk.Adjust(iAllocCurrent))
+			{
+			iAllocCurrent = allocnext;
+			RProperty::Set(KUidOomPropertyCategory, iUid + KOOMDummyPluginCurrentAllocationBytes, iAllocCurrent);
+			}
+		}
+	}
+
+void CAllocSimulation::SetPaused(TBool aPaused)
+	{
+	iPaused = aPaused;
+	}
+
+void CAllocSimulation::FreeMemory()
+	{
+	iChunk.Adjust(0);
+	iAllocCurrent = 0;
+	RProperty::Set(KUidOomPropertyCategory, iUid + KOOMDummyPluginCurrentAllocationBytes, iAllocCurrent);
+	}
+
+TBool CAllocSimulation::CompareTo(const TUint* aUid, const CAllocSimulation& aSelf)
+	{
+	return *aUid==aSelf.iUid;
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomallocserver/srvsrc/server.cpp	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,277 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+#include "server.h"
+#include <e32property.h>
+#include "t_oomdummyplugin_properties.h"
+
+inline CShutdown::CShutdown()
+	:CTimer(-1)
+	{CActiveScheduler::Add(this);}
+inline void CShutdown::ConstructL()
+	{CTimer::ConstructL();}
+inline void CShutdown::Start()
+	{After(KMyShutdownDelay);}
+
+inline CMyServer::CMyServer()
+	:CServer2(CActive::EPriorityStandard, ESharableSessions)
+	{}
+
+inline CMySession::CMySession()
+	{}
+inline CMyServer& CMySession::Server()
+	{return *static_cast<CMyServer*>(const_cast<CServer2*>(CSession2::Server()));}
+inline TBool CMySession::ReceivePending() const
+	{return !iReceiveMsg.IsNull();}
+
+
+///////////////////////
+
+void CMySession::CreateL()
+//
+// 2nd phase construct for sessions - called by the CServer framework
+//
+	{
+	Server().AddSession();
+	}
+
+CMySession::~CMySession()
+	{
+	Server().DropSession();
+	}
+
+void CMySession::Send(const TDesC& aMessage)
+//
+// Deliver the message to the client, truncating if required
+// If the write fails, panic the client, not the sender
+//
+	{
+	if (ReceivePending())
+		{
+		TPtrC m(aMessage);
+		if (iReceiveLen<aMessage.Length())
+			m.Set(m.Left(iReceiveLen));
+		TInt r=iReceiveMsg.Write(0,m);
+		if (r==KErrNone)
+			iReceiveMsg.Complete(KErrNone);
+		else
+			PanicClient(iReceiveMsg,EPanicBadDescriptor);
+		}
+	}
+
+void CMySession::ServiceL(const RMessage2& aMessage)
+//
+// Handle a client request.
+// Leaving is handled by CMyServer::ServiceError() which reports
+// the error code to the client
+//
+	{
+	switch (aMessage.Function())
+		{
+		case EAllocServReset:
+			aMessage.Complete(Server().AllocManager().Reset());
+			break;
+		case EAllocServConfig:
+			Server().AllocManager().ConfigureL(aMessage.Int0(),
+					aMessage.Int1(), aMessage.Int2(), aMessage.Int3());
+			aMessage.Complete(KErrNone);
+			break;
+		case EAllocServStart:
+			aMessage.Complete(Server().AllocManager().StartAllocating());
+			break;
+		case EAllocServStop:
+			aMessage.Complete(Server().AllocManager().StopAllocating());
+			break;
+		case EAllocServMemoryLow:
+			aMessage.Complete(Server().AllocManager().MemoryLow(aMessage.Int0()));
+			break;
+		case EAllocServMemoryGood:
+			aMessage.Complete(Server().AllocManager().MemoryGood(aMessage.Int0()));
+			break;
+		default:
+			PanicClient(aMessage, EPanicIllegalFunction);
+			break;
+		}
+	}
+
+void CMySession::ServiceError(const RMessage2& aMessage,TInt aError)
+//
+// Handle an error from CMySession::ServiceL()
+// A bad descriptor error implies a badly programmed client, so panic it;
+// otherwise use the default handling (report the error to the client)
+//
+	{
+	if (aError==KErrBadDescriptor)
+		PanicClient(aMessage,EPanicBadDescriptor);
+	CSession2::ServiceError(aMessage,aError);
+	}
+
+void CShutdown::RunL()
+//
+// Initiate server exit when the timer expires
+//
+	{
+	CActiveScheduler::Stop();
+	}
+
+CServer2* CMyServer::NewLC()
+	{
+	CMyServer* self=new(ELeave) CMyServer;
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	return self;
+	}
+
+void CMyServer::ConstructL()
+//
+// 2nd phase construction - ensure the timer and server objects are running
+//
+	{
+	StartL(KAllocServerName);
+	iShutdown.ConstructL();
+	// ensure that the server still exits even if the 1st client fails to connect
+	iShutdown.Start();
+	DefinePropertiesL();
+	iAllocManager = CAllocManager::NewL();
+	}
+
+_LIT_SECURITY_POLICY_PASS(KAlwaysPass);
+
+void CMyServer::DefinePropertiesL()
+	{
+	TInt err;
+	for(TUint i=KUidOOMDummyPluginFirstImplementation;i<=KUidOOMDummyPluginLastImplementation;i++)
+		{
+		err = RProperty::Define(KUidOomPropertyCategory, i + KOOMDummyPluginLowMemoryCount, RProperty::EInt, KAlwaysPass, KAlwaysPass);
+		if(err != KErrNone && err != KErrAlreadyExists) User::Leave(err);
+		err = RProperty::Define(KUidOomPropertyCategory, i + KOOMDummyPluginGoodMemoryCount, RProperty::EInt, KAlwaysPass, KAlwaysPass);
+		if(err != KErrNone && err != KErrAlreadyExists) User::Leave(err);
+		err = RProperty::Define(KUidOomPropertyCategory, i + KOOMDummyPluginCurrentAllocationBytes, RProperty::EInt, KAlwaysPass, KAlwaysPass);
+		if(err != KErrNone && err != KErrAlreadyExists) User::Leave(err);
+		err = RProperty::Define(KUidOomPropertyCategory, i + KOOMDummyPluginBytesRequested, RProperty::EInt, KAlwaysPass, KAlwaysPass);
+		if(err != KErrNone && err != KErrAlreadyExists) User::Leave(err);
+		}
+	}
+
+CSession2* CMyServer::NewSessionL(const TVersion&,const RMessage2&) const
+//
+// Cretae a new client session. This should really check the version number.
+//
+	{
+	return new(ELeave) CMySession();
+	}
+
+void CMyServer::AddSession()
+//
+// A new session is being created
+// Cancel the shutdown timer if it was running
+//
+	{
+	++iSessionCount;
+	iShutdown.Cancel();
+	}
+
+void CMyServer::DropSession()
+//
+// A session is being destroyed
+// Start the shutdown timer if it is the last session.
+//
+	{
+	if (--iSessionCount==0)
+		iShutdown.Start();
+	}
+
+void CMyServer::Send(const TDesC& aMessage)
+//
+// Pass on the signal to all clients
+//
+	{
+	iSessionIter.SetToFirst();
+	CSession2* s;
+	while ((s=iSessionIter++)!=0)
+		static_cast<CMySession*>(s)->Send(aMessage);
+	}
+
+CMyServer::~CMyServer()
+	{
+	delete iAllocManager;
+	}
+
+CAllocManager& CMyServer::AllocManager()
+	{
+	return *iAllocManager;
+	}
+
+void PanicClient(const RMessagePtr2& aMessage,TMyPanic aPanic)
+//
+// RMessage::Panic() also completes the message. This is:
+// (a) important for efficient cleanup within the kernel
+// (b) a problem if the message is completed a second time
+//
+	{
+	_LIT(KPanic,"MyServer");
+	aMessage.Panic(KPanic,aPanic);
+	}
+
+static void RunServerL()
+//
+// Perform all server initialisation, in particular creation of the
+// scheduler and server and then run the scheduler
+//
+	{
+	// naming the server thread after the server helps to debug panics
+	User::LeaveIfError(RThread::RenameMe(KAllocServerName));
+	//
+	// create and install the active scheduler we need
+	CActiveScheduler* s=new(ELeave) CActiveScheduler;
+	CleanupStack::PushL(s);
+	CActiveScheduler::Install(s);
+	//
+	// create the server (leave it on the cleanup stack)
+	CMyServer::NewLC();
+	//
+	// Initialisation complete, now signal the client
+	RProcess::Rendezvous(KErrNone);
+	//
+	// Ready to run
+	CActiveScheduler::Start();
+	//
+	// Cleanup the server and scheduler
+	CleanupStack::PopAndDestroy(2);
+	}
+
+TInt E32Main()
+//
+// Server process entry-point
+//
+	{
+	__UHEAP_MARK;
+	//
+	CTrapCleanup* cleanup=CTrapCleanup::New();
+	TInt r=KErrNoMemory;
+	if (cleanup)
+		{
+		TRAP(r,RunServerL());
+		delete cleanup;
+		}
+	//
+	__UHEAP_MARKEND;
+	return r;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyapp/data/t_oomdummyapp.rls	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,49 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+
+//  LOCALISATION STRINGS
+
+// Caption string for app.
+#define qtn_caption_string "t_oomdummyapp"
+
+// First item in "Options" menu pane
+#define qtn_command1 "Message"
+
+// Second item in "Options" menu pane
+#define qtn_command2 "Message from file"
+
+#define qtn_help "Help"
+
+#define qtn_about "About"
+
+// Third item in "Options" menu pane
+#define qtn_exit "Exit"
+
+// When user requests ECommand1 event, text below is shown.
+#define qtn_command1_text "OOM dummy app"
+
+#define qtn_loc_resource_file_1 "\\resource\\apps\\t_oomdummyapp_0xE6CFBA00"
+
+#define qtn_about_dialog_title "About"
+
+#define qtn_about_dialog_text "t_oomdummyapp Version 1.0.0\n\nAuthor: \n\nSupport: support@mycompany.com\n\n(c) Your copyright notice"
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyapp/data/t_oomdummyapp.rss	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,188 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+//  RESOURCE IDENTIFIER
+NAME T_OO	// 4 letter ID
+
+
+//  INCLUDES
+#include <eikon.rh>
+#include <avkon.rsg>
+#include <avkon.rh>
+#include <appinfo.rh>
+#include "t_oomdummyapp.hrh"
+#include "t_oomdummyapp.rls"
+
+//  RESOURCE DEFINITIONS
+// -----------------------------------------------------------------------------
+//
+//	Define the resource file signature
+//	This resource should be empty.
+//
+// -----------------------------------------------------------------------------
+//
+RESOURCE RSS_SIGNATURE
+	{
+	}
+
+// -----------------------------------------------------------------------------
+//
+//	Default Document Name
+//
+// -----------------------------------------------------------------------------
+//
+RESOURCE TBUF r_default_document_name
+	{
+	buf="T_OO";
+	}
+
+// -----------------------------------------------------------------------------
+//
+//	Define default menu and CBA key.
+//
+// -----------------------------------------------------------------------------
+//
+RESOURCE EIK_APP_INFO
+	{
+	menubar = r_menubar;
+	cba = R_AVKON_SOFTKEYS_OPTIONS_EXIT;
+	}
+
+
+// -----------------------------------------------------------------------------
+//
+//   r_menubar
+//   Main menubar
+//
+// -----------------------------------------------------------------------------
+//
+RESOURCE MENU_BAR r_menubar
+	{
+	titles =
+		{
+		MENU_TITLE { menu_pane = r_menu; }
+		};
+	}
+
+
+// -----------------------------------------------------------------------------
+//
+//   r_menu
+//   Menu for "Options"
+//
+// -----------------------------------------------------------------------------
+//
+RESOURCE MENU_PANE r_menu
+	{
+	items =
+		{
+		// added the new Options menu command here
+		MENU_ITEM
+				{
+				command = ECommand1;
+				txt = qtn_command1;
+				},
+		MENU_ITEM
+				{
+				command = ECommand2;
+				txt = qtn_command2;
+				},
+		MENU_ITEM
+				{
+				command = EHelp;
+				txt = qtn_help;
+				},
+		MENU_ITEM
+				{
+				command = EAbout;
+				txt = qtn_about;
+				},
+		MENU_ITEM
+				{
+				command = EAknSoftkeyExit;
+				txt = qtn_exit;
+				}
+		};
+	}
+
+// -----------------------------------------------------------------------------
+//
+// About dialog resource.
+//
+// -----------------------------------------------------------------------------
+//
+RESOURCE DIALOG r_about_query_dialog
+	{
+	flags = EGeneralQueryFlags | EEikDialogFlagNoBorder | EEikDialogFlagNoShadow;
+	buttons = R_AVKON_SOFTKEYS_OK_EMPTY;
+	items=
+		{
+		DLG_LINE 
+			{
+			type = EAknCtPopupHeadingPane;
+			id = EAknMessageQueryHeaderId;
+			itemflags = EEikDlgItemNonFocusing;
+			control = AVKON_HEADING
+				{
+				};
+			},
+		DLG_LINE
+			{
+			type = EAknCtMessageQuery;
+			id = EAknMessageQueryContentId;
+			control = AVKON_MESSAGE_QUERY
+				{
+				};
+			}
+		};
+	}
+
+
+// -----------------------------------------------------------------------------
+//
+// Resources for messages.
+//
+// -----------------------------------------------------------------------------
+//
+RESOURCE TBUF32 r_caption_string { buf=qtn_caption_string; }
+RESOURCE TBUF32 r_about_dialog_title { buf=qtn_about_dialog_title; }
+RESOURCE TBUF r_about_dialog_text { buf=qtn_about_dialog_text; }
+RESOURCE TBUF r_command1_text { buf=qtn_command1_text; }
+
+
+// ---------------------------------------------------------------------------- 
+//
+// r_localisable_app_info
+//
+// ---------------------------------------------------------------------------- 
+//
+RESOURCE LOCALISABLE_APP_INFO r_localisable_app_info
+	{
+	short_caption = qtn_caption_string;
+	caption_and_icon = 
+	CAPTION_AND_ICON_INFO
+		{
+		caption = qtn_caption_string;
+
+		number_of_icons = 1;
+		icon_file = "\\resource\\apps\\t_oomdummyapp_0xE6CFBA00.mif";
+		};
+	}
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyapp/data/t_oomdummyapp_reg.rss	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,38 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+#include "t_oomdummyapp.hrh"
+#include "t_oomdummyapp.rls"
+#include <appinfo.rh>
+#include <t_oomdummyapp_0xE6CFBA00.rsg>
+
+UID2 KUidAppRegistrationResourceFile
+UID3 _UID3
+
+RESOURCE APP_REGISTRATION_INFO
+	{
+	app_file="t_oomdummyapp_0xE6CFBA00";
+	localisable_resource_file =  qtn_loc_resource_file_1;
+	localisable_resource_id = R_LOCALISABLE_APP_INFO;
+
+	embeddability=KAppNotEmbeddable;
+	newfile=KAppDoesNotSupportNewFile;
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyapp/gfx/qgn_menu_t_oomdummyapp.svg	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1 Tiny//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11-tiny.dtd">
+<svg baseProfile="tiny" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="100%" height="100%" viewBox="0 0 88 87.999">
+<g>
+<g>
+<g>
+<g>
+<rect fill="none" width="88" height="87.999"/>
+</g>
+</g>
+<g>
+<linearGradient id="XMLID_7_" gradientUnits="userSpaceOnUse" x1="12.3042" y1="18.3799" x2="63.4113" y2="79.287">
+<stop offset="0" style="stop-color:#B3DDFF"/>
+<stop offset="0.8146" style="stop-color:#084296"/>
+<stop offset="1" style="stop-color:#084296"/>
+</linearGradient>
+<path fill="url(#XMLID_7_)" d="M32.135,7.415L14.363,17.432v23.167c0,0,8.926,15.351,10.468,18.001       c-2.386,1.704-15.44,11.03-15.44,11.03l21.613,12.652c0,0,12.907-9.85,14.71-11.226c1.979,1.109,16.231,9.101,16.231,9.101       l16.664-15.132c0,0-14.066-6.929-16.888-8.318c1.467-3.01,10.531-21.604,10.531-21.604l-22.298-9.59       c0,0-1.486,3.173-2.093,4.467c-2.046-0.88-6.573-2.826-6.573-2.826s-3.713,2.463-5.696,3.778       c-0.327-0.744-0.542-1.233-0.657-1.495c0.007-0.824,0.213-23.72,0.213-23.72L32.135,7.415z"/>
+<linearGradient id="XMLID_8_" gradientUnits="userSpaceOnUse" x1="40.8276" y1="52.1914" x2="16.1997" y2="21.1353">
+<stop offset="0" style="stop-color:#5AA7E0"/>
+<stop offset="1" style="stop-color:#3366CC"/>
+</linearGradient>
+<polygon fill="url(#XMLID_8_)" points="59.051,57.621 69.536,36.111 50.944,28.115 48.852,32.581 41.493,29.418 34.719,33.911        32.932,29.849 33.117,9.157 16.363,18.601 16.363,40.06 27.476,59.169 13.064,69.463 30.856,79.879 45.546,68.669        61.667,77.708 75.089,65.521 "/>
+<linearGradient id="XMLID_9_" gradientUnits="userSpaceOnUse" x1="60.585" y1="31.876" x2="53.8582" y2="45.1125">
+<stop offset="0" style="stop-color:#5AA7E0"/>
+<stop offset="1" style="stop-color:#3366CC"/>
+</linearGradient>
+<polygon fill="url(#XMLID_9_)" points="41.26,48.783 50.944,28.115 69.536,36.111 59.051,57.621 "/>
+<polygon fill="#0046B7" points="16.363,40.06 27.476,59.169 41.26,48.783 32.932,29.849 "/>
+<polygon fill="#3366CC" points="16.363,40.06 16.363,18.601 33.117,9.157 32.932,29.849 "/>
+<polygon fill="#CFECFF" points="26.696,39.23 41.493,29.418 59.523,37.168 45.546,47.954 "/>
+<path fill="#5AA7E0" d="M41.954,55.286"/>
+<polygon fill="#3366CC" points="26.696,39.23 27.476,59.169 45.546,68.669 45.546,47.954 "/>
+<polygon fill="#5AA7E0" points="13.064,69.463 27.476,59.169 45.546,68.669 30.856,79.879 "/>
+<linearGradient id="XMLID_10_" gradientUnits="userSpaceOnUse" x1="29.2085" y1="63.6836" x2="48.7102" y2="56.1976">
+<stop offset="0" style="stop-color:#5AA7E0"/>
+<stop offset="0.0056" style="stop-color:#5AA7E0"/>
+<stop offset="0.85" style="stop-color:#3366CC"/>
+<stop offset="1" style="stop-color:#3366CC"/>
+</linearGradient>
+<polygon fill="url(#XMLID_10_)" points="43.423,46.971 27.476,59.169 45.546,68.669 45.546,47.954 "/>
+<polygon fill="#0046B7" points="45.546,47.954 45.546,68.669 59.051,57.621 59.523,37.168 "/>
+<linearGradient id="XMLID_11_" gradientUnits="userSpaceOnUse" x1="45.3936" y1="59.5186" x2="59.0508" y2="59.5186">
+<stop offset="0" style="stop-color:#0046B7"/>
+<stop offset="1" style="stop-color:#3366CC"/>
+</linearGradient>
+<polygon fill="url(#XMLID_11_)" points="45.394,50.368 45.546,68.669 59.051,57.621 "/>
+<linearGradient id="XMLID_12_" gradientUnits="userSpaceOnUse" x1="60.8945" y1="68.6807" x2="57.2953" y2="58.792">
+<stop offset="0" style="stop-color:#5AA7E0"/>
+<stop offset="0.4101" style="stop-color:#5AA7E0"/>
+<stop offset="1" style="stop-color:#3366CC"/>
+</linearGradient>
+<polygon fill="url(#XMLID_12_)" points="61.667,77.708 45.546,68.669 59.051,57.621 75.089,65.521 "/>
+</g>
+</g>
+</g>
+</svg>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyapp/group/Icons_scalable_dc.mk	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,54 @@
+# ============================================================================
+#  Name	 : Icons_scalable_dc.mk
+#  Part of  : t_oomdummyapp
+#
+#  Description: This is file for creating .mif file (scalable icon)
+# 
+# ============================================================================
+
+
+ifeq (WINS,$(findstring WINS, $(PLATFORM)))
+ZDIR=$(EPOCROOT)epoc32\release\$(PLATFORM)\$(CFG)\Z
+else
+ZDIR=$(EPOCROOT)epoc32\data\z
+endif
+
+TARGETDIR=$(ZDIR)\resource\apps
+ICONTARGETFILENAME=$(TARGETDIR)\t_oomdummyapp_0xE6CFBA00.mif
+
+ICONDIR=..\gfx
+
+do_nothing :
+	@rem do_nothing
+
+MAKMAKE : do_nothing
+
+BLD : do_nothing
+
+CLEAN : do_nothing
+
+LIB : do_nothing
+
+CLEANLIB : do_nothing
+
+# ----------------------------------------------------------------------------
+# NOTE: if you have JUSTINTIME enabled for your S60 3rd FP1 or newer SDK
+# and this command crashes, consider adding "/X" to the command line.
+# See <http://forum.nokia.com/document/Forum_Nokia_Technical_Library_v1_35/contents/FNTL/Build_process_fails_at_mif_file_creation_in_S60_3rd_Ed_FP1_SDK.htm>
+# ----------------------------------------------------------------------------
+
+RESOURCE : $(ICONTARGETFILENAME)
+
+$(ICONTARGETFILENAME) : $(ICONDIR)\qgn_menu_t_oomdummyapp.svg
+	mifconv $(ICONTARGETFILENAME) \
+		/c32 $(ICONDIR)\qgn_menu_t_oomdummyapp.svg
+
+FREEZE : do_nothing
+
+SAVESPACE : do_nothing
+
+RELEASABLES :
+	@echo $(ICONTARGETFILENAME)
+
+FINAL : do_nothing
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyapp/group/bld.inf	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,29 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_TESTMMPFILES
+
+gnumakefile icons_scalable_dc.mk
+
+t_oomdummyapp.mmp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyapp/group/t_oomdummyapp.mmp	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,81 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+#include <platform_paths.hrh>
+
+TARGET			t_oomdummyapp_0xE6CFBA00.exe
+TARGETTYPE		exe
+UID		  0x100039CE 0xE6CFBA00
+
+// This is a SYSTEMINCLUDE macro containing the middleware
+// layer specific include directories
+MW_LAYER_SYSTEMINCLUDE
+
+SOURCEPATH		../src
+SOURCE			t_oomdummyapp.cpp
+SOURCE			t_oomdummyappApplication.cpp
+SOURCE			t_oomdummyappAppView.cpp
+SOURCE			t_oomdummyappAppUi.cpp
+SOURCE			t_oomdummyappDocument.cpp
+SOURCE			CMsgHandler.cpp
+
+SOURCEPATH		../data
+
+START RESOURCE	t_oomdummyapp.rss
+HEADER
+TARGET t_oomdummyapp_0xE6CFBA00
+TARGETPATH resource/apps
+END //RESOURCE
+
+START RESOURCE	t_oomdummyapp_reg.rss
+TARGET t_oomdummyapp_0xE6CFBA00_reg
+TARGETPATH 	  /private/10003a3f/apps
+END //RESOURCE
+
+USERINCLUDE	   ../inc
+USERINCLUDE    ../../inc
+USERINCLUDE    ../help
+
+LIBRARY		   euser.lib
+LIBRARY		   apparc.lib
+LIBRARY		   cone.lib
+LIBRARY		   eikcore.lib
+LIBRARY		   avkon.lib
+LIBRARY		   commonengine.lib
+LIBRARY		   efsrv.lib 
+LIBRARY		   estor.lib
+LIBRARY        aknnotify.lib
+LIBRARY        hlplch.lib 
+LIBRARY        oommonitor.lib
+
+LANG SC
+
+VENDORID	  	  0
+SECUREID		  0xE6CFBA00
+CAPABILITY	  	  ReadUserData WriteDeviceData
+
+#ifdef ENABLE_ABIV2_MODE
+  DEBUGGABLE_UDEBONLY
+#endif
+
+EPOCHEAPSIZE	0x1000 0x1000000
+EPOCSTACKSIZE   0x4000
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyapp/help/Custom.xml	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,18 @@
+<?xml version="1.0"?>
+<!DOCTYPE cshcust SYSTEM "/cshlpcmp/dtd/CSHcust.dtd">
+<?xml:stylesheet href="/cshlpcmp/xsl/cshcust.xsl" title="CS-Help customization" type="text/xsl"?>
+<cshcust>
+<parastyle name="body" font="sansserif" size="10"/>
+<parastyle name="tip" font="sansserif" size="10" left="20"></parastyle>
+<parastyle name="note" font="sansserif" size="10" left="20"></parastyle>
+<parastyle name="important" font="sansserif" size="10" left="20"></parastyle>
+<body style="body"/>
+<titlestyle fontstyle="sansserif" size="10"/>
+<listbullet1style bulletchar="8226"/>
+<listbullet2style bulletchar="8226"/>
+<lists leftindent="20"/>
+</cshcust>
+
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyapp/help/build_help.mk	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,45 @@
+# ============================================================================
+#  Name	 : build_help.mk
+#  Part of  : t_oomdummyapp
+# ============================================================================
+#  Name	 : build_help.mk
+#  Part of  : t_oomdummyapp
+#
+#  Description: This make file will build the application help file (.hlp)
+# 
+# ============================================================================
+
+do_nothing :
+	@rem do_nothing
+
+# build the help from the MAKMAKE step so the header file generated
+# will be found by cpp.exe when calculating the dependency information
+# in the mmp makefiles.
+
+MAKMAKE : t_oomdummyapp_0xE6CFBA00.hlp
+t_oomdummyapp_0xE6CFBA00.hlp : t_oomdummyapp.xml t_oomdummyapp.cshlp Custom.xml
+	cshlpcmp t_oomdummyapp.cshlp
+ifeq (WINS,$(findstring WINS, $(PLATFORM)))
+	copy t_oomdummyapp_0xE6CFBA00.hlp $(EPOCROOT)epoc32\$(PLATFORM)\c\resource\help
+endif
+
+BLD : do_nothing
+
+CLEAN :
+	del t_oomdummyapp_0xE6CFBA00.hlp
+	del t_oomdummyapp_0xE6CFBA00.hlp.hrh
+
+LIB : do_nothing
+
+CLEANLIB : do_nothing
+
+RESOURCE : do_nothing
+		
+FREEZE : do_nothing
+
+SAVESPACE : do_nothing
+
+RELEASABLES :
+	@echo t_oomdummyapp_0xE6CFBA00.hlp
+
+FINAL : do_nothing
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyapp/help/t_oomdummyapp.cshlp	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,19 @@
+<?xml version="1.0"?>
+<!DOCTYPE cshproj SYSTEM "/epoc32/tools/cshlpcmp/dtd/cshproj.dtd">
+<?xml:stylesheet href="/epoc32/tools/cshlpcmp/xsl/CSHproj.xsl" title="CS-Help project" type="text/xsl"?>
+<cshproj>
+<helpfileUID>0xE6CFBA00</helpfileUID>
+<directories>
+	<input></input>
+	<output></output>
+	<graphics></graphics>
+	<working>temp\</working>
+</directories>
+<files>
+	<source>
+	<xmlfile>t_oomdummyapp.xml</xmlfile>
+	</source>
+	<destination>t_oomdummyapp_0xE6CFBA00.hlp</destination>
+	<customization>custom.xml</customization>
+	</files>
+</cshproj>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyapp/help/t_oomdummyapp.xml	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,13 @@
+<?xml version="1.0"?>
+<!DOCTYPE asptml SYSTEM "/epoc32/tools/cshlpcmp/dtd/asptml.dtd">
+<?xml:stylesheet href="/epoc32/tools/cshlpcmp/xsl/asptml.xsl" title="asptml" type="text/xsl"?>
+<asptml>
+<uid value="0xE6CFBA00"/>
+<topic><category>t_oomdummyapp</category><topictitle>General Information</topictitle>
+<synonyms>General Information</synonyms>
+<context contextUID="General_Information"/>
+<index>General Information</index>
+<p>Insert your help here.</p>
+<p></p>
+</topic>
+</asptml>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyapp/inc/CMsgHandler.h	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,71 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+#ifndef CMSGHANDLER_H
+#define CMSGHANDLER_H
+
+#include <e32base.h>	// For CActive, link against: euser.lib
+#include <e32msgqueue.h>
+#include "t_oomdummyappAppUi.h"
+
+class CMsgHandler : public CActive
+	{
+public:
+	// Cancel and destroy
+	~CMsgHandler();
+
+	// Two-phased constructor.
+	static CMsgHandler* NewL(Ct_oomdummyappAppUi& aOwner);
+
+	// Two-phased constructor.
+	static CMsgHandler* NewLC(Ct_oomdummyappAppUi& aOwner);
+
+public:
+	// New functions
+	// Function for making the initial request
+	void StartL();
+
+private:
+	// C++ constructor
+	CMsgHandler(Ct_oomdummyappAppUi& aOwner);
+
+	// Second-phase constructor
+	void ConstructL();
+
+private:
+	// From CActive
+	// Handle completion
+	void RunL();
+
+	// How to cancel me
+	void DoCancel();
+
+	// Override to handle leaves from RunL(). Default implementation causes
+	// the active scheduler to panic.
+	TInt RunError(TInt aError);
+
+private:
+	TInt iState; // State of the active object
+	RMsgQueue<TInt> iMsgQueue; // messages from the harness
+	Ct_oomdummyappAppUi& iOwner;
+
+	};
+
+#endif // CMSGHANDLER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyapp/inc/t_oomdummyapp.hrh	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,35 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+#ifndef __T_OOMDUMMYAPP_HRH__
+#define __T_OOMDUMMYAPP_HRH__
+
+#define _UID3 0xE6CFBA00
+
+// t_oomdummyapp enumerate command codes
+enum Tt_oomdummyappIds
+	{
+	ECommand1 = 0x6001, // start value must not be 0
+	ECommand2,
+	EHelp,
+	EAbout
+	};
+
+#endif // __T_OOMDUMMYAPP_HRH__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyapp/inc/t_oomdummyapp.pan	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,37 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+#ifndef __T_OOMDUMMYAPP_PAN__
+#define __T_OOMDUMMYAPP_PAN__
+
+/** t_oomdummyapp application panic codes */
+enum Tt_oomdummyappPanics
+	{
+	Et_oomdummyappUi = 1
+	// add further panics here
+	};
+
+inline void Panic(Tt_oomdummyappPanics aReason)
+	{
+	_LIT(applicationName, "t_oomdummyapp");
+	User::Panic(applicationName, aReason);
+	}
+
+#endif // __T_OOMDUMMYAPP_PAN__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyapp/inc/t_oomdummyappAppUi.h	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,104 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+#ifndef __T_OOMDUMMYAPPAPPUI_h__
+#define __T_OOMDUMMYAPPAPPUI_h__
+
+// INCLUDES
+#include <aknappui.h>
+
+// FORWARD DECLARATIONS
+class Ct_oomdummyappAppView;
+class CMsgHandler;
+
+// CLASS DECLARATION
+/**
+ * Ct_oomdummyappAppUi application UI class.
+ * Interacts with the user through the UI and request message processing
+ * from the handler class
+ */
+class Ct_oomdummyappAppUi : public CAknAppUi
+	{
+public:
+	
+	void SetPriorityBusy();
+	void SetPriorityHigh();
+	void SetPriorityNormal();
+	
+	// Constructors and destructor
+
+	/**
+	 * ConstructL.
+	 * 2nd phase constructor.
+	 */
+	void ConstructL();
+
+	/**
+	 * Ct_oomdummyappAppUi.
+	 * C++ default constructor. This needs to be public due to
+	 * the way the framework constructs the AppUi
+	 */
+	Ct_oomdummyappAppUi();
+
+	/**
+	 * ~Ct_oomdummyappAppUi.
+	 * Virtual Destructor.
+	 */
+	virtual ~Ct_oomdummyappAppUi();
+
+	void HandleHarnessCommandL(TInt aCommand);
+private:
+	// Functions from base classes
+
+	/**
+	 * From CEikAppUi, HandleCommandL.
+	 * Takes care of command handling.
+	 * @param aCommand Command to be handled.
+	 */
+	void HandleCommandL(TInt aCommand);
+
+	/**
+	 *  HandleStatusPaneSizeChange.
+	 *  Called by the framework when the application status pane
+	 *  size is changed.
+	 */
+	void HandleStatusPaneSizeChange();
+
+	/**
+	 *  From CCoeAppUi, HelpContextL.
+	 *  Provides help context for the application.
+	 *  size is changed.
+	 */
+	CArrayFix<TCoeHelpContext>* HelpContextL() const;
+
+private:
+	// Data
+
+	/**
+	 * The application view
+	 * Owned by Ct_oomdummyappAppUi
+	 */
+	Ct_oomdummyappAppView* iAppView;
+	CMsgHandler* iMsgHandler;
+
+	};
+
+#endif // __T_OOMDUMMYAPPAPPUI_h__
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyapp/inc/t_oomdummyappAppView.h	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,95 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+#ifndef __T_OOMDUMMYAPPAPPVIEW_h__
+#define __T_OOMDUMMYAPPAPPVIEW_h__
+
+// INCLUDES
+#include <coecntrl.h>
+
+// CLASS DECLARATION
+class Ct_oomdummyappAppView : public CCoeControl
+	{
+public:
+	// New methods
+
+	/**
+	 * NewL.
+	 * Two-phased constructor.
+	 * Create a Ct_oomdummyappAppView object, which will draw itself to aRect.
+	 * @param aRect The rectangle this view will be drawn to.
+	 * @return a pointer to the created instance of Ct_oomdummyappAppView.
+	 */
+	static Ct_oomdummyappAppView* NewL(const TRect& aRect);
+
+	/**
+	 * NewLC.
+	 * Two-phased constructor.
+	 * Create a Ct_oomdummyappAppView object, which will draw itself
+	 * to aRect.
+	 * @param aRect Rectangle this view will be drawn to.
+	 * @return A pointer to the created instance of Ct_oomdummyappAppView.
+	 */
+	static Ct_oomdummyappAppView* NewLC(const TRect& aRect);
+
+	/**
+	 * ~Ct_oomdummyappAppView
+	 * Virtual Destructor.
+	 */
+	virtual ~Ct_oomdummyappAppView();
+
+public:
+	// Functions from base classes
+
+	/**
+	 * From CCoeControl, Draw
+	 * Draw this Ct_oomdummyappAppView to the screen.
+	 * @param aRect the rectangle of this view that needs updating
+	 */
+	void Draw(const TRect& aRect) const;
+
+	/**
+	 * From CoeControl, SizeChanged.
+	 * Called by framework when the view size is changed.
+	 */
+	virtual void SizeChanged();
+
+private:
+	// Constructors
+
+	/**
+	 * ConstructL
+	 * 2nd phase constructor.
+	 * Perform the second phase construction of a
+	 * Ct_oomdummyappAppView object.
+	 * @param aRect The rectangle this view will be drawn to.
+	 */
+	void ConstructL(const TRect& aRect);
+
+	/**
+	 * Ct_oomdummyappAppView.
+	 * C++ default constructor.
+	 */
+	Ct_oomdummyappAppView();
+
+	};
+
+#endif // __T_OOMDUMMYAPPAPPVIEW_h__
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyapp/inc/t_oomdummyappApplication.h	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,74 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+#ifndef __T_OOMDUMMYAPPAPPLICATION_H__
+#define __T_OOMDUMMYAPPAPPLICATION_H__
+
+// INCLUDES
+#include <aknapp.h>
+#include "t_oomdummyapp.hrh"
+
+// UID for the application;
+// this should correspond to the uid defined in the mmp file
+const TUid KUidt_oomdummyappApp =
+	{
+	_UID3
+	};
+
+// CLASS DECLARATION
+
+/**
+ * Ct_oomdummyappApplication application class.
+ * Provides factory to create concrete document object.
+ * An instance of Ct_oomdummyappApplication is the application part of the
+ * AVKON application framework for the t_oomdummyapp example application.
+ */
+class Ct_oomdummyappApplication : public CAknApplication
+	{
+public:
+	Ct_oomdummyappApplication(TUid aUid, TUint aAlloc);
+	// Functions from base classes
+
+	/**
+	 * From CApaApplication, AppDllUid.
+	 * @return Application's UID (KUidt_oomdummyappApp).
+	 */
+	TUid AppDllUid() const;
+
+	~Ct_oomdummyappApplication();
+protected:
+	// Functions from base classes
+
+	/**
+	 * From CApaApplication, CreateDocumentL.
+	 * Creates Ct_oomdummyappDocument document object. The returned
+	 * pointer in not owned by the Ct_oomdummyappApplication object.
+	 * @return A pointer to the created document object.
+	 */
+	CApaDocument* CreateDocumentL();
+	
+private:
+	TUid iUID;
+	TUint iAlloc;
+	TAny* iMemory;
+	};
+
+#endif // __T_OOMDUMMYAPPAPPLICATION_H__
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyapp/inc/t_oomdummyappDocument.h	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,102 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+#ifndef __T_OOMDUMMYAPPDOCUMENT_h__
+#define __T_OOMDUMMYAPPDOCUMENT_h__
+
+// INCLUDES
+#include <akndoc.h>
+
+// FORWARD DECLARATIONS
+class Ct_oomdummyappAppUi;
+class CEikApplication;
+
+// CLASS DECLARATION
+
+/**
+ * Ct_oomdummyappDocument application class.
+ * An instance of class Ct_oomdummyappDocument is the Document part of the
+ * AVKON application framework for the t_oomdummyapp example application.
+ */
+class Ct_oomdummyappDocument : public CAknDocument
+	{
+public:
+	// Constructors and destructor
+
+	/**
+	 * NewL.
+	 * Two-phased constructor.
+	 * Construct a Ct_oomdummyappDocument for the AVKON application aApp
+	 * using two phase construction, and return a pointer
+	 * to the created object.
+	 * @param aApp Application creating this document.
+	 * @return A pointer to the created instance of Ct_oomdummyappDocument.
+	 */
+	static Ct_oomdummyappDocument* NewL(CEikApplication& aApp);
+
+	/**
+	 * NewLC.
+	 * Two-phased constructor.
+	 * Construct a Ct_oomdummyappDocument for the AVKON application aApp
+	 * using two phase construction, and return a pointer
+	 * to the created object.
+	 * @param aApp Application creating this document.
+	 * @return A pointer to the created instance of Ct_oomdummyappDocument.
+	 */
+	static Ct_oomdummyappDocument* NewLC(CEikApplication& aApp);
+
+	/**
+	 * ~Ct_oomdummyappDocument
+	 * Virtual Destructor.
+	 */
+	virtual ~Ct_oomdummyappDocument();
+
+public:
+	// Functions from base classes
+
+	/**
+	 * CreateAppUiL
+	 * From CEikDocument, CreateAppUiL.
+	 * Create a Ct_oomdummyappAppUi object and return a pointer to it.
+	 * The object returned is owned by the Uikon framework.
+	 * @return Pointer to created instance of AppUi.
+	 */
+	CEikAppUi* CreateAppUiL();
+
+private:
+	// Constructors
+
+	/**
+	 * ConstructL
+	 * 2nd phase constructor.
+	 */
+	void ConstructL();
+
+	/**
+	 * Ct_oomdummyappDocument.
+	 * C++ default constructor.
+	 * @param aApp Application creating this document.
+	 */
+	Ct_oomdummyappDocument(CEikApplication& aApp);
+
+	};
+
+#endif // __T_OOMDUMMYAPPDOCUMENT_h__
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyapp/inc/t_oomdummyappmsgs.h	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,8 @@
+#ifndef T_OOMDUMMAPPMSGS_H_
+#define T_OOMDUMMAPPMSGS_H_
+
+const TInt KOomDummyAppSetBusy = 5;
+const TInt KOomDummyAppSetNormalPriority = 6;
+const TInt KOomDummyAppSetHighPriority = 7;
+
+#endif /*T_OOMDUMMAPPMSGS_H_*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyapp/sis/backup_registration.xml	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,5 @@
+<?xml version="1.0" standalone="yes"?>
+<backup_registration>
+  <system_backup/>
+  <restore requires_reboot = "no"/>
+</backup_registration>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyapp/sis/t_oomdummyapp_S60_3_X_v_1_0_0.pkg	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,37 @@
+; Installation file for t_oomdummyapp application
+;
+; This is an auto-generated PKG file by Carbide.
+; This file uses variables specific to Carbide builds that will not work
+; on command-line builds. If you want to use this generated PKG file from the
+; command-line tools you will need to modify the variables with the appropriate
+; values: $(EPOCROOT), $(PLATFORM), $(TARGET)
+;
+;Language - standard language definitions
+&EN
+
+; standard SIS file header
+#{"t_oomdummyapp"},(0xE6CFBA00),1,0,0
+
+;Localised Vendor name
+%{"Vendor-EN"}
+
+;Unique Vendor name
+:"Vendor"
+
+;Supports Series 60 v 3.0
+[0x101F7961], 0, 0, 0, {"Series60ProductID"}
+
+;Files to install
+;You should change the source paths to match that of your environment
+;<source> <destination>
+"$(EPOCROOT)Epoc32\release\$(PLATFORM)\$(TARGET)\t_oomdummyapp_0xE6CFBA00.exe"		-"!:\sys\bin\t_oomdummyapp_0xE6CFBA00.exe"
+"$(EPOCROOT)Epoc32\data\z\resource\apps\t_oomdummyapp_0xE6CFBA00.rsc"		-"!:\resource\apps\t_oomdummyapp_0xE6CFBA00.rsc"
+"$(EPOCROOT)Epoc32\data\z\private\10003a3f\apps\t_oomdummyapp_0xE6CFBA00_reg.rsc"	-"!:\private\10003a3f\import\apps\t_oomdummyapp_0xE6CFBA00_reg.rsc"
+"$(EPOCROOT)Epoc32\data\z\resource\apps\t_oomdummyapp_0xE6CFBA00.mif" -"!:\resource\apps\t_oomdummyapp_0xE6CFBA00.mif"
+"..\help\t_oomdummyapp_0xE6CFBA00.hlp"							 -"!:\resource\help\t_oomdummyapp_0xE6CFBA00.hlp"
+
+; Add any installation notes if applicable
+;"t_oomdummyapp.txt"		-"!:\private\E6CFBA00\t_oomdummyapp.txt"
+
+;required for application to be covered by backup/restore facility 
+"..\sis\backup_registration.xml"		-"!:\private\E6CFBA00\backup_registration.xml"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyapp/src/CMsgHandler.cpp	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,83 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+#include "CMsgHandler.h"
+
+CMsgHandler::CMsgHandler(Ct_oomdummyappAppUi& aOwner) :
+	CActive(EPriorityStandard), // Standard priority
+	iOwner(aOwner)
+	{
+	}
+
+CMsgHandler* CMsgHandler::NewLC(Ct_oomdummyappAppUi& aOwner)
+	{
+	CMsgHandler* self = new (ELeave) CMsgHandler(aOwner);
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	return self;
+	}
+
+CMsgHandler* CMsgHandler::NewL(Ct_oomdummyappAppUi& aOwner)
+	{
+	CMsgHandler* self = CMsgHandler::NewLC(aOwner);
+	CleanupStack::Pop(); // self;
+	return self;
+	}
+
+void CMsgHandler::ConstructL()
+	{
+	User::LeaveIfError(iMsgQueue.Open(15)); // Initialize message queue from process parameters
+	CActiveScheduler::Add(this); // Add to scheduler
+	StartL();
+	}
+
+CMsgHandler::~CMsgHandler()
+	{
+	Cancel(); // Cancel any request, if outstanding
+	iMsgQueue.Close(); // Destroy the RMsgQueue object
+	// Delete instance variables if any
+	}
+
+void CMsgHandler::DoCancel()
+	{
+	iMsgQueue.CancelDataAvailable();
+	}
+
+void CMsgHandler::StartL()
+	{
+	Cancel(); // Cancel any request, just to be sure
+	iMsgQueue.NotifyDataAvailable(iStatus);
+	SetActive(); // Tell scheduler a request is active
+	}
+
+void CMsgHandler::RunL()
+	{
+	TInt command;
+	while(KErrNone==iMsgQueue.Receive(command))
+		{
+		iOwner.HandleHarnessCommandL(command);
+		}
+	StartL();
+	}
+
+TInt CMsgHandler::RunError(TInt aError)
+	{
+	return aError;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyapp/src/t_oomdummyapp.cpp	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,96 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+// INCLUDE FILES
+#include <eikstart.h>
+#include "t_oomdummyappApplication.h"
+
+_LIT(KFakeUidParam,"uid=");
+_LIT(KAllocParam,"alloc=");
+LOCAL_C CApaApplication* NewApplication()
+	{
+	TUid uid(KUidt_oomdummyappApp);
+	TUint alloc = 0;
+	//override uid from command line (add "uid=6789ABCD" anywhere)
+	TInt cmdsize = User::CommandLineLength();
+	HBufC *cmdbuf = NULL;
+	if(cmdsize > 0) cmdbuf = HBufC::New(cmdsize);
+	if(cmdbuf)
+		{
+		TPtr cmdline(cmdbuf->Des());
+		User::CommandLine(cmdline);
+		TLex lex(*cmdbuf);
+		while(!lex.Eos())
+			{
+			lex.SkipSpaceAndMark();
+			while(!lex.Eos() && lex.Get() != '=')
+				{
+				}
+			if(lex.MarkedToken().CompareF(KFakeUidParam) == 0)
+				{
+				lex.SkipSpaceAndMark();
+				while(!lex.Eos() && lex.Get().IsHexDigit())
+					{
+					}
+				TUint id;
+				TLex num(lex.MarkedToken());
+				if(KErrNone==num.Val(id,EHex))
+					{
+					RDebug::Printf("\tapp uid override %x", id);
+					uid = TUid::Uid(id);
+					}
+				}
+			else if(lex.MarkedToken().CompareF(KAllocParam) == 0)
+				{
+				lex.SkipSpaceAndMark();
+				while(!lex.Eos() && lex.Get().IsHexDigit())
+					{
+					}
+				TLex num(lex.MarkedToken());
+				if(KErrNone!=num.Val(alloc,EHex))
+					{
+					alloc = 0;
+					}
+				}
+			}
+		/*
+		TInt offset = cmdbuf->Find(KFakeUidParam);
+		if(offset >=0 && offset + 12 <= cmdbuf->Length())
+			{
+			TLex lex(cmdbuf->Mid(offset+4,8));
+			TUint id;
+			if(KErrNone==lex.Val(id,EHex))
+				{
+				RDebug::Printf("\tapp uid override %x", id);
+				uid = TUid::Uid(id);
+				}
+			}
+		TInt offset = cmdbuf->Find(KAllocParam);
+		if(offset >=0 && offset + 12 <= cmdbuf->Length())*/
+		delete cmdbuf;
+		}
+	return new Ct_oomdummyappApplication(uid, alloc);
+	}
+
+GLDEF_C TInt E32Main()
+	{
+	return EikStart::RunApplication(NewApplication);
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyapp/src/t_oomdummyappAppUi.cpp	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,270 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+// INCLUDE FILES
+#include <avkon.hrh>
+#include <aknmessagequerydialog.h>
+#include <aknnotewrappers.h>
+#include <stringloader.h>
+#include <s32file.h>
+#include <hlplch.h>
+
+#include <t_oomdummyapp_0xE6CFBA00.rsg>
+#include <oommonitorsession.h>
+
+//#include "t_oomdummyapp_0xE6CFBA00.hlp.hrh"
+#include "t_oomdummyapp.hrh"
+#include "t_oomdummyapp.pan"
+#include "t_oomdummyappApplication.h"
+#include "t_oomdummyappAppUi.h"
+#include "t_oomdummyappAppView.h"
+#include "CMsgHandler.h"
+#include "t_oomdummyappmsgs.h"
+
+_LIT( KFileName, "C:\\private\\E6CFBA00\\t_oomdummyapp.txt" );
+_LIT( KText, "OOM dummy app");
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+
+// -----------------------------------------------------------------------------
+// Ct_oomdummyappAppUi::ConstructL()
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void Ct_oomdummyappAppUi::ConstructL()
+	{
+	// Initialise app UI with standard value.
+	BaseConstructL(CAknAppUi::EAknEnableSkin);
+
+	// Create view object
+	iAppView = Ct_oomdummyappAppView::NewL(ClientRect());
+
+	// Create a file to write the text to
+	TInt err = CCoeEnv::Static()->FsSession().MkDirAll(KFileName);
+	if ((KErrNone != err) && (KErrAlreadyExists != err))
+		{
+		return;
+		}
+
+	RFile file;
+	err = file.Replace(CCoeEnv::Static()->FsSession(), KFileName, EFileWrite);
+	CleanupClosePushL(file);
+	if (KErrNone != err)
+		{
+		CleanupStack::PopAndDestroy(1); // file
+		return;
+		}
+
+	RFileWriteStream outputFileStream(file);
+	CleanupClosePushL(outputFileStream);
+	outputFileStream << KText;
+
+	CleanupStack::PopAndDestroy(2); // outputFileStream, file
+
+	TRAP_IGNORE(iMsgHandler = CMsgHandler::NewL(*this)); //if not launched by test harness, the message queue won't exist
+	}
+// -----------------------------------------------------------------------------
+// Ct_oomdummyappAppUi::Ct_oomdummyappAppUi()
+// C++ default constructor can NOT contain any code, that might leave.
+// -----------------------------------------------------------------------------
+//
+Ct_oomdummyappAppUi::Ct_oomdummyappAppUi()
+	{
+	// No implementation required
+	}
+
+// -----------------------------------------------------------------------------
+// Ct_oomdummyappAppUi::~Ct_oomdummyappAppUi()
+// Destructor.
+// -----------------------------------------------------------------------------
+//
+Ct_oomdummyappAppUi::~Ct_oomdummyappAppUi()
+	{
+	if (iAppView)
+		{
+		delete iAppView;
+		iAppView = NULL;
+		}
+	delete iMsgHandler;
+	}
+
+// -----------------------------------------------------------------------------
+// Ct_oomdummyappAppUi::HandleCommandL()
+// Takes care of command handling.
+// -----------------------------------------------------------------------------
+//
+void Ct_oomdummyappAppUi::HandleCommandL(TInt aCommand)
+	{
+	switch (aCommand)
+		{
+		case EEikCmdExit:
+		case EAknSoftkeyExit:
+			Exit();
+			break;
+
+		case ECommand1:
+			{
+
+			// Load a string from the resource file and display it
+			HBufC* textResource = StringLoader::LoadLC(R_COMMAND1_TEXT);
+			CAknInformationNote* informationNote;
+
+			informationNote = new (ELeave) CAknInformationNote;
+
+			// Show the information Note with
+			// textResource loaded with StringLoader.
+			informationNote->ExecuteLD(*textResource);
+
+			// Pop HBuf from CleanUpStack and Destroy it.
+			CleanupStack::PopAndDestroy(textResource);
+			}
+			break;
+		case ECommand2:
+			{
+			RFile rFile;
+
+			//Open file where the stream text is
+			User::LeaveIfError(rFile.Open(CCoeEnv::Static()->FsSession(),
+					KFileName, EFileStreamText));//EFileShareReadersOnly));// EFileStreamText));
+			CleanupClosePushL(rFile);
+
+			// copy stream from file to RFileStream object
+			RFileReadStream inputFileStream(rFile);
+			CleanupClosePushL(inputFileStream);
+
+			// HBufC descriptor is created from the RFileStream object.
+			HBufC* fileData = HBufC::NewLC(inputFileStream, 32);
+
+			CAknInformationNote* informationNote;
+
+			informationNote = new (ELeave) CAknInformationNote;
+			// Show the information Note
+			informationNote->ExecuteLD(*fileData);
+
+			// Pop loaded resources from the cleanup stack
+			CleanupStack::PopAndDestroy(3); // filedata, inputFileStream, rFile
+			}
+			break;
+		case EHelp:
+			{
+
+			CArrayFix<TCoeHelpContext>* buf = CCoeAppUi::AppHelpContextL();
+			HlpLauncher::LaunchHelpApplicationL(iEikonEnv->WsSession(), buf);
+			}
+			break;
+		case EAbout:
+			{
+
+			CAknMessageQueryDialog* dlg = new (ELeave) CAknMessageQueryDialog();
+			dlg->PrepareLC(R_ABOUT_QUERY_DIALOG);
+			HBufC* title = iEikonEnv->AllocReadResourceLC(R_ABOUT_DIALOG_TITLE);
+			dlg->QueryHeading()->SetTextL(*title);
+			CleanupStack::PopAndDestroy(); //title
+			HBufC* msg = iEikonEnv->AllocReadResourceLC(R_ABOUT_DIALOG_TEXT);
+			dlg->SetMessageTextL(*msg);
+			CleanupStack::PopAndDestroy(); //msg
+			dlg->RunLD();
+			}
+			break;
+		default:
+			Panic(Et_oomdummyappUi);
+			break;
+		}
+	}
+
+void Ct_oomdummyappAppUi::HandleHarnessCommandL(TInt aCommand)
+	{
+	switch(aCommand)
+		{
+		case 0:
+			Exit();
+			break;
+		case 1:
+			ActivateTopViewL();
+			break;
+		case KOomDummyAppSetBusy:
+			SetPriorityBusy();
+			break;
+		case KOomDummyAppSetNormalPriority:
+			SetPriorityNormal();
+			break;
+		case KOomDummyAppSetHighPriority:
+			SetPriorityHigh();
+			break;
+		}
+	}
+
+void Ct_oomdummyappAppUi::SetPriorityBusy()
+	{
+	ROomMonitorSession oomSession;
+	oomSession.Connect();
+	oomSession.SetOomPriority(ROomMonitorSession::EOomPriorityBusy);
+	oomSession.Close();
+	}
+
+void Ct_oomdummyappAppUi::SetPriorityNormal()
+	{
+	ROomMonitorSession oomSession;
+	oomSession.Connect();
+	oomSession.SetOomPriority(ROomMonitorSession::EOomPriorityNormal);
+	oomSession.Close();
+	}
+
+void Ct_oomdummyappAppUi::SetPriorityHigh()
+	{
+	ROomMonitorSession oomSession;
+	oomSession.Connect();
+	oomSession.SetOomPriority(ROomMonitorSession::EOomPriorityHigh);
+	oomSession.Close();
+	}
+
+
+// -----------------------------------------------------------------------------
+//  Called by the framework when the application status pane
+//  size is changed.  Passes the new client rectangle to the
+//  AppView
+// -----------------------------------------------------------------------------
+//
+void Ct_oomdummyappAppUi::HandleStatusPaneSizeChange()
+	{
+	iAppView->SetRect(ClientRect());
+	}
+
+CArrayFix<TCoeHelpContext>* Ct_oomdummyappAppUi::HelpContextL() const
+	{
+	// Note: Help will not work if the application uid3 is not in the
+	// protected range.  The default uid3 range for projects created
+	// from this template (0xE0000000 - 0xEFFFFFFF) are not in the protected range so that they
+	// can be self signed and installed on the device during testing.
+	// Once you get your official uid3 from Symbian Ltd. and find/replace
+	// all occurrences of uid3 in your project, the context help will
+	// work. Alternatively, a patch now exists for the versions of 
+	// HTML help compiler in SDKs and can be found here along with an FAQ:
+	// http://www3.symbian.com/faq.nsf/AllByDate/E9DF3257FD565A658025733900805EA2?OpenDocument
+	CArrayFixFlat<TCoeHelpContext>* array = new (ELeave) CArrayFixFlat<
+			TCoeHelpContext> (1);
+	CleanupStack::PushL(array);
+	//array->AppendL(TCoeHelpContext(KUidt_oomdummyappApp, KGeneral_Information));
+	CleanupStack::Pop(array);
+	return array;
+	}
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyapp/src/t_oomdummyappAppView.cpp	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,117 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+
+// INCLUDE FILES
+#include <coemain.h>
+#include "t_oomdummyappAppView.h"
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// Ct_oomdummyappAppView::NewL()
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+Ct_oomdummyappAppView* Ct_oomdummyappAppView::NewL(const TRect& aRect)
+	{
+	Ct_oomdummyappAppView* self = Ct_oomdummyappAppView::NewLC(aRect);
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+// -----------------------------------------------------------------------------
+// Ct_oomdummyappAppView::NewLC()
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+Ct_oomdummyappAppView* Ct_oomdummyappAppView::NewLC(const TRect& aRect)
+	{
+	Ct_oomdummyappAppView* self = new (ELeave) Ct_oomdummyappAppView;
+	CleanupStack::PushL(self);
+	self->ConstructL(aRect);
+	return self;
+	}
+
+// -----------------------------------------------------------------------------
+// Ct_oomdummyappAppView::ConstructL()
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void Ct_oomdummyappAppView::ConstructL(const TRect& aRect)
+	{
+	// Create a window for this application view
+	CreateWindowL();
+
+	// Set the windows size
+	SetRect(aRect);
+
+	// Activate the window, which makes it ready to be drawn
+	ActivateL();
+	}
+
+// -----------------------------------------------------------------------------
+// Ct_oomdummyappAppView::Ct_oomdummyappAppView()
+// C++ default constructor can NOT contain any code, that might leave.
+// -----------------------------------------------------------------------------
+//
+Ct_oomdummyappAppView::Ct_oomdummyappAppView()
+	{
+	// No implementation required
+	}
+
+// -----------------------------------------------------------------------------
+// Ct_oomdummyappAppView::~Ct_oomdummyappAppView()
+// Destructor.
+// -----------------------------------------------------------------------------
+//
+Ct_oomdummyappAppView::~Ct_oomdummyappAppView()
+	{
+	// No implementation required
+	}
+
+// -----------------------------------------------------------------------------
+// Ct_oomdummyappAppView::Draw()
+// Draws the display.
+// -----------------------------------------------------------------------------
+//
+void Ct_oomdummyappAppView::Draw(const TRect& /*aRect*/) const
+	{
+	// Get the standard graphics context
+	CWindowGc& gc = SystemGc();
+
+	// Gets the control's extent
+	TRect drawRect(Rect());
+
+	// Clears the screen
+	gc.Clear(drawRect);
+
+	}
+
+// -----------------------------------------------------------------------------
+// Ct_oomdummyappAppView::SizeChanged()
+// Called by framework when the view size is changed.
+// -----------------------------------------------------------------------------
+//
+void Ct_oomdummyappAppView::SizeChanged()
+	{
+	DrawNow();
+	}
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyapp/src/t_oomdummyappApplication.cpp	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,62 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+
+// INCLUDE FILES
+#include "t_oomdummyapp.hrh"
+#include "t_oomdummyappDocument.h"
+#include "t_oomdummyappApplication.h"
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+Ct_oomdummyappApplication::Ct_oomdummyappApplication(TUid aUid, TUint aAlloc) : iUID(aUid), iAlloc(aAlloc)
+	{
+	
+	}
+
+// -----------------------------------------------------------------------------
+// Ct_oomdummyappApplication::CreateDocumentL()
+// Creates CApaDocument object
+// -----------------------------------------------------------------------------
+//
+CApaDocument* Ct_oomdummyappApplication::CreateDocumentL()
+	{
+	if(iAlloc > 0) iMemory = User::AllocL(iAlloc);
+	// Create an t_oomdummyapp document, and return a pointer to it
+	return Ct_oomdummyappDocument::NewL(*this);
+	}
+
+Ct_oomdummyappApplication::~Ct_oomdummyappApplication()
+	{
+	delete iMemory;
+	}
+
+// -----------------------------------------------------------------------------
+// Ct_oomdummyappApplication::AppDllUid()
+// Returns application UID
+// -----------------------------------------------------------------------------
+//
+TUid Ct_oomdummyappApplication::AppDllUid() const
+	{
+	// Return the UID for the t_oomdummyapp application
+	return iUID;
+	}
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyapp/src/t_oomdummyappDocument.cpp	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,97 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+
+// INCLUDE FILES
+#include "t_oomdummyappAppUi.h"
+#include "t_oomdummyappDocument.h"
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// Ct_oomdummyappDocument::NewL()
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+Ct_oomdummyappDocument* Ct_oomdummyappDocument::NewL(CEikApplication& aApp)
+	{
+	Ct_oomdummyappDocument* self = NewLC(aApp);
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+// -----------------------------------------------------------------------------
+// Ct_oomdummyappDocument::NewLC()
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+Ct_oomdummyappDocument* Ct_oomdummyappDocument::NewLC(CEikApplication& aApp)
+	{
+	Ct_oomdummyappDocument* self = new (ELeave) Ct_oomdummyappDocument(aApp);
+
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	return self;
+	}
+
+// -----------------------------------------------------------------------------
+// Ct_oomdummyappDocument::ConstructL()
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void Ct_oomdummyappDocument::ConstructL()
+	{
+	// No implementation required
+	}
+
+// -----------------------------------------------------------------------------
+// Ct_oomdummyappDocument::Ct_oomdummyappDocument()
+// C++ default constructor can NOT contain any code, that might leave.
+// -----------------------------------------------------------------------------
+//
+Ct_oomdummyappDocument::Ct_oomdummyappDocument(CEikApplication& aApp) :
+	CAknDocument(aApp)
+	{
+	// No implementation required
+	}
+
+// ---------------------------------------------------------------------------
+// Ct_oomdummyappDocument::~Ct_oomdummyappDocument()
+// Destructor.
+// ---------------------------------------------------------------------------
+//
+Ct_oomdummyappDocument::~Ct_oomdummyappDocument()
+	{
+	// No implementation required
+	}
+
+// ---------------------------------------------------------------------------
+// Ct_oomdummyappDocument::CreateAppUiL()
+// Constructs CreateAppUi.
+// ---------------------------------------------------------------------------
+//
+CEikAppUi* Ct_oomdummyappDocument::CreateAppUiL()
+	{
+	// Create the application user interface, and return a pointer to it;
+	// the framework takes ownership of this object
+	return new (ELeave) Ct_oomdummyappAppUi;
+	}
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyplugin/data/t_oomdummyplugin.rss	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,102 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+
+#include <ecom\registryinfo.rh>
+#include <oommonitorplugin.hrh>
+
+RESOURCE REGISTRY_INFO theInfo
+	{
+	dll_uid = 0x10286A33;
+	interfaces =
+		{
+		INTERFACE_INFO
+			{
+			interface_uid = KOomPluginInterfaceUidValue;
+			implementations =
+				{
+				IMPLEMENTATION_INFO
+					{
+					implementation_uid = 0x10286A34;
+					version_no = 1;
+					display_name = "dummy 1";
+					default_data = "";
+					opaque_data = "";
+					},
+				IMPLEMENTATION_INFO
+					{
+					implementation_uid = 0x10286A35;
+					version_no = 1;
+					display_name = "dummy 2";
+					default_data = "";
+					opaque_data = "";
+					},
+				IMPLEMENTATION_INFO
+					{
+					implementation_uid = 0x10286A36;
+					version_no = 1;
+					display_name = "dummy 3";
+					default_data = "";
+					opaque_data = "";
+					},
+				IMPLEMENTATION_INFO
+					{
+					implementation_uid = 0x10286A37;
+					version_no = 1;
+					display_name = "dummy 4";
+					default_data = "";
+					opaque_data = "";
+					},
+				IMPLEMENTATION_INFO
+					{
+					implementation_uid = 0x10286A38;
+					version_no = 1;
+					display_name = "dummy 5";
+					default_data = "";
+					opaque_data = "";
+					},
+				IMPLEMENTATION_INFO
+					{
+					implementation_uid = 0x10286A39;
+					version_no = 1;
+					display_name = "dummy 6";
+					default_data = "";
+					opaque_data = "";
+					},
+				IMPLEMENTATION_INFO
+					{
+					implementation_uid = 0x10286A3A;
+					version_no = 1;
+					display_name = "dummy 7";
+					default_data = "";
+					opaque_data = "";
+					},
+				IMPLEMENTATION_INFO
+					{
+					implementation_uid = 0x10286A3B;
+					version_no = 1;
+					display_name = "dummy 8";
+					default_data = "";
+					opaque_data = "";
+					}
+				};
+			}
+		};
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyplugin/group/bld.inf	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,28 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_TESTMMPFILES
+t_oomdummyplugin.mmp
+
+PRJ_TESTEXPORTS
+../inc/t_oomdummyplugin_properties.h ../../inc/t_oomdummyplugin_properties.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyplugin/group/t_oomdummyplugin.mmp	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,52 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+
+#include <platform_paths.hrh>
+
+TARGET		  t_oomdummyplugin.dll
+TARGETTYPE	  PLUGIN
+// UID2 = 0x10009d8d for ECOM plugins.
+// UID3 = the 'DLL UID' (see resource file)
+UID			 0x10009d8d 0x10286A33
+CAPABILITY CAP_GENERAL_DLL
+
+// This is a SYSTEMINCLUDE macro containing the middleware
+// layer specific include directories
+MW_LAYER_SYSTEMINCLUDE
+
+LIBRARY euser.lib
+LIBRARY t_oomclient.lib 
+LIBRARY        oommonitor.lib
+
+USERINCLUDE ../inc
+USERINCLUDE ../../inc
+
+
+SOURCEPATH ../data
+RESOURCE t_oomdummyplugin.rss
+
+SOURCEPATH ../src
+SOURCE ecom_entry.cpp
+SOURCE dummyplugin.cpp
+
+#ifdef ENABLE_ABIV2_MODE
+DEBUGGABLE
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyplugin/inc/debug.h	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,36 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+#ifndef DEBUG_H_
+#define DEBUG_H_
+
+#include <e32debug.h>
+
+#ifdef _DEBUG
+#define TRACE_FUNC RDebug::Printf("\t%s[%x]", __PRETTY_FUNCTION__, iInstance);
+#define TRACE_FUNC_ENTRY RDebug::Printf("\t+%s[%x]", __PRETTY_FUNCTION__, iInstance);
+#define TRACE_FUNC_EXIT RDebug::Printf("\t-%s[%x]", __PRETTY_FUNCTION__, iInstance);
+#else
+#define TRACE_FUNC
+#define TRACE_FUNC_ENTRY 
+#define TRACE_FUNC_EXIT
+#endif
+
+#endif /* DEBUG_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyplugin/inc/dummyplugin.h	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,69 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+#ifndef DUMMYPLUGIN_H_
+#define DUMMYPLUGIN_H_
+
+#include <oommonitorplugin.h>
+#include "t_oomclient.h"
+
+class CDummyOomPlugin : public COomMonitorPlugin
+	{
+public:
+	static CDummyOomPlugin* NewL(TInt aInstance);
+	~CDummyOomPlugin();
+private:
+	CDummyOomPlugin(TInt aInstance);
+	void ConstructL();
+	//from COomMonitorPlugin
+	virtual void FreeRam();
+	virtual void MemoryGood();
+
+private:
+	TInt iInstance;
+	TInt iLowMemoryCallCount;
+	TInt iGoodMemoryCallCount;
+	ROOMAllocSession iAllocServer;
+	};
+
+
+/*
+class CDummyOomPluginV2 : public COomMonitorPluginV2
+	{
+public:
+	static CDummyOomPluginV2* NewL(TInt aInstance);
+	~CDummyOomPluginV2();
+private:
+	CDummyOomPluginV2(TInt aInstance);
+	void ConstructL();
+	//from COomMonitorPlugin
+	virtual void FreeRam(TInt aBytesRequested);
+	virtual void MemoryGood();
+
+private:
+	TInt iInstance;
+	TInt iLowMemoryCallCount;
+	TInt iGoodMemoryCallCount;
+	ROOMAllocSession iAllocServer;
+	};
+*/
+
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyplugin/inc/t_oomdummyplugin_properties.h	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,37 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+#ifndef DUMMYPLUGIN_PROPETIES_H_
+#define DUMMYPLUGIN_PROPETIES_H_
+
+const TUid KUidOomPropertyCategory = {0x10286A3E};
+
+//The key is the UID of the implementation instance, i.e. 10286A34 To 10286A3D
+const TInt KUidOOMDummyPluginFirstImplementation(0x10286A34);
+const TInt KUidOOMDummyPluginLastImplementation(0x10286A3D);
+
+const TUint KOOMDummyPluginImplementationCount = 10;
+
+const TUint KOOMDummyPluginLowMemoryCount = 0;
+const TUint KOOMDummyPluginGoodMemoryCount = 1 * KOOMDummyPluginImplementationCount;
+const TUint KOOMDummyPluginCurrentAllocationBytes = 2 * KOOMDummyPluginImplementationCount;
+const TUint KOOMDummyPluginBytesRequested = 3 * KOOMDummyPluginImplementationCount;
+
+#endif /* DUMMYPLUGIN_PROPETIES_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyplugin/src/dummyplugin.cpp	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,69 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+#include <e32property.h>
+#include <e32cmn.h>
+#include "dummyplugin.h"
+#include "debug.h"
+#include "t_oomdummyplugin_properties.h"
+
+CDummyOomPlugin* CDummyOomPlugin::NewL(TInt aInstance)
+	{
+	CDummyOomPlugin* self = new(ELeave)CDummyOomPlugin(aInstance);
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+CDummyOomPlugin::CDummyOomPlugin(TInt aInstance) :
+iInstance(aInstance)
+	{
+	
+	}
+
+void CDummyOomPlugin::ConstructL()
+	{
+	TRACE_FUNC_ENTRY;
+	//connect to alloc server
+	User::LeaveIfError(iAllocServer.Connect());
+	TRACE_FUNC_EXIT;
+	}
+
+CDummyOomPlugin::~CDummyOomPlugin()
+	{
+	TRACE_FUNC;
+	}
+
+void CDummyOomPlugin::FreeRam()
+	{
+	TRACE_FUNC;
+	iLowMemoryCallCount++;
+	RProperty::Set(KUidOomPropertyCategory, iInstance + KOOMDummyPluginLowMemoryCount, iLowMemoryCallCount);
+	iAllocServer.MemoryLow(TUid::Uid(iInstance));
+	}
+
+void CDummyOomPlugin::MemoryGood()
+	{
+	TRACE_FUNC;
+	iGoodMemoryCallCount++;
+	RProperty::Set(KUidOomPropertyCategory, iInstance + KOOMDummyPluginGoodMemoryCount, iGoodMemoryCallCount);
+	iAllocServer.MemoryGood(TUid::Uid(iInstance));
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyplugin/src/ecom_entry.cpp	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,62 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+#include <ecom\implementationproxy.h>
+#include "dummyplugin.h"
+
+#define DECLARE_CREATE_INSTANCE(UID) CDummyOomPlugin* CreateInstance##UID() { return CDummyOomPlugin::NewL(UID); }
+#define IMPLEMENTATION_INSTANCE(UID) IMPLEMENTATION_PROXY_ENTRY(UID, CreateInstance##UID)
+
+// #define DECLARE_CREATE_INSTANCEV2(UID) CDummyOomPluginV2* CreateInstance##UID() { return CDummyOomPluginV2::NewL(UID); }
+// #define IMPLEMENTATION_INSTANCEV2(UID) IMPLEMENTATION_PROXY_ENTRY(UID, CreateInstance##UID)
+
+//ECOM factory functions
+DECLARE_CREATE_INSTANCE(0x10286A34)
+DECLARE_CREATE_INSTANCE(0x10286A35)
+DECLARE_CREATE_INSTANCE(0x10286A36)
+DECLARE_CREATE_INSTANCE(0x10286A37)
+DECLARE_CREATE_INSTANCE(0x10286A38)
+DECLARE_CREATE_INSTANCE(0x10286A39)
+DECLARE_CREATE_INSTANCE(0x10286A3A)
+DECLARE_CREATE_INSTANCE(0x10286A3B)
+// DECLARE_CREATE_INSTANCEV2(0x10286A3C)
+// DECLARE_CREATE_INSTANCEV2(0x10286A3D)
+
+// Define the private interface UIDs
+const TImplementationProxy ImplementationTable[] =
+	{
+	IMPLEMENTATION_INSTANCE(0x10286A34),
+	IMPLEMENTATION_INSTANCE(0x10286A35),
+	IMPLEMENTATION_INSTANCE(0x10286A36),
+	IMPLEMENTATION_INSTANCE(0x10286A37),
+	IMPLEMENTATION_INSTANCE(0x10286A38),
+	IMPLEMENTATION_INSTANCE(0x10286A39),
+	IMPLEMENTATION_INSTANCE(0x10286A3A),
+	IMPLEMENTATION_INSTANCE(0x10286A3B)// ,
+	// IMPLEMENTATION_INSTANCEV2(0x10286A3C),
+	// IMPLEMENTATION_INSTANCEV2(0x10286A3D)
+	};
+
+EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount)
+	{
+	aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy);
+
+	return ImplementationTable;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyplugin2/data/t_oomdummyplugin2.rss	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,55 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+
+
+#include <ecom\registryinfo.rh>
+#include <oommonitorplugin.hrh>
+
+RESOURCE REGISTRY_INFO theInfo
+	{
+	dll_uid = 0x10286A81;
+	interfaces =
+		{
+		INTERFACE_INFO
+			{
+			interface_uid = KOomPluginInterfaceV2UidValue;
+			implementations =
+				{
+				IMPLEMENTATION_INFO
+					{
+					implementation_uid = 0x10286A3C;
+					version_no = 1;
+					display_name = "dummyv2 1";
+					default_data = "";
+					opaque_data = "";
+					},
+				IMPLEMENTATION_INFO
+					{
+					implementation_uid = 0x10286A3D;
+					version_no = 1;
+					display_name = "dummyv2 2";
+					default_data = "";
+					opaque_data = "";
+					}
+				};
+			}
+		};
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyplugin2/group/bld.inf	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,28 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_TESTMMPFILES
+t_oomdummyplugin2.mmp
+
+PRJ_TESTEXPORTS
+../inc/t_oomdummyplugin_properties2.h ../../inc/t_oomdummyplugin_properties2.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyplugin2/group/t_oomdummyplugin2.mmp	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,51 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+
+#include <platform_paths.hrh>
+
+TARGET		  t_oomdummyplugin2.dll
+TARGETTYPE	  PLUGIN
+// UID2 = 0x10009d8d for ECOM plugins.
+// UID3 = the 'DLL UID' (see resource file)
+UID			 0x10009d8d 0x10286A81
+CAPABILITY CAP_GENERAL_DLL
+
+// This is a SYSTEMINCLUDE macro containing the middleware
+// layer specific include directories
+MW_LAYER_SYSTEMINCLUDE
+
+USERINCLUDE ../inc
+USERINCLUDE ../../inc
+
+LIBRARY euser.lib
+LIBRARY t_oomclient.lib
+LIBRARY        oommonitor.lib
+
+SOURCEPATH ../data
+RESOURCE t_oomdummyplugin2.rss
+
+SOURCEPATH ../src
+SOURCE ecom_entry2.cpp
+SOURCE dummyplugin2.cpp
+
+#ifdef ENABLE_ABIV2_MODE
+DEBUGGABLE
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyplugin2/inc/debug.h	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,36 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+#ifndef DEBUG_H_
+#define DEBUG_H_
+
+#include <e32debug.h>
+
+#ifdef _DEBUG
+#define TRACE_FUNC RDebug::Printf("\t%s[%x]", __PRETTY_FUNCTION__, iInstance);
+#define TRACE_FUNC_ENTRY RDebug::Printf("\t+%s[%x]", __PRETTY_FUNCTION__, iInstance);
+#define TRACE_FUNC_EXIT RDebug::Printf("\t-%s[%x]", __PRETTY_FUNCTION__, iInstance);
+#else
+#define TRACE_FUNC
+#define TRACE_FUNC_ENTRY 
+#define TRACE_FUNC_EXIT
+#endif
+
+#endif /* DEBUG_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyplugin2/inc/dummyplugin2.h	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,50 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+#ifndef DUMMYPLUGIN2_H_
+#define DUMMYPLUGIN2_H_
+
+#include <oommonitorplugin.h>
+#include "t_oomclient.h"
+
+
+
+class CDummyOomPluginV2 : public COomMonitorPluginV2
+	{
+public:
+	static CDummyOomPluginV2* NewL(TInt aInstance);
+	~CDummyOomPluginV2();
+private:
+	CDummyOomPluginV2(TInt aInstance);
+	void ConstructL();
+	//from COomMonitorPlugin
+	virtual void FreeRam(TInt aBytesRequested);
+	virtual void MemoryGood();
+
+private:
+	TInt iInstance;
+	TInt iLowMemoryCallCount;
+	TInt iGoodMemoryCallCount;
+	ROOMAllocSession iAllocServer;
+	};
+
+
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyplugin2/inc/t_oomdummyplugin_properties2.h	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,21 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyplugin2/src/dummyplugin2.cpp	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,71 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+#include <e32property.h>
+#include <e32cmn.h>
+#include "dummyplugin2.h"
+#include "debug.h"
+#include "t_oomdummyplugin_properties.h"
+
+
+CDummyOomPluginV2* CDummyOomPluginV2::NewL(TInt aInstance)
+	{
+	CDummyOomPluginV2* self = new(ELeave)CDummyOomPluginV2(aInstance);
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+CDummyOomPluginV2::CDummyOomPluginV2(TInt aInstance) :
+iInstance(aInstance)
+	{
+	
+	}
+
+void CDummyOomPluginV2::ConstructL()
+	{
+	TRACE_FUNC_ENTRY;
+	//connect to alloc server
+	User::LeaveIfError(iAllocServer.Connect());
+	TRACE_FUNC_EXIT;
+	}
+
+CDummyOomPluginV2::~CDummyOomPluginV2()
+	{
+	TRACE_FUNC;
+	}
+
+void CDummyOomPluginV2::FreeRam(TInt aBytesRequested)
+	{
+	TRACE_FUNC;
+	iLowMemoryCallCount++;
+	RProperty::Set(KUidOomPropertyCategory, iInstance + KOOMDummyPluginLowMemoryCount, iLowMemoryCallCount);
+	TInt err = RProperty::Set(KUidOomPropertyCategory, iInstance + KOOMDummyPluginBytesRequested, aBytesRequested);
+	iAllocServer.MemoryLow(TUid::Uid(iInstance));
+	}
+
+void CDummyOomPluginV2::MemoryGood()
+	{
+	TRACE_FUNC;
+	iGoodMemoryCallCount++;
+	RProperty::Set(KUidOomPropertyCategory, iInstance + KOOMDummyPluginGoodMemoryCount, iGoodMemoryCallCount);
+	iAllocServer.MemoryGood(TUid::Uid(iInstance));
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyplugin2/src/ecom_entry2.cpp	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,43 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+#include <ecom\implementationproxy.h>
+#include "dummyplugin2.h"
+
+#define DECLARE_CREATE_INSTANCEV2(UID) CDummyOomPluginV2* CreateInstance##UID() { return CDummyOomPluginV2::NewL(UID); }
+#define IMPLEMENTATION_INSTANCEV2(UID) IMPLEMENTATION_PROXY_ENTRY(UID, CreateInstance##UID)
+
+//ECOM factory functions
+DECLARE_CREATE_INSTANCEV2(0x10286A3C)
+DECLARE_CREATE_INSTANCEV2(0x10286A3D)
+
+// Define the private interface UIDs
+const TImplementationProxy ImplementationTable[] =
+	{
+	IMPLEMENTATION_INSTANCEV2(0x10286A3C),
+	IMPLEMENTATION_INSTANCEV2(0x10286A3D)
+	};
+
+EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount)
+	{
+	aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy);
+
+	return ImplementationTable;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomharness/group/bld.inf	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,25 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_TESTMMPFILES
+t_oomharness.mmp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomharness/group/t_oomharness.mmp	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,50 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+
+#include <platform_paths.hrh>
+
+TARGET		  t_oomharness.exe
+TARGETTYPE	  exe
+UID			 0 0xEF1971CE
+
+// This is a SYSTEMINCLUDE macro containing the middleware
+// layer specific include directories
+MW_LAYER_SYSTEMINCLUDE
+
+USERINCLUDE ../inc
+USERINCLUDE ../../inc
+
+SOURCEPATH	  ../src
+SOURCE		  t_oomharness.cpp
+SOURCE        CDummyApplicationHandle.cpp
+
+LIBRARY		 euser.lib
+LIBRARY		 t_oomclient.lib
+LIBRARY      hal.lib
+LIBRARY        oommonitor.lib
+
+
+#ifdef ENABLE_ABIV2_MODE
+DEBUGGABLE
+#endif
+
+EPOCHEAPSIZE 0x4000 0x4000000
+CAPABILITY WriteDeviceData
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomharness/inc/CDummyApplicationHandle.h	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,91 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+#ifndef CDUMMYAPPLICATIONHANDLE_H
+#define CDUMMYAPPLICATIONHANDLE_H
+
+// INCLUDES
+#include <e32std.h>
+#include <e32base.h>
+#include <e32msgqueue.h> 
+
+// a few uids...use appuidlister to extract from the app_reg.rsc files
+const TUid KUidAbout = {0x10005a22};
+const TUid KUidBLID = {0x101f85a0};
+const TUid KUidBrowserNG = {0x10008d39};
+const TUid KUidCalendar = {0x10005901};
+const TUid KUidClock = {0x10005903};
+const TUid KUidGallery = {0x101f8599};
+const TUid KUidPhonebook2 = {0x101f4cce};
+const TUid KUidProfileApp = {0x100058f8};
+
+// CLASS DECLARATION
+
+/**
+ *  CCDummyApplicationHandle
+ * A helper class for launching dummy apps and checking their status
+ */
+class CCDummyApplicationHandle : public CBase
+	{
+public:
+	// Constructors and destructor
+
+	/**
+	 * Destructor.
+	 */
+	~CCDummyApplicationHandle();
+
+	/**
+	 * Two-phased constructor.
+	 */
+	static CCDummyApplicationHandle* NewL(TUid aUid, TInt aExtraMemoryAllocation = 0);
+
+	/**
+	 * Two-phased constructor.
+	 */
+	static CCDummyApplicationHandle* NewLC(TUid aUid, TInt aExtraMemoryAllocation = 0);
+
+	inline RProcess& Process() { return iProcess; }
+	inline const TUid& Uid() { return iUid; }
+	
+	void SendMessage(TInt aMessage);
+	
+	void BringToForeground();
+	
+	static TBool CompareTo(const TUid* aKey, const CCDummyApplicationHandle& aValue);
+private:
+
+	/**
+	 * Constructor for performing 1st stage construction
+	 */
+	CCDummyApplicationHandle(TUid aUid);
+
+	/**
+	 * EPOC default constructor for performing 2nd stage construction
+	 */
+	void ConstructL(TInt aExtraMemoryAllocation = 0);
+
+	RProcess iProcess;
+	//a channel for sending control messages to the dummy app...
+	RMsgQueue<TInt> iMsgQueue;
+	TUid iUid;
+	};
+
+#endif // CDUMMYAPPLICATIONHANDLE_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomharness/inc/cleanuputils.h	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,35 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+ */
+
+template <class T>
+class CleanupResetAndDestroy
+	{
+public:
+	inline static void PushL(T& aRef);
+private:
+	static void ResetAndDestroy(TAny *aPtr);
+	};
+	
+template <class T>
+inline void CleanupResetAndDestroyPushL(T& aRef);
+
+
+#include "cleanuputils.inl"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomharness/inc/cleanuputils.inl	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,37 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+template <class T>
+inline void CleanupResetAndDestroy<T>::PushL(T& aRef)
+	{
+	CleanupStack::PushL(TCleanupItem(&ResetAndDestroy,&aRef));
+	}
+
+template <class T>
+void CleanupResetAndDestroy<T>::ResetAndDestroy(TAny *aPtr)
+	{
+	static_cast<T*>(aPtr)->ResetAndDestroy();
+	}
+
+template <class T>
+inline void CleanupResetAndDestroyPushL(T& aRef)
+	{
+	CleanupResetAndDestroy<T>::PushL(aRef);
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomharness/inc/t_oomharness.h	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,308 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+#ifndef __T_OOMHARNESS_H__
+#define __T_OOMHARNESS_H__
+
+//  Include Files
+
+#include <e32base.h>
+#include <e32hashtab.h>
+#include <e32cmn.h>
+
+#include "CDummyApplicationHandle.h"
+#include "t_oomclient.h"
+#include <oommonitorsession.h>
+
+const TTimeIntervalMicroSeconds32 KSettlingTime = 500000;
+
+//  Function Prototypes
+
+GLDEF_C TInt E32Main();
+
+class COomTestHarness : public CBase
+	{
+public:
+	// Constructors and destructor
+	static COomTestHarness* NewLC();
+	
+	~COomTestHarness();
+	
+	void StartL();
+	
+private:
+
+// Test setup functions...
+	
+	// Close any dummy apps
+	// Free all memory being eaten by the server
+	// Update the call counts on the plugins (add them if they're not there already)
+	void ResetL();
+	
+	void EatMemoryL(TInt aKBytesToLeaveFree);
+	
+	// Set up the plugins and applications - this is the starting point for many test cases
+	// 5 applications are started with approx 1 MB used for each
+	// 1MB (approx) of memory is reserved for each one of the plugins
+	void CommonSetUpL();
+	
+	void StartApplicationL(TInt32 aUid, TInt aInitialAllocationInKBs);
+	
+// Results checking functions...
+	
+	// Returns KErrNone if we get the expected result
+	TInt AppIsRunning(TInt32 aUid, TBool aExpectedResult);
+	
+	// Has FreeRam been called on this plugin since the last call to this function (or since the whole class has been reset)?
+	// Returns KErrNone if we get the expected result
+	TInt PluginFreeRamCalledL(TInt32 aUid, TBool aExpectedResult);
+
+	// Has FreeRam been called on this plugin since the last call to this function (or since the whole class has been reset)?
+	// Returns KErrNone if we get the expected result
+	TInt PluginMemoryGoodCalledL(TInt32 aUid, TBool aExpectedResult);
+	
+// Utility functions
+	
+	// Wait a while for the system to settle down
+	inline void Settle();
+
+	TInt BringAppToForeground(TInt32 aUid);
+	
+	void EatMemoryUntilWeAreStuckUnderTheLowThresholdL();
+	
+// The tests...
+	
+	// Test normal application closure for a single app
+	// Start three applications
+	// The lowest priority app should be in the foregound
+	// ... with the next lowest behind it
+	// ... followed by the highest priority application at the back
+	// The middle application should be configured to eat 5MB of memory
+	// A low memory event is triggered and the middle application only should be closed
+	TInt AppCloseTest1L();
+	
+	// Tests the idle time rule mechanism for app closure
+	// Start three applications
+	// The lowest priority app should be in the foregound
+	// ... with the next lowest behind it
+	// ... followed by the highest priority application at the back
+	// After an idle period the highest priority app is configured to become the lowest priority
+	// The middle and highest application should be configured to eat 5MB of memory
+	// A low memory event is triggered and the middle application only should be closed
+	// Note that this test should be the same as AppCloseTest1L, with the exception of the idle period which causes different apps to be closed
+	TInt AppCloseIdleTimeTest1L();
+	
+	// Test system plugins and continue mode
+	// Simulate a low memory event
+	// Two system plugins should free enough memory, but four will be run because they work in "continue" mode
+	TInt PluginTest1L();
+	
+	// Test application plugins
+	// Start two target apps
+	// Simulate a low memory event
+	// The one of the application plugins should now be run, displacing one of the system plugins
+	// The target apps are of sufficiently high priority that they will not be closed
+	TInt PluginTest2L();
+	
+	// Test that the aBytesRequested is correctly passed to the FreeMemory function of V2 plugins
+	// Initialise P4 plugin to consume 5MB of memory
+	// No other plugins are configured to release memory
+	// Simulate a low memory event (go just below the low threshold)
+	// Check that the P4 plugin has been called
+	// Check that the P4 plugin has received a request for > 500K and less than <1500K
+	TInt PluginV2Test1L();
+	
+	// Test simple prioritisation of application plugins
+	// Start two target applications
+	// Configure all plugins to consume 0.5MB
+	// Simulate a low memory event
+	// Some of the low priority app plugins with those target applications should be called
+	// The highest priority app with that target application should not be called (the lower priority plugins should free enough memory)
+	TInt AppPluginTest1L();
+	
+	// Test simple prioritisation of application plugins
+	// Start two target applications
+	// Configure all plugins to consume 0.5MB
+	// The app plugin with the highest priority is configured to be assigned the lowest priority after an idle time
+	// Wait until the idle time rule applies
+	// Simulate a low memory event
+	// The plugin that initially had the highest priority (but now has the lowest priority) should be called
+	// Note that this test should be the same as AppPluginTest1L with the addition of the idle period
+	TInt AppPluginIdleTimeTest1L();	
+	
+	// Test idle time handling for plugins
+	// Start two target apps
+	// Simulate a low memory event
+	// The one of the application plugins should now be run, displacing one of the system plugins
+	// The target apps are of sufficiently high priority that they will not be closed
+	TInt PluginIdleTimeTest2L();
+	
+	// Test the optional allocation mechanism
+	// Configure the plugins not to release any RAM when FreeRam is called
+	// Configure one priority 7 application to release 12MB when FreeRam is called
+	// Start this application (plus another one so it isn't in the foreground)
+	// Drop just below the good memory level
+	// Request an optional allocation of 10MB referencing a priority 8 plugin
+	// All of the plugins below P8 should be called
+	// The P7 application should be closed freeing the required memory
+	TInt OptionalAllocationTest1L();
+	
+	
+	// Test the optional allocation mechanism - minimum requested RAM behaviour - successful request
+	// Configure the plugins not to release any RAM when FreeRam is called
+	// Configure one priority 7 application to release 5MB when FreeRam is called
+	// Start this application (plus another one so it isn't in the foreground)
+	// Drop just above the good memory level
+	// Request an optional allocation of 10MB (5MB minimum) referencing a priority 8 plugin
+	// All of the plugins below P8 should be called
+	// The P7 application should be closed freeing the required minimum amount memory
+	// The returned available memory should be about 5MB ( > 3MB and < 7MB )
+	TInt OptionalAllocationTest2L();
+	
+	// Test the optional allocation mechanism - minimum requested RAM behaviour - failed request
+	// Configure the plugins not to release any RAM when FreeRam is called
+	// Configure one priority 7 application to release 3MB when FreeRam is called
+	// Start this application (plus another one so it isn't in the foreground)
+	// Drop just above the good memory level
+	// Request an optional allocation of 10MB (5MB minimum) referencing a priority 8 plugin
+	// All of the plugins below P8 should be called
+	// The P7 application should be closed but it won't free enough memory
+	// The optional allocation should fail with KErrNoMemory
+	TInt OptionalAllocationTest3L();
+	
+	
+	// Test the async optional allocation mechanism
+	// Configure the plugins not to release any RAM when FreeRam is called
+	// Configure one priority 7 application to release 12MB when FreeRam is called
+	// Start this application (plus another one so it isn't in the foreground)
+	// Drop just below the good memory level
+	// Request an optional allocation of 10MB referencing a priority 8 plugin
+	// All of the plugins below P8 should be called
+	// The P7 application should be closed freeing the required memory
+	TInt OptionalAllocationAsyncTest1L();
+	
+	
+	// Test the async optional allocation mechanism - minimum requested RAM behaviour - successful request
+	// Configure the plugins not to release any RAM when FreeRam is called
+	// Configure one priority 7 application to release 5MB when FreeRam is called
+	// Start this application (plus another one so it isn't in the foreground)
+	// Drop just above the good memory level
+	// Request an optional allocation of 10MB (5MB minimum) referencing a priority 8 plugin
+	// All of the plugins below P8 should be called
+	// The P7 application should be closed freeing the required minimum amount memory
+	// The returned available memory should be about 5MB ( > 3MB and < 7MB )
+	TInt OptionalAllocationAsyncTest2L();
+	
+	// Test the async optional allocation mechanism - minimum requested RAM behaviour - failed request
+	// Configure the plugins not to release any RAM when FreeRam is called
+	// Configure one priority 7 application to release 3MB when FreeRam is called
+	// Start this application (plus another one so it isn't in the foreground)
+	// Drop just above the good memory level
+	// Request an optional allocation of 10MB (5MB minimum) referencing a priority 8 plugin
+	// All of the plugins below P8 should be called
+	// The P7 application should be closed but it won't free enough memory
+	// The optional allocation should fail with KErrNoMemory
+	TInt OptionalAllocationAsyncTest3L();
+	
+	
+	// Test that force priority check applies (only) to selected priorities
+	// Setup three plugins (priorities 7, 8 & 9)to eat 5MB each
+	// The configuration file should force a check after priority 8
+	// Drop just under the low threshold
+	// Plugins P7 & P8 should be called (P8 is called even though the P7 plugin freed enough memory)
+	// Plugin P9 should not be called because enou
+	TInt ForcePriorityCheck1L();
+	
+	// Test the Busy API on the OOM server
+	// Start three applications
+	// Ensure that the lowest priority app is not in the foreground
+	// Call the busy API on the OOM monitor for the lowest priority app
+	// Simulate a low memory event by going just under the low threshold
+	// The busy application should not be closed
+	// The other (non-foreground) application should be closed
+	TInt BusyApplicationTest1L();
+
+	// Test the Normal-priority API on the OOM server
+	// Start three applications
+	// Ensure that the lowest priority app is not in the foreground
+	// Call the busy API on the OOM monitor for the lowest priority app
+	// Then call the not-busy API on the OOM monitor for the lowest priority app
+	// Simulate a low memory event by going just under the low threshold
+	// The lowest priority app should be closed (because it is no longer busy)
+	TInt NormalPriorityApplicationTest1L();
+	
+	// Test that sync mode configuration is working for system plugins
+	// Configure three system plugins to release 5MB of memory each.
+	// The plugins are configured as follows
+	// Plugin 1: Priority 7, sync mode continue
+	// Plugin 2: Priority 8, sync mode check
+	// Plugin 3: Priority 9, sync mode continue
+	// Drop just under the low threshold
+	// Plugins 1 & 2 should be called (even though plugin 1 alone has freed enough RAM)
+	// Plugin 3 won't be called because the check on the priority 8 plugin discovers that enough RAM has been freed
+	TInt PluginSyncModeTest1L();	
+	
+	
+	// Start three applications
+	// One is set to NEVER_CLOSE, one is low priority, one is a dummy app to ensure that the first two are not in the foreground
+	// Configure applications not to release any memory
+	// Go just significantly under the low memory threshold
+	// Wait for the system to recover, if we have moved above the low memory threshold then go significantly under it again. Repeat this step until we no longer go above low.
+	// Check that the low priority application is closed
+	// Check that the NEVER_CLOSE application is not closed (even though we're still below the low theshold)
+	TInt NeverCloseTest1L();
+	
+	TInt GetFreeMemory();
+	
+	// Utility function which calls the async version of optional RAM request and makes it behave like the sync version
+	TInt RequestOptionalRamASyncWrapper(TInt aBytesRequested, TInt aMinimumBytesNeeded, TInt aPluginId, TInt& aBytesAvailable);
+	
+private:
+	COomTestHarness();
+	
+	void ConstructL();
+
+private:	
+	
+	struct TPluginCallCount
+		{
+		TInt iFreeRamCallCount;
+		TInt iMemoryGoodCallCount;
+		};
+	
+	RHashMap<TInt32, TPluginCallCount> iPluginCallCounts;
+	
+	RPointerArray<CCDummyApplicationHandle> iApps;
+	
+	ROOMAllocSession iAllocServer;
+	
+	RChunk iChunk;
+	TInt iChunkSize;
+	
+	ROomMonitorSession iOomSession;
+	};
+
+#endif  // __T_OOMHARNESS_H__
+
+inline void COomTestHarness::Settle()
+	{
+	//wait for oom system to settle
+	User::After(KSettlingTime);
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomharness/sis/t_oomharness_EKA2.pkg	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,24 @@
+; Installation file for Symbian OS 9.x for generic console application
+; Installation file for t_oomharness EXE
+;
+; This is an auto-generated PKG file by Carbide.
+; This file uses variables specific to Carbide builds that will not work
+; on command-line builds. If you want to use this generated PKG file from the
+; command-line tools you will need to modify the variables with the appropriate
+; values: $(EPOCROOT), $(PLATFORM), $(TARGET)
+;
+
+;
+; UID is the exe's UID
+;
+#{"t_oomharness EXE"},(0xEF1971CE),1,0,0
+
+
+;Localised Vendor name
+%{"Vendor-EN"}
+
+;Unique Vendor name
+:"Vendor"
+
+"$(EPOCROOT)Epoc32\release\$(PLATFORM)\$(TARGET)\t_oomharness.exe"		  -"!:\sys\bin\t_oomharness.exe"
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomharness/src/CDummyApplicationHandle.cpp	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,78 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+#include <w32std.h>
+#include "CDummyApplicationHandle.h"
+
+CCDummyApplicationHandle::CCDummyApplicationHandle(TUid aUid)
+: iUid(aUid)
+	{
+	// No implementation required
+	}
+
+CCDummyApplicationHandle::~CCDummyApplicationHandle()
+	{
+	if(iMsgQueue.Handle())
+		{
+		iMsgQueue.SendBlocking(0);
+		iMsgQueue.Close();
+		}
+	iProcess.Close();
+	}
+
+CCDummyApplicationHandle* CCDummyApplicationHandle::NewLC(TUid aUid, TInt aExtraMemoryAllocation)
+	{
+	CCDummyApplicationHandle* self = new (ELeave) CCDummyApplicationHandle(aUid);
+	CleanupStack::PushL(self);
+	self->ConstructL(aExtraMemoryAllocation);
+	return self;
+	}
+
+CCDummyApplicationHandle* CCDummyApplicationHandle::NewL(TUid aUid, TInt aExtraMemoryAllocation)
+	{
+	CCDummyApplicationHandle* self = CCDummyApplicationHandle::NewLC(aUid, aExtraMemoryAllocation);
+	CleanupStack::Pop(); // self;
+	return self;
+	}
+
+void CCDummyApplicationHandle::ConstructL(TInt aExtraMemoryAllocation)
+	{
+	TBuf<28> params;
+	params.Format(_L("uid=%08x alloc=%x"), iUid, aExtraMemoryAllocation);
+	User::LeaveIfError(iProcess.Create(_L("z:\\sys\\bin\\t_oomdummyapp_0xE6CFBA00.exe"), params));
+	User::LeaveIfError(iMsgQueue.CreateGlobal(KNullDesC, 4));
+	User::LeaveIfError(iProcess.SetParameter(15, iMsgQueue));
+	iProcess.Resume();
+	}
+
+void CCDummyApplicationHandle::SendMessage(TInt aMessage)
+	{
+	iMsgQueue.SendBlocking(aMessage);
+	}
+
+TBool CCDummyApplicationHandle::CompareTo(const TUid* aKey, const CCDummyApplicationHandle& aValue)
+	{
+	return aValue.iUid == *aKey;
+	}
+
+void CCDummyApplicationHandle::BringToForeground()
+	{
+	SendMessage(1);
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomharness/src/t_oomharness.cpp	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,1715 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+//  Include Files  
+
+#include "t_oomharness.h"
+#include "CDummyApplicationHandle.h"
+#include "cleanuputils.h"
+#include "t_oomdummyplugin_properties.h"
+#include <e32base.h>
+#include <e32std.h>
+#include <e32cons.h>			// Console
+#include <e32hal.h>
+#include <e32property.h>
+#include <e32cmn.h>
+#include <hal.h>
+#include "t_oomdummyplugin_properties.h"
+#include "../../t_oomdummyapp/inc/t_oomdummyappmsgs.h"
+
+
+//  Constants
+
+_LIT(KTextConsoleTitle, "Console");
+_LIT(KTextFailed, " failed, leave code = %d");
+_LIT(KTextPressAnyKey, " [press any key]\n");
+
+const TInt KOomLowMemoryThreshold = 4096;
+const TInt KOomJustUnderLowMemoryThreshold = 4000;
+const TInt KOomSignificantlyUnderLowMemoryThreshold = 2024;
+const TInt KOomJustAboveGoodMemoryThreshold = 5100;
+const TInt KOomHarnessInitialEatenMemory = 1024; // Just eat 1K of memory initially, this can grow later
+
+const TInt KOomTestFirstIdlePeriod = 40000000; // 40 seconds
+
+const TInt KOomHarnessMaxEatenMemory = 64 * 1024 * 1024;
+
+//  Global Variables
+
+LOCAL_D CConsoleBase* console; // write all messages to this
+
+
+void COomTestHarness::StartL()
+	{
+	ResetL();
+
+	TInt err = KErrNone;
+	TBool testsFailed = EFalse;
+
+	err = AppCloseTest1L();
+	if (err != KErrNone)
+		testsFailed = ETrue;
+	
+	ResetL();
+	
+	err = AppCloseIdleTimeTest1L();
+	if (err != KErrNone)
+		testsFailed = ETrue;
+
+	ResetL();
+	
+	err = PluginTest1L();
+	if (err != KErrNone)
+		testsFailed = ETrue;
+
+	ResetL();
+
+	
+	err = PluginTest2L();
+	if (err != KErrNone)
+		testsFailed = ETrue;
+	
+	ResetL();
+
+	err = AppPluginTest1L();
+	if (err != KErrNone)
+		testsFailed = ETrue;
+
+	ResetL();
+	
+	err = AppPluginIdleTimeTest1L();
+	if (err != KErrNone)
+		testsFailed = ETrue;
+
+	ResetL();
+	
+	err = OptionalAllocationTest1L();
+	if (err != KErrNone)
+		testsFailed = ETrue;
+
+	ResetL();	
+	
+	err = OptionalAllocationTest2L();
+	if (err != KErrNone)
+		testsFailed = ETrue;
+	
+	ResetL();	
+	
+	err = OptionalAllocationTest3L();
+	if (err != KErrNone)
+		testsFailed = ETrue;
+	
+	ResetL();
+		
+	err = PluginV2Test1L();
+	if (err != KErrNone)
+		testsFailed = ETrue;
+
+	ResetL();
+	
+	err = ForcePriorityCheck1L();
+	if (err != KErrNone)
+		testsFailed = ETrue;
+	
+	ResetL();
+
+	err = PluginSyncModeTest1L();
+	if (err != KErrNone)
+		testsFailed = ETrue;
+
+	ResetL();
+
+	err = NeverCloseTest1L();
+	if (err != KErrNone)
+		testsFailed = ETrue;
+
+	ResetL();
+	
+	err = OptionalAllocationAsyncTest1L();
+	if (err != KErrNone)
+		testsFailed = ETrue;
+
+	ResetL();	
+	
+	err = OptionalAllocationAsyncTest2L();
+	if (err != KErrNone)
+		testsFailed = ETrue;
+	
+	ResetL();	
+	
+	err = OptionalAllocationAsyncTest3L();
+	if (err != KErrNone)
+		testsFailed = ETrue;
+	
+	ResetL();
+
+//	if (err == KErrNone)
+//		err = BusyApplicationTest1L();
+
+	ResetL();
+		
+//	if (err == KErrNone)
+//		err = NormalPriorityApplicationTest1L();
+	
+	if (!testsFailed)
+		console->Printf(_L("All tests passed\n"));
+	else
+		console->Printf(_L("Tests failed\n"));
+	}
+
+// Test normal application closure for a single app
+// Start three applications
+// The lowest priority app should be in the foregound
+// ... with the next lowest behind it
+// ... followed by the highest priority application at the back
+// The middle and highest priority application should be configured to eat 5MB of memory
+// A low memory event is triggered and the middle application only should be closed
+TInt COomTestHarness::AppCloseTest1L()
+	{
+	// The lowest priority app should be in the foregound
+	// ... with the next lowest behind it
+	// ... followed by the highest priority application at the back
+	StartApplicationL(0x101f8599, 5 * 1024); // P9 app
+	StartApplicationL(0x10005901, 5 * 1024); // P8 app, configure it to eat 5MB
+	StartApplicationL(0x10005a22, 0); // P7 app
+	
+	BringAppToForeground(0x10005a22);
+	
+	Settle();
+	
+	// Go significantly under the low memory threshold
+	EatMemoryL(KOomSignificantlyUnderLowMemoryThreshold);
+	
+	Settle();
+	
+	TInt err = KErrNone;
+	
+	// The P8 application should be closed
+	err = AppIsRunning(0x10005901, EFalse);
+	
+	// The P7 app should still be running because it was in the foreground
+	if (err == KErrNone)
+		err = AppIsRunning(0x10005a22, ETrue);	
+	
+	// The P9 app should still be running because the P8 application freed enough memory
+	if (err == KErrNone)
+		err = AppIsRunning(0x101f8599, ETrue);	
+
+	if (err == KErrNone)
+		console->Printf(_L("App Close Test 1 passed\n"));
+	else
+		console->Printf(_L("App Close Test 1 failed\n"));	
+	
+	return err;
+	
+	}
+
+// Tests the idle time rule mechanism for app closure
+// Start three applications
+// The lowest priority app should be in the foregound
+// ... with the next lowest behind it
+// ... followed by the highest priority application at the back
+// After an idle period the highest priority app is configured to become the lowest priority
+// The middle and highest application should be configured to eat 5MB of memory
+// A low memory event is triggered and the middle application only should be closed
+// Note that this test should be the same as AppCloseTest1L, with the exception of the idle period which causes different apps to be closed
+TInt COomTestHarness::AppCloseIdleTimeTest1L()
+	{
+	// The lowest priority app should be in the foregound
+	// ... with the next lowest behind it
+	// ... followed by the highest priority application at the back
+	StartApplicationL(0x101f8599, 5 * 1024); // P9 app (which becomes a P2 app after the idle time)
+	StartApplicationL(0x10005901, 5 * 1024); // P8 app, configure it to eat 5MB
+	StartApplicationL(0x10005a22, 0); // P7 app
+	
+	BringAppToForeground(0x10005a22);
+	
+	Settle();
+	
+	// Wait for the first set of idle time rules to apply
+	User::After(KOomTestFirstIdlePeriod);
+	
+	// Go significantly under the low memory threshold
+	EatMemoryL(KOomSignificantlyUnderLowMemoryThreshold);
+	
+	Settle();
+	
+	// The first two system plugins should have been closed, releasing the required memory
+	// The following two system plugins won't be called (the app plugins will now take their place)
+	TInt err = KErrNone;
+	
+	// The P9 app should have become a P2 app after the idle period, therefore it should have been the first candidate for closure
+	if (err == KErrNone)
+		err = AppIsRunning(0x101f8599, EFalse);		
+	
+	// The P8 application should still be running because the P9 app (that has become a P2 app) has freed the required memory
+	err = AppIsRunning(0x10005901, ETrue);
+	
+	// The P7 app should still be running because it was in the foreground
+	if (err == KErrNone)
+		err = AppIsRunning(0x10005a22, ETrue);	
+	
+	if (err == KErrNone)
+		console->Printf(_L("App Close Idle Time Test 1 passed\n"));
+	else
+		console->Printf(_L("App Close Idle Time Test 1 failed\n"));	
+	
+	return err;
+	
+	}
+
+
+
+TInt COomTestHarness::PluginTest1L()
+	{
+	// Configure the plugins to eat 0.5MB each:
+	for (TInt pluginIndex = KUidOOMDummyPluginFirstImplementation; pluginIndex <= KUidOOMDummyPluginLastImplementation - 2; pluginIndex++)
+		{
+		User::LeaveIfError(iAllocServer.Configure(TUid::Uid(pluginIndex), 0, 0x80000, 0x80000));
+		}
+	
+	Settle();
+	
+	// Go just under the low memory threshold
+	EatMemoryL(KOomJustUnderLowMemoryThreshold);
+	
+	Settle();
+	
+	// The first four system plugins should have been run, releasing the required memory
+	// All four plugins should be called, even though the first two will release enough memory (this is because
+	// plugins are always run in continue mode)
+	TInt err = KErrNone;
+	
+	err = PluginFreeRamCalledL(KUidOOMDummyPluginFirstImplementation, ETrue);
+	
+	if (err == KErrNone)
+		err = PluginFreeRamCalledL(KUidOOMDummyPluginFirstImplementation + 1, ETrue);
+	
+	if (err == KErrNone)
+		err = PluginFreeRamCalledL(KUidOOMDummyPluginFirstImplementation + 2, ETrue);
+	
+	if (err == KErrNone)
+		err = PluginFreeRamCalledL(0x10286A3C, ETrue);
+	
+	
+	// Finally check that the plugins have been notified of the final good memory state
+	if (err == KErrNone)
+		err = PluginMemoryGoodCalledL(KUidOOMDummyPluginFirstImplementation, ETrue);
+	
+	if (err == KErrNone)
+		err = PluginMemoryGoodCalledL(KUidOOMDummyPluginFirstImplementation + 1, ETrue);
+	
+	if (err == KErrNone)
+		err = PluginMemoryGoodCalledL(KUidOOMDummyPluginFirstImplementation + 2, ETrue);
+	
+	if (err == KErrNone)
+		err = PluginMemoryGoodCalledL(0x10286A3C, ETrue);
+
+	if (err == KErrNone)
+		console->Printf(_L("Plugin Test 1 passed\n"));
+	else
+		console->Printf(_L("Plugin Test 1 failed\n"));	
+	
+	return err;
+	}
+
+
+// Test application plugins
+// Start two target apps
+// Simulate a low memory event
+// The one of the application plugins should now be run, displacing one of the system plugins
+// The target apps are of sufficiently high priority that they will not be closed
+TInt COomTestHarness::PluginTest2L()
+	{
+	// Configure the plugins to eat 0.5MB each:
+	for (TInt pluginIndex = KUidOOMDummyPluginFirstImplementation; pluginIndex <= KUidOOMDummyPluginLastImplementation - 2; pluginIndex++)
+		{
+		User::LeaveIfError(iAllocServer.Configure(TUid::Uid(pluginIndex), 0, 0x80000, 0x80000));
+		}
+	
+	// Start the two target applications (plus a third so that the target apps are not in the foreground)
+	StartApplicationL(0x10005901, 0);
+	StartApplicationL(0x10005a22, 0);
+	StartApplicationL(0x101f8599, 0);
+	
+	BringAppToForeground(0x101f8599);
+	
+	Settle();
+	
+	// Go just under the low memory threshold
+	EatMemoryL(KOomJustUnderLowMemoryThreshold);
+	
+	Settle();
+	
+	// The first two system plugins should have been closed, releasing the required memory
+	// The following two system plugins won't be called (the app plugins will now take their place)
+	TInt err = KErrNone;
+	
+	// The following plugins should be called...
+	// Application plugins: 10286A3A 10286A3B
+	// System plugins: 10286A3C(v2 plugin) 10286A34
+	
+	if (err == KErrNone)
+		err = PluginFreeRamCalledL(0x10286A3B, ETrue);
+
+	if (err == KErrNone)
+		err = PluginFreeRamCalledL(0x10286A3A, ETrue);
+
+	// Plugins and apps with higher priorities will not be called/closed because 0x10286A3A is configured to check memory before running anything else
+	if (err == KErrNone)
+		err = PluginFreeRamCalledL(0x10286A3C, EFalse);
+	
+	if (err == KErrNone)
+		err = PluginFreeRamCalledL(0x10286A34, EFalse);
+
+	if (err == KErrNone)
+		err = PluginFreeRamCalledL(0x10286A35, EFalse);	
+	
+	if (err == KErrNone)
+		err = AppIsRunning(0x10005a22, ETrue);		
+	
+	if (err == KErrNone)
+		err = AppIsRunning(0x10005901, ETrue);
+		
+	if (err == KErrNone)
+		err = AppIsRunning(0x101f8599, ETrue);		
+	
+	
+	if (err == KErrNone)
+		console->Printf(_L("Plugin Test 2 passed\n"));
+	else
+		console->Printf(_L("Plugin Test 2 failed\n"));	
+	
+	return err;
+	
+	}
+
+
+
+// Test that the aBytesRequested is correctly passed to the FreeMemory function of V2 plugins
+// Initialise P4 plugin to consume 5MB of memory
+// No other plugins are configured to release memory
+// Simulate a low memory event (go just below the low threshold)
+// Check that the P4 plugin has been called
+// Check that the P4 plugin has received a request for > 500K and less than <1500K
+TInt COomTestHarness::PluginV2Test1L()
+	{
+	// Configure the P4 V2 plugin to eat 5MB:
+	User::LeaveIfError(iAllocServer.Configure(TUid::Uid(0x10286A3C), 0, 0x500000, 0x500000));
+	
+	Settle();
+	
+	// Go just under the low memory threshold
+	EatMemoryL(KOomJustUnderLowMemoryThreshold);
+	
+	Settle();
+	
+	// The first four system plugins should have been closed, releasing the required memory
+	// All four plugins should be called, even though the first two will release enough memory (this is because
+	// plugins are always run in continue mode)
+	TInt err = KErrNone;
+	
+	// Check that the P4 plugin has been called
+	err = PluginFreeRamCalledL(0x10286A3C, ETrue);
+	
+	// Check that the request for memory was about right
+	// Note: regular system variation makes it impossible to test for an exact number
+	TInt requestedMemory = 0;
+	err = RProperty::Get(KUidOomPropertyCategory, 0x10286A3C + KOOMDummyPluginBytesRequested, requestedMemory);
+	if ((requestedMemory < 512 * 1024)
+			|| (requestedMemory > 1500 * 1024))
+		err = KErrGeneral;
+	
+	// Check that the higher priority V2 plugin has not been called
+	if (err == KErrNone)
+		err = PluginFreeRamCalledL(0x10286A3D, EFalse);
+	
+	if (err == KErrNone)
+		console->Printf(_L("Plugin V2 Test 1 passed\n"));
+	else
+		console->Printf(_L("Plugin V2 Test 1 failed\n"));	
+	
+	return err;
+	}
+
+
+// Test simple prioritisation of application plugins
+// Start two target applications
+// Configure all plugins to consume 0.5MB
+// Simulate a low memory event
+// Some of the low priority app plugins with those target applications should be called
+// The highest priority app with that target application should not be called (the lower priority plugins should free enough memory)
+TInt COomTestHarness::AppPluginTest1L()
+	{
+	// Configure the plugins to eat 0.5MB each:
+	for (TInt pluginIndex = KUidOOMDummyPluginFirstImplementation; pluginIndex <= KUidOOMDummyPluginLastImplementation - 2; pluginIndex++)
+		{
+		User::LeaveIfError(iAllocServer.Configure(TUid::Uid(pluginIndex), 0, 0x80000, 0x80000));
+		}
+	
+	// Start the two target applications (plus a third so that the target apps are not in the foreground)
+	StartApplicationL(0x10005901, 0);
+	StartApplicationL(0x10005a22, 0);
+	StartApplicationL(0x101f8599, 0);
+	
+	TInt err = KErrNone;
+	
+	// Check that all of the apps are running
+	if (err == KErrNone)
+		err = AppIsRunning(0x10005901, ETrue);
+
+	if (err == KErrNone)
+		err = AppIsRunning(0x10005a22, ETrue);
+
+	if (err == KErrNone)
+		err = AppIsRunning(0x101f8599, ETrue);
+
+	if (err == KErrNone)
+		console->Printf(_L("Apps started\n"));
+	else
+		console->Printf(_L("Apps not started\n"));
+	
+
+	
+	BringAppToForeground(0x101f8599);
+	
+	Settle();
+	
+	// Go just under the low memory threshold
+	EatMemoryL(KOomJustUnderLowMemoryThreshold);
+	
+	Settle();
+	
+	// The following application plugins should be called...
+	// Application plugins: 10286A3A 10286A3B
+	
+	if (err == KErrNone)
+		err = PluginFreeRamCalledL(0x10286A3A, ETrue);
+	
+	if (err == KErrNone)
+		err = PluginFreeRamCalledL(0x10286A3B, ETrue);
+
+	// The following plugin should not be called because other plugins (including some unchecked system plugins) have freed enough memory
+	// 10286A38
+
+	if (err == KErrNone)
+		err = PluginFreeRamCalledL(0x10286A38, EFalse);	
+	
+	if (err == KErrNone)
+		console->Printf(_L("App Plugin Test 1 passed\n"));
+	else
+		console->Printf(_L("App Plugin Test 1 failed\n"));	
+	
+	return err;
+
+	}
+
+// Test simple prioritisation of application plugins
+// Start two target applications
+// Configure all plugins to consume 0.5MB
+// The app plugin with the highest priority is configured to be assigned the lowest priority after an idle time
+// Wait until the idle time rule applies
+// Simulate a low memory event
+// The plugin that initially had the highest priority (but now has the lowest priority) should be called
+// Note that this test should be the same as AppPluginTest1L with the addition of the idle period
+TInt COomTestHarness::AppPluginIdleTimeTest1L()
+	{
+	// Configure the plugins to eat 0.5MB each:
+	for (TInt pluginIndex = KUidOOMDummyPluginFirstImplementation; pluginIndex <= KUidOOMDummyPluginLastImplementation - 2; pluginIndex++)
+		{
+		User::LeaveIfError(iAllocServer.Configure(TUid::Uid(pluginIndex), 0, 0x80000, 0x80000));
+		}
+	
+	// Start the two target applications (plus a third so that the target apps are not in the foreground)
+	StartApplicationL(0x10005901, 0);
+	StartApplicationL(0x10005a22, 0);
+	StartApplicationL(0x101f8599, 0);
+	
+	BringAppToForeground(0x101f8599);
+	
+	TInt err = KErrNone;	
+	
+	Settle();
+	
+	User::After(KOomTestFirstIdlePeriod);
+	
+	// Go just under the low memory threshold
+	EatMemoryL(KOomJustUnderLowMemoryThreshold);
+	
+	Settle();
+	
+	// The following application plugins should be called...
+	// Application plugins: 10286A3A 10286A3B
+	
+	if (err == KErrNone)
+		err = PluginFreeRamCalledL(0x10286A3A, ETrue);
+	
+	if (err == KErrNone)
+		err = PluginFreeRamCalledL(0x10286A3B, ETrue);
+
+	// The following plugin should also be called (its priority was initially too high but has been reduced after the idle time)
+	// 10286A38
+
+	if (err == KErrNone)
+		err = PluginFreeRamCalledL(0x10286A38, ETrue);	
+	
+	if (err == KErrNone)
+		console->Printf(_L("Plugin Idle Time Test 1 passed\n"));
+	else
+		console->Printf(_L("Plugin Idle Time Test 1 failed\n"));	
+	
+	return err;
+
+	}
+
+
+// Test the optional allocation mechanism
+// Configure the plugins not to release any RAM when FreeRam is called
+// Configure one priority 7 application to release 12MB when FreeRam is called
+// Start this application (plus another one so it isn't in the foreground)
+// Drop just above the good memory level
+// Request an optional allocation of 10MB referencing a priority 8 plugin
+// All of the plugins below P8 should be called
+// The P7 application should be closed freeing the required memory
+TInt COomTestHarness::OptionalAllocationTest1L()
+	{
+	// Start an application (plus a second so that the first app is not in the foreground)
+	// The first application is set to consume 12MB of RAM
+	StartApplicationL(0x10005A22, 12 * 1024);
+	StartApplicationL(0x101F8599, 0);
+	
+	BringAppToForeground(0x101F8599);
+	
+	Settle();
+	
+	// Go just above the good memory threshold
+	EatMemoryL(KOomJustAboveGoodMemoryThreshold);
+	
+	Settle();
+	
+	// Request 10 MB of data, using the priority of the referenced plugin (constant priority 8)
+	TInt bytesAvailable;
+	TInt err = iOomSession.RequestOptionalRam(10 * 1024 * 1024, 10 * 1024 * 1024, 0x10286A37, bytesAvailable);
+	
+	// Check that all system plugins below P8 have been called
+	
+	if (err == KErrNone)
+		err = PluginFreeRamCalledL(0x10286A34, ETrue);
+	
+	if (err == KErrNone)
+		err = PluginFreeRamCalledL(0x10286A35, ETrue);
+
+	if (err == KErrNone)
+		err = PluginFreeRamCalledL(0x10286A36, ETrue);
+	
+	// This the P8 system plugin has not been called
+	if (err == KErrNone)
+		err = PluginFreeRamCalledL(0x10286A37, EFalse);
+	
+	// Check that the low priority app plugin has been called
+	if (err == KErrNone)
+		err = PluginFreeRamCalledL(0x10286A3B, ETrue);
+
+	// Check that the P7 application has been closed
+	if (err == KErrNone)
+		err = AppIsRunning(0x10005A22, EFalse);
+
+	if (err == KErrNone)
+		console->Printf(_L("Optional Allocation Test 1 passed\n"));
+	else
+		console->Printf(_L("Optional Allocation Test 1 failed\n"));	
+		
+	
+	return err;
+	}
+
+
+// Test the optional allocation mechanism - minimum requested RAM behaviour - successful request
+// Configure the plugins not to release any RAM when FreeRam is called
+// Configure one priority 7 application to release 5MB when FreeRam is called
+// Start this application (plus another one so it isn't in the foreground)
+// Drop just above the good memory level
+// Request an optional allocation of 10MB (5MB minimum) referencing a priority 8 plugin
+// All of the plugins below P8 should be called
+// The P7 application should be closed freeing the required minimum amount memory
+// The returned available memory should be about 5MB ( > 3MB and < 7MB )
+TInt COomTestHarness::OptionalAllocationTest2L()
+	{
+	// Start an application (plus a second so that the first app is not in the foreground)
+	// The first application is set to consume 5MB of RAM
+	StartApplicationL(0x10005A22, 5 * 1024);
+	StartApplicationL(0x101F8599, 0);
+	
+	BringAppToForeground(0x101F8599);
+	
+	Settle();
+	
+	// Go just above the good memory threshold
+	EatMemoryL(KOomJustAboveGoodMemoryThreshold);
+	
+	Settle();
+	
+	// Request 10 MB of data, using the priority of the referenced plugin (constant priority 8)
+	// Say that 5MB is the minimum we need
+	TInt bytesAvailable;
+	TInt err = iOomSession.RequestOptionalRam(10 * 1024 * 1024, 5 * 1024 * 1024, 0x10286A37, bytesAvailable);
+	
+	if (err == KErrNone)
+		{
+		// Check that the reported bytes available is > 3MB and < 7MB
+		if ((bytesAvailable < 3 * 1024 * 1024)
+				|| (bytesAvailable > 7 * 1024 * 1024))
+			{
+			err = KErrGeneral;
+			}
+		}
+	
+	// Check that all system plugins below P8 have been called
+	
+	if (err == KErrNone)
+		err = PluginFreeRamCalledL(0x10286A34, ETrue);
+	
+	if (err == KErrNone)
+		err = PluginFreeRamCalledL(0x10286A35, ETrue);
+	
+	if (err == KErrNone)
+		err = PluginFreeRamCalledL(0x10286A36, ETrue);
+	
+	// This the P8 system plugin has not been called
+	if (err == KErrNone)
+		err = PluginFreeRamCalledL(0x10286A37, EFalse);
+	
+	// Check that the low priority app plugin has been called
+	if (err == KErrNone)
+		err = PluginFreeRamCalledL(0x10286A3B, ETrue);
+	
+	// Check that the P7 application has been closed
+	if (err == KErrNone)
+		err = AppIsRunning(0x10005A22, EFalse);
+
+	if (err == KErrNone)
+		console->Printf(_L("Optional Allocation Test 2 passed\n"));
+	else
+		console->Printf(_L("Optional Allocation Test 2 failed\n"));	
+		
+	
+	return err;
+	}
+
+
+
+// Test the optional allocation mechanism - minimum requested RAM behaviour - failed request
+// Configure the plugins not to release any RAM when FreeRam is called
+// Configure one priority 7 application to release 3MB when FreeRam is called
+// Start this application (plus another one so it isn't in the foreground)
+// Drop just above the good memory level
+// Request an optional allocation of 10MB (5MB minimum) referencing a priority 8 plugin
+// All of the plugins below P8 should be called
+// The P7 application should be closed but it won't free enough memory
+// The optional allocation should fail with KErrNoMemory
+TInt COomTestHarness::OptionalAllocationTest3L()
+	{
+	// Start an application (plus a second so that the first app is not in the foreground)
+	// The first application is set to consume 5MB of RAM
+	StartApplicationL(0x10005A22, 3 * 1024);
+	StartApplicationL(0x101F8599, 0);
+	
+	BringAppToForeground(0x101F8599);
+	
+	Settle();
+	
+	// Go just above the good memory threshold
+	EatMemoryL(KOomJustAboveGoodMemoryThreshold);
+	
+	Settle();
+	
+	// Request 10 MB of data, using the priority of the referenced plugin (constant priority 8)
+	// Say that 5MB is the minimum we need
+	TInt bytesAvailable;
+	TInt err = iOomSession.RequestOptionalRam(10 * 1024 * 1024, 5 * 1024 * 1024, 0x10286A37, bytesAvailable);
+	
+	// We expect an error because it has not been possible to free the minimum memory
+	if (err == KErrNoMemory)
+		{
+		err = KErrNone;
+		}
+	else
+		{
+		err = KErrGeneral;
+		}
+	
+	// Check that all system plugins below P8 have been called
+	
+	if (err == KErrNone)
+		err = PluginFreeRamCalledL(0x10286A34, ETrue);
+	
+	if (err == KErrNone)
+		err = PluginFreeRamCalledL(0x10286A35, ETrue);
+	
+	if (err == KErrNone)
+		err = PluginFreeRamCalledL(0x10286A36, ETrue);
+	
+	// This the P8 system plugin has not been called
+	if (err == KErrNone)
+		err = PluginFreeRamCalledL(0x10286A37, EFalse);
+	
+	// Check that the low priority app plugin has been called
+	if (err == KErrNone)
+		err = PluginFreeRamCalledL(0x10286A3B, ETrue);
+	
+	// Check that the P7 application has been closed
+	if (err == KErrNone)
+		err = AppIsRunning(0x10005A22, EFalse);
+
+	if (err == KErrNone)
+		console->Printf(_L("Optional Allocation Test 3 passed\n"));
+	else
+		console->Printf(_L("Optional Allocation Test 3 failed\n"));	
+		
+	
+	return err;
+	}
+
+
+// Test that force priority check applies (only) to selected priorities
+// Setup three plugins (priorities 7, 8 & 9)to eat 5MB each
+// The configuration file should force a check after priority 8
+// Drop just under the low threshold
+// Plugins P7 & P8 should be called (P8 is called even though the P7 plugin freed enough memory)
+// Plugin P9 should not be called because enou
+TInt COomTestHarness::ForcePriorityCheck1L()
+	{
+	// Configure the P7, P8 and P9 plugins to eat 5MB each:
+	User::LeaveIfError(iAllocServer.Configure(TUid::Uid(0x10286A36), 0, 0x500000, 0x500000)); // P7
+	User::LeaveIfError(iAllocServer.Configure(TUid::Uid(0x10286A37), 0, 0x500000, 0x500000)); // P8
+	User::LeaveIfError(iAllocServer.Configure(TUid::Uid(0x10286A3D), 0, 0x500000, 0x500000)); // P9
+	
+	Settle();
+	
+	// Go just under the low memory threshold
+	EatMemoryL(KOomJustUnderLowMemoryThreshold);
+	
+	Settle();
+	
+	TInt err = KErrNone;
+	
+	// The P7 plugin should have been called and is the first to release RAM
+	if (err == KErrNone)
+		err = PluginFreeRamCalledL(0x10286A36, ETrue);
+	
+	// The P8 plugin should be called even though the P7 plugin has already released enough memory because the plugin runs in continue mode and there is no forced check
+	if (err == KErrNone)
+		err = PluginFreeRamCalledL(0x10286A37, ETrue);
+
+	// The P9 plugin should not be called because of the force priority check (the P7 & P8 plugins have already released plenty of RAM)
+	if (err == KErrNone)
+		err = PluginFreeRamCalledL(0x10286A3D, EFalse);	
+	
+	if (err == KErrNone)
+		console->Printf(_L("Force Prioirty Check Test 1 passed\n"));
+	else
+		console->Printf(_L("Force Prioirty Check Test 1 failed\n"));	
+	
+	return err;
+	
+	}
+
+
+
+// Test the Busy API on the OOM server
+// Start three applications
+// Ensure that the lowest priority app is not in the foreground
+// Call the busy API on the OOM monitor for the lowest priority app
+// Simulate a low memory event by going just under the low threshold
+// The busy application should not be closed
+// The other (non-foreground) application should be closed
+TInt COomTestHarness::BusyApplicationTest1L()
+	{
+	// Start the two target applications (plus a third so that the target apps are not in the foreground)
+	StartApplicationL(0x10005901, 0);
+	StartApplicationL(0x101f8599, 0);
+	StartApplicationL(0x10005a22, 0); // Lowest priority app
+	
+	BringAppToForeground(0x101f8599); // TODO: this doesn't seem to be working - message not getting through to the dummy application
+	
+	Settle();
+	
+	// Send the second app a message to make itself busy
+	TInt id = iApps.Find<TUid>(TUid::Uid(0x10005a22), CCDummyApplicationHandle::CompareTo);
+	User::LeaveIfError(id);
+	iApps[id]->SendMessage(KOomDummyAppSetBusy);
+	
+	Settle();
+	
+	// Go just under the low memory threshold
+	EatMemoryL(KOomJustUnderLowMemoryThreshold);
+	
+	Settle();
+	
+	// The first four system plugins should have been closed, releasing the required memory
+	// All four plugins should be called, even though the first two will release enough memory (this is because
+	// plugins are always run in continue mode)
+	TInt err = KErrNone;
+	
+	// Check that the busy application is still running
+	if (err == KErrNone)
+		err = AppIsRunning(0x10005a22, ETrue);
+
+	// Check that the higher priority but non-busy application has been close
+	if (err == KErrNone)
+		err = AppIsRunning(0x10005901, EFalse);
+
+	if (err == KErrNone)
+		console->Printf(_L("Busy Application Test 1 passed\n"));
+	else
+		console->Printf(_L("Busy Application Test 1 failed\n"));	
+	
+	return err;
+	}
+
+
+// Test the NotBusy API on the OOM server
+// Start three applications
+// Ensure that the lowest priority app is not in the foreground
+// Call the busy API on the OOM monitor for the lowest priority app
+// Then call the not-busy API on the OOM monitor for the lowest priority app
+// Simulate a low memory event by going just under the low threshold
+// The lowest priority app should be closed (because it is no longer busy)
+TInt COomTestHarness::NormalPriorityApplicationTest1L()
+	{
+	// Start the two target applications (plus a third so that the target apps are not in the foreground)
+	StartApplicationL(0x10005901, 0);
+	StartApplicationL(0x10005a22, 0); // Lowest priority app
+	StartApplicationL(0x101f8599, 0);
+	
+	BringAppToForeground(0x101f8599);
+	
+	Settle();
+	
+	// Send the second app a message to make itself busy
+	TInt id = iApps.Find<TUid>(TUid::Uid(0x10005a22), CCDummyApplicationHandle::CompareTo);
+	User::LeaveIfError(id);
+	// TODO: temp removed - needs to be put back
+//	iApps[id]->SendMessage(KOomDummyAppSetBusy);
+	
+	// Send the second app a message to make itself normal priority
+	id = iApps.Find<TUid>(TUid::Uid(0x10005a22), CCDummyApplicationHandle::CompareTo);
+	User::LeaveIfError(id);
+	iApps[id]->SendMessage(KOomDummyAppSetNormalPriority);
+
+
+	// Go just under the low memory threshold
+	EatMemoryL(KOomJustUnderLowMemoryThreshold);
+	
+	Settle();
+	
+	// The first four system plugins should have been closed, releasing the required memory
+	// All four plugins should be called, even though the first two will release enough memory (this is because
+	// plugins are always run in continue mode)
+	TInt err = KErrNone;
+	
+	// Check that the no-longer-busy application has been closed
+	if (err == KErrNone)
+		err = AppIsRunning(0x10005a22, EFalse);
+
+	if (err == KErrNone)
+		console->Printf(_L("Normal Priority Application Test 1 passed\n"));
+	else
+		console->Printf(_L("Normal Priority  Application Test 2 failed\n"));	
+	
+	return err;
+	}
+
+
+
+// Start three applications
+// One is set to NEVER_CLOSE, one is low priority, one is a dummy app to ensure that the first two are not in the foreground
+// Configure applications not to release any memory
+// Go just significantly under the low memory threshold
+// Wait for the system to recover, if we have moved above the low memory threshold then go significantly under it again. Repeat this step until we no longer go above low.
+// Check that the low priority application is closed
+// Check that the NEVER_CLOSE application is not closed (even though we're still below the low theshold)
+TInt COomTestHarness::NeverCloseTest1L()
+	{
+	// Start the two target applications (plus a third so that the target apps are not in the foreground)
+	StartApplicationL(0x10005a22, 0); // Lowest priority app
+	StartApplicationL(0x10008d39, 0); // NEVER_CLOSE application
+	StartApplicationL(0x101f8599, 0);
+	
+	BringAppToForeground(0x101f8599);
+	
+	Settle();
+	
+	EatMemoryUntilWeAreStuckUnderTheLowThresholdL();
+	
+	Settle();
+	
+	// The first four system plugins should have been closed, releasing the required memory
+	// All four plugins should be called, even though the first two will release enough memory (this is because
+	// plugins are always run in continue mode)
+	TInt err = KErrNone;
+	
+	// The NEVER_CLOSE app should still be running (even though we are still below the low threshold)
+	if (err == KErrNone)
+		err = AppIsRunning(0x10008d39, ETrue);
+
+	// The low priority app should still be closed (even though we are still below the low threshold)
+	if (err == KErrNone)
+		err = AppIsRunning(0x10005a22, EFalse);
+
+	if (err == KErrNone)
+		console->Printf(_L("Never Close Test 1 passed\n"));
+	else
+		console->Printf(_L("Never Close Test 2 failed\n"));	
+	
+	return err;
+	}
+
+
+
+
+
+// Test that sync mode configuration is working for system plugins
+// Configure three system plugins to release 5MB of memory each.
+// The plugins are configured as follows
+// Plugin 1: Priority 7, sync mode continue
+// Plugin 2: Priority 8, sync mode check
+// Plugin 3: Priority 9, sync mode continue
+// Drop just under the low threshold
+// Plugins 1 & 2 should be called (even though plugin 1 alone has freed enough RAM)
+// Plugin 3 won't be called because the check on the priority 8 plugin discovers that enough RAM has been freed
+TInt COomTestHarness::PluginSyncModeTest1L()
+	{
+	// Configure three plugins to eat 5MB each:
+	User::LeaveIfError(iAllocServer.Configure(TUid::Uid(0x10286A36), 0, 0x500000, 0x500000));
+	User::LeaveIfError(iAllocServer.Configure(TUid::Uid(0x10286A37), 0, 0x500000, 0x500000));
+	User::LeaveIfError(iAllocServer.Configure(TUid::Uid(0x10286A3D), 0, 0x500000, 0x500000));
+	
+	Settle();
+	
+	// Go just under the low memory threshold
+	EatMemoryL(KOomJustUnderLowMemoryThreshold);
+	
+	Settle();
+	
+	// The first four system plugins should have been run, releasing the required memory
+	// All four plugins should be called, even though the first two will release enough memory (this is because
+	// plugins are always run in continue mode)
+	TInt err = KErrNone;
+	
+	// Check that the first two plugins have been called, but not the third
+	err = PluginFreeRamCalledL(0x10286A36, ETrue);
+	
+	if (err == KErrNone)
+		err = PluginFreeRamCalledL(0x10286A37, ETrue);
+	
+	if (err == KErrNone)
+		err = PluginFreeRamCalledL(0x10286A3D, EFalse);
+	
+	if (err == KErrNone)
+		console->Printf(_L("Plugin Sync Mode Test 1 passed\n"));
+	else
+		console->Printf(_L("Plugin Sync Mode Test 1 failed\n"));	
+	
+	return err;
+	}
+
+
+
+
+// Test the optional allocation mechanism
+// Configure the plugins not to release any RAM when FreeRam is called
+// Configure one priority 7 application to release 12MB when FreeRam is called
+// Start this application (plus another one so it isn't in the foreground)
+// Drop just above the good memory level
+// Request an optional allocation of 10MB referencing a priority 8 plugin
+// All of the plugins below P8 should be called
+// The P7 application should be closed freeing the required memory
+TInt COomTestHarness::OptionalAllocationAsyncTest1L()
+	{
+	// Start an application (plus a second so that the first app is not in the foreground)
+	// The first application is set to consume 12MB of RAM
+	StartApplicationL(0x10005A22, 12 * 1024);
+	StartApplicationL(0x101F8599, 0);
+	
+	BringAppToForeground(0x101F8599);
+	
+	Settle();
+	
+	// Go just above the good memory threshold
+	EatMemoryL(KOomJustAboveGoodMemoryThreshold);
+	
+	Settle();
+	
+	// Request 10 MB of data, using the priority of the referenced plugin (constant priority 8)
+	TInt bytesAvailable;
+	TInt err = RequestOptionalRamASyncWrapper(10 * 1024 * 1024, 10 * 1024 * 1024, 0x10286A37, bytesAvailable);
+	
+	// Check that all system plugins below P8 have been called
+	
+	if (err == KErrNone)
+		err = PluginFreeRamCalledL(0x10286A34, ETrue);
+	
+	if (err == KErrNone)
+		err = PluginFreeRamCalledL(0x10286A35, ETrue);
+	
+	if (err == KErrNone)
+		err = PluginFreeRamCalledL(0x10286A36, ETrue);
+	
+	// This the P8 system plugin has not been called
+	if (err == KErrNone)
+		err = PluginFreeRamCalledL(0x10286A37, EFalse);
+	
+	// Check that the low priority app plugin has been called
+	if (err == KErrNone)
+		err = PluginFreeRamCalledL(0x10286A3B, ETrue);
+	
+	// Check that the P7 application has been closed
+	if (err == KErrNone)
+		err = AppIsRunning(0x10005A22, EFalse);
+
+	if (err == KErrNone)
+		console->Printf(_L("Optional Allocation (Async) Test 1 passed\n"));
+	else
+		console->Printf(_L("Optional Allocation (Async) Test 1 failed\n"));	
+		
+	
+	return err;
+	}
+
+
+// Test the optional allocation mechanism - minimum requested RAM behaviour - successful request
+// Configure the plugins not to release any RAM when FreeRam is called
+// Configure one priority 7 application to release 5MB when FreeRam is called
+// Start this application (plus another one so it isn't in the foreground)
+// Drop just above the good memory level
+// Request an optional allocation of 10MB (5MB minimum) referencing a priority 8 plugin
+// All of the plugins below P8 should be called
+// The P7 application should be closed freeing the required minimum amount memory
+// The returned available memory should be about 5MB ( > 3MB and < 7MB )
+TInt COomTestHarness::OptionalAllocationAsyncTest2L()
+	{
+	// Start an application (plus a second so that the first app is not in the foreground)
+	// The first application is set to consume 5MB of RAM
+	StartApplicationL(0x10005A22, 5 * 1024);
+	StartApplicationL(0x101F8599, 0);
+	
+	BringAppToForeground(0x101F8599);
+	
+	Settle();
+	
+	// Go just above the good memory threshold
+	EatMemoryL(KOomJustAboveGoodMemoryThreshold);
+	
+	Settle();
+	
+	// Request 10 MB of data, using the priority of the referenced plugin (constant priority 8)
+	// Say that 5MB is the minimum we need
+	TInt bytesAvailable;
+	TInt err = RequestOptionalRamASyncWrapper(10 * 1024 * 1024, 5 * 1024 * 1024, 0x10286A37, bytesAvailable);
+	
+	if (err == KErrNone)
+		{
+		// Check that the reported bytes available is > 3MB and < 7MB
+		if ((bytesAvailable < 3 * 1024 * 1024)
+				|| (bytesAvailable > 7 * 1024 * 1024))
+			{
+			err = KErrGeneral;
+			}
+		}
+	
+	// Check that all system plugins below P8 have been called
+	
+	if (err == KErrNone)
+		err = PluginFreeRamCalledL(0x10286A34, ETrue);
+	
+	if (err == KErrNone)
+		err = PluginFreeRamCalledL(0x10286A35, ETrue);
+	
+	if (err == KErrNone)
+		err = PluginFreeRamCalledL(0x10286A36, ETrue);
+	
+	// This the P8 system plugin has not been called
+	if (err == KErrNone)
+		err = PluginFreeRamCalledL(0x10286A37, EFalse);
+	
+	// Check that the low priority app plugin has been called
+	if (err == KErrNone)
+		err = PluginFreeRamCalledL(0x10286A3B, ETrue);
+	
+	// Check that the P7 application has been closed
+	if (err == KErrNone)
+		err = AppIsRunning(0x10005A22, EFalse);
+
+	if (err == KErrNone)
+		console->Printf(_L("Optional Allocation (Async) Test 2 passed\n"));
+	else
+		console->Printf(_L("Optional Allocation (Async) Test 2 failed\n"));	
+		
+	
+	return err;
+	}
+
+
+
+// Test the optional allocation mechanism - minimum requested RAM behaviour - failed request
+// Configure the plugins not to release any RAM when FreeRam is called
+// Configure one priority 7 application to release 3MB when FreeRam is called
+// Start this application (plus another one so it isn't in the foreground)
+// Drop just above the good memory level
+// Request an optional allocation of 10MB (5MB minimum) referencing a priority 8 plugin
+// All of the plugins below P8 should be called
+// The P7 application should be closed but it won't free enough memory
+// The optional allocation should fail with KErrNoMemory
+TInt COomTestHarness::OptionalAllocationAsyncTest3L()
+	{
+	// Start an application (plus a second so that the first app is not in the foreground)
+	// The first application is set to consume 5MB of RAM
+	StartApplicationL(0x10005A22, 3 * 1024);
+	StartApplicationL(0x101F8599, 0);
+	
+	BringAppToForeground(0x101F8599);
+	
+	Settle();
+	
+	// Go just above the good memory threshold
+	EatMemoryL(KOomJustAboveGoodMemoryThreshold);
+	
+	Settle();
+	
+	// Request 10 MB of data, using the priority of the referenced plugin (constant priority 8)
+	// Say that 5MB is the minimum we need
+	TInt bytesAvailable;
+	TInt err = RequestOptionalRamASyncWrapper(10 * 1024 * 1024, 5 * 1024 * 1024, 0x10286A37, bytesAvailable);
+	
+	// We expect an error because it has not been possible to free the minimum memory
+	if (err == KErrNoMemory)
+		{
+		err = KErrNone;
+		}
+	else
+		{
+		err = KErrGeneral;
+		}
+	
+	// Check that all system plugins below P8 have been called
+	
+	if (err == KErrNone)
+		err = PluginFreeRamCalledL(0x10286A34, ETrue);
+	
+	if (err == KErrNone)
+		err = PluginFreeRamCalledL(0x10286A35, ETrue);
+	
+	if (err == KErrNone)
+		err = PluginFreeRamCalledL(0x10286A36, ETrue);
+	
+	// This the P8 system plugin has not been called
+	if (err == KErrNone)
+		err = PluginFreeRamCalledL(0x10286A37, EFalse);
+	
+	// Check that the low priority app plugin has been called
+	if (err == KErrNone)
+		err = PluginFreeRamCalledL(0x10286A3B, ETrue);
+	
+	// Check that the P7 application has been closed
+	if (err == KErrNone)
+		err = AppIsRunning(0x10005A22, EFalse);
+
+	if (err == KErrNone)
+		console->Printf(_L("Optional Allocation (Async) Test 3 passed\n"));
+	else
+		console->Printf(_L("Optional Allocation (Async) Test 3 failed\n"));	
+		
+	
+	return err;
+	}
+
+
+
+
+//////////////////////////////////////////////////////////////////////////////
+
+
+TInt COomTestHarness::BringAppToForeground(TInt32 aUid)
+	{
+	//bring app to foreground
+	TInt id = iApps.Find<TUid>(TUid::Uid(aUid), CCDummyApplicationHandle::CompareTo);
+	User::LeaveIfError(id);
+	iApps[id]->BringToForeground();
+	User::After(KSettlingTime);
+	}
+
+
+COomTestHarness* COomTestHarness::NewLC()
+	{
+	COomTestHarness* self = new (ELeave) COomTestHarness();
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	return self;
+	}
+
+void COomTestHarness::ConstructL()
+	{
+	User::LeaveIfError(iAllocServer.Connect());
+	User::LeaveIfError(iOomSession.Connect());
+	
+	User::LeaveIfError(iChunk.CreateLocal(KOomHarnessInitialEatenMemory, KOomHarnessMaxEatenMemory));
+	iChunkSize = KOomHarnessInitialEatenMemory;
+	
+	ResetL();
+	}
+
+
+COomTestHarness::~COomTestHarness()
+	{
+	iApps.ResetAndDestroy();
+	iAllocServer.Close();
+	iChunk.Close();
+	iPluginCallCounts.Close();
+	}
+
+	
+void COomTestHarness::ResetL()
+	{
+	Settle();
+	
+	// Close any dummy apps
+	iApps.ResetAndDestroy();
+	
+	Settle();
+
+	// Free all memory being eaten by the server
+	iChunk.Adjust(KOomHarnessInitialEatenMemory); // Just eat 1K of memory initially, this can grow later
+	iChunkSize = KOomHarnessInitialEatenMemory;
+	
+	User::LeaveIfError(iAllocServer.Reset());
+	
+	// Wait for the system to settle before getting the call counts (freeing the memory could cause some more movement).
+	Settle();
+	
+	// Update the call counts on the plugins (add them if they're not there already)
+	for (TInt pluginUid = KUidOOMDummyPluginFirstImplementation; pluginUid <= KUidOOMDummyPluginLastImplementation; pluginUid++)
+		{
+		TInt lowMemoryCount = 0;
+		RProperty::Get(KUidOomPropertyCategory, pluginUid + KOOMDummyPluginLowMemoryCount, lowMemoryCount);
+
+		TInt goodMemoryCallCount = 0;
+		RProperty::Get(KUidOomPropertyCategory, pluginUid + KOOMDummyPluginGoodMemoryCount, goodMemoryCallCount);
+		
+		TPluginCallCount pluginCallCount;
+		pluginCallCount.iFreeRamCallCount = lowMemoryCount;
+		pluginCallCount.iMemoryGoodCallCount = goodMemoryCallCount;
+		
+		iPluginCallCounts.InsertL(pluginUid, pluginCallCount);
+		};
+	}
+
+void COomTestHarness::EatMemoryL(TInt aKBytesToLeaveFree)
+	{
+	Settle();
+	
+    TMemoryInfoV1Buf meminfo;
+    UserHal::MemoryInfo(meminfo);
+    TInt freeMem = meminfo().iFreeRamInBytes;
+
+    // Resize the dummy chunk to consume the correct ammount of memory
+	iChunkSize = freeMem + iChunkSize - (aKBytesToLeaveFree * 1024);
+	TInt err = iChunk.Adjust(iChunkSize);
+	User::LeaveIfError(err);
+	}
+
+// Set up the plugins and applications - this is the starting point for many test cases
+// 5 applications are started with approx 0.5 MB used for each
+// 0.5MB (approx) of memory is reserved for each one of the plugins
+void COomTestHarness::CommonSetUpL()
+	{
+	// Configure the plugins to eat 0.5MB each:
+	for (TInt pluginIndex = KUidOOMDummyPluginFirstImplementation; pluginIndex <= KUidOOMDummyPluginLastImplementation; pluginIndex++)
+		{
+		User::LeaveIfError(iAllocServer.Configure(TUid::Uid(pluginIndex), 0, 0x80000, 0x80000));
+		}
+	}
+	
+void COomTestHarness::StartApplicationL(TInt32 aUid, TInt aInitialAllocationInKBs)
+	{
+	User::ResetInactivityTime();
+	CCDummyApplicationHandle *app = CCDummyApplicationHandle::NewLC(TUid::Uid(aUid), aInitialAllocationInKBs * 1024);
+	iApps.AppendL(app);
+	CleanupStack::Pop(app);
+	Settle();
+	}
+
+// Returns KErrNone if we get the expected result
+TInt COomTestHarness::AppIsRunning(TInt32 aUid, TBool aExpectedResult)
+	{
+	TBool appRunning = ETrue;
+	
+	TInt id = iApps.Find<TUid>(TUid::Uid(aUid), CCDummyApplicationHandle::CompareTo);
+	if (id < 0)
+		appRunning = EFalse;
+	else if(iApps[id]->Process().ExitType() != EExitPending)
+		appRunning = EFalse;
+	
+	TInt err = KErrNone;
+	
+	if (aExpectedResult != appRunning)
+		err = KErrGeneral;
+	
+	if (aExpectedResult != appRunning)
+		{
+		console->Printf(_L("Application running state not as expected %x \n"), aUid);
+		err = KErrGeneral;
+		}	
+	
+	return err;
+	}
+
+
+// Utility function which calls the async version of optional RAM request and makes it behave like the sync version
+TInt COomTestHarness::RequestOptionalRamASyncWrapper(TInt aBytesRequested, TInt aMinimumBytesNeeded, TInt aPluginId, TInt& aBytesAvailable)
+	{
+	TInt err = KErrNone;
+	TRequestStatus status;
+	iOomSession.RequestOptionalRam(aBytesRequested, aMinimumBytesNeeded, aPluginId, status);
+	User::WaitForRequest(status);
+	
+	if (status.Int() < 0)
+		err = status.Int();
+	else
+		aBytesAvailable = status.Int();
+	
+	return err;
+	}
+
+
+TInt COomTestHarness::GetFreeMemory()
+	{
+	User::CompressAllHeaps();
+	
+	TInt current = 0;
+	HAL::Get( HALData::EMemoryRAMFree, current );
+	
+	return current;
+	}
+
+// Has FreeRam been called on this plugin since the last call to this function (or since the whole class has been reset)?
+// Returns KErrNone if we get the expected result
+TInt COomTestHarness::PluginFreeRamCalledL(TInt32 aUid, TBool aExpectedResult)
+	{
+	TInt newLowMemoryCount = 0;
+	TInt err = RProperty::Get(KUidOomPropertyCategory, aUid + KOOMDummyPluginLowMemoryCount, newLowMemoryCount);
+
+	if (err != KErrNone)
+		console->Printf(_L("Unable to get plugin FreeRam count\n"));
+	
+	TBool freeRamHasBeenCalledOnPlugin = EFalse;
+	TPluginCallCount* pluginCallCount = iPluginCallCounts.Find(aUid);
+	
+	if (pluginCallCount)
+		{
+		freeRamHasBeenCalledOnPlugin = (pluginCallCount->iFreeRamCallCount != newLowMemoryCount);
+		
+		if (freeRamHasBeenCalledOnPlugin)
+			{
+			// Update the list of old counts with the current value so we can see if it has changed next time this function is called
+			pluginCallCount->iFreeRamCallCount = newLowMemoryCount;
+			iPluginCallCounts.InsertL(aUid, *pluginCallCount);
+			}
+		}
+	else
+		{
+		console->Printf(_L("Unable to find call count.\n"));
+		err = KErrNotFound;
+		}
+		
+	if (aExpectedResult != freeRamHasBeenCalledOnPlugin)
+		{
+		console->Printf(_L("Plugin FreeRam count not as expected %x \n"), aUid);
+		err = KErrGeneral;
+		}
+	
+	return err;
+	}
+
+// Has FreeRam been called on this plugin since the last call to this function (or since the whole class has been reset)?
+// Returns KErrNone if we get the expected result
+TInt COomTestHarness::PluginMemoryGoodCalledL(TInt32 aUid, TBool aExpectedResult)
+	{
+	TInt newGoodMemoryCount = 0;
+	RProperty::Get(KUidOomPropertyCategory, aUid + KOOMDummyPluginGoodMemoryCount, newGoodMemoryCount);
+
+	TBool memoryGoodHasBeenCalledOnPlugin = EFalse;
+	TPluginCallCount* pluginCallCount = iPluginCallCounts.Find(aUid);
+	
+	if (pluginCallCount)
+		{
+		memoryGoodHasBeenCalledOnPlugin = (pluginCallCount->iMemoryGoodCallCount != newGoodMemoryCount);
+		
+		if (memoryGoodHasBeenCalledOnPlugin)
+			{
+			// Update the list of old counts with the current value so we can see if it has changed next time this function is called
+			pluginCallCount->iMemoryGoodCallCount = newGoodMemoryCount;
+			iPluginCallCounts.InsertL(aUid, *pluginCallCount);
+			}
+		}
+	
+	TInt err = KErrNone;
+	
+	if (aExpectedResult != memoryGoodHasBeenCalledOnPlugin)
+		err = KErrGeneral;
+	
+	return err;
+	}
+
+void COomTestHarness::EatMemoryUntilWeAreStuckUnderTheLowThresholdL()
+	{
+	while (ETrue)
+		{
+		// Go significantly under the low memory threshold
+		EatMemoryL(KOomSignificantlyUnderLowMemoryThreshold);
+		Settle();
+		// If we are still under the memory threshold then the OOM monitor has not been able to recover,
+		// so our job here is done...
+		if (GetFreeMemory() < (KOomLowMemoryThreshold * 1024))
+			break;
+		
+		// If memory has been released to take us above the low memory threshold then go again...
+		}	
+	}
+
+
+COomTestHarness::COomTestHarness()
+	{
+	// TODO
+	}
+
+
+//  Local Functions
+LOCAL_C void MainL()
+	{
+	COomTestHarness* testHarness = COomTestHarness::NewLC();
+	
+	testHarness->StartL();
+	
+	CleanupStack::PopAndDestroy(testHarness);
+	}
+
+//  Local Functions
+LOCAL_C void OldMainL()
+	{
+	//
+	// add your program code here, example code below
+	//
+	const TInt implementations(KUidOOMDummyPluginLastImplementation-KUidOOMDummyPluginFirstImplementation+1);
+	TInt initialLowCount[implementations];
+	TInt initialGoodCount[implementations];
+	TInt finalLowCount[implementations];
+	TInt finalGoodCount[implementations];
+	TInt tmp;
+	TBuf<80> line;
+	TBool pass = ETrue;
+	ROOMAllocSession allocServer;
+    TMemoryInfoV1Buf meminfo;
+	//connect to alloc server
+	User::LeaveIfError(allocServer.Connect());
+	CleanupClosePushL(allocServer);
+	//configure alloc server
+	User::LeaveIfError(allocServer.Reset());
+/*	User::LeaveIfError(allocServer.Configure(TUid::Uid(KUidOOMDummyPluginFirstImplementation), 0x100000, 0x1000, 0x400000));
+	User::LeaveIfError(allocServer.Configure(TUid::Uid(KUidOOMDummyPluginFirstImplementation+3), 0x100000, 0x1000, 0x400000));
+	User::LeaveIfError(allocServer.StartAllocating());
+	for(TInt i=0;i<5;i++)
+		{
+	    UserHal::MemoryInfo(meminfo);
+	    console->Printf(_L("free mem %d"), meminfo().iFreeRamInBytes);
+	    User::After(1000000);
+		}*/
+	//create dummy apps (note app with that UID *must* exist or apparc won't allow contruction due to missing app_reg.rsc)
+	RPointerArray<CCDummyApplicationHandle> apps;
+	CleanupResetAndDestroyPushL(apps);
+	CCDummyApplicationHandle *app = CCDummyApplicationHandle::NewLC(KUidCalendar, 0x100000);
+	apps.AppendL(app);
+	CleanupStack::Pop(app);
+	app = CCDummyApplicationHandle::NewLC(KUidClock, 0x100000);
+	apps.AppendL(app);
+	CleanupStack::Pop(app);
+	app = CCDummyApplicationHandle::NewLC(KUidAbout, 0x100000);
+	apps.AppendL(app);
+	CleanupStack::Pop(app);
+	
+	//wait for oom system to settle
+	User::After(KSettlingTime);
+	
+	//verify apps started OK
+	for(TInt i=0;i<apps.Count();i++)
+		{
+		if(apps[i]->Process().ExitType() != EExitPending)
+			{
+			pass = EFalse;
+			console->Printf(_L("app %x not running (status %d)\n"),apps[i]->Uid().iUid,apps[i]->Process().ExitType());
+			}
+		}
+	
+	//bring calendar to foreground
+	TInt id = apps.Find<TUid>(KUidCalendar, CCDummyApplicationHandle::CompareTo);
+	User::LeaveIfError(id);
+	apps[id]->BringToForeground();
+	User::After(KSettlingTime);
+	
+	//eat memory to invoke low memory handler
+    UserHal::MemoryInfo(meminfo);
+    TInt freeMem = meminfo().iFreeRamInBytes;
+	TAny *ptr = User::Alloc(freeMem - 247 * 1024);
+	CleanupStack::PushL(ptr);
+	
+	//wait for oom system to settle
+	User::After(KSettlingTime);
+	
+	//verify some apps were closed
+	for(TInt i=0;i<apps.Count();i++)
+		{
+		if(apps[i]->Process().ExitType() != EExitPending)
+			{
+			console->Printf(_L("app %x not running (status %d)\n"),apps[i]->Uid().iUid,apps[i]->Process().ExitType());
+			}
+		else
+			{
+			console->Printf(_L("app %x still running\n"),apps[i]->Uid().iUid);
+			}
+		}
+	
+	//release memory to invoke good memory handler
+	CleanupStack::PopAndDestroy(ptr);
+	
+	//wait for oom system to settle
+	User::After(KSettlingTime);
+	
+/*	console->Write(_L("Initial Counts\n"));
+	for(TInt id=0;id<KOOMDummyPluginImplementationCount;id++)
+		{
+		User::LeaveIfError(RProperty::Get(KUidOomPropertyCategory, id + KUidOOMDummyPluginFirstImplementation + KOOMDummyPluginLowMemoryCount, tmp));
+		initialLowCount[id] = tmp;
+		User::LeaveIfError(RProperty::Get(KUidOomPropertyCategory, id + KUidOOMDummyPluginFirstImplementation + KOOMDummyPluginGoodMemoryCount, tmp));
+		initialGoodCount[id] = tmp;
+		line.Format(_L("%x %d %d\n"), KUidOOMDummyPluginFirstImplementation + id, initialLowCount[id], initialGoodCount[id]);
+		console->Write(line);
+		}
+	//check status of dummy apps
+	User::After(2000000);
+	line.Format(_L("app1 %d app2 %d\n"), app1.ExitType(), app2.ExitType());
+	console->Write(line);
+	if(app1.ExitType() != EExitPending || app2.ExitType() != EExitPending) pass = EFalse;
+	if(pass)
+		console->Write(_L("verdict: pass"));
+	else
+		console->Write(_L("verdict: fail"));
+	console->Getch();
+
+    UserHal::MemoryInfo(meminfo);
+    TInt freeMem = meminfo().iFreeRamInBytes;
+	TAny *ptr = User::Alloc(freeMem - 260000);
+	CleanupStack::PushL(ptr);
+	console->Write(_L("Counts after alloc\n"));
+	for(TInt id=0;id<KOOMDummyPluginImplementationCount;id++)
+		{
+		User::LeaveIfError(RProperty::Get(KUidOomPropertyCategory, id + KUidOOMDummyPluginFirstImplementation + KOOMDummyPluginLowMemoryCount, tmp));
+		finalLowCount[id] = tmp;
+		User::LeaveIfError(RProperty::Get(KUidOomPropertyCategory, id + KUidOOMDummyPluginFirstImplementation + KOOMDummyPluginGoodMemoryCount, tmp));
+		finalGoodCount[id] = tmp;
+		line.Format(_L("%x %d %d\n"), KUidOOMDummyPluginFirstImplementation + id, finalLowCount[id], finalGoodCount[id]);
+		console->Write(line);
+		if(finalLowCount[id] - initialLowCount[id] != 1) pass = EFalse;
+		}
+	//check status of dummy apps
+	User::After(2000000);
+	line.Format(_L("app1 %d app2 %d\n"), app1.ExitType(), app2.ExitType());
+	console->Write(line);
+	if(app1.ExitType() == EExitPending || app2.ExitType() == EExitPending) pass = EFalse;
+	if(pass)
+		console->Write(_L("verdict: pass"));
+	else
+		console->Write(_L("verdict: fail"));
+	console->Getch();
+	CleanupStack::PopAndDestroy(ptr);
+	console->Write(_L("Counts after free\n"));
+	for(TInt id=0;id<KOOMDummyPluginImplementationCount;id++)
+		{
+		User::LeaveIfError(RProperty::Get(KUidOomPropertyCategory, id + KUidOOMDummyPluginFirstImplementation + KOOMDummyPluginLowMemoryCount, tmp));
+		finalLowCount[id] = tmp;
+		User::LeaveIfError(RProperty::Get(KUidOomPropertyCategory, id + KUidOOMDummyPluginFirstImplementation + KOOMDummyPluginGoodMemoryCount, tmp));
+		finalGoodCount[id] = tmp;
+		line.Format(_L("%x %d %d\n"), KUidOOMDummyPluginFirstImplementation + id, finalLowCount[id], finalGoodCount[id]);
+		console->Write(line);
+		if(finalGoodCount[id] - initialGoodCount[id] != 1) pass = EFalse;
+		}
+	//check status of dummy apps
+	User::After(2000000);
+	line.Format(_L("app1 %d app2 %d\n"), app1.ExitType(), app2.ExitType());
+	console->Write(line);
+	if(app1.ExitType() == EExitPending || app2.ExitType() == EExitPending) pass = EFalse;*/
+	if(pass)
+		console->Write(_L("verdict: pass"));
+	else
+		console->Write(_L("verdict: fail"));
+	console->Getch();
+	allocServer.Reset();
+	CleanupStack::PopAndDestroy(2);//apps, allocServer
+	}
+
+LOCAL_C void DoStartL()
+	{
+	// Create active scheduler (to run active objects)
+	CActiveScheduler* scheduler = new (ELeave) CActiveScheduler();
+	CleanupStack::PushL(scheduler);
+	CActiveScheduler::Install(scheduler);
+
+	MainL();
+
+	// Delete active scheduler
+	CleanupStack::PopAndDestroy(scheduler);
+	}
+
+//  Global Functions
+
+GLDEF_C TInt E32Main()
+	{
+	// Create cleanup stack
+	__UHEAP_MARK;
+	CTrapCleanup* cleanup = CTrapCleanup::New();
+
+	// Create output console
+	TRAPD(createError, console = Console::NewL(KTextConsoleTitle, TSize(
+			KConsFullScreen, KConsFullScreen)));
+	if (createError)
+		return createError;
+
+	// Run application code inside TRAP harness, wait keypress when terminated
+	TRAPD(mainError, DoStartL());
+	if (mainError)
+		console->Printf(KTextFailed, mainError);
+	console->Printf(KTextPressAnyKey);
+	console->Getch();
+
+	delete console;
+	delete cleanup;
+	__UHEAP_MARKEND;
+	return KErrNone;
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomharness_stif/BWINS/t_oomharness_stifu.def	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,3 @@
+EXPORTS
+	?LibEntryL@@YAPAVCTestModuleBase@@XZ @ 1 NONAME ; class CTestModuleBase * LibEntryL(void)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomharness_stif/EABI/t_oomharness_stifu.def	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,3 @@
+EXPORTS
+	_Z9LibEntryLv @ 1 NONAME
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomharness_stif/group/bld.inf	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,32 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+
+PRJ_PLATFORMS
+// specify the platforms your component needs to be built for here
+// defaults to WINS MARM so you can ignore this if you just build these
+DEFAULT
+
+PRJ_TESTEXPORTS
+
+PRJ_TESTMMPFILES
+t_oomharness_stif.mmp
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomharness_stif/group/t_oomharness_stif.mmp	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,54 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+#include <platform_paths.hrh>
+
+//uncomment to enable tests which require CLIENT_REQUEST_QUEUE
+macro CLIENT_REQUEST_QUEUE
+
+TARGET      t_oomharness_stif.dll
+TARGETTYPE  dll
+// First UID is DLL UID, Second UID is STIF Test Framework UID
+UID             0x1000008D 0x101FB3E7
+
+VENDORID        VID_DEFAULT
+
+CAPABILITY	ALL -TCB
+
+// This is a SYSTEMINCLUDE macro containing the middleware
+// layer specific include directories
+MW_LAYER_SYSTEMINCLUDE		
+
+USERINCLUDE ../inc
+USERINCLUDE ../../inc
+
+	
+SOURCEPATH      ../src
+SOURCE		t_oomharness.cpp
+SOURCE		t_oomharnessCases.cpp
+SOURCE		CDummyApplicationHandle.cpp
+
+LIBRARY     euser.lib
+LIBRARY     stiftestinterface.lib
+LIBRARY     stiftestengine.lib
+LIBRARY		t_oomclient.lib 
+LIBRARY 	hal.lib
+LIBRARY        oommonitor.lib
+	
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomharness_stif/inc/CDummyApplicationHandle.h	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,94 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+#ifndef CDUMMYAPPLICATIONHANDLE_H
+#define CDUMMYAPPLICATIONHANDLE_H
+
+// INCLUDES
+#include <e32std.h>
+#include <e32base.h>
+#include <e32msgqueue.h> 
+
+// a few uids...use appuidlister to extract from the app_reg.rsc files
+// and mappings to uids not used by tests anymore
+const TInt KOomTestAppUid  = 0xE6CFBA01; // 0x101f8599
+const TInt KOomTestApp2Uid = 0xE6CFBA02; // 0x10005901
+const TInt KOomTestApp3Uid = 0xE6CFBA03; // 0x10005a22
+const TInt KOomTestApp4Uid = 0xE6CFBA04; // 0x101f4cd5
+const TInt KOomTestApp5Uid = 0xE6CFBA05; // 0x10005234
+const TInt KOomTestApp6Uid = 0xE6CFBA06; // 0x10207218
+const TInt KOomTestApp7Uid = 0xE6CFBA07; // 0x10008d39
+const TInt KOomTestApp8Uid = 0xE6CFBA08; // 0x10005903
+const TInt KOomTestApp9Uid = 0xE6CFBA09; // 0x101f4cce
+const TInt KOomTestApp10Uid = 0xE6CFBA0A; // 0x101f4cd2
+
+// CLASS DECLARATION
+
+/**
+ *  CCDummyApplicationHandle
+ * A helper class for launching dummy apps and checking their status
+ */
+NONSHARABLE_CLASS ( CCDummyApplicationHandle ) : public CBase
+	{
+public:
+	// Constructors and destructor
+
+	/**
+	 * Destructor.
+	 */
+	~CCDummyApplicationHandle();
+
+	/**
+	 * Two-phased constructor.
+	 */
+	static CCDummyApplicationHandle* NewL(TUid aUid, TInt aExtraMemoryAllocation = 0);
+
+	/**
+	 * Two-phased constructor.
+	 */
+	static CCDummyApplicationHandle* NewLC(TUid aUid, TInt aExtraMemoryAllocation = 0);
+
+	inline RProcess& Process() { return iProcess; }
+	inline const TUid& Uid() { return iUid; }
+	
+	void SendMessage(TInt aMessage);
+	
+	void BringToForeground();
+	
+	static TBool CompareTo(const TUid* aKey, const CCDummyApplicationHandle& aValue);
+private:
+
+	/**
+	 * Constructor for performing 1st stage construction
+	 */
+	CCDummyApplicationHandle(TUid aUid);
+
+	/**
+	 * EPOC default constructor for performing 2nd stage construction
+	 */
+	void ConstructL(TInt aExtraMemoryAllocation = 0);
+
+	RProcess iProcess;
+	//a channel for sending control messages to the dummy app...
+	RMsgQueue<TInt> iMsgQueue;
+	TUid iUid;
+	};
+
+#endif // CDUMMYAPPLICATIONHANDLE_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomharness_stif/inc/t_oomharness.h	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,681 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+#ifndef T_OOMHARNESS_H
+#define T_OOMHARNESS_H
+
+// INCLUDES
+#include "StifTestModule.h"
+#include <StifLogger.h>
+#include <e32hashtab.h>
+#include <e32cmn.h>
+#include "CDummyApplicationHandle.h"
+#include "t_oomclient.h"
+#include <oommonitorsession.h>
+#include <e32property.h>
+
+// CONSTANTS
+
+const TInt KSettlingTime = 2000000;
+const TInt KOomHarnessInitialEatenMemory= 1024; // Just eat 1K of memory initially, this can grow later
+const TInt KOomHarnessMaxEatenMemory = 64 * 1024 * 1024;
+
+const TInt KTimeout = 20000000; //20 secs
+
+enum TTestStates
+    {
+    // EInit: Test initialisation phase
+    ETestInit,
+    
+    // EPossiblePass: In the case of memorymonitor reporting EAboveTreshhold
+    ETestAbove,
+    
+    // EFail: All other cases including timeout
+    ETestBelow,
+    
+    ETestTimeout
+    };
+
+// MACROS
+// None
+
+// Logging path
+_LIT( KT_OomHarnessLogPath, "\\logs\\testframework\\T_OomHarness\\" ); 
+// Log file
+_LIT( KT_OomHarnessLogFile, "T_OomHarness.txt" ); 
+_LIT( KT_OomHarnessLogFileWithTitle, "T_OomHarness_[%S].txt" ); 
+
+// Function pointer related internal definitions
+// Rounding known bug in GCC
+#define GETPTR &  
+#define ENTRY(str,func) {_S(str), GETPTR func,0,0,0}
+#define FUNCENTRY(func) {_S(#func), GETPTR func,0,0,0}
+#define OOM_ENTRY(str,func,a,b,c) {_S(str), GETPTR func,a,b,c}
+#define OOM_FUNCENTRY(func,a,b,c) {_S(#func), GETPTR func,a,b,c}
+
+// FUNCTION PROTOTYPES
+// None
+
+// FORWARD DECLARATIONS
+class COomTestHarness;
+class CMemoryMonitorStatusWatcher;
+class CMemoryMonitorTimeoutWatcher;
+
+// DATA TYPES
+// None
+
+// A typedef for function that does the actual testing,
+// function is a type 
+// TInt COomTestHarness::<NameOfFunction> ( TTestResult& aResult )
+typedef TInt (COomTestHarness::* TestFunction)(TTestResult&);    
+
+// CLASS DECLARATION
+
+/**
+*  An internal structure containing a test case name and
+*  the pointer to function doing the test
+*
+*  @lib ?library
+*  @since ?Series60_version
+*/
+class TCaseInfoInternal
+    {
+    public:
+        const TText* iCaseName;
+        TestFunction iMethod;
+        TBool           iIsOOMTest;
+        TInt            iFirstMemoryAllocation;
+        TInt            iLastMemoryAllocation;
+    };
+
+// CLASS DECLARATION
+
+/**
+*  A structure containing a test case name and
+*  the pointer to function doing the test
+*
+*  @lib ?library
+*  @since ?Series60_version
+*/
+class TCaseInfo
+    {
+    public:
+        TPtrC iCaseName;    
+        TestFunction iMethod;
+        TBool           iIsOOMTest;
+        TInt            iFirstMemoryAllocation;
+        TInt            iLastMemoryAllocation;
+
+    TCaseInfo( const TText* a ) : iCaseName( (TText*) a )
+        {        
+        };
+
+    };
+
+// CLASS DECLARATION
+
+/**
+*  This a T_OomHarness class.
+*  ?other_description_lines
+*
+*  @lib ?library
+*  @since ?Series60_version
+*/
+NONSHARABLE_CLASS(COomTestHarness) : public CTestModuleBase
+    {
+    public:  // Constructors and destructor
+
+
+        /**
+        * Two-phased constructor.
+        */
+        static COomTestHarness* NewL();
+
+        /**
+        * Destructor.
+        */
+        virtual ~COomTestHarness();
+
+    public: // New functions
+    // None
+
+    public: // Functions from base classes
+
+        /**
+        * From CTestModuleBase InitL is used to initialize the 
+        *       T_OomHarness. It is called once for every instance of 
+        *       TestModule T_OomHarness after its creation.
+        * @since ?Series60_version
+        * @param aIniFile Initialization file for the test module (optional)
+        * @param aFirstTime Flag is true when InitL is executed for first 
+        *               created instance of T_OomHarness.
+        * @return Symbian OS error code
+        */
+        TInt InitL( TFileName& aIniFile, TBool aFirstTime );
+
+        /**
+        * From CTestModuleBase GetTestCasesL is used to inquiry test cases 
+        *   from T_OomHarness. 
+        * @since ?Series60_version
+        * @param aTestCaseFile Test case file (optional)
+        * @param aTestCases  Array of TestCases returned to test framework
+        * @return Symbian OS error code
+        */
+        TInt GetTestCasesL( const TFileName& aTestCaseFile, 
+                            RPointerArray<TTestCaseInfo>& aTestCases );
+    
+        /**
+        * From CTestModuleBase RunTestCaseL is used to run an individual 
+        *   test case. 
+        * @since ?Series60_version
+        * @param aCaseNumber Test case number
+        * @param aTestCaseFile Test case file (optional)
+        * @param aResult Test case result returned to test framework (PASS/FAIL)
+        * @return Symbian OS error code (test case execution error, which is 
+        *           not reported in aResult parameter as test case failure).
+        */   
+        TInt RunTestCaseL( const TInt aCaseNumber, 
+                           const TFileName& aTestCaseFile,
+                           TTestResult& aResult );
+
+        /**
+        * From CTestModuleBase; OOMTestQueryL is used to specify is particular
+        * test case going to be executed using OOM conditions
+        * @param aTestCaseFile Test case file (optional)
+        * @param aCaseNumber Test case number (optional)
+        * @param aFailureType OOM failure type (optional)
+        * @param aFirstMemFailure The first heap memory allocation failure value (optional)
+        * @param aLastMemFailure The last heap memory allocation failure value (optional)
+        * @return TBool
+        */
+        virtual TBool OOMTestQueryL( const TFileName& /* aTestCaseFile */, 
+                                     const TInt /* aCaseNumber */, 
+                                     TOOMFailureType& aFailureType,
+                                     TInt& /* aFirstMemFailure */, 
+                                     TInt& /* aLastMemFailure */ );
+
+        /**
+        * From CTestModuleBase; OOMTestInitializeL may be used to initialize OOM
+        * test environment
+        * @param aTestCaseFile Test case file (optional)
+        * @param aCaseNumber Test case number (optional)
+        * @return None
+        */
+        virtual void OOMTestInitializeL( const TFileName& /* aTestCaseFile */, 
+                                    const TInt /* aCaseNumber */ ); 
+        /**
+        * From CTestModuleBase; OOMTestFinalizeL may be used to finalize OOM
+        * test environment
+        * @param aTestCaseFile Test case file (optional)
+        * @param aCaseNumber Test case number (optional)
+        * @return None
+        */
+        virtual void OOMTestFinalizeL( const TFileName& /* aTestCaseFile */, 
+                                       const TInt /* aCaseNumber */ );
+
+        /**
+        * From CTestModuleBase; OOMHandleWarningL
+        * @param aTestCaseFile Test case file (optional)
+        * @param aCaseNumber Test case number (optional)
+        * @param aFailNextValue FailNextValue for OOM test execution (optional)
+        * @return None
+        */
+        virtual void OOMHandleWarningL( const TFileName& /* aTestCaseFile */,
+                                        const TInt /* aCaseNumber */, 
+                                        TInt& /* aFailNextValue */);
+        void AllocateMemoryL(TInt aKBytes);
+        
+    protected:  // New functions    
+    // None
+
+    protected:  // Functions from base classes
+    // None
+
+    private:
+
+        /**
+        * C++ default constructor.
+        */
+        COomTestHarness();
+
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+        void ConstructL();
+
+        // Prohibit copy constructor if not deriving from CBase.
+        // ?classname( const ?classname& );
+        // Prohibit assigment operator if not deriving from CBase.
+        // ?classname& operator=( const ?classname& );
+
+        /**
+        * Function returning test case name and pointer to test case function.
+        * @since ?Series60_version
+        * @param aCaseNumber test case number
+        * @return TCaseInfo 
+        */
+        const TCaseInfo Case ( const TInt aCaseNumber ) const;
+
+        // Test setup functions...
+        	
+        	// Close any dummy apps
+        	// Free all memory being eaten by the server
+        	// Update the call counts on the plugins (add them if they're not there already)
+        	void ResetL();
+        	
+        	void EatMemoryL(TInt aKBytesToLeaveFree);
+        	        	
+        	// Set up the plugins and applications - this is the starting point for many test cases
+        	// 5 applications are started with approx 1 MB used for each
+        	// 1MB (approx) of memory is reserved for each one of the plugins
+        	void CommonSetUpL();
+        	
+        	void StartApplicationL(TInt32 aUid, TInt aInitialAllocationInKBs);
+        	
+        // Results checking functions...
+        	
+        	// Returns KErrNone if we get the expected result
+        	TInt AppIsRunning(TInt32 aUid, TBool aExpectedResult);
+        	
+        	// Has FreeRam been called on this plugin since the last call to this function (or since the whole class has been reset)?
+        	// Returns KErrNone if we get the expected result
+        	TInt PluginFreeRamCalledL(TInt32 aUid, TBool aExpectedResult);
+
+        	// Has FreeRam been called on this plugin since the last call to this function (or since the whole class has been reset)?
+        	// Returns KErrNone if we get the expected result
+        	TInt PluginMemoryGoodCalledL(TInt32 aUid, TBool aExpectedResult);        
+        
+        	// Utility functions
+        	
+        	// Wait a while for the system to settle down
+        	inline void Settle();
+
+        	void BringAppToForeground(TInt32 aUid);
+        	
+ 
+        	TInt GetFreeMemory();
+        	
+        	// Utility function which calls the async version of optional RAM request and makes it behave like the sync version
+        	TInt RequestOptionalRamASyncWrapper(TInt aBytesRequested, TInt aMinimumBytesNeeded, TInt aPluginId, TInt& aBytesAvailable);        	
+        	
+        	// Utility function which starts the memory monitor property watcher.
+        	// The watcher stops the active scheduler when the monitor status changes
+        	void StartMemoryMonitorStatusWatcher(TInt& aTestState);
+        	
+        	// Utility function which starts the timeout watcher and the active scheduler 
+			// The watcher stops the active scheduler when the monitor status changes
+			// This function also cancels any pending requests when we are done
+        	void StartTimerAndRunWatcher(TInt& aTestState);
+        	
+        	// The tests...
+        	
+        	// Test normal application closure for a single app
+        	// Start three applications
+        	// The lowest priority app should be in the foregound
+        	// ... with the next lowest behind it
+        	// ... followed by the highest priority application at the back
+        	// The middle application should be configured to eat 5MB of memory
+        	// A low memory event is triggered and the middle application only should be closed
+        	TInt AppCloseTest1L(TTestResult& aResult);
+        	
+        	// Tests the idle time rule mechanism for app closure
+        	// Start three applications
+        	// The lowest priority app should be in the foregound
+        	// ... with the next lowest behind it
+        	// ... followed by the highest priority application at the back
+        	// After an idle period the highest priority app is configured to become the lowest priority
+        	// The middle and highest application should be configured to eat 5MB of memory
+        	// A low memory event is triggered and the middle application only should be closed
+        	// Note that this test should be the same as AppCloseTest1L, with the exception of the idle period which causes different apps to be closed
+        	TInt AppCloseIdleTimeTest1L(TTestResult& aResult);
+
+        	//Tests the that window group z order is considered when closing apps.
+        	//Start 3 apps of equal priority, ensuring their z order is known
+        	//Starts another lower priority app and puts that in the foreground
+        	//A low memory event is triggered such that only one app needs to be closed
+        	//The closed app should be the one furthest from the foreground in the z order
+        	TInt AppCloseEqualPrioritiesL(TTestResult& aResult);        	
+        	
+        	// Test system plugins and continue mode
+        	// Simulate a low memory event
+        	// Two system plugins should free enough memory, but four will be run because they work in "continue" mode
+        	TInt PluginTest1L(TTestResult& aResult);
+        	
+        	// Test application plugins
+        	// Start two target apps
+        	// Simulate a low memory event
+        	// The one of the application plugins should now be run, displacing one of the system plugins
+        	// The target apps are of sufficiently high priority that they will not be closed
+        	TInt PluginTest2L(TTestResult& aResult);
+        	
+        	// Test that the aBytesRequested is correctly passed to the FreeMemory function of V2 plugins
+        	// Initialise P4 plugin to consume 5MB of memory
+        	// No other plugins are configured to release memory
+        	// Simulate a low memory event (go just below the low threshold)
+        	// Check that the P4 plugin has been called
+        	// Check that the P4 plugin has received a request for > 500K and less than <1500K
+        	TInt PluginV2Test1L(TTestResult& aResult);
+        	
+        	// Test simple prioritisation of application plugins
+        	// Start two target applications
+        	// Configure all plugins to consume 0.5MB
+        	// Simulate a low memory event
+        	// Some of the low priority app plugins with those target applications should be called
+        	// The highest priority app with that target application should not be called (the lower priority plugins should free enough memory)
+        	TInt AppPluginTest1L(TTestResult& aResult);
+        	
+        	// Test simple prioritisation of application plugins
+        	// Start two target applications
+        	// Configure all plugins to consume 0.5MB
+        	// The app plugin with the highest priority is configured to be assigned the lowest priority after an idle time
+        	// Wait until the idle time rule applies
+        	// Simulate a low memory event
+        	// The plugin that initially had the highest priority (but now has the lowest priority) should be called
+        	// Note that this test should be the same as AppPluginTest1L with the addition of the idle period
+        	TInt AppPluginIdleTimeTest1L(TTestResult& aResult);	
+        	
+        	// Test idle time handling for plugins
+        	// Start two target apps
+        	// Simulate a low memory event
+        	// The one of the application plugins should now be run, displacing one of the system plugins
+        	// The target apps are of sufficiently high priority that they will not be closed
+        	TInt PluginIdleTimeTest2L(TTestResult& aResult);
+        	
+        	// Test the optional allocation mechanism
+        	// Configure the plugins not to release any RAM when FreeRam is called
+        	// Configure one priority 7 application to release 12MB when FreeRam is called
+        	// Start this application (plus another one so it isn't in the foreground)
+        	// Drop just below the good memory level
+        	// Request an optional allocation of 10MB referencing a priority 8 plugin
+        	// All of the plugins below P8 should be called
+        	// The P7 application should be closed freeing the required memory
+        	TInt OptionalAllocationTest1L(TTestResult& aResult);
+        	
+        	
+        	// Test the optional allocation mechanism - minimum requested RAM behaviour - successful request
+        	// Configure the plugins not to release any RAM when FreeRam is called
+        	// Configure one priority 7 application to release 5MB when FreeRam is called
+        	// Start this application (plus another one so it isn't in the foreground)
+        	// Drop just above the good memory level
+        	// Request an optional allocation of 10MB (5MB minimum) referencing a priority 8 plugin
+        	// All of the plugins below P8 should be called
+        	// The P7 application should be closed freeing the required minimum amount memory
+        	// The returned available memory should be about 5MB ( > 3MB and < 7MB )
+        	TInt OptionalAllocationTest2L(TTestResult& aResult);
+        	
+        	// Test the optional allocation mechanism - minimum requested RAM behaviour - failed request
+        	// Configure the plugins not to release any RAM when FreeRam is called
+        	// Configure one priority 7 application to release 3MB when FreeRam is called
+        	// Start this application (plus another one so it isn't in the foreground)
+        	// Drop just above the good memory level
+        	// Request an optional allocation of 10MB (5MB minimum) referencing a priority 8 plugin
+        	// All of the plugins below P8 should be called
+        	// The P7 application should be closed but it won't free enough memory
+        	// The optional allocation should fail with KErrNoMemory
+        	TInt OptionalAllocationTest3L(TTestResult& aResult);
+        	
+        	
+        	// Test that force priority check applies (only) to selected priorities
+        	// Setup three plugins (priorities 7, 8 & 9)to eat 5MB each
+        	// The configuration file should force a check after priority 8
+        	// Drop just under the low threshold
+        	// Plugins P7 & P8 should be called (P8 is called even though the P7 plugin freed enough memory)
+        	// Plugin P9 should not be called because enou
+        	TInt ForcePriorityCheck1L(TTestResult& aResult);
+        	
+        	// Test the Busy API on the OOM server
+        	// Start three applications
+        	// Ensure that the lowest priority app is not in the foreground
+        	// Call the busy API on the OOM monitor for the lowest priority app
+        	// Simulate a low memory event by going just under the low threshold
+        	// The busy application should not be closed
+        	// The other (non-foreground) application should be closed
+        	TInt BusyApplicationTest1L(TTestResult& aResult);
+
+        	// Test the Normal-priority API on the OOM server
+        	// Start three applications
+        	// Ensure that the lowest priority app is not in the foreground
+        	// Call the busy API on the OOM monitor for the lowest priority app
+        	// Then call the not-busy API on the OOM monitor for the lowest priority app
+        	// Simulate a low memory event by going just under the low threshold
+        	// The lowest priority app should be closed (because it is no longer busy)
+        	TInt NormalPriorityApplicationTest1L(TTestResult& aResult);
+        
+        	// Test the async optional allocation mechanism
+        	// Configure the plugins not to release any RAM when FreeRam is called
+        	// Configure one priority 7 application to release 12MB when FreeRam is called
+        	// Start this application (plus another one so it isn't in the foreground)
+        	// Drop just below the good memory level
+        	// Request an optional allocation of 10MB referencing a priority 8 plugin
+        	// All of the plugins below P8 should be called
+        	// The P7 application should be closed freeing the required memory
+        	TInt OptionalAllocationAsyncTest1L(TTestResult& aResult);
+        	
+        	
+        	// Test the async optional allocation mechanism - minimum requested RAM behaviour - successful request
+        	// Configure the plugins not to release any RAM when FreeRam is called
+        	// Configure one priority 7 application to release 5MB when FreeRam is called
+        	// Start this application (plus another one so it isn't in the foreground)
+        	// Drop just above the good memory level
+        	// Request an optional allocation of 10MB (5MB minimum) referencing a priority 8 plugin
+        	// All of the plugins below P8 should be called
+        	// The P7 application should be closed freeing the required minimum amount memory
+        	// The returned available memory should be about 5MB ( > 3MB and < 7MB )
+        	TInt OptionalAllocationAsyncTest2L(TTestResult& aResult);
+        	
+        	// Test the async optional allocation mechanism - minimum requested RAM behaviour - failed request
+        	// Configure the plugins not to release any RAM when FreeRam is called
+        	// Configure one priority 7 application to release 3MB when FreeRam is called
+        	// Start this application (plus another one so it isn't in the foreground)
+        	// Drop just above the good memory level
+        	// Request an optional allocation of 10MB (5MB minimum) referencing a priority 8 plugin
+        	// All of the plugins below P8 should be called
+        	// The P7 application should be closed but it won't free enough memory
+        	// The optional allocation should fail with KErrNoMemory
+        	TInt OptionalAllocationAsyncTest3L(TTestResult& aResult);
+
+        	// Test that sync mode configuration is working for system plugins
+        	// Configure three system plugins to release 5MB of memory each.
+        	// The plugins are configured as follows
+        	// Plugin 1: Priority 7, sync mode continue
+        	// Plugin 2: Priority 8, sync mode check
+        	// Plugin 3: Priority 9, sync mode continue
+        	// Drop just under the low threshold
+        	// Plugins 1 & 2 should be called (even though plugin 1 alone has freed enough RAM)
+        	// Plugin 3 won't be called because the check on the priority 8 plugin discovers that enough RAM has been freed
+        	TInt PluginSyncModeTest1L(TTestResult& aResult);	
+        	
+        	
+        	// Start three applications
+        	// One is set to NEVER_CLOSE, one is low priority, one is a dummy app to ensure that the first two are not in the foreground
+        	// Configure applications not to release any memory
+        	// Go just significantly under the low memory threshold
+        	// Wait for the system to recover, if we have moved above the low memory threshold then go significantly under it again. Repeat this step until we no longer go above low.
+        	// Check that the low priority application is closed
+        	// Check that the NEVER_CLOSE application is not closed (even though we're still below the low theshold)
+        	TInt NeverCloseTest1L(TTestResult& aResult);
+        	
+        	TInt AppCloseTwoSessionsL(TTestResult& aResult);
+
+            TInt CallIfTargetAppNotRunningTest1L(TTestResult& aResult);            	
+        
+            TInt AppCloseSpecificThresholdTest1L(TTestResult& aResult);
+            
+            // test that the plugins are left in the off state if a request for optional RAM 
+            // cannot be granted
+            TInt PluginTestInsufficientMemoryFreedL(TTestResult& aResult);
+            
+            // test that the plugins are left in the off state if a request for optional RAM 
+            // cannot be granted
+            // The test makes the optional RAM call from a state where memory is between the 
+            // global low and good thresholds
+            TInt PluginTestInsufficientMemoryFreed2L(TTestResult& aResult);
+            
+            
+    public:     // Data
+    // None
+
+    protected:  // Data
+    // None
+
+    private:    // Data
+        // Pointer to test (function) to be executed
+        TestFunction iMethod;
+
+        // Pointer to logger
+        CStifLogger * iLog;
+
+        // Normal logger
+        CStifLogger* iStdLog;
+
+        // Test case logger
+        CStifLogger* iTCLog;
+
+        // Flag saying if test case title should be added to log file name
+        TBool iAddTestCaseTitleToLogName;
+
+        // ?one_line_short_description_of_data
+        //?data_declaration;
+
+        // Reserved pointer for future extension
+        //TAny* iReserved;
+
+    	struct TPluginCallCount
+    		{
+    		TInt iFreeRamCallCount;
+    		TInt iMemoryGoodCallCount;
+    		};
+    	
+    	RHashMap<TInt32, TPluginCallCount> iPluginCallCounts;
+    	
+    	RPointerArray<CCDummyApplicationHandle> iApps;
+    	
+    	ROOMAllocSession iAllocServer;
+    	
+    	RChunk iChunk;
+    	TInt iChunkSize;    	
+
+        RChunk iDummyChunk;
+        TInt iDummyChunkSize;        
+    	
+    	ROomMonitorSession iOomSession;
+    	
+    	//CActiveScheduler needed by the memory monitor watchers
+    	CActiveScheduler* iScheduler;
+    	
+    	//The watchers
+    	CMemoryMonitorStatusWatcher* iStatusWatcher;
+    	CMemoryMonitorTimeoutWatcher* iTimeoutWatcher;      
+    	
+    	
+    public:     // Friend classes
+    // None
+
+    protected:  // Friend classes
+    // None
+
+    private:    // Friend classes
+    // None
+
+    };
+
+/**
+*  This CMemoryMonitorStatusWatcher class signals a client if the memorymonitor status becomes different from EFreeingMemory.
+*  ?other_description_lines
+*
+*  @lib ?library
+*  @since ?Series60_version
+*/
+NONSHARABLE_CLASS(CMemoryMonitorStatusWatcher) : public CActive
+    {
+    public:
+        static CMemoryMonitorStatusWatcher* NewL();
+        ~CMemoryMonitorStatusWatcher();
+        void Start(TInt* aWatcherState);
+    private:
+        CMemoryMonitorStatusWatcher();
+        void ConstructL();
+        void DoCancel();
+        void RunL();
+    private:
+        RProperty iMonitorProperty;
+        TInt* iTestState;
+    };
+
+/**
+*  This CMemoryMonitorTimeoutWatcher class signals a client if the memorymonitor takes too long to leave EFreeingMemory state.
+*  ?other_description_lines
+*
+*  @lib ?library
+*  @since ?Series60_version
+*/
+NONSHARABLE_CLASS(CMemoryMonitorTimeoutWatcher) : public CTimer
+    {
+public:
+    static CMemoryMonitorTimeoutWatcher* NewL();
+    ~CMemoryMonitorTimeoutWatcher();
+    void Start(TInt* aTestState, const TTimeIntervalMicroSeconds32& aTimeout);
+    
+private:
+    CMemoryMonitorTimeoutWatcher();
+    void ConstructL();
+    void DoCancel();
+    void RunL();
+private:
+    TInt* iTestState;
+    };
+
+struct TReturnStatus
+    {
+    TInt iId;
+    TBool iCompleted;
+    TInt iReturnStatus;
+    };
+
+
+NONSHARABLE_CLASS(CAsyncRequester) : public CActive
+    {
+public:
+    static CAsyncRequester* NewL(RChunk aChunk, TInt aChunkSize);
+    ~CAsyncRequester();
+    void Start(TInt aBytesToRequest, TReturnStatus* aReturnStatus);
+    
+private:
+    CAsyncRequester(RChunk aChunk, TInt aChunkSize);
+    void ConstructL();
+    void DoCancel();
+    void RunL();
+private:
+    ROomMonitorSession iSession;
+    TReturnStatus* iReturnStatus;
+    RChunk iChunk;
+    TInt iChunkSize;
+    };
+
+
+
+inline void COomTestHarness::Settle()
+	{
+	//wait for oom system to settle
+	User::After(TTimeIntervalMicroSeconds32(KSettlingTime));
+	}
+
+#endif      // T_OOMHARNESS_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomharness_stif/src/CDummyApplicationHandle.cpp	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,78 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+#include <w32std.h>
+#include "CDummyApplicationHandle.h"
+
+CCDummyApplicationHandle::CCDummyApplicationHandle(TUid aUid)
+: iUid(aUid)
+	{
+	// No implementation required
+	}
+
+CCDummyApplicationHandle::~CCDummyApplicationHandle()
+	{
+	if(iMsgQueue.Handle())
+		{
+		iMsgQueue.SendBlocking(0);
+		iMsgQueue.Close();
+		}
+	iProcess.Close();
+	}
+
+CCDummyApplicationHandle* CCDummyApplicationHandle::NewLC(TUid aUid, TInt aExtraMemoryAllocation)
+	{
+	CCDummyApplicationHandle* self = new (ELeave) CCDummyApplicationHandle(aUid);
+	CleanupStack::PushL(self);
+	self->ConstructL(aExtraMemoryAllocation);
+	return self;
+	}
+
+CCDummyApplicationHandle* CCDummyApplicationHandle::NewL(TUid aUid, TInt aExtraMemoryAllocation)
+	{
+	CCDummyApplicationHandle* self = CCDummyApplicationHandle::NewLC(aUid, aExtraMemoryAllocation);
+	CleanupStack::Pop(); // self;
+	return self;
+	}
+
+void CCDummyApplicationHandle::ConstructL(TInt aExtraMemoryAllocation)
+	{
+	TBuf<28> params;
+	params.Format(_L("uid=%08x alloc=%x"), iUid, aExtraMemoryAllocation);
+	User::LeaveIfError(iProcess.Create(_L("t_oomdummyapp_0xE6CFBA00.exe"), params));
+	User::LeaveIfError(iMsgQueue.CreateGlobal(KNullDesC, 4));
+	User::LeaveIfError(iProcess.SetParameter(15, iMsgQueue));
+	iProcess.Resume();
+	}
+
+void CCDummyApplicationHandle::SendMessage(TInt aMessage)
+	{
+	iMsgQueue.SendBlocking(aMessage);
+	}
+
+TBool CCDummyApplicationHandle::CompareTo(const TUid* aKey, const CCDummyApplicationHandle& aValue)
+	{
+	return aValue.iUid == *aKey;
+	}
+
+void CCDummyApplicationHandle::BringToForeground()
+	{
+	SendMessage(1);
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomharness_stif/src/t_oomharness.cpp	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,584 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+
+// INCLUDE FILES
+#include <Stiftestinterface.h>
+#include "t_oomharness.h"
+#include <e32math.h>
+#include "SettingServerClient.h"
+#include <e32property.h>
+
+// EXTERNAL DATA STRUCTURES
+// None
+
+// EXTERNAL FUNCTION PROTOTYPES  
+// None
+
+// CONSTANTS
+// None
+
+// MACROS
+// None
+
+// LOCAL CONSTANTS AND MACROS
+// None
+
+// MODULE DATA STRUCTURES
+// None
+
+// LOCAL FUNCTION PROTOTYPES
+// None
+
+// FORWARD DECLARATIONS
+// None
+
+// ==================== LOCAL FUNCTIONS =======================================
+
+
+/*
+-------------------------------------------------------------------------------
+
+    DESCRIPTION
+    
+    This file (t_oomharness.cpp) contains all test framework related parts of
+    this test module. Actual test cases are implemented in file 
+    t_oomharnesscases.cpp.
+
+    COomTestHarness is an example of test module implementation. This example
+    uses hard coded test cases (i.e it does not have any test case
+    configuration file).
+
+    Example uses function pointers to call test cases. This provides an easy
+    method to add new test cases.
+
+    See function Cases in file t_oomharnesscases.cpp for instructions how to
+    add new test cases. It is not necessary to modify this file when adding
+    new test cases.
+
+    To take this module into use, add following lines to test framework
+    initialisation file:
+
+# t_oomharness_stif
+[New_Module]
+ModuleName= t_oomharness_stif
+[End_Module]
+
+-------------------------------------------------------------------------------
+*/
+
+// ================= MEMBER FUNCTIONS =========================================
+
+/*
+-------------------------------------------------------------------------------
+
+    Class: COomTestHarness
+
+    Method: COomTestHarness
+
+    Description: C++ default constructor can NOT contain any code, that
+    might leave.
+
+    Parameters: None
+
+    Return Values: None
+
+    Errors/Exceptions: None
+
+    Status: Approved
+
+-------------------------------------------------------------------------------
+*/
+COomTestHarness::COomTestHarness()
+    {
+    }
+
+/*
+-------------------------------------------------------------------------------
+
+    Class: COomTestHarness
+
+    Method: ConstructL
+
+    Description: Symbian 2nd phase constructor that can leave.
+
+    Note: If OOM test case uses STIF Logger, then STIF Logger must be created
+    with static buffer size parameter (aStaticBufferSize). Otherwise Logger 
+    allocates memory from heap and therefore causes error situations with OOM 
+    testing. For more information about STIF Logger construction, see STIF 
+    Users Guide.
+
+    Parameters: None
+
+    Return Values: None
+
+    Errors/Exceptions: None
+
+    Status: Approved
+
+-------------------------------------------------------------------------------
+*/
+void COomTestHarness::ConstructL()
+    {
+    //Read logger settings to check whether test case name is to be
+    //appended to log file name.
+    RSettingServer settingServer;
+    TInt ret = settingServer.Connect();
+    if(ret != KErrNone)
+        {
+        User::Leave(ret);
+        }
+    // Struct to StifLogger settigs.
+    TLoggerSettings loggerSettings; 
+    // Parse StifLogger defaults from STIF initialization file.
+    ret = settingServer.GetLoggerSettings(loggerSettings);
+    if(ret != KErrNone)
+        {
+        User::Leave(ret);
+        } 
+    // Close Setting server session
+    settingServer.Close();
+    iAddTestCaseTitleToLogName = loggerSettings.iAddTestCaseTitle;
+    
+    // Constructing static buffer size logger, needed with OOM testing because
+    // normally logger allocates memory from heap!
+    iStdLog = CStifLogger::NewL( KT_OomHarnessLogPath, 
+                              KT_OomHarnessLogFile,
+                              CStifLogger::ETxt,
+                              CStifLogger::EFile,
+                              ETrue,
+                              ETrue,
+                              ETrue,
+                              EFalse,
+                              ETrue,
+                              EFalse,
+                              100 );
+    iLog = iStdLog;
+    
+    // Sample how to use logging
+    _LIT( KLogInfo, "t_oomharness logging starts!" );
+    iLog->Log( KLogInfo );
+    
+	User::LeaveIfError(iAllocServer.Connect());
+	User::LeaveIfError(iOomSession.Connect());
+	
+	User::LeaveIfError(iChunk.CreateLocal(KOomHarnessInitialEatenMemory, KOomHarnessMaxEatenMemory));
+	iChunkSize = KOomHarnessInitialEatenMemory;
+	
+    iScheduler = new (ELeave) CActiveScheduler;
+    CActiveScheduler::Install( iScheduler );
+    
+    iStatusWatcher = CMemoryMonitorStatusWatcher::NewL();
+    iTimeoutWatcher = CMemoryMonitorTimeoutWatcher::NewL();
+    
+	ResetL();
+    }
+
+/*
+-------------------------------------------------------------------------------
+
+    Class: COomTestHarness
+
+    Method: NewL
+
+    Description: Two-phased constructor. Constructs new COomTestHarness
+    instance and returns pointer to it.
+
+    Parameters:    None
+
+    Return Values: COomTestHarness*: new object.
+
+    Errors/Exceptions: Leaves if memory allocation fails or ConstructL leaves.
+
+    Status: Approved
+
+-------------------------------------------------------------------------------
+*/
+COomTestHarness* COomTestHarness::NewL()
+    {
+    COomTestHarness* self = new (ELeave) COomTestHarness;
+
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop();
+
+    return self;
+    }
+
+/*
+-------------------------------------------------------------------------------
+
+    Class: COomTestHarness
+
+    Method: ~COomTestHarness
+
+    Description: Destructor.
+
+    Parameters:    None
+
+    Return Values: None
+
+    Errors/Exceptions: None
+
+    Status: Approved
+
+-------------------------------------------------------------------------------
+*/
+COomTestHarness::~COomTestHarness()
+    { 
+    iLog = NULL;
+    delete iStdLog;
+    iStdLog = NULL;
+    delete iTCLog;
+    iTCLog = NULL;
+	iApps.ResetAndDestroy();
+	iAllocServer.Close();
+	iChunk.Close();
+	iPluginCallCounts.Close();
+	delete iScheduler;
+    delete iStatusWatcher;
+    delete iTimeoutWatcher;
+    }
+
+/*
+-------------------------------------------------------------------------------
+    Class: COomTestHarness
+
+    Method: InitL
+
+    Description: Method for test case initialization
+    
+    Parameters: None
+
+    Return Values: None
+
+    Errors/Exceptions: None
+
+    Status: Approved
+-------------------------------------------------------------------------------
+*/
+TInt COomTestHarness::InitL( TFileName& /*aIniFile*/, 
+                         TBool /*aFirstTime*/ )
+    {
+    return KErrNone;
+
+    }
+
+/*
+-------------------------------------------------------------------------------
+
+    Class: COomTestHarness
+
+    Method: GetTestCases
+
+    Description: GetTestCases is used to inquire test cases 
+    from the test module. Because this test module has hard coded test cases
+    (i.e cases are not read from file), paramter aConfigFile is not used.
+
+    This function loops through all cases defined in Cases() function and 
+    adds corresponding items to aTestCases array.
+
+    Parameters: const TFileName&  : in: Configuration file name. Not used                                                       
+                RPointerArray<TTestCaseInfo>& aTestCases: out: 
+                      Array of TestCases.
+    
+    Return Values: KErrNone: No error
+
+    Errors/Exceptions: Function leaves if any memory allocation operation fails
+
+    Status: Proposal
+    
+-------------------------------------------------------------------------------
+*/      
+TInt COomTestHarness::GetTestCasesL( const TFileName& /*aConfig*/, 
+                                 RPointerArray<TTestCaseInfo>& aTestCases )
+    {
+    // Loop through all test cases and create new
+    // TTestCaseInfo items and append items to aTestCase array    
+    for( TInt i = 0; Case(i).iMethod != NULL; i++ )
+        {
+        // Allocate new TTestCaseInfo from heap for a testcase definition.
+        TTestCaseInfo* newCase = new( ELeave ) TTestCaseInfo();
+    
+        // PushL TTestCaseInfo to CleanupStack.    
+        CleanupStack::PushL( newCase );
+
+        // Set number for the testcase.
+        // When the testcase is run, this comes as a parameter to RunTestCaseL.
+        newCase->iCaseNumber = i;
+
+        // Set title for the test case. This is shown in UI to user.
+        newCase->iTitle.Copy( Case(i).iCaseName );
+
+        // Append TTestCaseInfo to the testcase array. After appended 
+        // successfully the TTestCaseInfo object is owned (and freed) 
+        // by the TestServer. 
+        User::LeaveIfError(aTestCases.Append ( newCase ) );
+        
+        // Pop TTestCaseInfo from the CleanupStack.
+        CleanupStack::Pop( newCase );
+        }
+
+    return KErrNone;
+
+    }
+
+/*
+-------------------------------------------------------------------------------
+
+    Class: COomTestHarness
+
+    Method: RunTestCase
+
+    Description: Run a specified testcase.
+
+    Function runs a test case specified by test case number. Test case file
+    parameter is not used.
+
+    If case number is valid, this function runs a test case returned by
+    function Cases(). 
+
+    Parameters: const TInt aCaseNumber: in: Testcase number 
+                const TFileName& : in: Configuration file name. Not used
+                TTestResult& aResult: out: Testcase result
+
+    Return Values: KErrNone: Testcase ran.
+                   KErrNotFound: Unknown testcase
+
+    Errors/Exceptions: None
+    
+    Status: Proposal
+
+-------------------------------------------------------------------------------
+*/
+TInt COomTestHarness::RunTestCaseL( const TInt aCaseNumber,
+                                const TFileName& /* aConfig */,
+                                TTestResult& aResult )
+    {
+    // Return value
+    TInt execStatus = KErrNone;
+
+    // Get the pointer to test case function
+    TCaseInfo tmp = Case ( aCaseNumber );
+
+    _LIT( KLogInfo, "Starting testcase [%S]" );
+    iLog->Log( KLogInfo, &tmp.iCaseName);
+
+    // Check that case number was valid
+    if ( tmp.iMethod != NULL )
+        {
+        //Open new log file with test case title in file name
+        if(iAddTestCaseTitleToLogName)
+            {
+            //delete iLog; //Close currently opened log
+            //iLog = NULL;
+            //Delete test case logger if exists
+            if(iTCLog)
+                {
+                delete iTCLog;
+                iTCLog = NULL;
+                }
+                
+            TFileName logFileName;
+            TName title;
+            TestModuleIf().GetTestCaseTitleL(title);
+        
+            logFileName.Format(KT_OomHarnessLogFileWithTitle, &title);
+
+            iTCLog = CStifLogger::NewL(KT_OomHarnessLogPath, 
+                                     logFileName,
+                                     CStifLogger::ETxt,
+                                     CStifLogger::EFile,
+                                     ETrue,
+                                     ETrue,
+                                     ETrue,
+                                     EFalse,
+                                     ETrue,
+                                     EFalse,
+                                     100);
+            iLog = iTCLog;
+            }
+
+        // Valid case was found, call it via function pointer
+        iMethod = tmp.iMethod;        
+        //execStatus  = ( this->*iMethod )( aResult );
+        TRAPD(err, execStatus  = ( this->*iMethod )( aResult ));
+        if(iAddTestCaseTitleToLogName)
+            {
+            //Restore standard log and destroy test case logger
+            iLog = iStdLog;
+            delete iTCLog; //Close currently opened log
+            iTCLog = NULL;
+            }
+        User::LeaveIfError(err);
+        
+        }
+    else
+        {
+        // Valid case was not found, return error.
+        execStatus = KErrNotFound;
+        }
+
+    // Return case execution status (not the result of the case execution)
+    return execStatus;
+
+    }
+
+/*
+-------------------------------------------------------------------------------
+
+    Class: COomTestHarness
+
+    Method: OOMTestQueryL
+
+    Description: Checks test case information for OOM execution. 
+
+    Return Values: TBool
+
+    Errors/Exceptions: None
+
+    Status: Proposal
+
+-------------------------------------------------------------------------------
+*/
+TBool COomTestHarness::OOMTestQueryL( const TFileName& /* aTestCaseFile */, 
+                                  const TInt aCaseNumber, 
+                                  TOOMFailureType& /* aFailureType */, 
+                                  TInt& aFirstMemFailure, 
+                                  TInt& aLastMemFailure ) 
+    {
+    _LIT( KLogInfo, "COomTestHarness::OOMTestQueryL" );
+    iLog->Log( KLogInfo ); 
+
+    aFirstMemFailure = Case( aCaseNumber ).iFirstMemoryAllocation;
+    aLastMemFailure = Case( aCaseNumber ).iLastMemoryAllocation;
+
+    return Case( aCaseNumber ).iIsOOMTest;
+    }
+
+/*
+-------------------------------------------------------------------------------
+
+    Class: COomTestHarness
+
+    Method: OOMTestInitializeL
+
+    Description: Used to perform the test environment setup for a particular
+    OOM test case. Test Modules may use the initialization file to read 
+    parameters for Test Module initialization but they can also have their own
+    configure file or some other routine to initialize themselves. 
+
+    NOTE: User may add implementation for OOM test environment initialization.
+    Usually no implementation is required.
+
+    Return Values: None
+
+    Errors/Exceptions: None
+
+    Status: Proposal
+
+-------------------------------------------------------------------------------
+*/
+void COomTestHarness::OOMTestInitializeL( const TFileName& /* aTestCaseFile */, 
+                                      const TInt /* aCaseNumber */ )
+    {
+    _LIT( KLogInfo, "COomTestHarness::OOMTestInitializeL" );
+    iLog->Log( KLogInfo ); 
+
+    }
+
+/*
+-------------------------------------------------------------------------------
+
+    Class: COomTestHarness
+
+    Method: OOMHandleWarningL
+
+    Description: Used in OOM testing to provide a way to the derived TestModule 
+    to handle warnings related to non-leaving or TRAPped allocations.
+
+    In some cases the allocation should be skipped, either due to problems in 
+    the OS code or components used by the code being tested, or even inside the
+    tested components which are implemented this way on purpose (by design), so
+    it is important to give the tester a way to bypass allocation failures.
+
+    NOTE: User may add implementation for OOM test warning handling. Usually no
+    implementation is required.    
+
+    Return Values: None
+
+    Errors/Exceptions: None
+
+    Status: Proposal
+
+-------------------------------------------------------------------------------
+*/
+void COomTestHarness::OOMHandleWarningL( const TFileName& /* aTestCaseFile */,
+                                     const TInt /* aCaseNumber */, 
+                                     TInt& /* aFailNextValue */ )
+    {
+    _LIT( KLogInfo, "COomTestHarness::OOMHandleWarningL" );
+    iLog->Log( KLogInfo );
+
+    }
+
+/*
+-------------------------------------------------------------------------------
+
+    Class: COomTestHarness
+
+    Method: OOMTestFinalizeL
+
+    Description: Used to perform the test environment cleanup for a particular OOM 
+    test case.
+
+    NOTE: User may add implementation for OOM test environment finalization.
+    Usually no implementation is required.   
+
+    Return Values: None
+
+    Errors/Exceptions: None
+
+    Status: Proposal
+
+-------------------------------------------------------------------------------
+*/
+void COomTestHarness::OOMTestFinalizeL( const TFileName& /* aTestCaseFile */, 
+                                    const TInt /* aCaseNumber */ )
+    {
+    _LIT( KLogInfo, "COomTestHarness::OOMTestFinalizeL" );
+    iLog->Log( KLogInfo );
+
+    }
+
+// ========================== OTHER EXPORTED FUNCTIONS =========================
+
+// -----------------------------------------------------------------------------
+// LibEntryL is a polymorphic Dll entry point
+// Returns: CTestModuleBase*: Pointer to Test Module object
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CTestModuleBase* LibEntryL()
+    {
+    return COomTestHarness::NewL();
+
+    }
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomharness_stif/src/t_oomharnesscases.cpp	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,3332 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+
+// INCLUDE FILES
+#include <e32hal.h>	//User::HAL
+#include <e32property.h> //RProperty
+#include "t_oomharness.h"
+#include "CDummyApplicationHandle.h"
+#include "../../t_oomdummyapp/inc/t_oomdummyappmsgs.h"
+#include "t_oomdummyplugin_properties.h"
+#include <hal.h>
+
+// EXTERNAL DATA STRUCTURES
+// None
+
+// EXTERNAL FUNCTION PROTOTYPES  
+// None
+
+// CONSTANTS
+// None
+
+// MACROS
+// None
+
+// LOCAL CONSTANTS AND MACROS
+
+const TInt KOomJustUnderLowMemoryThreshold = 4000;
+const TInt KOomSignificantlyUnderLowMemoryThreshold = 2024;
+const TInt KOomBetweenLowAndGoodThresholds = 4300;
+const TInt KOomJustAboveGoodMemoryThreshold = 5100;
+
+const TInt KOomTestFirstIdlePeriod = 40000000; // 40 seconds
+
+
+// MODULE DATA STRUCTURES
+// None
+
+// LOCAL FUNCTION PROTOTYPES
+// None
+
+// FORWARD DECLARATIONS
+// None
+
+// ==================== LOCAL FUNCTIONS =======================================
+
+/*
+-------------------------------------------------------------------------------
+
+    DESCRIPTION
+
+    This module contains the implementation of COomTestHarness class 
+    member functions that does the actual tests.
+
+-------------------------------------------------------------------------------
+*/
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+/*
+-------------------------------------------------------------------------------
+
+    Class: COomTestHarness
+
+    Method: Case
+
+    Description: Returns a test case by number.
+
+    This function contains an array of all available test cases 
+    i.e pair of case name and test function. If case specified by parameter
+    aCaseNumber is found from array, then that item is returned.
+
+    The reason for this rather complicated function is to specify all the
+    test cases only in one place. It is not necessary to understand how
+    function pointers to class member functions works when adding new test
+    cases. See function body for instructions how to add new test case.
+    
+    Parameters:    const TInt aCaseNumber :in:      Test case number
+
+    Return Values: const TCaseInfo Struct containing case name & function
+
+    Errors/Exceptions: None
+
+    Status: Proposal
+
+-------------------------------------------------------------------------------
+*/ 
+const TCaseInfo COomTestHarness::Case ( 
+    const TInt aCaseNumber ) const 
+     {
+
+    /*
+    * To add new test cases, implement new test case function and add new 
+    * line to KCases array specify the name of the case and the function 
+    * doing the test case
+    * In practice, do following
+    *
+    * 1) Make copy of existing test case function and change its name
+    *    and functionality. Note that the function must be added to 
+    *    OOMHard.cpp file and to OOMHard.h 
+    *    header file.
+    *
+    * 2) Add entry to following KCases array either by using:
+    *
+    * 2.1: FUNCENTRY or ENTRY macro
+    * ENTRY macro takes two parameters: test case name and test case 
+    * function name.
+    *
+    * FUNCENTRY macro takes only test case function name as a parameter and
+    * uses that as a test case name and test case function name.
+    *
+    * Or
+    *
+    * 2.2: OOM_FUNCENTRY or OOM_ENTRY macro. Note that these macros are used
+    * only with OOM (Out-Of-Memory) testing!
+    *
+    * OOM_ENTRY macro takes five parameters: test case name, test case 
+    * function name, TBool which specifies is method supposed to be run using
+    * OOM conditions, TInt value for first heap memory allocation failure and 
+    * TInt value for last heap memory allocation failure.
+    * 
+    * OOM_FUNCENTRY macro takes test case function name as a parameter and uses
+    * that as a test case name, TBool which specifies is method supposed to be
+    * run using OOM conditions, TInt value for first heap memory allocation 
+    * failure and TInt value for last heap memory allocation failure. 
+    */ 
+
+    static TCaseInfoInternal const KCases[] =
+        {
+        // To add new test cases, add new items to this array
+        
+        // NOTE: When compiled to GCCE, there must be Classname::
+        // declaration in front of the method name, e.g. 
+        // COomTestHarness::PrintTest. Otherwise the compiler
+        // gives errors.
+                        		
+        ENTRY( "App Close Test 1", COomTestHarness::AppCloseTest1L ),
+        ENTRY( "App Close Idle Time", COomTestHarness::AppCloseIdleTimeTest1L ),
+        ENTRY( "App Close Equal Priorities", COomTestHarness::AppCloseEqualPrioritiesL ),        
+        ENTRY( "Plugin Test 1", COomTestHarness::PluginTest1L ),
+        ENTRY( "Plugin Test 2", COomTestHarness::PluginTest2L ),
+        ENTRY( "App Plugin Test 1", COomTestHarness::AppPluginTest1L ),
+        ENTRY( "App Plugin Idle Time Test 1", COomTestHarness::AppPluginIdleTimeTest1L ),
+        ENTRY( "Optional Allocation Test 1", COomTestHarness::OptionalAllocationTest1L ),
+        ENTRY( "Optional Allocation Test 2", COomTestHarness::OptionalAllocationTest2L ),
+        ENTRY( "Optional Allocation Test 3", COomTestHarness::OptionalAllocationTest3L ),
+        ENTRY( "Plugin V2 Test 1", COomTestHarness::PluginV2Test1L ),
+        ENTRY( "Force Priority Check Test 1", COomTestHarness::ForcePriorityCheck1L ),
+		ENTRY( "Plugin Sync Mode Test 1", COomTestHarness::PluginSyncModeTest1L ),
+		ENTRY( "Never Close Test 1", COomTestHarness::NeverCloseTest1L ),
+		ENTRY( "Optional Allocation Async Test 1", COomTestHarness::OptionalAllocationAsyncTest1L ),
+		ENTRY( "Optional Allocation Async Test 2", COomTestHarness::OptionalAllocationAsyncTest2L ),
+		ENTRY( "Optional Allocation Async Test 3", COomTestHarness::OptionalAllocationAsyncTest3L ),
+#ifdef CLIENT_REQUEST_QUEUE
+		ENTRY( "App Close Two Client Sessions", COomTestHarness::AppCloseTwoSessionsL ),
+#endif		
+        ENTRY( "Call If Target App Not Running Test 1", COomTestHarness::CallIfTargetAppNotRunningTest1L ),		
+#ifdef __WINS__
+        ENTRY( "App Close Specific Threshold Test 1", COomTestHarness::AppCloseSpecificThresholdTest1L ),     
+#endif
+        ENTRY( "Plugin Test Insufficient Memory Freed", COomTestHarness::PluginTestInsufficientMemoryFreedL ),
+        ENTRY( "Plugin Test Insufficient Memory Freed 2", COomTestHarness::PluginTestInsufficientMemoryFreed2L ),
+        };
+
+    // Verify that case number is valid
+    if( (TUint) aCaseNumber >= sizeof( KCases ) / 
+                               sizeof( TCaseInfoInternal ) )
+        {
+
+        // Invalid case, construct empty object
+        TCaseInfo null( (const TText*) L"" );
+        null.iMethod = NULL;
+        null.iIsOOMTest = EFalse;
+        null.iFirstMemoryAllocation = 0;
+        null.iLastMemoryAllocation = 0;
+        return null;
+
+        } 
+
+    // Construct TCaseInfo object and return it
+    TCaseInfo tmp ( KCases[ aCaseNumber ].iCaseName );
+    tmp.iMethod = KCases[ aCaseNumber ].iMethod;
+    tmp.iIsOOMTest = KCases[ aCaseNumber ].iIsOOMTest;
+    tmp.iFirstMemoryAllocation = KCases[ aCaseNumber ].iFirstMemoryAllocation;
+    tmp.iLastMemoryAllocation = KCases[ aCaseNumber ].iLastMemoryAllocation;
+    return tmp;
+
+    }
+
+TInt COomTestHarness::AppCloseTest1L(TTestResult& aResult)
+	{
+	ResetL();
+	
+	// The lowest priority app should be in the foregound
+	// ... with the next lowest behind it
+	// ... followed by the highest priority application at the back
+	StartApplicationL(KOomTestAppUid, 5 * 1024); // P9 app
+	StartApplicationL(KOomTestApp2Uid, 5 * 1024); // P8 app, configure it to eat 5MB
+	StartApplicationL(KOomTestApp3Uid, 0); // P7 app
+	
+	BringAppToForeground(KOomTestApp3Uid);
+	
+	//start watchers
+	TInt memTestState = ETestInit;
+	TInt err = KErrNone;
+	
+	StartMemoryMonitorStatusWatcher(memTestState);
+
+    // Go significantly under the low memory threshold
+    EatMemoryL(KOomSignificantlyUnderLowMemoryThreshold);
+
+    //start timer, start scheduler & stop watchers when done
+    StartTimerAndRunWatcher(memTestState);
+    
+    if (err == KErrNone && memTestState == ETestAbove)
+        {
+        err = AppIsRunning(KOomTestApp2Uid, EFalse);
+        
+        if (err != KErrNone)
+            {
+            _LIT( KResult ,"P8 App KOomTestApp2Uid incorrectly running");
+            aResult.iResultDes.Copy( KResult );
+            aResult.iResult = KErrGeneral;
+           // Case was executed but failed
+            }
+        if (err == KErrNone)
+            {	
+            err = AppIsRunning(KOomTestApp3Uid, ETrue);	
+            if (err != KErrNone)
+                {
+                // The P7 app should still be running because it was in the foreground
+                _LIT( KResult ,"(P7 App KOomTestApp3Uid not running");
+                aResult.iResultDes.Copy( KResult );
+                aResult.iResult = KErrGeneral;
+                // Case was executed but failed
+                }
+            }
+        if (err == KErrNone)
+            {	
+            err = AppIsRunning(KOomTestAppUid, ETrue);	
+            if (err != KErrNone)
+                {
+                // The P9 app should still be running because the P8 application freed enough memory
+                _LIT( KResult ,"P9 App KOomTestAppUid not running");
+                aResult.iResultDes.Copy( KResult );
+                aResult.iResult = KErrGeneral;
+                // Case was executed but failed
+                }
+            }
+        if (err == KErrNone)
+            {
+            _LIT( KDescription , "Test case passed");
+            aResult.SetResult( KErrNone, KDescription );
+            }
+        }
+    else
+        {
+        _LIT( KResult ,"Watchers failed to start or Application Timeout or Memory Still Below Treshhold ");
+        aResult.iResultDes.Copy( KResult );
+        aResult.iResult = KErrGeneral;
+        // case was not executed or case was executed but never finished or failed 
+        }
+	ResetL();    
+    return KErrNone;	
+	}
+
+// Tests the idle time rule mechanism for app closure
+// Start three applications
+// The lowest priority app should be in the foregound
+// ... with the next lowest behind it
+// ... followed by the highest priority application at the back
+// After an idle period the highest priority app is configured to become the lowest priority
+// The middle and highest application should be configured to eat 5MB of memory
+// A low memory event is triggered and the middle application only should be closed
+// Note that this test should be the same as AppCloseTest1L, with the exception of the idle period which causes different apps to be closed
+TInt COomTestHarness::AppCloseIdleTimeTest1L(TTestResult& aResult)
+	{
+	ResetL();
+	
+	// The lowest priority app should be in the foregound
+	// ... with the next lowest behind it
+	// ... followed by the highest priority application at the back
+	StartApplicationL(KOomTestAppUid, 5 * 1024); // P9 app (which becomes a P2 app after the idle time)
+	StartApplicationL(KOomTestApp2Uid, 5 * 1024); // P8 app, configure it to eat 5MB
+	StartApplicationL(KOomTestApp3Uid, 0); // P7 app
+	
+	BringAppToForeground(KOomTestApp3Uid);
+	
+	// Wait for the first set of idle time rules to apply
+	User::After(KOomTestFirstIdlePeriod);
+	
+	//start watchers
+	TInt memTestState = ETestInit;
+    TInt err = KErrNone;
+    StartMemoryMonitorStatusWatcher(memTestState);
+    
+    // Go significantly under the low memory threshold
+    EatMemoryL(KOomSignificantlyUnderLowMemoryThreshold);
+
+    //start timer, start scheduler & stop watchers when done
+    StartTimerAndRunWatcher(memTestState);        
+
+    if (err == KErrNone && memTestState == ETestAbove)
+        {
+	    err = AppIsRunning(KOomTestAppUid, EFalse);		
+
+	    if (err != KErrNone)
+	        {
+	        // The P9 app should have become a P2 app after the idle period, therefore it should have been the first candidate for closure
+	        _LIT( KResult ,"P9->P2 App KOomTestAppUid running");
+	        aResult.iResultDes.Copy( KResult );
+	        aResult.iResult = KErrGeneral;
+	        // Case was executed but failed
+	        }	
+
+	    if (err == KErrNone)
+	        {	
+	        err = AppIsRunning(KOomTestApp2Uid, ETrue);
+	        if (err != KErrNone)
+	            {
+	            // The P8 application should still be running because the P9 app (that has become a P2 app) has freed the required memory
+	            _LIT( KResult ,"P8 App KOomTestApp2Uid not running");
+	            aResult.iResultDes.Copy( KResult );
+	            aResult.iResult = KErrGeneral;
+	            // Case was executed but failed
+	            }		
+	        }
+
+	    if (err == KErrNone)
+	        {	
+	        err = AppIsRunning(KOomTestApp3Uid, ETrue);	
+	        if (err != KErrNone)
+	            {
+	            // The P7 app should still be running because it was in the foreground
+	            _LIT( KResult ,"P7 App KOomTestApp3Uid not running");
+	            aResult.iResultDes.Copy( KResult );
+	            aResult.iResult = KErrGeneral;
+	            // Case was executed but failed
+	            }	
+	        }
+
+	    if (err == KErrNone)
+	        {
+	        _LIT( KDescription , "Test case passed");
+	        aResult.SetResult( KErrNone, KDescription );
+	        }
+        }
+    else
+        {
+        _LIT( KResult ,"Watchers failed to start or Application Timeout or Memory Still Below Treshhold ");
+        aResult.iResultDes.Copy( KResult );
+        aResult.iResult = KErrGeneral;
+        // case was not executed or case was executed but never finished or failed 
+        }
+    
+	ResetL();    
+    return KErrNone;	
+	}
+
+TInt COomTestHarness::AppCloseEqualPrioritiesL(TTestResult& aResult)
+	{
+	ResetL();
+	
+	StartApplicationL(KOomTestApp4Uid, 3 * 1024); // P7 app1, configure it to eat 5MB
+
+	Settle();	
+	
+	StartApplicationL(KOomTestApp3Uid, 3 * 1024); // P7 app2, configure it to eat 5MB
+
+	Settle();
+	
+	StartApplicationL(KOomTestApp5Uid, 3 * 1024); // P7 app3, configure it to eat 5MB
+
+	Settle();	
+	
+	StartApplicationL(KOomTestAppUid, 0); //P9 app
+	
+	Settle();
+	
+    //start watchers
+    TInt memTestState = ETestInit;
+    TInt err = KErrNone;
+    
+    StartMemoryMonitorStatusWatcher(memTestState);
+	
+    // Go significantly under the low memory threshold
+    EatMemoryL(KOomSignificantlyUnderLowMemoryThreshold);
+
+    //start timer, start scheduler & stop watchers when done
+    StartTimerAndRunWatcher(memTestState);
+
+
+    if (err == KErrNone && memTestState == ETestAbove)
+        {
+        err = AppIsRunning(KOomTestApp4Uid, EFalse);	
+        if (err != KErrNone)
+            {
+            // The P7 app furthest to the back in the z order should be closed.
+            // This should release sufficient memory.
+            _LIT( KResult ,"P7 App KOomTestApp4Uid incorrectly running");
+            aResult.iResultDes.Copy( KResult );
+            aResult.iResult = KErrGeneral;
+           // Case was executed but failed
+            }
+        
+        // the other 3 apps should all still be running
+        if (err == KErrNone)
+            {	
+            err = AppIsRunning(KOomTestApp3Uid, ETrue);	
+            if (err != KErrNone)
+                {
+                _LIT( KResult ,"App KOomTestApp3Uid not running");
+                aResult.iResultDes.Copy( KResult );
+                aResult.iResult = KErrGeneral;
+                // Case was executed but failed
+                }
+            }
+        if (err == KErrNone)
+            {	
+            err = AppIsRunning(KOomTestApp5Uid, ETrue);	
+            if (err != KErrNone)
+                {
+                _LIT( KResult ,"App KOomTestApp5Uid not running");
+                aResult.iResultDes.Copy( KResult );
+                aResult.iResult = KErrGeneral;
+                // Case was executed but failed
+                }
+            }
+        if (err == KErrNone)
+            {	
+            err = AppIsRunning(KOomTestAppUid, ETrue);	
+            if (err != KErrNone)
+                {
+                // The P9 app should still be running because the P8 application freed enough memory
+                _LIT( KResult ,"P9 App KOomTestAppUid not running");
+                aResult.iResultDes.Copy( KResult );
+                aResult.iResult = KErrGeneral;
+                // Case was executed but failed
+                }
+            }
+        if (err == KErrNone)
+            {
+            _LIT( KDescription , "Test case passed");
+            aResult.SetResult( KErrNone, KDescription );
+            }
+        }
+    else
+        {
+        _LIT( KResult ,"Watchers failed to start or Application Timeout or Memory Still Below Treshhold ");
+        aResult.iResultDes.Copy( KResult );
+        aResult.iResult = KErrGeneral;
+        // case was not executed or case was executed but never finished or failed 
+        }
+    
+	ResetL();    
+    return KErrNone;	
+	}
+
+
+TInt COomTestHarness::PluginTest1L(TTestResult& aResult)
+	{
+	ResetL();
+	
+	// Configure the plugins to eat 0.6MB each:
+	for (TInt pluginIndex = KUidOOMDummyPluginFirstImplementation; pluginIndex <= KUidOOMDummyPluginLastImplementation - 2; pluginIndex++)
+		{
+		User::LeaveIfError(iAllocServer.Configure(TUid::Uid(pluginIndex), 0, 0x96000, 0x96000));
+		}
+	//start application so that plugin 0x10286A3A which does the check can be called
+	StartApplicationL(KOomTestApp2Uid, 0);
+	
+    //start watchers
+    TInt memTestState = ETestInit;
+    TInt err = KErrNone;
+    
+    StartMemoryMonitorStatusWatcher(memTestState);
+
+    // Go just under the low memory threshold
+    EatMemoryL(KOomJustUnderLowMemoryThreshold);
+    
+    //start timer, start scheduler & stop watchers when done
+    StartTimerAndRunWatcher(memTestState);
+    
+    if (err == KErrNone && memTestState == ETestAbove)
+        {	
+        // The first two app plugins should have been run, releasing 
+        // the required memory. The second app plugin to be run - 10286A3A - has a check,
+        // so no other plugins should have run.
+        err = PluginFreeRamCalledL(0x10286A3B, ETrue);	
+        if (err != KErrNone)
+            {
+            _LIT( KResult ,"Plugin 0x10286A3B FreeRam not called");
+            aResult.iResultDes.Copy( KResult );
+            aResult.iResult = KErrGeneral;
+            // Case was executed but failed
+            }
+        
+        if (err == KErrNone)
+            {	
+            err = PluginFreeRamCalledL(0x10286A3A, ETrue);
+            if (err != KErrNone)
+                {
+                _LIT( KResult ,"Plugin 0x10286A3A FreeRam not called");
+                aResult.iResultDes.Copy( KResult );
+                aResult.iResult = KErrGeneral;
+                // Case was executed but failed
+                }
+            }
+    
+        // These two plugins should not be called	
+        if (err == KErrNone)
+            {	
+            err = PluginFreeRamCalledL(0x10286A38, EFalse);
+            if (err != KErrNone)
+                {
+                _LIT( KResult ,"Plugin 0x10286A38 FreeRam incorrectly called");
+                aResult.iResultDes.Copy( KResult );
+                aResult.iResult = KErrGeneral;
+                // Case was executed but failed
+                }
+            }	
+        
+        if 	(err == KErrNone)
+            {
+            err = PluginFreeRamCalledL(0x10286A34, EFalse);
+            if (err != KErrNone)
+                {
+                _LIT( KResult ,"Plugin 0x10286A34 FreeRam incorrectly called");
+                aResult.iResultDes.Copy( KResult );
+                aResult.iResult = KErrGeneral;
+                // Case was executed but failed
+                }
+            }	
+    
+        // Finally check that the plugins have been notified of the final good memory state
+        if (err == KErrNone)
+            {					
+            err = PluginMemoryGoodCalledL(0x10286A3A, ETrue);
+            if (err != KErrNone)
+                {
+                _LIT( KResult ,"plugin  0x10286A3A MemoryGood not called");
+                aResult.iResultDes.Copy( KResult );
+                aResult.iResult = KErrGeneral;
+                // Case was executed but failed
+                }
+            }
+            
+        if (err == KErrNone)
+            {					
+            err = PluginMemoryGoodCalledL(0x10286A3B, ETrue);
+            if (err != KErrNone)
+                {
+                _LIT( KResult ,"plugin  0x10286A3B MemoryGood not called");
+                aResult.iResultDes.Copy( KResult );
+                aResult.iResult = KErrGeneral;
+                // Case was executed but failed
+                }
+            }
+        
+        if (err == KErrNone)
+            {					
+            err = PluginMemoryGoodCalledL(0x10286A34, EFalse);
+            if (err != KErrNone)
+                {
+                _LIT( KResult ,"plugin  0x10286A34 MemoryGood incorrectly called");
+                aResult.iResultDes.Copy( KResult );
+                aResult.iResult = KErrGeneral;
+                // Case was executed but failed
+                }
+            }
+        
+        if (err == KErrNone)
+            {
+            // MemoryGood should not be called on this plugin because FreeMemory was never called on it
+            // 10286A38
+            err = PluginMemoryGoodCalledL(0x10286A38, EFalse);	
+            if (err != KErrNone)
+                {
+                _LIT( KResult ,"plugin 0x10286A38 MemoryGood incorrectly called");
+                aResult.iResultDes.Copy( KResult );
+                aResult.iResult = KErrGeneral;
+                // Case was executed but failed
+                }
+            }
+        
+        
+        if (err == KErrNone)
+            {
+            _LIT( KDescription , "Test case passed");
+            aResult.SetResult( KErrNone, KDescription );
+            }
+        }
+    else
+        {
+        _LIT( KResult ,"Watchers failed to start or Application Timeout or Memory Still Below Treshhold");
+        aResult.iResultDes.Copy( KResult );
+        aResult.iResult = KErrGeneral;
+        // case was not executed or case was executed but never finished or failed 
+        }
+
+	ResetL();    
+    return KErrNone;	
+	}
+
+
+// Test application plugins
+// Start two target apps
+// Simulate a low memory event
+// The one of the application plugins should now be run, displacing one of the system plugins
+// The target apps are of sufficiently high priority that they will not be closed
+TInt COomTestHarness::PluginTest2L(TTestResult& aResult)
+	{
+	ResetL();
+	
+	// Configure the plugins to eat 0.5MB each:
+	for (TInt pluginIndex = KUidOOMDummyPluginFirstImplementation; pluginIndex <= KUidOOMDummyPluginLastImplementation - 2; pluginIndex++)
+		{
+		User::LeaveIfError(iAllocServer.Configure(TUid::Uid(pluginIndex), 0, 0x80000, 0x80000));
+		}
+	
+	// Start the two target applications (plus a third so that the target apps are not in the foreground)
+	StartApplicationL(KOomTestApp2Uid, 0);
+	StartApplicationL(KOomTestApp3Uid, 0);
+	StartApplicationL(KOomTestAppUid, 0);
+	
+	BringAppToForeground(KOomTestAppUid);
+    
+    //start watchers
+    TInt memTestState = ETestInit;
+    TInt err = KErrNone;
+    
+    StartMemoryMonitorStatusWatcher(memTestState);
+
+    // Go just under the low memory threshold
+    EatMemoryL(KOomJustUnderLowMemoryThreshold);
+
+    //start timer, start scheduler & stop watchers when done
+    StartTimerAndRunWatcher(memTestState);
+    
+    if (err == KErrNone && memTestState == ETestAbove)
+        {
+        // The first two system plugins should have been closed, releasing the required memory
+        // The following two system plugins won't be called (the app plugins will now take their place)
+        
+        // The following plugins should be called...
+        // Application plugins: 10286A3A 10286A3B
+        // System plugins: 10286A3C(v2 plugin) 10286A34
+        
+        err = PluginFreeRamCalledL(0x10286A3B, ETrue);
+        if (err != KErrNone)
+            {
+            _LIT( KResult ,"plugin  0x10286A3B not called ");
+            aResult.iResultDes.Copy( KResult );
+            aResult.iResult = KErrGeneral;
+            // Case was executed but failed
+            }
+        
+        if (err == KErrNone)
+            {					
+            err = PluginFreeRamCalledL(0x10286A3A, ETrue);
+            if (err != KErrNone)
+                {
+                _LIT( KResult ,"plugin  0x10286A3A not called ");
+                aResult.iResultDes.Copy( KResult );
+                aResult.iResult = KErrGeneral;
+                // Case was executed but failed
+                }
+            }
+        
+        if (err == KErrNone)
+            {	
+            // Plugins and apps with higher priorities will not be called/closed because 0x10286A3A is configured to check memory before running anything else
+            err = PluginFreeRamCalledL(0x10286A3C, EFalse);
+            if (err != KErrNone)
+                {
+                _LIT( KResult ,"plugin 0x10286A3C incorrectly called ");
+                aResult.iResultDes.Copy( KResult );
+                aResult.iResult = KErrGeneral;
+                // Case was executed but failed
+                }
+            }
+        
+        if (err == KErrNone)
+            {		
+            err = PluginFreeRamCalledL(0x10286A34, EFalse);
+            if (err != KErrNone)
+                {
+                _LIT( KResult ,"plugin 0x10286A34 incorrectly called");
+                aResult.iResultDes.Copy( KResult );
+                aResult.iResult = KErrGeneral;
+                // Case was executed but failed
+                }
+            }
+        
+        if (err == KErrNone)
+            {	
+            // The following plugin should also be called (max_batch_size only applies to application closures, not running plugins)
+            // 10286A35
+            err = PluginFreeRamCalledL(0x10286A35, EFalse);	
+            if (err != KErrNone)
+                {
+                _LIT( KResult ,"Plugin 0x10286A35 incorrectly called");
+                aResult.iResultDes.Copy( KResult );
+                aResult.iResult = KErrGeneral;
+                // Case was executed but failed
+                }
+            }
+        
+        if (err == KErrNone)
+            {		
+            err = AppIsRunning(KOomTestApp3Uid, ETrue);		
+            if (err != KErrNone)
+                {
+                _LIT( KResult ,"App KOomTestApp3Uid not running");
+                aResult.iResultDes.Copy( KResult );
+                aResult.iResult = KErrGeneral;
+                // Case was executed but failed
+                }
+            }
+        
+        if (err == KErrNone)
+            {		
+            err = AppIsRunning(KOomTestApp2Uid, ETrue);
+            if (err != KErrNone)
+                {
+                _LIT( KResult ,"App KOomTestApp2Uid not running");
+                aResult.iResultDes.Copy( KResult );
+                aResult.iResult = KErrGeneral;
+                // Case was executed but failed
+                }
+            }
+        
+        if (err == KErrNone)
+            {			
+            err = AppIsRunning(KOomTestAppUid, ETrue);		
+            if (err != KErrNone)
+                {
+                _LIT( KResult ,"plugin KOomTestAppUid not running");
+                aResult.iResultDes.Copy( KResult );
+                aResult.iResult = KErrGeneral;
+                // Case was executed but failed
+                }
+            }
+        
+        if (err == KErrNone)
+            {
+            _LIT( KDescription , "Test case passed");
+            aResult.SetResult( KErrNone, KDescription );
+            }
+        }
+    else
+        {
+        _LIT( KResult ,"Watchers failed to start or Application Timeout or Memory Still Below Treshhold ");
+        aResult.iResultDes.Copy( KResult );
+        aResult.iResult = KErrGeneral;
+        // case was not executed or case was executed but never finished or failed 
+        }
+
+	ResetL();    
+    return KErrNone;	
+	}
+
+
+
+// Test that the aBytesRequested is correctly passed to the FreeMemory function of V2 plugins
+// Initialise P4 plugin to consume 5MB of memory
+// No other plugins are configured to release memory
+// Simulate a low memory event (go just below the low threshold)
+// Check that the P4 plugin has been called
+// Check that the P4 plugin has received a request for > 500K and less than <1500K
+TInt COomTestHarness::PluginV2Test1L(TTestResult& aResult)
+	{
+	ResetL();
+	
+	// Configure the P4 V2 plugin to eat 5MB:
+	User::LeaveIfError(iAllocServer.Configure(TUid::Uid(0x10286A3C), 0, 0x500000, 0x500000));
+	
+    //start watchers
+    TInt memTestState = ETestInit;
+    TInt err = KErrNone;
+    
+    StartMemoryMonitorStatusWatcher(memTestState);
+	
+    // Go just under the low memory threshold
+    EatMemoryL(KOomJustUnderLowMemoryThreshold);
+
+    //start timer, start scheduler & stop watchers when done
+    StartTimerAndRunWatcher(memTestState);
+    
+    if (err == KErrNone && memTestState == ETestAbove)
+        {
+        // The first four system plugins should have been closed, releasing the required memory
+        // All four plugins should be called, even though the first two will release enough memory (this is because
+        // plugins are always run in continue mode)
+        
+        // Check that the P4 plugin has been called
+        err = PluginFreeRamCalledL(0x10286A3C, ETrue);
+        
+        // Check that the request for memory was about right
+        // Note: regular system variation makes it impossible to test for an exact number
+        TInt requestedMemory = 0;
+        err = RProperty::Get(KUidOomPropertyCategory, 0x10286A3C + KOOMDummyPluginBytesRequested, requestedMemory);
+        if ((requestedMemory < 512 * 1024) || (requestedMemory > 1500 * 1024))
+            {
+            _LIT( KResult ,"requestedMemory incorrect");
+            aResult.iResultDes.Copy( KResult );
+            aResult.iResult = KErrGeneral;
+            // Case was executed but failed
+            }		
+    
+        if (err == KErrNone)
+            {
+            // Check that the higher priority V2 plugin has not been called
+            err = PluginFreeRamCalledL(0x10286A3D, EFalse);
+            if (err != KErrNone)
+                {
+                _LIT( KResult ,"plugin 0x10286A3D incorrectly called");
+                aResult.iResultDes.Copy( KResult );
+                aResult.iResult = KErrGeneral;
+                // Case was executed but failed
+                }
+            }
+        
+        if (err == KErrNone)
+            {
+            _LIT( KDescription , "Test case passed");
+            aResult.SetResult( KErrNone, KDescription );
+            }
+        }
+    else
+        {
+        _LIT( KResult ,"Watchers failed to start or Application Timeout or Memory Still Below Treshhold ");
+        aResult.iResultDes.Copy( KResult );
+        aResult.iResult = KErrGeneral;
+        // case was not executed or case was executed but never finished or failed 
+        }
+
+	ResetL();    
+    return KErrNone;	
+	}
+
+
+// Test simple prioritisation of application plugins
+// Start two target applications
+// Configure all plugins to consume 0.5MB
+// Simulate a low memory event
+// Some of the low priority app plugins with those target applications should be called
+// The highest priority app with that target application should not be called (the lower priority plugins should free enough memory)
+TInt COomTestHarness::AppPluginTest1L(TTestResult& aResult)
+	{
+	ResetL();
+	
+	// Configure the plugins to eat 0.5MB each:
+	for (TInt pluginIndex = KUidOOMDummyPluginFirstImplementation; pluginIndex <= KUidOOMDummyPluginLastImplementation - 2; pluginIndex++)
+		{
+		User::LeaveIfError(iAllocServer.Configure(TUid::Uid(pluginIndex), 0, 0x80000, 0x80000));
+		}
+	
+	// Start the two target applications (plus a third so that the target apps are not in the foreground)
+	StartApplicationL(KOomTestApp2Uid, 0);
+	StartApplicationL(KOomTestApp3Uid, 0);
+	StartApplicationL(KOomTestAppUid, 0);
+	
+
+    TInt err = KErrNone;
+    
+    // Check that all of the apps are running
+    err = AppIsRunning(KOomTestApp2Uid, ETrue);
+    if (err != KErrNone)
+        {
+        _LIT( KResult ,"app KOomTestApp2Uid not running");
+        aResult.iResultDes.Copy( KResult );
+        aResult.iResult = KErrGeneral;
+        // Case was executed but failed
+        }
+    
+    if (err == KErrNone)
+        {
+        err = AppIsRunning(KOomTestApp3Uid, ETrue);
+        if (err != KErrNone)
+            {
+            _LIT( KResult ,"app KOomTestApp3Uid not running");
+            aResult.iResultDes.Copy( KResult );
+            aResult.iResult = KErrGeneral;
+            // Case was executed but failed
+            }
+        }
+    
+    if (err == KErrNone)
+        {	
+        err = AppIsRunning(KOomTestAppUid, ETrue);
+        if (err != KErrNone)
+            {
+            _LIT( KResult ,"app KOomTestAppUid not running");
+            aResult.iResultDes.Copy( KResult );
+            aResult.iResult = KErrGeneral;
+            // Case was executed but failed
+            }
+        }
+
+    // Now eat some memory till we are below treshhold and wait for the memory monitor to bring us above treshhold again
+    TInt memTestState = ETestInit;
+    
+    if (err == KErrNone)
+        {	
+        BringAppToForeground(KOomTestAppUid);
+        
+        //start watchers
+        StartMemoryMonitorStatusWatcher(memTestState);
+        
+        // Go just under the low memory threshold
+        EatMemoryL(KOomJustUnderLowMemoryThreshold);
+
+        //start timer, start scheduler & stop watchers when done
+        StartTimerAndRunWatcher(memTestState);
+        
+        // fail tests if watchers failed or memory was not freed
+        if (memTestState != ETestAbove)
+            {
+            _LIT( KResult ,"Watchers failed to start or Application Timeout or Memory Still Below Treshhold ");
+            aResult.iResultDes.Copy( KResult );
+            aResult.iResult = KErrGeneral;
+            // case was not executed or case was executed but never finished or failed 
+            //if memteststate is not desired signal to other cases that they should not pass
+            if (err == KErrNone)
+                {
+                err = KErrGeneral;
+                }
+            }
+        }
+    
+    // Check plugins for memory free calls
+    // The following application plugins should be called...
+    // Application plugins: 10286A3A 10286A3B
+    if (err == KErrNone)
+        {
+        err = PluginFreeRamCalledL(0x10286A3A, ETrue);
+        if (err != KErrNone)
+            {
+            _LIT( KResult ,"plugin 0x10286A3A FreeRam not called");
+            aResult.iResultDes.Copy( KResult );
+            aResult.iResult = KErrGeneral;
+            // Case was executed but failed
+            }
+        }
+    
+    if (err == KErrNone)
+        {	
+        err = PluginFreeRamCalledL(0x10286A3B, ETrue);
+        if (err != KErrNone)
+            {
+            _LIT( KResult ,"plugin 0x10286A3B FreeRam not called");
+            aResult.iResultDes.Copy( KResult );
+            aResult.iResult = KErrGeneral;
+            // Case was executed but failed
+            }
+        }
+    
+    if (err == KErrNone)
+        {
+        // The following plugin should not be called because other plugins (including some unchecked system plugins) have freed enough memory
+        // 10286A38
+        err = PluginFreeRamCalledL(0x10286A38, EFalse);	
+        if (err != KErrNone)
+            {
+            _LIT( KResult ,"plugin 0x10286A38 FreeRam incorrectly called");
+            aResult.iResultDes.Copy( KResult );
+            aResult.iResult = KErrGeneral;
+            // Case was executed but failed
+            }
+        }
+    
+    if (err == KErrNone)
+        {
+        _LIT( KDescription , "Test case passed");
+        aResult.SetResult( KErrNone, KDescription );
+        }
+    
+	ResetL();    
+    return KErrNone;	
+	}
+
+// Test simple prioritisation of application plugins
+// Start two target applications
+// Configure all plugins to consume 0.5MB
+// The app plugin with the highest priority is configured to be assigned the lowest priority after an idle time
+// Wait until the idle time rule applies
+// Simulate a low memory event
+// The plugin that initially had the highest priority (but now has the lowest priority) should be called
+// Note that this test should be the same as AppPluginTest1L with the addition of the idle period
+TInt COomTestHarness::AppPluginIdleTimeTest1L(TTestResult& aResult)
+	{
+	ResetL();
+	
+	// Configure the plugins to eat 0.5MB each:
+	for (TInt pluginIndex = KUidOOMDummyPluginFirstImplementation; pluginIndex <= KUidOOMDummyPluginLastImplementation - 2; pluginIndex++)
+		{
+		User::LeaveIfError(iAllocServer.Configure(TUid::Uid(pluginIndex), 0, 0x80000, 0x80000));
+		}
+	
+	// Start the two target applications (plus a third so that the target apps are not in the foreground)
+	StartApplicationL(KOomTestApp2Uid, 0);
+	StartApplicationL(KOomTestApp3Uid, 0);
+	StartApplicationL(KOomTestAppUid, 0);
+	
+	BringAppToForeground(KOomTestAppUid);
+	
+	User::After(KOomTestFirstIdlePeriod);
+	
+   //start watchers
+    TInt memTestState = ETestInit;
+    TInt err = KErrNone;
+    
+    StartMemoryMonitorStatusWatcher(memTestState);
+    
+    // Go just under the low memory threshold
+    EatMemoryL(KOomJustUnderLowMemoryThreshold);
+
+    //start timer, start scheduler & stop watchers when done
+    StartTimerAndRunWatcher(memTestState);
+
+    if (err == KErrNone && memTestState == ETestAbove)
+        {
+        // The following application plugins should be called...
+        // Application plugins: 10286A3A 10286A3B
+        
+        err = PluginFreeRamCalledL(0x10286A3A, ETrue);
+        if (err != KErrNone)
+            {
+            _LIT( KResult ,"plugin 0x10286A3A FreeRam not called");
+            aResult.iResultDes.Copy( KResult );
+            aResult.iResult = KErrGeneral;
+            // Case was executed but failed
+            }
+    
+        if (err == KErrNone)
+            {	
+            err = PluginFreeRamCalledL(0x10286A3B, ETrue);
+            if (err != KErrNone)
+                {
+                _LIT( KResult ,"plugin 0x10286A3B FreeRam not called");
+                aResult.iResultDes.Copy( KResult );
+                aResult.iResult = KErrGeneral;
+                // Case was executed but failed
+                }
+            }
+        
+        if (err == KErrNone)
+            {	
+            // The following plugin should also be called (its priority was initially too high but has been reduced after the idle time)
+            // 10286A38
+            err = PluginFreeRamCalledL(0x10286A38, ETrue);	
+            if (err != KErrNone)
+                {
+                _LIT( KResult ,"plugin 0x10286A38 FreeRam not called");
+                aResult.iResultDes.Copy( KResult );
+                aResult.iResult = KErrGeneral;
+                // Case was executed but failed
+                }
+            }
+        
+        if (err == KErrNone)
+            {
+            _LIT( KDescription , "Test case passed");
+            aResult.SetResult( KErrNone, KDescription );
+            }
+        }
+    else
+        {
+        _LIT( KResult ,"Watchers failed to start or Application Timeout or Memory Still Below Treshhold ");
+        aResult.iResultDes.Copy( KResult );
+        aResult.iResult = KErrGeneral;
+        // case was not executed or case was executed but never finished or failed 
+        }
+
+    ResetL();    
+    return KErrNone;	
+	}
+
+
+// Test the optional allocation mechanism
+// Configure the plugins not to release any RAM when FreeRam is called
+// Configure one priority 7 application to release 12MB when FreeRam is called
+// Start this application (plus another one so it isn't in the foreground)
+// Drop just above the good memory level
+// Request an optional allocation of 10MB referencing a priority 8 plugin
+// All of the plugins below P8 should be called
+// The P7 application should be closed freeing the required memory
+TInt COomTestHarness::OptionalAllocationTest1L(TTestResult& aResult)
+	{
+	ResetL();
+	
+	// Start an application (plus a second so that the first app is not in the foreground)
+	// The first application is set to consume 12MB of RAM
+	StartApplicationL(KOomTestApp3Uid, 12 * 1024);
+	StartApplicationL(KOomTestAppUid, 0);
+	
+	BringAppToForeground(KOomTestAppUid);
+
+   // Go just above the good memory threshold
+    EatMemoryL(KOomJustAboveGoodMemoryThreshold);
+	    
+    //start watchers
+    TInt memTestState = ETestInit;
+    TInt err = KErrNone;
+    TInt bytesAvailable;
+    
+    StartMemoryMonitorStatusWatcher(memTestState);
+    
+    // Request 10 MB of data, using the priority of the referenced plugin (constant priority 8)
+    err = iOomSession.RequestOptionalRam(10 * 1024 * 1024, 10 * 1024 * 1024, 0x10286A37, bytesAvailable);
+    
+    if(err == KErrNone)
+        {
+        //start timer, start scheduler & stop watchers when done
+        StartTimerAndRunWatcher(memTestState);
+        }
+
+    if (err == KErrNone && memTestState == ETestAbove)
+        {
+        // Check that all system plugins below P8 have been called
+        if (err == KErrNone)
+            {		
+            err = PluginFreeRamCalledL(0x10286A34, ETrue);
+            if (err != KErrNone)
+                {
+                _LIT( KResult ,"plugin 0x10286A34 FreeRam not called");
+                aResult.iResultDes.Copy( KResult );
+                aResult.iResult = KErrGeneral;
+                // Case was executed but failed
+                }
+            }
+        
+        if (err == KErrNone)
+            {			
+            err = PluginFreeRamCalledL(0x10286A35, ETrue);
+            if (err != KErrNone)
+                {
+                _LIT( KResult ,"plugin 0x10286A35 FreeRam not called");
+                aResult.iResultDes.Copy( KResult );
+                aResult.iResult = KErrGeneral;
+                // Case was executed but failed
+                }		
+            }
+        
+        if (err == KErrNone)
+            {	
+            err = PluginFreeRamCalledL(0x10286A36, ETrue);
+            if (err != KErrNone)
+                {
+                _LIT( KResult ,"plugin 0x10286A36 FreeRam not called");
+                aResult.iResultDes.Copy( KResult );
+                aResult.iResult = KErrGeneral;
+                // Case was executed but failed
+                }
+            }
+        
+        if (err == KErrNone)
+            {			
+            // This the P8 system plugin has not been called
+            err = PluginFreeRamCalledL(0x10286A37, EFalse);
+            if (err != KErrNone)
+                {
+                _LIT( KResult ,"plugin 0x10286A37 FreeRam incorrectly called");
+                aResult.iResultDes.Copy( KResult );
+                aResult.iResult = KErrGeneral;
+                // Case was executed but failed
+                }
+            }
+        
+        if (err == KErrNone)
+            {	
+            // Check that the low priority app plugin has been called
+            err = PluginFreeRamCalledL(0x10286A3B, ETrue);
+            if (err != KErrNone)
+                {
+                _LIT( KResult ,"low prioirity app 0x10286A3B not called");
+                aResult.iResultDes.Copy( KResult );
+                aResult.iResult = KErrGeneral;
+                // Case was executed but failed
+                }
+            }
+        
+        if (err == KErrNone)
+            {			
+            // Check that the P7 application has been closed
+            err = AppIsRunning(KOomTestApp3Uid, EFalse);
+            if (err != KErrNone)
+                {
+                _LIT( KResult ,"P7 app KOomTestApp3Uid not closed");
+                aResult.iResultDes.Copy( KResult );
+                aResult.iResult = KErrGeneral;
+                // Case was executed but failed
+                }
+            }
+    
+        if (err == KErrNone)
+            {
+            _LIT( KDescription , "Test case passed");
+            aResult.SetResult( KErrNone, KDescription );
+            }
+        }
+    else 
+        {
+        _LIT( KResult ,"RequestOptionalRam failed or Memory Still Below Treshhold or could not start watchers");
+        aResult.iResultDes.Copy( KResult );
+        aResult.iResult = KErrGeneral;
+        // case was not executed or case was executed but never finished or failed 
+        }
+    
+	ResetL();    
+    return KErrNone;	
+	}
+
+
+// Test the optional allocation mechanism - minimum requested RAM behaviour - successful request
+// Configure the plugins not to release any RAM when FreeRam is called
+// Configure one priority 7 application to release 5MB when FreeRam is called
+// Start this application (plus another one so it isn't in the foreground)
+// Drop just above the good memory level
+// Request an optional allocation of 10MB (5MB minimum) referencing a priority 8 plugin
+// All of the plugins below P8 should be called
+// The P7 application should be closed freeing the required minimum amount memory
+// The returned available memory should be about 5MB ( > 3MB and < 7MB )
+TInt COomTestHarness::OptionalAllocationTest2L(TTestResult& aResult)
+	{
+	ResetL();
+	
+	// Start an application (plus a second so that the first app is not in the foreground)
+	// The first application is set to consume 5MB of RAM
+	StartApplicationL(KOomTestApp3Uid, 5 * 1024);
+	StartApplicationL(KOomTestAppUid, 0);
+	
+	BringAppToForeground(KOomTestAppUid);
+
+	// Go just above the good memory threshold
+    EatMemoryL(KOomJustAboveGoodMemoryThreshold);
+    
+    //start watchers
+    TInt memTestState = ETestInit;
+    TInt err = KErrNone;
+    StartMemoryMonitorStatusWatcher(memTestState);
+    
+    // Request 10 MB of data, using the priority of the referenced plugin (constant priority 8)
+    // Say that 5MB is the minimum we need
+    TInt bytesAvailable;
+    err = iOomSession.RequestOptionalRam(10 * 1024 * 1024, 5 * 1024 * 1024, 0x10286A37, bytesAvailable);
+
+    if(err == KErrNone)
+        {
+        //start scheduler & stop watchers when done
+        StartTimerAndRunWatcher(memTestState);
+        }
+
+    if (err == KErrNone && memTestState == ETestAbove)
+        {
+        if (err == KErrNone)
+            {			
+            // Check that the reported bytes available is > 3MB and < 7MB
+            if ((bytesAvailable < 3 * 1024 * 1024)
+                    || (bytesAvailable > 7 * 1024 * 1024))
+                {
+                _LIT( KResult ,"reported bytes not > 3MB and < 7MB");
+                aResult.iResultDes.Copy( KResult );
+                aResult.iResult = KErrGeneral;
+                // Case was executed but failed
+                }
+            }
+        
+        // Check that all system plugins below P8 have been called
+    
+        if (err == KErrNone)
+            {			
+            err = PluginFreeRamCalledL(0x10286A34, ETrue);
+            if (err != KErrNone)
+                {
+                _LIT( KResult ,"Plugin 0x10286A34 FreeRam not called");
+                aResult.iResultDes.Copy( KResult );
+                aResult.iResult = KErrGeneral;
+                // Case was executed but failed
+                }
+            }
+        
+        if (err == KErrNone)
+            {			err = PluginFreeRamCalledL(0x10286A35, ETrue);
+            if (err != KErrNone)
+                {
+                _LIT( KResult ,"Plugin 0x10286A35 FreeRam not called");
+                aResult.iResultDes.Copy( KResult );
+                aResult.iResult = KErrGeneral;
+                // Case was executed but failed
+                }
+            }
+        
+        if (err == KErrNone)
+            {			
+            err = PluginFreeRamCalledL(0x10286A36, ETrue);
+            if (err != KErrNone)
+                {
+                _LIT( KResult ,"Plugin 0x10286A36 FreeRam not called");
+                aResult.iResultDes.Copy( KResult );
+                aResult.iResult = KErrGeneral;
+                // Case was executed but failed
+                }
+            }
+        
+        if (err == KErrNone)
+            {			
+            // This the P8 system plugin has not been called
+            err = PluginFreeRamCalledL(0x10286A37, EFalse);
+            if (err != KErrNone)
+                {
+                _LIT( KResult ,"Plugin 0x10286A37 FreeRam incorrectly called");
+                aResult.iResultDes.Copy( KResult );
+                aResult.iResult = KErrGeneral;
+                // Case was executed but failed
+                }
+            }
+        
+        if (err == KErrNone)
+            {			
+            // Check that the low priority app plugin has been called
+            err = PluginFreeRamCalledL(0x10286A3B, ETrue);
+            if (err != KErrNone)
+                {
+                _LIT( KResult ,"Plugin 0x10286A3B FreeRam not called");
+                aResult.iResultDes.Copy( KResult );
+                aResult.iResult = KErrGeneral;
+                // Case was executed but failed
+                }
+            }
+        
+        if (err == KErrNone)
+            {			
+            // Check that the P7 application has been closed
+            err = AppIsRunning(KOomTestApp3Uid, EFalse);
+            if (err != KErrNone)
+                {
+                _LIT( KResult ,"P7 app KOomTestApp3Uid not closed");
+                aResult.iResultDes.Copy( KResult );
+                aResult.iResult = KErrGeneral;
+                // Case was executed but failed
+                }
+            }
+        
+        if (err == KErrNone)
+            {
+            _LIT( KDescription , "Test case passed");
+            aResult.SetResult( KErrNone, KDescription );
+            }
+        }
+    else
+        {
+        _LIT( KResult ,"RequestOptionalRam failed or Memory Still Below Treshhold or could not start watchers");
+        aResult.iResultDes.Copy( KResult );
+        aResult.iResult = KErrGeneral;
+        // case was not executed or case was executed but never finished or failed 
+        }
+
+	ResetL();    
+    return KErrNone;	
+	}
+
+
+// Test the optional allocation mechanism - minimum requested RAM behaviour - failed request
+// Configure the plugins not to release any RAM when FreeRam is called
+// Configure one priority 7 application to release 3MB when FreeRam is called
+// Start this application (plus another one so it isn't in the foreground)
+// Drop just above the good memory level
+// Request an optional allocation of 10MB (5MB minimum) referencing a priority 8 plugin
+// All of the plugins below P8 should be called
+// The P7 application should be closed but it won't free enough memory
+// The optional allocation should fail with KErrNoMemory
+TInt COomTestHarness::OptionalAllocationTest3L(TTestResult& aResult)
+	{
+	ResetL();
+	
+	// Start an application (plus a second so that the first app is not in the foreground)
+	// The first application is set to consume 5MB of RAM
+	StartApplicationL(KOomTestApp3Uid, 3 * 1024);
+	StartApplicationL(KOomTestAppUid, 0);
+	
+	BringAppToForeground(KOomTestAppUid);
+
+    // Go just above the good memory threshold
+    EatMemoryL(KOomJustAboveGoodMemoryThreshold);
+    
+    //start watchers
+    TInt memTestState = ETestInit;
+    TInt err = KErrNone;
+    
+    StartMemoryMonitorStatusWatcher(memTestState);
+
+    // Request 10 MB of data, using the priority of the referenced plugin (constant priority 8)
+    // Say that 5MB is the minimum we need
+    TInt bytesAvailable;
+    err = iOomSession.RequestOptionalRam(10 * 1024 * 1024, 5 * 1024 * 1024, 0x10286A37, bytesAvailable);
+    // We expect an error because it has not been possible to free the minimum memory
+    if (err == KErrNoMemory)
+        {
+        err = KErrNone;
+        }
+    
+    if(err == KErrNone)
+        {
+        //start scheduler & stop watchers when done
+        StartTimerAndRunWatcher(memTestState);
+        }
+
+    if (err == KErrNone && memTestState == ETestAbove)
+        {      
+        // Check that all system plugins below P8 have been called
+    
+        if (err == KErrNone)
+            {		
+            err = PluginFreeRamCalledL(0x10286A34, ETrue);
+            if (err != KErrNone)
+                {
+                _LIT( KResult ,"Plugin 0x10286A34 FreeRam not called");
+                aResult.iResultDes.Copy( KResult );
+                aResult.iResult = KErrGeneral;
+                // Case was executed but failed
+                }
+            }
+        
+        if (err == KErrNone)
+            {			
+            err = PluginFreeRamCalledL(0x10286A35, ETrue);
+            if (err != KErrNone)
+                {
+                _LIT( KResult ,"Plugin 0x10286A35 FreeRam not called");
+                aResult.iResultDes.Copy( KResult );
+                aResult.iResult = KErrGeneral;
+                // Case was executed but failed
+                }
+            }
+        
+        if (err == KErrNone)
+            {			
+            err = PluginFreeRamCalledL(0x10286A36, ETrue);
+            if (err != KErrNone)
+                {
+                _LIT( KResult ,"Plugin 0x10286A36 FreeRam not called");
+                aResult.iResultDes.Copy( KResult );
+                aResult.iResult = KErrGeneral;
+                // Case was executed but failed
+                }
+            }
+        
+        if (err == KErrNone)
+            {			
+            // This the P8 system plugin has not been called
+            err = PluginFreeRamCalledL(0x10286A37, EFalse);
+            if (err != KErrNone)
+                {
+                _LIT( KResult ,"Plugin 0x10286A37 FreeRam incorrectly called");
+                aResult.iResultDes.Copy( KResult );
+                aResult.iResult = KErrGeneral;
+                // Case was executed but failed
+                }
+            }
+        
+        if (err == KErrNone)
+            {			
+            // Check that the low priority app plugin has been called
+            err = PluginFreeRamCalledL(0x10286A3B, ETrue);
+            if (err != KErrNone)
+                {
+                _LIT( KResult ,"Plugin 0x10286A3B FreeRam not called");
+                aResult.iResultDes.Copy( KResult );
+                aResult.iResult = KErrGeneral;
+                // Case was executed but failed
+                }
+            }
+        
+        if (err == KErrNone)
+            {			
+            // Check that the P7 application has been closed
+            err = AppIsRunning(KOomTestApp3Uid, EFalse);
+            if (err != KErrNone)
+                {
+                _LIT( KResult ,"P7 App KOomTestApp3Uid not closed");
+                aResult.iResultDes.Copy( KResult );
+                aResult.iResult = KErrGeneral;
+                // Case was executed but failed
+                }
+            }
+        
+        if (err == KErrNone)
+            {
+            _LIT( KDescription , "Test case passed");
+            aResult.SetResult( KErrNone, KDescription );
+            }
+        }
+    else
+        {
+        _LIT( KResult ,"RequestOptionalRam failed or Memory Still Below Treshhold or could not start watchers");
+        aResult.iResultDes.Copy( KResult );
+        aResult.iResult = KErrGeneral;
+        // case was not executed or case was executed but never finished or failed 
+        }
+    
+	ResetL();    
+    return KErrNone;	
+	}
+
+
+// Test that force priority check applies (only) to selected priorities
+// Setup three plugins (priorities 7, 8 & 9)to eat 5MB each
+// The configuration file should force a check after priority 8
+// Drop just under the low threshold
+// Plugins P7 & P8 should be called (P8 is called even though the P7 plugin freed enough memory)
+// Plugin P9 should not be called because enou
+TInt COomTestHarness::ForcePriorityCheck1L(TTestResult& aResult)
+	{
+	ResetL();
+	
+	// Configure the P7, P8 and P9 plugins to eat 5MB each:
+	User::LeaveIfError(iAllocServer.Configure(TUid::Uid(0x10286A36), 0, 0x300000, 0x300000)); // P7
+	User::LeaveIfError(iAllocServer.Configure(TUid::Uid(0x10286A37), 0, 0x300000, 0x300000)); // P8
+	User::LeaveIfError(iAllocServer.Configure(TUid::Uid(0x10286A3D), 0, 0x300000, 0x300000)); // P9
+	
+    //start watchers
+    TInt memTestState = ETestInit;
+    TInt err = KErrNone;
+    
+    StartMemoryMonitorStatusWatcher(memTestState);
+	
+    // Go just under the low memory threshold
+    EatMemoryL(KOomJustUnderLowMemoryThreshold);
+    
+    //start scheduler & stop watchers when done
+    StartTimerAndRunWatcher(memTestState);
+
+    if (err == KErrNone && memTestState == ETestAbove)
+        {
+        
+        // The P7 plugin should have been called and is the first to release RAM
+        err = PluginFreeRamCalledL(0x10286A36, ETrue);
+        if (err != KErrNone)
+            {
+            _LIT( KResult ,"P7 Plugin 0x10286A36 FreeRam not called");
+            aResult.iResultDes.Copy( KResult );
+            aResult.iResult = KErrGeneral;
+            // Case was executed but failed
+            }
+    
+        if (err == KErrNone)
+            {		
+            // The P8 plugin should be called even though the P7 plugin has already released enough memory because the plugin runs in continue mode and there is no forced check
+            err = PluginFreeRamCalledL(0x10286A37, ETrue);
+            if (err != KErrNone)
+                {
+                _LIT( KResult ,"P8 Plugin 0x10286A37 FreeRam not called");
+                aResult.iResultDes.Copy( KResult );
+                aResult.iResult = KErrGeneral;
+                // Case was executed but failed
+                }
+            }
+        
+        if (err == KErrNone)
+            {		
+            // The P9 plugin should not be called because of the force priority check (the P7 & P8 plugins have already released plenty of RAM)
+            err = PluginFreeRamCalledL(0x10286A3D, EFalse);	
+            if (err != KErrNone)
+                {
+                _LIT( KResult ,"P9 Plugin 0x10286A3D FreeRam incorrectly called");
+                aResult.iResultDes.Copy( KResult );
+                aResult.iResult = KErrGeneral;
+                // Case was executed but failed
+                }
+            }
+        
+        if (err == KErrNone)
+            {
+            _LIT( KDescription , "Test case passed");
+            aResult.SetResult( KErrNone, KDescription );
+            }
+        }
+    else
+        {
+        _LIT( KResult ,"Watchers failed to start or Application Timeout or Memory Still Below Treshhold ");
+        aResult.iResultDes.Copy( KResult );
+        aResult.iResult = KErrGeneral;
+        // case was not executed or case was executed but never finished or failed 
+        }
+    
+	ResetL();    
+    return KErrNone;	
+	}
+
+
+
+// Test the Busy API on the OOM server
+// Start three applications
+// Ensure that the lowest priority app is not in the foreground
+// Call the busy API on the OOM monitor for the lowest priority app
+// Simulate a low memory event by going just under the low threshold
+// The busy application should not be closed
+// The other (non-foreground) application should be closed
+TInt COomTestHarness::BusyApplicationTest1L(TTestResult& aResult)
+	{
+	ResetL();
+	
+	// Start the two target applications (plus a third so that the target apps are not in the foreground)
+	StartApplicationL(KOomTestApp2Uid, 0);
+	StartApplicationL(KOomTestAppUid, 0);
+	StartApplicationL(KOomTestApp3Uid, 0); // Lowest priority app
+	
+	BringAppToForeground(KOomTestAppUid); // TODO: this doesn't seem to be working - message not getting through to the dummy application
+	
+	Settle();
+	
+	// Send the second app a message to make itself busy
+	TInt id = iApps.Find<TUid>(TUid::Uid(KOomTestApp3Uid), CCDummyApplicationHandle::CompareTo);
+	User::LeaveIfError(id);
+	iApps[id]->SendMessage(KOomDummyAppSetBusy);
+	
+    //start watchers
+    TInt memTestState = ETestInit;
+    TInt err = KErrNone;
+
+    StartMemoryMonitorStatusWatcher(memTestState);
+	
+
+    // Go just under the low memory threshold
+    EatMemoryL(KOomJustUnderLowMemoryThreshold);
+
+    //start scheduler & stop watchers when done
+    StartTimerAndRunWatcher(memTestState);
+
+    if (err == KErrNone && memTestState == ETestAbove)
+        {
+        
+        // The first four system plugins should have been closed, releasing the required memory
+        // All four plugins should be called, even though the first two will release enough memory (this is because
+        // plugins are always run in continue mode)
+        
+        // Check that the busy application is still running
+        err = AppIsRunning(KOomTestApp3Uid, ETrue);
+        if (err != KErrNone)
+            {
+            _LIT( KResult ,"P7 App KOomTestApp3Uid not running");
+            aResult.iResultDes.Copy( KResult );
+            aResult.iResult = KErrGeneral;
+            // Case was executed but failed
+            }
+    
+        if (err == KErrNone)
+            {
+            // Check that the higher priority but non-busy application has been close
+            err = AppIsRunning(KOomTestApp2Uid, EFalse);
+            if (err != KErrNone)
+                {
+                _LIT( KResult ,"P7 App KOomTestApp2Uid not closed");
+                aResult.iResultDes.Copy( KResult );
+                aResult.iResult = KErrGeneral;
+                // Case was executed but failed
+                }
+            }
+        
+        if (err == KErrNone)
+            {
+            _LIT( KDescription , "Test case passed");
+            aResult.SetResult( KErrNone, KDescription );
+            }
+        }
+    else
+        {
+        _LIT( KResult ,"Watchers failed to start or Application Timeout or Memory Still Below Treshhold ");
+        aResult.iResultDes.Copy( KResult );
+        aResult.iResult = KErrGeneral;
+        // case was not executed or case was executed but never finished or failed 
+        }
+    
+	ResetL();    
+    return KErrNone;	
+	}
+
+
+// Test the NotBusy API on the OOM server
+// Start three applications
+// Ensure that the lowest priority app is not in the foreground
+// Call the busy API on the OOM monitor for the lowest priority app
+// Then call the not-busy API on the OOM monitor for the lowest priority app
+// Simulate a low memory event by going just under the low threshold
+// The lowest priority app should be closed (because it is no longer busy)
+TInt COomTestHarness::NormalPriorityApplicationTest1L(TTestResult& aResult)
+	{
+	ResetL();
+	
+	// Start the two target applications (plus a third so that the target apps are not in the foreground)
+	StartApplicationL(KOomTestApp2Uid, 0);
+	StartApplicationL(KOomTestApp3Uid, 0); // Lowest priority app
+	StartApplicationL(KOomTestAppUid, 0);
+	
+	BringAppToForeground(KOomTestAppUid);
+	
+	Settle();
+	
+	// Send the second app a message to make itself busy
+	TInt id = iApps.Find<TUid>(TUid::Uid(KOomTestApp3Uid), CCDummyApplicationHandle::CompareTo);
+	User::LeaveIfError(id);
+	// TODO: temp removed - needs to be put back
+//	iApps[id]->SendMessage(KOomDummyAppSetBusy);
+	
+	// Send the second app a message to make itself normal priority
+	id = iApps.Find<TUid>(TUid::Uid(KOomTestApp3Uid), CCDummyApplicationHandle::CompareTo);
+	User::LeaveIfError(id);
+	iApps[id]->SendMessage(KOomDummyAppSetNormalPriority);
+
+    //start watchers
+    TInt memTestState = ETestInit;
+    TInt err = KErrNone;
+    
+    StartMemoryMonitorStatusWatcher(memTestState);
+    
+
+    // Go just under the low memory threshold
+    EatMemoryL(KOomJustUnderLowMemoryThreshold);
+
+    //start scheduler & stop watchers when done
+    StartTimerAndRunWatcher(memTestState);
+
+
+    if (err == KErrNone && memTestState == ETestAbove)
+        {
+        
+        // The first four system plugins should have been closed, releasing the required memory
+        // All four plugins should be called, even though the first two will release enough memory (this is because
+        // plugins are always run in continue mode)
+        
+        // Check that the no-longer-busy application has been closed
+        err = AppIsRunning(KOomTestApp3Uid, EFalse);
+        if (err != KErrNone)
+            {
+            _LIT( KResult ,"App KOomTestApp3Uid not closed");
+            aResult.iResultDes.Copy( KResult );
+            aResult.iResult = KErrGeneral;
+            // Case was executed but failed
+            }
+        
+        if (err == KErrNone)
+            {
+            _LIT( KDescription , "Test case passed");
+            aResult.SetResult( KErrNone, KDescription );
+            }
+        }
+    else
+        {
+        _LIT( KResult ,"Watchers failed to start or Application Timeout or Memory Still Below Treshhold ");
+        aResult.iResultDes.Copy( KResult );
+        aResult.iResult = KErrGeneral;
+        // case was not executed or case was executed but never finished or failed 
+        }
+    
+	ResetL();    
+    return KErrNone;	
+	}
+
+
+
+// Start three applications
+// One is set to NEVER_CLOSE, one is low priority, one is a dummy app to ensure that the first two are not in the foreground
+// Configure applications not to release any memory
+// Go just significantly under the low memory threshold
+// Wait for the system to recover, if we have moved above the low memory threshold then go significantly under it again. Repeat this step until we no longer go above low.
+// Check that the low priority application is closed
+// Check that the NEVER_CLOSE application is not closed (even though we're still below the low theshold)
+TInt COomTestHarness::NeverCloseTest1L(TTestResult& aResult)
+	{
+	ResetL();
+	
+	// Start the two target applications (plus a third so that the target apps are not in the foreground)
+	StartApplicationL(KOomTestApp3Uid, 0); // Lowest priority app
+	StartApplicationL(KOomTestApp7Uid, 0); // NEVER_CLOSE application
+	StartApplicationL(KOomTestAppUid, 0);
+	
+	BringAppToForeground(KOomTestAppUid);
+	
+	
+    //start watchers
+    TInt memTestState = ETestInit;
+    TInt err = KErrNone;
+    TInt attemps = 10;
+    
+    while (memTestState != ETestBelow && attemps > 0)
+        {
+    StartMemoryMonitorStatusWatcher(memTestState);
+	
+    // eat memory
+        EatMemoryL(KOomSignificantlyUnderLowMemoryThreshold);
+
+    //start scheduler & stop watchers when done
+    StartTimerAndRunWatcher(memTestState);
+        attemps--;
+        }
+
+    if (err == KErrNone && memTestState == ETestBelow)
+        {
+        
+        // The NEVER_CLOSE app should still be running (even though we are still below the low threshold)
+        err = AppIsRunning(KOomTestApp7Uid, ETrue);
+        if (err != KErrNone)
+            {
+            _LIT( KResult ,"NEVER_CLOSE app KOomTestApp7Uid not running");
+            aResult.iResultDes.Copy( KResult );
+            aResult.iResult = KErrGeneral;
+            // Case was executed but failed
+            }
+    
+        if (err == KErrNone)
+            {	
+            // The low priority app should still be closed (even though we are still below the low threshold)
+            err = AppIsRunning(KOomTestApp3Uid, EFalse);
+            if (err != KErrNone)
+                {
+                _LIT( KResult ,"low priority app KOomTestApp3Uid incorrectly running");
+                aResult.iResultDes.Copy( KResult );
+                aResult.iResult = KErrGeneral;
+                // Case was executed but failed
+                }
+            }
+        
+        if (err == KErrNone)
+            {
+            _LIT( KDescription , "Test case passed");
+            aResult.SetResult( KErrNone, KDescription );
+            }
+        }
+    else
+        {        
+        _LIT( KResult ,"Watchers failed to start or Application Timeout or Memory Incorrectly Above Treshhold ");
+        aResult.iResultDes.Copy( KResult );
+        aResult.iResult = KErrGeneral;
+        // case was not executed or case was executed but never finished or failed 
+        }
+    
+	ResetL();    
+    return KErrNone;	
+	}
+
+
+
+
+
+// Test that sync mode configuration is working for system plugins
+// Configure three system plugins to release 5MB of memory each.
+// The plugins are configured as follows
+// Plugin 1: Priority 7, sync mode continue
+// Plugin 2: Priority 8, sync mode check
+// Plugin 3: Priority 9, sync mode continue
+// Drop just under the low threshold
+// Plugins 1 & 2 should be called (even though plugin 1 alone has freed enough RAM)
+// Plugin 3 won't be called because the check on the priority 8 plugin discovers that enough RAM has been freed
+TInt COomTestHarness::PluginSyncModeTest1L(TTestResult& aResult)
+	{
+	ResetL();
+	
+	// Configure three plugins to eat 5MB each:
+	User::LeaveIfError(iAllocServer.Configure(TUid::Uid(0x10286A36), 0, 0x300000, 0x300000));
+	User::LeaveIfError(iAllocServer.Configure(TUid::Uid(0x10286A37), 0, 0x300000, 0x300000));
+	User::LeaveIfError(iAllocServer.Configure(TUid::Uid(0x10286A3D), 0, 0x300000, 0x300000));
+	
+    //start watchers
+    TInt memTestState = ETestInit;
+    TInt err = KErrNone;
+    
+    StartMemoryMonitorStatusWatcher(memTestState);
+	
+    // Go just under the low memory threshold
+    EatMemoryL(KOomJustUnderLowMemoryThreshold);
+
+    //start scheduler & stop watchers when done
+    StartTimerAndRunWatcher(memTestState);
+
+    if (err == KErrNone && memTestState == ETestAbove)
+        {
+        
+        // The first four system plugins should have been run, releasing the required memory
+        // All four plugins should be called, even though the first two will release enough memory (this is because
+        // plugins are always run in continue mode)
+        
+        // Check that the first two plugins have been called, but not the third
+        err = PluginFreeRamCalledL(0x10286A36, ETrue);
+        if (err != KErrNone)
+            {
+            _LIT( KResult ,"plugin 0x10286A36 Free Ram not called");
+            aResult.iResultDes.Copy( KResult );
+            aResult.iResult = KErrGeneral;
+            // Case was executed but failed
+            }
+    
+        if (err == KErrNone)
+            {		
+            err = PluginFreeRamCalledL(0x10286A37, ETrue);
+            if (err != KErrNone)
+                {
+                _LIT( KResult ,"plugin 0x10286A37 Free Ram not called");
+                aResult.iResultDes.Copy( KResult );
+                aResult.iResult = KErrGeneral;
+                // Case was executed but failed
+                }
+            }
+    
+        if (err == KErrNone)
+            {			
+            err = PluginFreeRamCalledL(0x10286A3D, EFalse);
+            if (err != KErrNone)
+                {
+                _LIT( KResult ,"plugin 0x10286A3D Free Ram incorrectly called");
+                aResult.iResultDes.Copy( KResult );
+                aResult.iResult = KErrGeneral;
+                // Case was executed but failed
+                }
+            }
+        
+        if (err == KErrNone)
+            {
+            _LIT( KDescription , "Test case passed");
+            aResult.SetResult( KErrNone, KDescription );
+            }
+        }
+    else
+        {
+        _LIT( KResult ,"Watchers failed to start or Application Timeout or Memory Still Below Treshhold ");
+        aResult.iResultDes.Copy( KResult );
+        aResult.iResult = KErrGeneral;
+        // case was not executed or case was executed but never finished or failed 
+        }
+    
+	ResetL();    
+    return KErrNone;	
+	}
+
+
+
+
+// Test the optional allocation mechanism
+// Configure the plugins not to release any RAM when FreeRam is called
+// Configure one priority 7 application to release 12MB when FreeRam is called
+// Start this application (plus another one so it isn't in the foreground)
+// Drop just above the good memory level
+// Request an optional allocation of 10MB referencing a priority 8 plugin
+// All of the plugins below P8 should be called
+// The P7 application should be closed freeing the required memory
+TInt COomTestHarness::OptionalAllocationAsyncTest1L(TTestResult& aResult)
+	{
+	ResetL();
+	
+	// Start an application (plus a second so that the first app is not in the foreground)
+	// The first application is set to consume 12MB of RAM
+	StartApplicationL(KOomTestApp3Uid, 12 * 1024);
+	StartApplicationL(KOomTestAppUid, 0);
+	
+	BringAppToForeground(KOomTestAppUid);
+	
+	// Go just above the good memory threshold
+	EatMemoryL(KOomJustAboveGoodMemoryThreshold);
+    
+    //start watchers
+    TInt memTestState = ETestInit;
+    TInt err = KErrNone; 
+    TInt bytesAvailable;
+    
+    StartMemoryMonitorStatusWatcher(memTestState);
+    
+    // Request 10 MB of data, using the priority of the referenced plugin (constant priority 8)
+    err = RequestOptionalRamASyncWrapper(10 * 1024 * 1024, 10 * 1024 * 1024, 0x10286A37, bytesAvailable);
+
+    if (err == KErrNone)
+        {
+        //start scheduler & stop watchers when done
+        StartTimerAndRunWatcher(memTestState);
+        }
+
+    if (err == KErrNone && memTestState == ETestAbove)
+        {        
+        // Check that all system plugins below P8 have been called
+        
+        err = PluginFreeRamCalledL(0x10286A34, ETrue);
+        if (err != KErrNone)
+            {
+            _LIT( KResult ,"plugin 0x10286A34 Free Ram not called");
+            aResult.iResultDes.Copy( KResult );
+            aResult.iResult = KErrGeneral;
+            // Case was executed but failed
+            }
+    
+        if (err == KErrNone)
+            {		
+            err = PluginFreeRamCalledL(0x10286A35, ETrue);
+            if (err != KErrNone)
+                {
+                _LIT( KResult ,"plugin 0x10286A35 Free Ram not called");
+                aResult.iResultDes.Copy( KResult );
+                aResult.iResult = KErrGeneral;
+                // Case was executed but failed
+                }
+            }
+    
+        if (err == KErrNone)
+            {	
+            err = PluginFreeRamCalledL(0x10286A36, ETrue);
+            if (err != KErrNone)
+                {
+                _LIT( KResult ,"plugin 0x10286A36 Free Ram not called");
+                aResult.iResultDes.Copy( KResult );
+                aResult.iResult = KErrGeneral;
+                // Case was executed but failed
+                }
+            }
+    
+        if (err == KErrNone)
+            {			
+            // This the P8 system plugin has not been called
+            err = PluginFreeRamCalledL(0x10286A37, EFalse);
+            if (err != KErrNone)
+                {
+                _LIT( KResult ,"plugin 0x10286A37 Free Ram incorrectly called");
+                aResult.iResultDes.Copy( KResult );
+                aResult.iResult = KErrGeneral;
+                // Case was executed but failed
+                }
+            }
+    
+        if (err == KErrNone)
+            {				
+            // Check that the low priority app plugin has been called
+            err = PluginFreeRamCalledL(0x10286A3B, ETrue);
+            if (err != KErrNone)
+                {
+                _LIT( KResult ,"plugin 0x10286A3B Free Ram not called");
+                aResult.iResultDes.Copy( KResult );
+                aResult.iResult = KErrGeneral;
+                // Case was executed but failed
+                }
+            }
+    
+        if (err == KErrNone)
+            {				
+            // Check that the P7 application has been closed
+            err = AppIsRunning(KOomTestApp3Uid, EFalse);
+            if (err != KErrNone)
+                {
+                _LIT( KResult ,"P7 App KOomTestApp3Uid incorrectly running");
+                aResult.iResultDes.Copy( KResult );
+                aResult.iResult = KErrGeneral;
+                // Case was executed but failed
+                }
+            }
+        
+        if (err == KErrNone)
+            {
+            _LIT( KDescription , "Test case passed");
+            aResult.SetResult( KErrNone, KDescription );
+            }
+        }
+    else
+        {
+        _LIT( KResult ,"RequestOptionalRam failed or Memory Still Below Treshhold or could not start watchers");
+        aResult.iResultDes.Copy( KResult );
+        aResult.iResult = KErrGeneral;
+        // case was not executed or case was executed but never finished or failed 
+        }
+    
+	ResetL();    
+    return KErrNone;	
+	}
+
+
+// Test the optional allocation mechanism - minimum requested RAM behaviour - successful request
+// Configure the plugins not to release any RAM when FreeRam is called
+// Configure one priority 7 application to release 5MB when FreeRam is called
+// Start this application (plus another one so it isn't in the foreground)
+// Drop just above the good memory level
+// Request an optional allocation of 10MB (5MB minimum) referencing a priority 8 plugin
+// All of the plugins below P8 should be called
+// The P7 application should be closed freeing the required minimum amount memory
+// The returned available memory should be about 5MB ( > 3MB and < 7MB )
+TInt COomTestHarness::OptionalAllocationAsyncTest2L(TTestResult& aResult)
+	{
+	ResetL();
+	
+	// Start an application (plus a second so that the first app is not in the foreground)
+	// The first application is set to consume 5MB of RAM
+	StartApplicationL(KOomTestApp3Uid, 5 * 1024);
+	StartApplicationL(KOomTestAppUid, 0);
+	
+	BringAppToForeground(KOomTestAppUid);
+	
+	// Go just above the good memory threshold
+	EatMemoryL(KOomJustAboveGoodMemoryThreshold);
+    
+	//start watchers
+    TInt memTestState = ETestInit;
+    TInt err = KErrNone;
+    TInt bytesAvailable;
+    
+    StartMemoryMonitorStatusWatcher(memTestState);
+  
+    // Request 10 MB of data, using the priority of the referenced plugin (constant priority 8)
+    // Say that 5MB is the minimum we need
+    err = RequestOptionalRamASyncWrapper(10 * 1024 * 1024, 5 * 1024 * 1024, 0x10286A37, bytesAvailable);  
+
+    if (err == KErrNone)
+        {
+        //start scheduler & stop watchers when done
+        StartTimerAndRunWatcher(memTestState);
+        }
+
+    if (err == KErrNone && memTestState == ETestAbove)
+        {    
+        if (err == KErrNone)
+            {
+            // Check that the reported bytes available is > 3MB and < 7MB
+            if ((bytesAvailable < 3 * 1024 * 1024)
+                    || (bytesAvailable > 7 * 1024 * 1024))
+                {
+                _LIT( KResult ,"bytesAvailable not ( > 3MB and < 7MB )");
+                aResult.iResultDes.Copy( KResult );
+                aResult.iResult = KErrGeneral;
+                // Case was executed but failed
+                }
+            }
+    
+        if (err == KErrNone)
+            {		
+            // Check that all system plugins below P8 have been called
+            
+            err = PluginFreeRamCalledL(0x10286A34, ETrue);
+            if (err != KErrNone)
+                {
+                _LIT( KResult ,"plugin 0x10286A34 Free Ram not called");
+                aResult.iResultDes.Copy( KResult );
+                aResult.iResult = KErrGeneral;
+                // Case was executed but failed
+                }
+            }
+    
+        if (err == KErrNone)
+            {				
+            err = PluginFreeRamCalledL(0x10286A35, ETrue);
+            if (err != KErrNone)
+                {
+                _LIT( KResult ,"plugin 0x10286A35 Free Ram not called");
+                aResult.iResultDes.Copy( KResult );
+                aResult.iResult = KErrGeneral;
+                // Case was executed but failed
+                }
+            }
+    
+        if (err == KErrNone)
+            {				
+            err = PluginFreeRamCalledL(0x10286A36, ETrue);
+            if (err != KErrNone)
+                {
+                _LIT( KResult ,"plugin 0x10286A36 Free Ram not called");
+                aResult.iResultDes.Copy( KResult );
+                aResult.iResult = KErrGeneral;
+                // Case was executed but failed
+                }
+            }
+    
+        if (err == KErrNone)
+            {				
+            // This the P8 system plugin has not been called
+            err = PluginFreeRamCalledL(0x10286A37, EFalse);
+            if (err != KErrNone)
+                {
+                _LIT( KResult ,"plugin 0x10286A37 Free Ram incorrectly called");
+                aResult.iResultDes.Copy( KResult );
+                aResult.iResult = KErrGeneral;
+                // Case was executed but failed
+                }
+            }
+    
+        if (err == KErrNone)
+            {				
+            // Check that the low priority app plugin has been called
+            err = PluginFreeRamCalledL(0x10286A3B, ETrue);
+            if (err != KErrNone)
+                {
+                _LIT( KResult ,"plugin 0x10286A3B Free Ram not called");
+                aResult.iResultDes.Copy( KResult );
+                aResult.iResult = KErrGeneral;
+                // Case was executed but failed
+                }
+            }
+    
+        if (err == KErrNone)
+            {				
+            // Check that the P7 application has been closed
+            err = AppIsRunning(KOomTestApp3Uid, EFalse);
+            if (err != KErrNone)
+                {
+                _LIT( KResult ,"P7 App KOomTestApp3Uid incorrectly running");
+                aResult.iResultDes.Copy( KResult );
+                aResult.iResult = KErrGeneral;
+                // Case was executed but failed
+                }
+            }
+        
+        if (err == KErrNone)
+            {
+            _LIT( KDescription , "Test case passed");
+            aResult.SetResult( KErrNone, KDescription );
+            }
+        }
+    else
+        {
+        _LIT( KResult ,"RequestOptionalRam failed or Memory Still Below Treshhold or could not start watchers");
+        aResult.iResultDes.Copy( KResult );
+        aResult.iResult = KErrGeneral;
+        // case was not executed or case was executed but never finished or failed 
+        }
+
+	ResetL();    
+    return KErrNone;	
+	}
+
+
+
+// Test the optional allocation mechanism - minimum requested RAM behaviour - failed request
+// Configure the plugins not to release any RAM when FreeRam is called
+// Configure one priority 7 application to release 3MB when FreeRam is called
+// Start this application (plus another one so it isn't in the foreground)
+// Drop just above the good memory level
+// Request an optional allocation of 10MB (5MB minimum) referencing a priority 8 plugin
+// All of the plugins below P8 should be called
+// The P7 application should be closed but it won't free enough memory
+// The optional allocation should fail with KErrNoMemory
+TInt COomTestHarness::OptionalAllocationAsyncTest3L(TTestResult& aResult)
+	{
+	ResetL();
+	
+	// Start an application (plus a second so that the first app is not in the foreground)
+	// The first application is set to consume 5MB of RAM
+	StartApplicationL(KOomTestApp3Uid, 3 * 1024);
+	StartApplicationL(KOomTestAppUid, 0);
+	
+	BringAppToForeground(KOomTestAppUid);
+	
+	// Go just above the good memory threshold
+	EatMemoryL(KOomJustAboveGoodMemoryThreshold);
+    
+    //start watchers
+    TInt memTestState = ETestInit;
+    TInt err = KErrNone;
+    
+    StartMemoryMonitorStatusWatcher(memTestState);
+    
+    // Request 10 MB of data, using the priority of the referenced plugin (constant priority 8)
+    // Say that 5MB is the minimum we need
+    TInt bytesAvailable;
+       
+    err = RequestOptionalRamASyncWrapper(10 * 1024 * 1024, 5 * 1024 * 1024, 0x10286A37, bytesAvailable);
+    // We expect an error because it has not been possible to free the minimum memory
+    if(err == KErrNoMemory)
+        {
+        err = KErrNone;
+        }
+
+    if (err == KErrNone)
+        {
+        //start scheduler & stop watchers when done
+        StartTimerAndRunWatcher(memTestState);
+        }
+
+    if (err == KErrNone && memTestState == ETestAbove)
+        {
+
+        if (err == KErrNone)
+            {	
+            // Check that all system plugins below P8 have been called
+            
+            err = PluginFreeRamCalledL(0x10286A34, ETrue);
+            if (err != KErrNone)
+                {
+                _LIT( KResult ,"plugin 0x10286A34 Free Ram not called");
+                aResult.iResultDes.Copy( KResult );
+                aResult.iResult = KErrGeneral;
+                // Case was executed but failed
+                }
+            }
+    
+        if (err == KErrNone)
+            {			
+            err = PluginFreeRamCalledL(0x10286A35, ETrue);
+            if (err != KErrNone)
+                {
+                _LIT( KResult ,"plugin 0x10286A35 Free Ram not called");
+                aResult.iResultDes.Copy( KResult );
+                aResult.iResult = KErrGeneral;
+                // Case was executed but failed
+                }
+            }
+    
+        if (err == KErrNone)
+            {			
+            err = PluginFreeRamCalledL(0x10286A36, ETrue);
+            if (err != KErrNone)
+                {
+                _LIT( KResult ,"plugin 0x10286A36 Free Ram not called");
+                aResult.iResultDes.Copy( KResult );
+                aResult.iResult = KErrGeneral;
+                // Case was executed but failed
+                }
+            }
+    
+        if (err == KErrNone)
+            {				
+            // This the P8 system plugin has not been called
+            err = PluginFreeRamCalledL(0x10286A37, EFalse);
+            if (err != KErrNone)
+                {
+                _LIT( KResult ,"plugin 0x10286A37 Free Ram incorrectly called");
+                aResult.iResultDes.Copy( KResult );
+                aResult.iResult = KErrGeneral;
+                // Case was executed but failed
+                }
+            }
+    
+        if (err == KErrNone)
+            {			
+            // Check that the low priority app plugin has been called
+            err = PluginFreeRamCalledL(0x10286A3B, ETrue);
+            if (err != KErrNone)
+                {
+                _LIT( KResult ,"plugin 0x10286A3B Free Ram not called");
+                aResult.iResultDes.Copy( KResult );
+                aResult.iResult = KErrGeneral;
+                // Case was executed but failed
+                }
+            }
+    
+        if (err == KErrNone)
+            {			
+            // Check that the P7 application has been closed
+            err = AppIsRunning(KOomTestApp3Uid, EFalse);
+            if (err != KErrNone)
+                {
+                _LIT( KResult ,"P7 App KOomTestApp3Uid incorrectly running");
+                aResult.iResultDes.Copy( KResult );
+                aResult.iResult = KErrGeneral;
+                // Case was executed but failed
+                }
+            }
+        
+        if (err == KErrNone)
+            {
+            _LIT( KDescription , "Test case passed");
+            aResult.SetResult( KErrNone, KDescription );
+            }
+        }
+    else
+        {
+        _LIT( KResult ,"minimum memory unexpectedly freed or still below treshhold or could not start watchers");
+        aResult.iResultDes.Copy( KResult );
+        aResult.iResult = KErrGeneral;
+        // Case was executed but failed
+        }
+    
+	ResetL();    
+    return KErrNone;	
+	}
+
+
+
+
+
+
+
+void COomTestHarness::BringAppToForeground(TInt32 aUid)
+	{
+	//bring app to foreground
+	TInt id = iApps.Find<TUid>(TUid::Uid(aUid), CCDummyApplicationHandle::CompareTo);
+	User::LeaveIfError(id);
+	iApps[id]->BringToForeground();
+	User::After(TTimeIntervalMicroSeconds32(KSettlingTime));
+	}
+
+
+void COomTestHarness::ResetL()
+	{
+	Settle();
+	
+	// Close any dummy apps
+	iApps.ResetAndDestroy();
+	
+	Settle();
+
+	// Free all memory being eaten by the server
+	iChunk.Adjust(KOomHarnessInitialEatenMemory); // Just eat 1K of memory initially, this can grow later
+	iChunkSize = KOomHarnessInitialEatenMemory;
+	
+	iDummyChunk.Close();
+	iDummyChunkSize = 0;
+	
+	User::LeaveIfError(iAllocServer.Reset());
+	
+	// Wait for the system to settle before getting the call counts (freeing the memory could cause some more movement).
+	Settle();
+	
+	// Update the call counts on the plugins (add them if they're not there already)
+	for (TInt pluginUid = KUidOOMDummyPluginFirstImplementation; pluginUid <= KUidOOMDummyPluginLastImplementation; pluginUid++)
+		{
+		TInt lowMemoryCount = 0;
+		RProperty::Get(KUidOomPropertyCategory, pluginUid + KOOMDummyPluginLowMemoryCount, lowMemoryCount);
+
+		TInt goodMemoryCallCount = 0;
+		RProperty::Get(KUidOomPropertyCategory, pluginUid + KOOMDummyPluginGoodMemoryCount, goodMemoryCallCount);
+		
+		TPluginCallCount pluginCallCount;
+		pluginCallCount.iFreeRamCallCount = lowMemoryCount;
+		pluginCallCount.iMemoryGoodCallCount = goodMemoryCallCount;
+		
+		iPluginCallCounts.InsertL(pluginUid, pluginCallCount);
+		};
+	} 
+
+void COomTestHarness::EatMemoryL(TInt aKBytesToLeaveFree)
+	{
+	Settle();
+	
+    TMemoryInfoV1Buf meminfo;
+    UserHal::MemoryInfo(meminfo);
+    TInt freeMem = meminfo().iFreeRamInBytes;
+
+    // Resize the dummy chunk to consume the correct ammount of memory
+	iChunkSize = freeMem + iChunkSize - (aKBytesToLeaveFree * 1024);
+	
+	if( iChunkSize > KOomHarnessMaxEatenMemory)
+	    {
+	    TInt dummy = (iChunkSize - KOomHarnessMaxEatenMemory)+ 2*1024*1024;
+	    /*
+	    if(dummy > (2 *1024 * 1024))
+	        {
+	        //User::LeaveIfError(iDummyChunk.CreateLocal(KOomHarnessInitialEatenMemory, ((dummy-(2*1024*1024)));
+	        dummy = dummy - 2*1024*1024;
+	        }
+	    */
+	    User::LeaveIfError(iDummyChunk.CreateLocal(KOomHarnessInitialEatenMemory, dummy));
+	    iDummyChunkSize = KOomHarnessInitialEatenMemory;
+	    TInt err1 = iDummyChunk.Adjust(dummy-1024);	
+	    UserHal::MemoryInfo(meminfo);
+	    freeMem = meminfo().iFreeRamInBytes;
+	    iChunkSize = freeMem + KOomHarnessInitialEatenMemory - (aKBytesToLeaveFree * 1024);
+	    }
+	    
+	    
+	TInt err = iChunk.Adjust(iChunkSize);
+	User::LeaveIfError(err);
+	}
+
+void COomTestHarness::AllocateMemoryL(TInt aKBytes)
+    {
+    TInt err = iChunk.Allocate(aKBytes * 1024);
+    User::LeaveIfError(err);    
+    }
+
+// Set up the plugins and applications - this is the starting point for many test cases
+// 5 applications are started with approx 0.5 MB used for each
+// 0.5MB (approx) of memory is reserved for each one of the plugins
+void COomTestHarness::CommonSetUpL()
+	{
+	// Configure the plugins to eat 0.5MB each:
+	for (TInt pluginIndex = KUidOOMDummyPluginFirstImplementation; pluginIndex <= KUidOOMDummyPluginLastImplementation; pluginIndex++)
+		{
+		User::LeaveIfError(iAllocServer.Configure(TUid::Uid(pluginIndex), 0, 0x80000, 0x80000));
+		}
+	}
+	
+void COomTestHarness::StartApplicationL(TInt32 aUid, TInt aInitialAllocationInKBs)
+	{
+	User::ResetInactivityTime();
+	CCDummyApplicationHandle *app = CCDummyApplicationHandle::NewLC(TUid::Uid(aUid), aInitialAllocationInKBs * 1024);
+	iApps.AppendL(app);
+	CleanupStack::Pop(app);
+	Settle();
+	}
+
+// Returns KErrNone if we get the expected result
+TInt COomTestHarness::AppIsRunning(TInt32 aUid, TBool aExpectedResult)
+	{
+	TBool appRunning = ETrue;
+	
+	TInt id = iApps.Find<TUid>(TUid::Uid(aUid), CCDummyApplicationHandle::CompareTo);
+	if (id < 0)
+		appRunning = EFalse;
+	else if(iApps[id]->Process().ExitType() != EExitPending)
+		appRunning = EFalse;
+	
+	TInt err = KErrNone;
+	
+	if (aExpectedResult != appRunning)
+		err = KErrGeneral;
+	
+	if (aExpectedResult != appRunning)
+		{
+		err = KErrGeneral;
+		}	
+	
+	return err;
+	}
+
+// Has FreeRam been called on this plugin since the last call to this function (or since the whole class has been reset)?
+// Returns KErrNone if we get the expected result
+TInt COomTestHarness::PluginFreeRamCalledL(TInt32 aUid, TBool aExpectedResult)
+	{
+	TInt newLowMemoryCount = 0;
+	TInt err = RProperty::Get(KUidOomPropertyCategory, aUid + KOOMDummyPluginLowMemoryCount, newLowMemoryCount);
+
+	//handle error?
+	
+	TBool freeRamHasBeenCalledOnPlugin = EFalse;
+	TPluginCallCount* pluginCallCount = iPluginCallCounts.Find(aUid);
+	
+	if (pluginCallCount)
+		{
+		freeRamHasBeenCalledOnPlugin = (pluginCallCount->iFreeRamCallCount != newLowMemoryCount);
+		
+		if (freeRamHasBeenCalledOnPlugin)
+			{
+			// Update the list of old counts with the current value so we can see if it has changed next time this function is called
+			pluginCallCount->iFreeRamCallCount = newLowMemoryCount;
+			iPluginCallCounts.InsertL(aUid, *pluginCallCount);
+			}
+		}
+	else
+		{
+		err = KErrNotFound;
+		}
+		
+	if (aExpectedResult != freeRamHasBeenCalledOnPlugin)
+		{
+		err = KErrGeneral;
+		}
+	
+	return err;
+	}
+
+// Has FreeRam been called on this plugin since the last call to this function (or since the whole class has been reset)?
+// Returns KErrNone if we get the expected result
+TInt COomTestHarness::PluginMemoryGoodCalledL(TInt32 aUid, TBool aExpectedResult)
+	{
+	TInt newGoodMemoryCount = 0;
+	RProperty::Get(KUidOomPropertyCategory, aUid + KOOMDummyPluginGoodMemoryCount, newGoodMemoryCount);
+
+	TBool memoryGoodHasBeenCalledOnPlugin = EFalse;
+	TPluginCallCount* pluginCallCount = iPluginCallCounts.Find(aUid);
+	
+	if (pluginCallCount)
+		{
+		memoryGoodHasBeenCalledOnPlugin = (pluginCallCount->iMemoryGoodCallCount != newGoodMemoryCount);
+		
+		if (memoryGoodHasBeenCalledOnPlugin)
+			{
+			// Update the list of old counts with the current value so we can see if it has changed next time this function is called
+			pluginCallCount->iMemoryGoodCallCount = newGoodMemoryCount;
+			iPluginCallCounts.InsertL(aUid, *pluginCallCount);
+			}
+		}
+	
+	TInt err = KErrNone;
+	
+	if (aExpectedResult != memoryGoodHasBeenCalledOnPlugin)
+		err = KErrGeneral;
+	
+	return err;
+	}
+
+// Utility function which calls the async version of optional RAM request and makes it behave like the sync version
+TInt COomTestHarness::RequestOptionalRamASyncWrapper(TInt aBytesRequested, TInt aMinimumBytesNeeded, TInt aPluginId, TInt& aBytesAvailable)
+	{
+	TInt err = KErrNone;
+	TRequestStatus status;
+	iOomSession.RequestOptionalRam(aBytesRequested, aMinimumBytesNeeded, aPluginId, status);
+	User::WaitForRequest(status);
+	
+	if (status.Int() < 0)
+		err = status.Int();
+	else
+		aBytesAvailable = status.Int();
+	
+	return err;
+	}
+
+void COomTestHarness::StartMemoryMonitorStatusWatcher(TInt& aTestState)
+    {
+    iStatusWatcher->Start(&aTestState);
+    }
+
+void COomTestHarness::StartTimerAndRunWatcher(TInt& aTestState)
+    {
+    //start timer
+    iTimeoutWatcher->Start(&aTestState, KTimeout);
+    
+    //start active scheduler to catch mem monitor status changes
+    CActiveScheduler::Start();
+    
+    //One of the active objects has fired. Cancelling all pending requests
+    iStatusWatcher->Cancel();
+    iTimeoutWatcher->Cancel();
+    }
+
+TInt COomTestHarness::GetFreeMemory()
+	{
+	User::CompressAllHeaps();
+	
+	TInt current = 0;
+	HAL::Get( HALData::EMemoryRAMFree, current );
+	
+	return current;
+	}
+
+
+CMemoryMonitorStatusWatcher* CMemoryMonitorStatusWatcher::NewL()
+    {
+    CMemoryMonitorStatusWatcher* self = new (ELeave) CMemoryMonitorStatusWatcher();
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(); // self;
+    return self;
+    }
+
+CMemoryMonitorStatusWatcher::~CMemoryMonitorStatusWatcher()
+    {
+    Cancel();
+    iMonitorProperty.Close();
+    }
+
+void CMemoryMonitorStatusWatcher::Start(TInt* aTestState)
+    {
+    iMonitorProperty.Subscribe(iStatus);
+    SetActive();
+
+    iTestState = aTestState;
+    }
+
+CMemoryMonitorStatusWatcher::CMemoryMonitorStatusWatcher() : CActive(CActive::EPriorityStandard)
+    {
+    }
+
+void CMemoryMonitorStatusWatcher::ConstructL()
+    {
+    CActiveScheduler::Add(this); // Add to scheduler
+    User::LeaveIfError(iMonitorProperty.Attach(KOomMemoryMonitorStatusPropertyCategory, KOomMemoryMonitorStatusPropertyKey));
+    }
+
+void CMemoryMonitorStatusWatcher::DoCancel()
+    {
+    iMonitorProperty.Cancel();
+    }
+
+void CMemoryMonitorStatusWatcher::RunL()
+    {
+    iMonitorProperty.Subscribe(iStatus);
+    SetActive();
+    
+    TInt monitorState = EFreeingMemory;
+    User::LeaveIfError(iMonitorProperty.Get(monitorState));
+    
+    if (monitorState != EFreeingMemory)
+        {
+        //Do not reschedule - signal client that request has completed
+        Cancel();
+        if(monitorState == EBelowTreshHold)
+            {
+            *iTestState = ETestBelow;
+            }
+        else
+            {
+            *iTestState = ETestAbove;
+            }
+        CActiveScheduler::Stop();
+        }
+    }
+
+CMemoryMonitorTimeoutWatcher* CMemoryMonitorTimeoutWatcher::NewL()
+    {
+    CMemoryMonitorTimeoutWatcher* self = new (ELeave) CMemoryMonitorTimeoutWatcher();
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(); // self;
+    return self;
+    }
+
+CMemoryMonitorTimeoutWatcher::~CMemoryMonitorTimeoutWatcher()
+    {
+    Cancel();
+    }
+
+void CMemoryMonitorTimeoutWatcher::Start(TInt* aTestState, const TTimeIntervalMicroSeconds32& aTimeout)
+    {
+    iTestState = aTestState;
+    After(aTimeout);
+    }
+
+void CMemoryMonitorTimeoutWatcher::ConstructL()
+    {
+    CTimer::ConstructL();
+    CActiveScheduler::Add(this); // Add to scheduler
+    }
+
+CMemoryMonitorTimeoutWatcher::CMemoryMonitorTimeoutWatcher() : CTimer(CActive::EPriorityStandard)
+    {
+    }
+
+void CMemoryMonitorTimeoutWatcher::DoCancel()
+    {
+    CTimer::DoCancel();
+    }
+
+void CMemoryMonitorTimeoutWatcher::RunL()
+    {
+    Cancel();
+    *iTestState = ETestTimeout;
+    CActiveScheduler::Stop();
+    }
+
+////////
+
+CAsyncRequester* CAsyncRequester::NewL(RChunk aChunk, TInt aChunkSize)
+    {
+    CAsyncRequester* self = new (ELeave) CAsyncRequester(aChunk, aChunkSize);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(); // self;
+    return self;
+    }
+
+CAsyncRequester::~CAsyncRequester()
+    {
+    Cancel();
+    iSession.Close();
+    }
+
+void CAsyncRequester::Start(TInt aBytesToRequest, TReturnStatus* aReturnStatus)
+    {
+    iReturnStatus = aReturnStatus;
+    //Request 2.8MB which will close KOomTestApp3Uid
+    iSession.RequestOptionalRam(aBytesToRequest, 0, 0x10286A3D, iStatus);
+    SetActive();
+    }
+
+void CAsyncRequester::ConstructL()
+    {
+    User::LeaveIfError(iSession.Connect());    
+    CActiveScheduler::Add(this); // Add to scheduler
+    }
+
+CAsyncRequester::CAsyncRequester(RChunk aChunk, TInt aChunkSize) 
+    : CActive(CActive::EPriorityStandard),
+    iChunk(aChunk),
+    iChunkSize(aChunkSize)
+    {
+    }
+
+void CAsyncRequester::DoCancel()
+    {
+    }
+
+void CAsyncRequester::RunL()
+    {
+    iReturnStatus->iCompleted = ETrue;
+    iReturnStatus->iReturnStatus = iStatus.Int();
+    if (iReturnStatus->iId == 1)
+        {
+        TMemoryInfoV1Buf meminfo;
+        UserHal::MemoryInfo(meminfo);
+        TInt freeMem = meminfo().iFreeRamInBytes;
+
+        // Resize the dummy chunk to consume the correct ammount of memory
+        iChunkSize = freeMem + iChunkSize - (KOomJustAboveGoodMemoryThreshold * 1024);
+        TInt err = iChunk.Adjust(iChunkSize);
+        User::LeaveIfError(err);
+        }
+    else 
+        {
+        CActiveScheduler::Stop();
+        }
+    }
+
+/////////
+
+
+TInt COomTestHarness::AppCloseTwoSessionsL(TTestResult& aResult)
+    {
+    ResetL();
+    
+    StartApplicationL(KOomTestApp2Uid, 3 * 1024); // P8 app to be closed 
+    StartApplicationL(KOomTestAppUid, 3 * 1024);  // P9 app should not be closed
+    StartApplicationL(KOomTestApp3Uid, 3 * 1024); // P7 app to be closed 
+    StartApplicationL(KOomTestApp4Uid, 3 * 1024); // P7 app foreground should not be closed
+    
+    // Go just above the good memory threshold
+    EatMemoryL(KOomJustAboveGoodMemoryThreshold);
+    
+    Settle();
+    
+    TInt err = KErrNone;
+    CAsyncRequester* req1 = CAsyncRequester::NewL(iChunk, iChunkSize);
+    CleanupStack::PushL(req1);
+    CAsyncRequester* req2 = CAsyncRequester::NewL(iChunk, iChunkSize);
+    CleanupStack::PushL(req2);
+    TReturnStatus status1;
+    status1.iId = 1;
+    TReturnStatus status2;
+    status2.iId = 2;
+    
+    TInt memTestState = ETestInit;
+    iTimeoutWatcher->Start(&memTestState, KTimeout);
+        
+    //This request should close KOomTestApp3Uid
+    //On return the active object will allocate the memory it requested
+    req1->Start(3 * 1024 * 1024, &status1);
+
+    //The second request should be queued until the first request has completed, there will then be
+    //a pause for the memory to be allocated before the request is properly serviced.
+    req2->Start(3 * 1024 * 1024, &status2);
+
+    CActiveScheduler::Start();
+
+    //The active scheduler is stopped, we should return here once both AOs have been completed.
+    iTimeoutWatcher->Cancel();
+    
+    if (memTestState == ETestTimeout)
+        {
+        err = KErrTimedOut;
+        _LIT( KResult ,"Test has timed out, requests have not been completed");
+        aResult.iResultDes.Copy( KResult );
+        aResult.iResult = KErrGeneral;
+        // Case was executed but failed
+        }                
+    if (err == KErrNone)
+        {   
+        err = AppIsRunning(KOomTestApp4Uid, ETrue); 
+        if (err != KErrNone)
+            {
+            _LIT( KResult ,"Foreground App KOomTestApp4Uid not running");
+            aResult.iResultDes.Copy( KResult );
+            aResult.iResult = KErrGeneral;
+            // Case was executed but failed
+            }
+        }
+    if (err == KErrNone)
+        {   
+        err = AppIsRunning(KOomTestAppUid, ETrue); 
+        if (err != KErrNone)
+            {
+            _LIT( KResult ,"P9 App KOomTestAppUid not running");
+            aResult.iResultDes.Copy( KResult );
+            aResult.iResult = KErrGeneral;
+            // Case was executed but failed
+            }
+        }
+    if (err == KErrNone)
+        {   
+        err = AppIsRunning(KOomTestApp3Uid, EFalse);  
+        if (err != KErrNone)
+            {
+            _LIT( KResult ,"P7 App KOomTestApp3Uid incorrectly  running");
+            aResult.iResultDes.Copy( KResult );
+            aResult.iResult = KErrGeneral;
+            // Case was executed but failed
+            }
+        }
+    if (err == KErrNone)
+        {   
+        err = AppIsRunning(KOomTestApp2Uid, EFalse);  
+        if (err != KErrNone)
+            {
+            _LIT( KResult ,"P7 App KOomTestApp2Uid incorrectly  running");
+            aResult.iResultDes.Copy( KResult );
+            aResult.iResult = KErrGeneral;
+            // Case was executed but failed
+            }
+        }
+    if (err == KErrNone)
+        {
+        _LIT( KDescription , "Test case passed");
+        aResult.SetResult( KErrNone, KDescription );
+        }
+    
+    CleanupStack::PopAndDestroy(2);
+    ResetL();    
+    return KErrNone;        
+    }
+
+
+TInt COomTestHarness::CallIfTargetAppNotRunningTest1L(TTestResult& aResult)
+    {
+    ResetL();
+    
+    // Configure the plugins to eat 0.5MB each:
+    for (TInt pluginIndex = KUidOOMDummyPluginFirstImplementation; pluginIndex <= KUidOOMDummyPluginLastImplementation - 2; pluginIndex++)
+        {
+        User::LeaveIfError(iAllocServer.Configure(TUid::Uid(pluginIndex), 0, 0x80000, 0x80000));
+        }
+    
+    StartApplicationL(KOomTestApp3Uid, 0);
+    
+
+    TInt err = KErrNone;
+    
+    // Now eat some memory till we are below treshhold and wait for the memory monitor to bring us above treshhold again
+    TInt memTestState = ETestInit;
+    
+    //start watchers
+    StartMemoryMonitorStatusWatcher(memTestState);
+    
+    // Go just under the low memory threshold
+    EatMemoryL(KOomJustUnderLowMemoryThreshold);
+
+    //start timer, start scheduler & stop watchers when done
+    StartTimerAndRunWatcher(memTestState);
+    
+    // fail tests if watchers failed or memory was not freed
+    if (memTestState != ETestAbove)
+        {
+        _LIT( KResult ,"Watchers failed to start or Application Timeout or Memory Still Below Treshhold ");
+        aResult.iResultDes.Copy( KResult );
+        aResult.iResult = KErrGeneral;
+        // case was not executed or case was executed but never finished or failed 
+        //if memteststate is not desired signal to other cases that they should not pass
+        err = KErrGeneral;
+        }
+    
+    // The following application plugins should be called...
+    // Application plugins: 10286A3B
+    // The following application plugins should not be called...
+    // Application plugins: 10286A3A, 0x10286A38 
+    if (err == KErrNone)
+        {
+        //target app not running for this priority 3 app plugin
+        err = PluginFreeRamCalledL(0x10286A3A, EFalse);
+        if (err != KErrNone)
+            {
+            _LIT( KResult ,"plugin 0x10286A3A FreeRam incorrectly called");
+            aResult.iResultDes.Copy( KResult );
+            aResult.iResult = KErrGeneral;
+            // Case was executed but failed
+            }
+        }
+    
+    if (err == KErrNone)
+        {   
+        //target app is running for this priority 4 app plugin
+        err = PluginFreeRamCalledL(0x10286A3B, ETrue);
+        if (err != KErrNone)
+            {
+            _LIT( KResult ,"plugin 0x10286A3B FreeRam not called");
+            aResult.iResultDes.Copy( KResult );
+            aResult.iResult = KErrGeneral;
+            // Case was executed but failed
+            }
+        }
+    
+    //By the time we get to this priority 9 plugin, the app plugins and other sys plugins 
+    // have freed enough memory and a sys plugin with "check ram" has been called
+    if (err == KErrNone)
+        {
+        err = PluginFreeRamCalledL(0x10286A38, EFalse); 
+        if (err != KErrNone)
+            {
+            _LIT( KResult ,"plugin 0x10286A38 FreeRam incorrectly called");
+            aResult.iResultDes.Copy( KResult );
+            aResult.iResult = KErrGeneral;
+            // Case was executed but failed
+            }
+        }
+    
+    if (err == KErrNone)
+        {
+        _LIT( KDescription , "Test case passed");
+        aResult.SetResult( KErrNone, KDescription );
+        }
+    
+    ResetL();
+    return KErrNone;    
+    }
+
+//Test that an app that has an app_specific_thresholds but no close_app can still be closed
+//
+//This test only works on emulator. On hw there are many more apps started which have default priority 
+//and these are closed before KOomTestApp8Uid as they are behind it in the z order, freeing sufficient memory
+//before we would get to KOomTestApp8Uid
+TInt COomTestHarness::AppCloseSpecificThresholdTest1L(TTestResult& aResult)
+    {
+    ResetL();
+    
+    StartApplicationL(KOomTestApp8Uid, 5 * 1024); // app with app_specific_thresholds but no close_app
+    StartApplicationL(KOomTestApp3Uid, 0); // P7 foreground app. Will not be closed
+    
+    BringAppToForeground(KOomTestApp3Uid);
+    
+    //start watchers
+    TInt memTestState = ETestInit;
+    TInt err = KErrNone;
+    
+    StartMemoryMonitorStatusWatcher(memTestState);
+
+    // Go significantly under the low memory threshold
+    EatMemoryL(KOomSignificantlyUnderLowMemoryThreshold);
+
+    //start timer, start scheduler & stop watchers when done
+    StartTimerAndRunWatcher(memTestState);
+    
+    if (memTestState == ETestAbove)
+        {
+        err = AppIsRunning(KOomTestApp8Uid, EFalse);
+        
+        if (err != KErrNone)
+            {
+            _LIT( KResult ,"P8 App KOomTestApp2Uid incorrectly running");
+            aResult.iResultDes.Copy( KResult );
+            aResult.iResult = KErrGeneral;
+           // Case was executed but failed
+            }
+        if (err == KErrNone)
+            {   
+            err = AppIsRunning(KOomTestApp3Uid, ETrue); 
+            if (err != KErrNone)
+                {
+                // The P7 app should still be running because it was in the foreground
+                _LIT( KResult ,"(P7 App KOomTestApp3Uid not running");
+                aResult.iResultDes.Copy( KResult );
+                aResult.iResult = KErrGeneral;
+                // Case was executed but failed
+                }
+            }
+        if (err == KErrNone)
+            {
+            _LIT( KDescription , "Test case passed");
+            aResult.SetResult( KErrNone, KDescription );
+            }
+        }
+    else
+        {
+        _LIT( KResult ,"Watchers failed to start or Application Timeout or Memory Still Below Treshhold ");
+        aResult.iResultDes.Copy( KResult );
+        aResult.iResult = KErrGeneral;
+        // case was not executed or case was executed but never finished or failed 
+        }
+    
+    ResetL();    
+    return KErrNone;        
+    }
+
+TInt COomTestHarness::PluginTestInsufficientMemoryFreedL(TTestResult& aResult)
+    {
+    ResetL();
+    
+    // Configure the plugins to eat 1kB each:
+    for (TInt pluginIndex = KUidOOMDummyPluginFirstImplementation; pluginIndex <= KUidOOMDummyPluginLastImplementation - 2; pluginIndex++)
+        {
+        User::LeaveIfError(iAllocServer.Configure(TUid::Uid(pluginIndex), 0, 0x400, 0x400));
+        }
+    
+    //start watchers
+    TInt err = KErrNone;
+    TInt bytesAvailable;
+    
+    // Go significantly under the low memory threshold
+    EatMemoryL(KOomJustAboveGoodMemoryThreshold);
+
+    // Request 5 MB of data, using the priority of the referenced plugin (constant priority 8)
+    err = iOomSession.RequestOptionalRam(5 * 1024 * 1024, 5 * 1024 * 1024, 0x10286A37, bytesAvailable);
+   
+    // There should be nothing that can be done to free this memory
+    if (err == KErrNoMemory)
+        {
+        err = KErrNone;
+        }
+    else    
+        {
+        _LIT( KResult ,"There should not have been actions available to successfully complete request");
+        aResult.iResultDes.Copy( KResult );
+        aResult.iResult = KErrGeneral;
+        // Case was executed but failed
+        }
+    
+    //Check a couple of plugins that should have been called
+    if (err == KErrNone)
+        {   
+        err = PluginFreeRamCalledL(0x10286A36, ETrue);
+        if (err != KErrNone)
+            {
+            _LIT( KResult ,"Plugin 0x10286A36 FreeRam not called");
+            aResult.iResultDes.Copy( KResult );
+            aResult.iResult = KErrGeneral;
+            // Case was executed but failed
+            }
+        }
+    if (err == KErrNone)
+        {   
+        err = PluginFreeRamCalledL(0x10286A3B, ETrue);
+        if (err != KErrNone)
+            {
+            _LIT( KResult ,"Plugin 0x10286A3B FreeRam not called");
+            aResult.iResultDes.Copy( KResult );
+            aResult.iResult = KErrGeneral;
+            // Case was executed but failed
+            }
+        }
+    
+    // This plugin should not be called as it is priority 9
+    if (err == KErrNone)
+        {   
+        err = PluginFreeRamCalledL(0x10286A3D, EFalse);
+        if (err != KErrNone)
+            {
+            _LIT( KResult ,"Plugin 0x10286A3D FreeRam incorrectly called");
+            aResult.iResultDes.Copy( KResult );
+            aResult.iResult = KErrGeneral;
+            // Case was executed but failed
+            }
+        }   
+    //This plugins should not be called as the target app is not running
+    if (err == KErrNone)
+        {   
+        err = PluginFreeRamCalledL(0x10286A3A, EFalse);  
+        if (err != KErrNone)
+            {
+            _LIT( KResult ,"Plugin 0x10286A3A FreeRam incorrectly called");
+            aResult.iResultDes.Copy( KResult );
+            aResult.iResult = KErrGeneral;
+            // Case was executed but failed
+            }
+        }
+
+    // MemoryGood should have been called on all plugins which were run as the request to 
+    // go below memory was triggered by an optional RAM request
+    if (err == KErrNone)
+        {                   
+        err = PluginMemoryGoodCalledL(0x10286A3B, ETrue);
+        if (err != KErrNone)
+            {
+            _LIT( KResult ,"plugin  0x10286A3B MemoryGood not called");
+            aResult.iResultDes.Copy( KResult );
+            aResult.iResult = KErrGeneral;
+            // Case was executed but failed
+            }
+        }
+        
+    if (err == KErrNone)
+        {                   
+        err = PluginMemoryGoodCalledL(0x10286A3C, ETrue);
+        if (err != KErrNone)
+            {
+            _LIT( KResult ,"plugin  0x10286A3C MemoryGood not called");
+            aResult.iResultDes.Copy( KResult );
+            aResult.iResult = KErrGeneral;
+            // Case was executed but failed
+            }
+        }
+    
+    if (err == KErrNone)
+        {                   
+        // MemoryGood should not be called on this plugin because FreeMemory was never called on it
+        err = PluginMemoryGoodCalledL(0x10286A37, EFalse);
+        if (err != KErrNone)
+            {
+            _LIT( KResult ,"plugin  0x10286A37 MemoryGood incorrectly called");
+            aResult.iResultDes.Copy( KResult );
+            aResult.iResult = KErrGeneral;
+            // Case was executed but failed
+            }
+        }
+    
+    if (err == KErrNone)
+        {
+        _LIT( KDescription , "Test case passed");
+        aResult.SetResult( KErrNone, KDescription );
+        }
+
+    ResetL();    
+    return KErrNone;        
+    }
+
+TInt COomTestHarness::PluginTestInsufficientMemoryFreed2L(TTestResult& aResult)
+    {
+    ResetL();
+    
+    // Configure the plugins to eat 1kB each:
+    for (TInt pluginIndex = KUidOOMDummyPluginFirstImplementation; pluginIndex <= KUidOOMDummyPluginLastImplementation - 2; pluginIndex++)
+        {
+        User::LeaveIfError(iAllocServer.Configure(TUid::Uid(pluginIndex), 0, 0x400, 0x400));
+        }
+    
+    //start watchers
+    TInt err = KErrNone;
+    TInt bytesAvailable;
+    
+    // Go significantly under the low memory threshold
+    EatMemoryL(KOomBetweenLowAndGoodThresholds);
+
+    // Request 5 MB of data, using the priority of the referenced plugin (constant priority 8)
+    err = iOomSession.RequestOptionalRam(5 * 1024 * 1024, 5 * 1024 * 1024, 0x10286A37, bytesAvailable);
+   
+    // There should be nothing that can be done to free this memory
+    if (err == KErrNoMemory)
+        {
+        err = KErrNone;
+        }
+    else    
+        {
+        _LIT( KResult ,"There should not have been actions available to successfully complete request");
+        aResult.iResultDes.Copy( KResult );
+        aResult.iResult = KErrGeneral;
+        // Case was executed but failed
+        }
+    
+    //Check a couple of plugins that should have been called
+    if (err == KErrNone)
+        {   
+        err = PluginFreeRamCalledL(0x10286A36, ETrue);
+        if (err != KErrNone)
+            {
+            _LIT( KResult ,"Plugin 0x10286A36 FreeRam not called");
+            aResult.iResultDes.Copy( KResult );
+            aResult.iResult = KErrGeneral;
+            // Case was executed but failed
+            }
+        }
+    if (err == KErrNone)
+        {   
+        err = PluginFreeRamCalledL(0x10286A3B, ETrue);
+        if (err != KErrNone)
+            {
+            _LIT( KResult ,"Plugin 0x10286A3B FreeRam not called");
+            aResult.iResultDes.Copy( KResult );
+            aResult.iResult = KErrGeneral;
+            // Case was executed but failed
+            }
+        }
+    
+    // This plugin should not be called as it is priority 9
+    if (err == KErrNone)
+        {   
+        err = PluginFreeRamCalledL(0x10286A3D, EFalse);
+        if (err != KErrNone)
+            {
+            _LIT( KResult ,"Plugin 0x10286A3D FreeRam incorrectly called");
+            aResult.iResultDes.Copy( KResult );
+            aResult.iResult = KErrGeneral;
+            // Case was executed but failed
+            }
+        }   
+    //This plugins should not be called as the target app is not running
+    if (err == KErrNone)
+        {   
+        err = PluginFreeRamCalledL(0x10286A3A, EFalse);  
+        if (err != KErrNone)
+            {
+            _LIT( KResult ,"Plugin 0x10286A3A FreeRam incorrectly called");
+            aResult.iResultDes.Copy( KResult );
+            aResult.iResult = KErrGeneral;
+            // Case was executed but failed
+            }
+        }
+
+    // MemoryGood should have been called on all plugins which were run as the request to 
+    // go below memory was triggered by an optional RAM request
+    if (err == KErrNone)
+        {                   
+        err = PluginMemoryGoodCalledL(0x10286A3B, ETrue);
+        if (err != KErrNone)
+            {
+            _LIT( KResult ,"plugin  0x10286A3B MemoryGood not called");
+            aResult.iResultDes.Copy( KResult );
+            aResult.iResult = KErrGeneral;
+            // Case was executed but failed
+            }
+        }
+        
+    if (err == KErrNone)
+        {                   
+        err = PluginMemoryGoodCalledL(0x10286A3C, ETrue);
+        if (err != KErrNone)
+            {
+            _LIT( KResult ,"plugin  0x10286A3C MemoryGood not called");
+            aResult.iResultDes.Copy( KResult );
+            aResult.iResult = KErrGeneral;
+            // Case was executed but failed
+            }
+        }
+    
+    if (err == KErrNone)
+        {                   
+        // MemoryGood should not be called on this plugin because FreeMemory was never called on it
+        err = PluginMemoryGoodCalledL(0x10286A37, EFalse);
+        if (err != KErrNone)
+            {
+            _LIT( KResult ,"plugin  0x10286A37 MemoryGood incorrectly called");
+            aResult.iResultDes.Copy( KResult );
+            aResult.iResult = KErrGeneral;
+            // Case was executed but failed
+            }
+        }
+    
+    if (err == KErrNone)
+        {
+        _LIT( KDescription , "Test case passed");
+        aResult.SetResult( KErrNone, KDescription );
+        }
+
+    ResetL();    
+    return KErrNone;        
+    }
+
+// ================= OTHER EXPORTED FUNCTIONS =================================
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomtestapp/data/t_oomtestapp.rss	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,171 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+//  RESOURCE IDENTIFIER
+NAME T_OT // 4 letter ID
+
+//  INCLUDES
+#include <eikon.rh>
+#include <avkon.rsg>
+#include <avkon.rh>
+#include <appinfo.rh>
+#include <commondialogs.hrh>
+#include <commondialogs.rh>
+#include "t_oomtestappcmd.hrh"
+
+//  RESOURCE DEFINITIONS
+RESOURCE RSS_SIGNATURE
+    {
+    }
+
+RESOURCE TBUF r_default_document_name
+	{
+	buf="T_OT";
+	}
+
+RESOURCE EIK_APP_INFO
+    {
+    menubar = r_menubar;
+    cba = R_AVKON_SOFTKEYS_OPTIONS_EXIT;
+    }
+
+RESOURCE MENU_BAR r_menubar
+    {
+    titles =
+        {
+        MENU_TITLE { menu_pane = r_menu; }
+        };
+    }
+
+RESOURCE MENU_PANE r_menu
+    {
+    items =
+        {
+        MENU_ITEM
+            {
+            command = EOomTestAppSelectConfig;
+            txt = "Select config xml";
+            },
+        MENU_ITEM
+            {
+            command = EOomTestAppToggleSystem;
+            txt = "Toggle system";
+            },
+        MENU_ITEM
+            {
+            command = EOomTestAppAllocMemory;
+            txt = "Alloc memory";
+            },
+        MENU_ITEM
+            {
+            command = EOomTestAppFreeMemory;
+            txt = "Free memory";
+            },
+        MENU_ITEM
+            {
+            command = EOomTestAppAllocMemWithPermission;
+            txt = "Alloc memory with permission";
+            },
+        MENU_ITEM
+            {
+            command = EOomTestAppSetPriority;
+            cascade = r_priority_menu;
+            txt = "Set priority";
+            },
+        MENU_ITEM
+            {
+            command = EAknSoftkeyExit;
+            txt = "Exit";
+            }
+        };
+    }
+
+RESOURCE MENU_PANE r_priority_menu
+    {
+    items =
+        {
+        MENU_ITEM
+            {
+            command = EOomTestAppSetPriorityNormal;
+            txt = "Normal";
+            },
+        MENU_ITEM
+            {
+            command = EOomTestAppSetPriorityHigh;
+            txt = "High";
+            },
+        MENU_ITEM
+            {
+            command = EOomTestAppSetPriorityBusy;
+            txt = "Busy";
+            }
+        };
+    }
+
+RESOURCE MEMORYSELECTIONDIALOG r_memory_selection
+    {
+    title = "";
+    softkey_1 = "Ok";
+    }
+
+RESOURCE FILESELECTIONDIALOG r_file_selection
+    {
+    title = "Select xml";
+    softkey_1_file = "Select";
+    softkey_1_folder = "Open";
+    softkey_2_root_level = "Cancel";
+    softkey_2_subfolder = "Back";
+    filters =
+        {
+        FILTER
+            {
+            filter_type = EFilenameFilter;
+            filter_style = EInclusiveFilter;
+            filter_data = { "*.xml" };
+            }
+        };
+    }
+
+RESOURCE DIALOG r_alloc_query
+     {
+     flags = EAknGeneralQueryFlags;
+     buttons = R_AVKON_SOFTKEYS_OK_CANCEL;
+     items =
+         {
+         DLG_LINE
+             {
+             type = EAknCtQuery;
+             id = EGeneralQuery;
+             control = AVKON_DATA_QUERY
+                 {
+                 layout = ENumberLayout;
+                 label = "KBs to allocate";
+                 control = AVKON_INTEGER_EDWIN
+                     {
+                     maxlength=10;
+                     min = 0;
+                     max = 0x7fffffff; // KMaxTInt
+                     };
+                 };
+             }
+         };
+     }
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomtestapp/data/t_oomtestapp_reg.rss	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,30 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+#include <appinfo.rh>
+#include "t_oomtestapp.hrh"
+
+UID2 KUidAppRegistrationResourceFile
+UID3 T_OOM_TESTAPP_UID
+
+RESOURCE APP_REGISTRATION_INFO
+	{
+    app_file = T_OOM_TESTAPP_NAME_STRING;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomtestapp/group/bld.inf	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,35 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_TESTMMPFILES
+t_oomtestapp.mmp
+t_oomtestapp2.mmp
+t_oomtestapp3.mmp
+t_oomtestapp4.mmp
+t_oomtestapp5.mmp
+t_oomtestapp6.mmp
+t_oomtestapp7.mmp
+t_oomtestapp8.mmp
+t_oomtestapp9.mmp
+t_oomtestapp10.mmp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomtestapp/group/oomtestapps.pkg	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,50 @@
+;Languages
+&EN
+
+#{"t_oomtestapps"},(0x101FB3E7),1,0,0,TYPE=SA
+
+;Localised Vendor name
+%{"t_oomtestapps EN"}
+
+; Vendor name
+: "t_oomtestapps"
+
+"\epoc32\release\armv5\urel\t_oomtestapp.exe"-"!:\sys\bin\t_oomtestapp.exe"
+"\epoc32\data\z\resource\apps\t_oomtestapp.rsc"-"!:\resource\apps\t_oomtestapp.rsc"
+"\epoc32\data\z\private\10003a3f\apps\t_oomtestapp_reg.rsc"-"!:\private\10003a3f\import\apps\t_oomtestapp_reg.rsc"
+
+"\epoc32\release\armv5\urel\t_oomtestapp2.exe"-"!:\sys\bin\t_oomtestapp2.exe"
+"\epoc32\data\z\resource\apps\t_oomtestapp2.rsc"-"!:\resource\apps\t_oomtestapp2.rsc"
+"\epoc32\data\z\private\10003a3f\apps\t_oomtestapp2_reg.rsc"-"!:\private\10003a3f\import\apps\t_oomtestapp2_reg.rsc"
+
+"\epoc32\release\armv5\urel\t_oomtestapp3.exe"-"!:\sys\bin\t_oomtestapp3.exe"
+"\epoc32\data\z\resource\apps\t_oomtestapp3.rsc"-"!:\resource\apps\t_oomtestapp3.rsc"
+"\epoc32\data\z\private\10003a3f\apps\t_oomtestapp3_reg.rsc"-"!:\private\10003a3f\import\apps\t_oomtestapp3_reg.rsc"
+
+"\epoc32\release\armv5\urel\t_oomtestapp4.exe"-"!:\sys\bin\t_oomtestapp4.exe"
+"\epoc32\data\z\resource\apps\t_oomtestapp4.rsc"-"!:\resource\apps\t_oomtestapp4.rsc"
+"\epoc32\data\z\private\10003a3f\apps\t_oomtestapp4_reg.rsc"-"!:\private\10003a3f\import\apps\t_oomtestapp4_reg.rsc"
+
+"\epoc32\release\armv5\urel\t_oomtestapp5.exe"-"!:\sys\bin\t_oomtestapp5.exe"
+"\epoc32\data\z\resource\apps\t_oomtestapp5.rsc"-"!:\resource\apps\t_oomtestapp5.rsc"
+"\epoc32\data\z\private\10003a3f\apps\t_oomtestapp5_reg.rsc"-"!:\private\10003a3f\import\apps\t_oomtestapp5_reg.rsc"
+
+"\epoc32\release\armv5\urel\t_oomtestapp6.exe"-"!:\sys\bin\t_oomtestapp6.exe"
+"\epoc32\data\z\resource\apps\t_oomtestapp6.rsc"-"!:\resource\apps\t_oomtestapp6.rsc"
+"\epoc32\data\z\private\10003a3f\apps\t_oomtestapp6_reg.rsc"-"!:\private\10003a3f\import\apps\t_oomtestapp6_reg.rsc"
+
+"\epoc32\release\armv5\urel\t_oomtestapp7.exe"-"!:\sys\bin\t_oomtestapp7.exe"
+"\epoc32\data\z\resource\apps\t_oomtestapp7.rsc"-"!:\resource\apps\t_oomtestapp7.rsc"
+"\epoc32\data\z\private\10003a3f\apps\t_oomtestapp7_reg.rsc"-"!:\private\10003a3f\import\apps\t_oomtestapp7_reg.rsc"
+
+"\epoc32\release\armv5\urel\t_oomtestapp8.exe"-"!:\sys\bin\t_oomtestapp8.exe"
+"\epoc32\data\z\resource\apps\t_oomtestapp8.rsc"-"!:\resource\apps\t_oomtestapp8.rsc"
+"\epoc32\data\z\private\10003a3f\apps\t_oomtestapp8_reg.rsc"-"!:\private\10003a3f\import\apps\t_oomtestapp8_reg.rsc"
+
+"\epoc32\release\armv5\urel\t_oomtestapp9.exe"-"!:\sys\bin\t_oomtestapp9.exe"
+"\epoc32\data\z\resource\apps\t_oomtestapp9.rsc"-"!:\resource\apps\t_oomtestapp9.rsc"
+"\epoc32\data\z\private\10003a3f\apps\t_oomtestapp9_reg.rsc"-"!:\private\10003a3f\import\apps\t_oomtestapp9_reg.rsc"
+
+"\epoc32\release\armv5\urel\t_oomtestapp10.exe"-"!:\sys\bin\t_oomtestapp10.exe"
+"\epoc32\data\z\resource\apps\t_oomtestapp10.rsc"-"!:\resource\apps\t_oomtestapp10.rsc"
+"\epoc32\data\z\private\10003a3f\apps\t_oomtestapp10_reg.rsc"-"!:\private\10003a3f\import\apps\t_oomtestapp10_reg.rsc"
Binary file sysresmonitoring/oommonitor/tsrc/oomtest/t_oomtestapp/group/oomtestapps.sisx has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomtestapp/group/t_oomtestapp.mmh	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,60 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+#include <platform_paths.hrh>
+
+TARGET          T_OOM_TESTAPP_NAME_EXE
+TARGETTYPE      exe
+EPOCHEAPSIZE    0x10000 0x4000000 // Min 64KB, Max 64MB
+UID             0x100039CE T_OOM_TESTAPP_UID
+CAPABILITY      WriteDeviceData AllFiles
+
+SOURCEPATH      ../src
+SOURCE          t_oomtestappapplication.cpp
+SOURCE          t_oomtestappappview.cpp
+SOURCE          t_oomtestappappui.cpp
+SOURCE          t_oomtestappdocument.cpp
+
+SOURCEPATH      ../data
+START RESOURCE  t_oomtestapp.rss
+HEADER
+TARGET          T_OOM_TESTAPP_NAME
+TARGETPATH      resource/apps
+END
+
+START RESOURCE  t_oomtestapp_reg.rss
+TARGET          T_OOM_TESTAPP_NAME_REG
+TARGETPATH      /private/10003a3f/apps
+END
+
+MW_LAYER_SYSTEMINCLUDE
+T_OOM_TEST_APPDEFS_INCLUDE
+USERINCLUDE    ../inc
+
+LIBRARY        euser.lib
+LIBRARY        apparc.lib
+LIBRARY        cone.lib
+LIBRARY        eikcore.lib
+LIBRARY        avkon.lib
+LIBRARY        efsrv.lib
+LIBRARY        oommonitor.lib
+LIBRARY        commondialogs.lib
+
+// End of File
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomtestapp/group/t_oomtestapp.mmp	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,25 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+#define T_OOM_TEST_APPDEFS_INCLUDE USERINCLUDE ../inc/appdefs
+#include "../inc/appdefs/t_oomtestapp.hrh"
+#include "t_oomtestapp.mmh"
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomtestapp/group/t_oomtestapp10.mmp	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,25 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+#define T_OOM_TEST_APPDEFS_INCLUDE USERINCLUDE ../inc/appdefs10
+#include "../inc/appdefs10/t_oomtestapp.hrh"
+#include "t_oomtestapp.mmh"
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomtestapp/group/t_oomtestapp2.mmp	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,26 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+
+#define T_OOM_TEST_APPDEFS_INCLUDE USERINCLUDE ../inc/appdefs2
+#include "../inc/appdefs2/t_oomtestapp.hrh"
+#include "t_oomtestapp.mmh"
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomtestapp/group/t_oomtestapp3.mmp	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,25 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+#define T_OOM_TEST_APPDEFS_INCLUDE USERINCLUDE ../inc/appdefs3
+#include "../inc/appdefs3/t_oomtestapp.hrh"
+#include "t_oomtestapp.mmh"
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomtestapp/group/t_oomtestapp4.mmp	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,25 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+#define T_OOM_TEST_APPDEFS_INCLUDE USERINCLUDE ../inc/appdefs4
+#include "../inc/appdefs4/t_oomtestapp.hrh"
+#include "t_oomtestapp.mmh"
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomtestapp/group/t_oomtestapp5.mmp	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,25 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+#define T_OOM_TEST_APPDEFS_INCLUDE USERINCLUDE ../inc/appdefs5
+#include "../inc/appdefs5/t_oomtestapp.hrh"
+#include "t_oomtestapp.mmh"
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomtestapp/group/t_oomtestapp6.mmp	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,25 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+#define T_OOM_TEST_APPDEFS_INCLUDE USERINCLUDE ../inc/appdefs6
+#include "../inc/appdefs6/t_oomtestapp.hrh"
+#include "t_oomtestapp.mmh"
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomtestapp/group/t_oomtestapp7.mmp	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,25 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+#define T_OOM_TEST_APPDEFS_INCLUDE USERINCLUDE ../inc/appdefs7
+#include "../inc/appdefs7/t_oomtestapp.hrh"
+#include "t_oomtestapp.mmh"
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomtestapp/group/t_oomtestapp8.mmp	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,25 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+#define T_OOM_TEST_APPDEFS_INCLUDE USERINCLUDE ../inc/appdefs8
+#include "../inc/appdefs8/t_oomtestapp.hrh"
+#include "t_oomtestapp.mmh"
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomtestapp/group/t_oomtestapp9.mmp	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,25 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+#define T_OOM_TEST_APPDEFS_INCLUDE USERINCLUDE ../inc/appdefs9
+#include "../inc/appdefs9/t_oomtestapp.hrh"
+#include "t_oomtestapp.mmh"
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomtestapp/inc/appdefs/t_oomtestapp.hrh	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,32 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+#ifndef T_OOMTESTAPP_HRH
+#define T_OOMTESTAPP_HRH
+
+#define T_OOM_TESTAPP_NAME        t_oomtestapp
+#define T_OOM_TESTAPP_NAME_EXE    t_oomtestapp.exe
+#define T_OOM_TESTAPP_NAME_STRING "t_oomtestapp"
+#define T_OOM_TESTAPP_NAME_REG    t_oomtestapp_reg
+#define T_OOM_TESTAPP_UID         0xE6CFBA01
+
+#endif // T_OOMTESTAPP_HRH
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomtestapp/inc/appdefs10/t_oomtestapp.hrh	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,32 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+#ifndef T_OOMTESTAPP_HRH
+#define T_OOMTESTAPP_HRH
+
+#define T_OOM_TESTAPP_NAME        t_oomtestapp10
+#define T_OOM_TESTAPP_NAME_EXE    t_oomtestapp10.exe
+#define T_OOM_TESTAPP_NAME_STRING "t_oomtestapp10"
+#define T_OOM_TESTAPP_NAME_REG    t_oomtestapp10_reg
+#define T_OOM_TESTAPP_UID         0xE6CFBA0A
+
+#endif // T_OOMTESTAPP_HRH
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomtestapp/inc/appdefs2/t_oomtestapp.hrh	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,32 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+#ifndef T_OOMTESTAPP_HRH
+#define T_OOMTESTAPP_HRH
+
+#define T_OOM_TESTAPP_NAME        t_oomtestapp2
+#define T_OOM_TESTAPP_NAME_EXE    t_oomtestapp2.exe
+#define T_OOM_TESTAPP_NAME_STRING "t_oomtestapp2"
+#define T_OOM_TESTAPP_NAME_REG    t_oomtestapp2_reg
+#define T_OOM_TESTAPP_UID         0xE6CFBA02
+
+#endif // T_OOMTESTAPP_HRH
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomtestapp/inc/appdefs3/t_oomtestapp.hrh	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,32 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+#ifndef T_OOMTESTAPP_HRH
+#define T_OOMTESTAPP_HRH
+
+#define T_OOM_TESTAPP_NAME        t_oomtestapp3
+#define T_OOM_TESTAPP_NAME_EXE    t_oomtestapp3.exe
+#define T_OOM_TESTAPP_NAME_STRING "t_oomtestapp3"
+#define T_OOM_TESTAPP_NAME_REG    t_oomtestapp3_reg
+#define T_OOM_TESTAPP_UID         0xE6CFBA03
+
+#endif // T_OOMTESTAPP_HRH
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomtestapp/inc/appdefs4/t_oomtestapp.hrh	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,32 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+#ifndef T_OOMTESTAPP_HRH
+#define T_OOMTESTAPP_HRH
+
+#define T_OOM_TESTAPP_NAME        t_oomtestapp4
+#define T_OOM_TESTAPP_NAME_EXE    t_oomtestapp4.exe
+#define T_OOM_TESTAPP_NAME_STRING "t_oomtestapp4"
+#define T_OOM_TESTAPP_NAME_REG    t_oomtestapp4_reg
+#define T_OOM_TESTAPP_UID         0xE6CFBA04
+
+#endif // T_OOMTESTAPP_HRH
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomtestapp/inc/appdefs5/t_oomtestapp.hrh	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,32 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+#ifndef T_OOMTESTAPP_HRH
+#define T_OOMTESTAPP_HRH
+
+#define T_OOM_TESTAPP_NAME        t_oomtestapp5
+#define T_OOM_TESTAPP_NAME_EXE    t_oomtestapp5.exe
+#define T_OOM_TESTAPP_NAME_STRING "t_oomtestapp5"
+#define T_OOM_TESTAPP_NAME_REG    t_oomtestapp5_reg
+#define T_OOM_TESTAPP_UID         0xE6CFBA05
+
+#endif // T_OOMTESTAPP_HRH
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomtestapp/inc/appdefs6/t_oomtestapp.hrh	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,32 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+#ifndef T_OOMTESTAPP_HRH
+#define T_OOMTESTAPP_HRH
+
+#define T_OOM_TESTAPP_NAME        t_oomtestapp6
+#define T_OOM_TESTAPP_NAME_EXE    t_oomtestapp6.exe
+#define T_OOM_TESTAPP_NAME_STRING "t_oomtestapp6"
+#define T_OOM_TESTAPP_NAME_REG    t_oomtestapp6_reg
+#define T_OOM_TESTAPP_UID         0xE6CFBA06
+
+#endif // T_OOMTESTAPP_HRH
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomtestapp/inc/appdefs7/t_oomtestapp.hrh	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,32 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+#ifndef T_OOMTESTAPP_HRH
+#define T_OOMTESTAPP_HRH
+
+#define T_OOM_TESTAPP_NAME        t_oomtestapp7
+#define T_OOM_TESTAPP_NAME_EXE    t_oomtestapp7.exe
+#define T_OOM_TESTAPP_NAME_STRING "t_oomtestapp7"
+#define T_OOM_TESTAPP_NAME_REG    t_oomtestapp7_reg
+#define T_OOM_TESTAPP_UID         0xE6CFBA07
+
+#endif // T_OOMTESTAPP_HRH
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomtestapp/inc/appdefs8/t_oomtestapp.hrh	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,32 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+#ifndef T_OOMTESTAPP_HRH
+#define T_OOMTESTAPP_HRH
+
+#define T_OOM_TESTAPP_NAME        t_oomtestapp8
+#define T_OOM_TESTAPP_NAME_EXE    t_oomtestapp8.exe
+#define T_OOM_TESTAPP_NAME_STRING "t_oomtestapp8"
+#define T_OOM_TESTAPP_NAME_REG    t_oomtestapp8_reg
+#define T_OOM_TESTAPP_UID         0xE6CFBA08
+
+#endif // T_OOMTESTAPP_HRH
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomtestapp/inc/appdefs9/t_oomtestapp.hrh	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,32 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+#ifndef T_OOMTESTAPP_HRH
+#define T_OOMTESTAPP_HRH
+
+#define T_OOM_TESTAPP_NAME        t_oomtestapp9
+#define T_OOM_TESTAPP_NAME_EXE    t_oomtestapp9.exe
+#define T_OOM_TESTAPP_NAME_STRING "t_oomtestapp9"
+#define T_OOM_TESTAPP_NAME_REG    t_oomtestapp9_reg
+#define T_OOM_TESTAPP_UID         0xE6CFBA09
+
+#endif // T_OOMTESTAPP_HRH
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomtestapp/inc/t_oomtestappapplication.h	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,52 @@
+/*
+ ============================================================================
+ Name		: t_oomtestappApplication.h
+ Author	  : 
+ Copyright   : Your copyright notice
+ Description : Declares main application class.
+ ============================================================================
+ */
+
+#ifndef __T_OOMTESTAPPAPPLICATION_H__
+#define __T_OOMTESTAPPAPPLICATION_H__
+
+// INCLUDES
+#include <aknapp.h>
+
+// CLASS DECLARATION
+
+/**
+ * Ct_oomtestappApplication application class.
+ * Provides factory to create concrete document object.
+ * An instance of Ct_oomtestappApplication is the application part of the
+ * AVKON application framework for the t_oomtestapp example application.
+ */
+class Ct_oomtestappApplication : public CAknApplication
+	{
+public:
+	Ct_oomtestappApplication();
+	// Functions from base classes
+
+	/**
+	 * From CApaApplication, AppDllUid.
+	 * @return Application's UID
+	 */
+	TUid AppDllUid() const;
+
+	~Ct_oomtestappApplication();
+protected:
+	// Functions from base classes
+
+	/**
+	 * From CApaApplication, CreateDocumentL.
+	 * Creates Ct_oomtestappDocument document object. The returned
+	 * pointer in not owned by the Ct_oomtestappApplication object.
+	 * @return A pointer to the created document object.
+	 */
+	CApaDocument* CreateDocumentL();
+	
+private:
+	};
+
+#endif // __T_OOMTESTAPPAPPLICATION_H__
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomtestapp/inc/t_oomtestappappui.h	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,92 @@
+/*
+ ============================================================================
+ Name		: t_oomtestappAppUi.h
+ Author	  : 
+ Copyright   : Your copyright notice
+ Description : Declares UI class for application.
+ ============================================================================
+ */
+
+#ifndef __T_OOMTESTAPPAPPUI_h__
+#define __T_OOMTESTAPPAPPUI_h__
+
+// INCLUDES
+#include <aknappui.h>
+#include <oommonitorsession.h>
+
+// FORWARD DECLARATIONS
+class Ct_oomtestappAppView;
+
+const TInt KKiloByte = 1024;
+
+// CLASS DECLARATION
+/**
+ * Ct_oomtestappAppUi application UI class.
+ * Interacts with the user through the UI and request message processing
+ * from the handler class
+ */
+class Ct_oomtestappAppUi : public CAknAppUi
+	{
+public:
+		
+	// Constructors and destructor
+
+	/**
+	 * ConstructL.
+	 * 2nd phase constructor.
+	 */
+	void ConstructL();
+
+	/**
+	 * Ct_oomtestappAppUi.
+	 * C++ default constructor. This needs to be public due to
+	 * the way the framework constructs the AppUi
+	 */
+	Ct_oomtestappAppUi();
+
+	/**
+	 * ~Ct_oomtestappAppUi.
+	 * Virtual Destructor.
+	 */
+	virtual ~Ct_oomtestappAppUi();
+
+	TInt AllocatedHeap() const;
+
+	TPtrC Priority() const;
+
+private:
+	// Functions from base classes
+
+	/**
+	 * From CEikAppUi, HandleCommandL.
+	 * Takes care of command handling.
+	 * @param aCommand Command to be handled.
+	 */
+	void HandleCommandL(TInt aCommand);
+
+	/**
+	 *  HandleStatusPaneSizeChange.
+	 *  Called by the framework when the application status pane
+	 *  size is changed.
+	 */
+	void HandleStatusPaneSizeChange();
+
+private:
+	// Data
+
+	/**
+	 * The application view
+	 * Owned by Ct_oomtestappAppUi
+	 */
+	Ct_oomtestappAppView* iAppView;
+
+    ROomMonitorSession iOomSession;
+    
+    TAny* iMem;
+
+    ROomMonitorSession::TOomPriority iPriority;
+
+	};
+
+#endif // __T_OOMTESTAPPAPPUI_h__
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomtestapp/inc/t_oomtestappappview.h	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,81 @@
+/*
+ ============================================================================
+ Name		: t_oomtestappAppView.h
+ Author	  : 
+ Copyright   : Your copyright notice
+ Description : Declares view class for application.
+ ============================================================================
+ */
+
+#ifndef __T_OOMTESTAPPAPPVIEW_h__
+#define __T_OOMTESTAPPAPPVIEW_h__
+
+// INCLUDES
+#include <coecntrl.h>
+
+class Ct_oomtestappAppUi;
+
+// CLASS DECLARATION
+class Ct_oomtestappAppView : public CCoeControl
+	{
+public:
+	// New methods
+
+	/**
+	 * NewL.
+	 * Two-phased constructor.
+	 * Create a Ct_oomtestappAppView object, which will draw itself to aRect.
+	 * @param aRect The rectangle this view will be drawn to.
+	 * @return a pointer to the created instance of Ct_oomtestappAppView.
+	 */
+	static Ct_oomtestappAppView* NewL(const TRect& aRect, Ct_oomtestappAppUi& aAppUi);
+
+	/**
+	 * ~Ct_oomtestappAppView
+	 * Virtual Destructor.
+	 */
+	virtual ~Ct_oomtestappAppView();
+
+public:
+	// Functions from base classes
+
+	/**
+	 * From CCoeControl, Draw
+	 * Draw this Ct_oomtestappAppView to the screen.
+	 * @param aRect the rectangle of this view that needs updating
+	 */
+	void Draw(const TRect& aRect) const;
+
+	/**
+	 * From CoeControl, SizeChanged.
+	 * Called by framework when the view size is changed.
+	 */
+	virtual void SizeChanged();
+
+private:
+	// Constructors
+
+	/**
+	 * ConstructL
+	 * 2nd phase constructor.
+	 * Perform the second phase construction of a
+	 * Ct_oomtestappAppView object.
+	 * @param aRect The rectangle this view will be drawn to.
+	 */
+	void ConstructL(const TRect& aRect);
+
+	/**
+	 * Ct_oomtestappAppView.
+	 * C++ default constructor.
+	 */
+	Ct_oomtestappAppView( Ct_oomtestappAppUi& aAppUi );
+
+private:
+    Ct_oomtestappAppUi& iAppUi;
+
+    const CFont* iFont; // not own
+
+	};
+
+#endif // __T_OOMTESTAPPAPPVIEW_h__
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomtestapp/inc/t_oomtestappcmd.hrh	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,27 @@
+/*
+============================================================================
+ Name       : t_oomtestappcmd.hrh
+ Author   : 
+ Copyright   : Your copyright notice
+ Description : This file contains all the resources for the t_oomtestapp.
+============================================================================
+*/
+
+
+#ifndef T_OOMTESTAPPCMD_HRH
+#define T_OOMTESTAPPCMD_HRH
+
+enum TOomTestAppCmds
+    {
+    EOomTestAppSelectConfig = 1000,
+    EOomTestAppToggleSystem,
+    EOomTestAppAllocMemory,
+    EOomTestAppFreeMemory,
+    EOomTestAppAllocMemWithPermission,
+    EOomTestAppSetPriority,
+    EOomTestAppSetPriorityNormal,
+    EOomTestAppSetPriorityHigh,
+    EOomTestAppSetPriorityBusy
+    };
+
+#endif // T_OOMTESTAPPCMD_HRH
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomtestapp/inc/t_oomtestappdocument.h	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,91 @@
+/*
+ ============================================================================
+ Name		: t_oomtestappDocument.h
+ Author	  : 
+ Copyright   : Your copyright notice
+ Description : Declares document class for application.
+ ============================================================================
+ */
+
+#ifndef __T_OOMTESTAPPDOCUMENT_h__
+#define __T_OOMTESTAPPDOCUMENT_h__
+
+// INCLUDES
+#include <akndoc.h>
+
+// FORWARD DECLARATIONS
+class Ct_oomtestappAppUi;
+class CEikApplication;
+
+// CLASS DECLARATION
+
+/**
+ * Ct_oomtestappDocument application class.
+ * An instance of class Ct_oomtestappDocument is the Document part of the
+ * AVKON application framework for the t_oomtestapp example application.
+ */
+class Ct_oomtestappDocument : public CAknDocument
+	{
+public:
+	// Constructors and destructor
+
+	/**
+	 * NewL.
+	 * Two-phased constructor.
+	 * Construct a Ct_oomtestappDocument for the AVKON application aApp
+	 * using two phase construction, and return a pointer
+	 * to the created object.
+	 * @param aApp Application creating this document.
+	 * @return A pointer to the created instance of Ct_oomtestappDocument.
+	 */
+	static Ct_oomtestappDocument* NewL(CEikApplication& aApp);
+
+	/**
+	 * NewLC.
+	 * Two-phased constructor.
+	 * Construct a Ct_oomtestappDocument for the AVKON application aApp
+	 * using two phase construction, and return a pointer
+	 * to the created object.
+	 * @param aApp Application creating this document.
+	 * @return A pointer to the created instance of Ct_oomtestappDocument.
+	 */
+	static Ct_oomtestappDocument* NewLC(CEikApplication& aApp);
+
+	/**
+	 * ~Ct_oomtestappDocument
+	 * Virtual Destructor.
+	 */
+	virtual ~Ct_oomtestappDocument();
+
+public:
+	// Functions from base classes
+
+	/**
+	 * CreateAppUiL
+	 * From CEikDocument, CreateAppUiL.
+	 * Create a Ct_oomtestappAppUi object and return a pointer to it.
+	 * The object returned is owned by the Uikon framework.
+	 * @return Pointer to created instance of AppUi.
+	 */
+	CEikAppUi* CreateAppUiL();
+
+private:
+	// Constructors
+
+	/**
+	 * ConstructL
+	 * 2nd phase constructor.
+	 */
+	void ConstructL();
+
+	/**
+	 * Ct_oomtestappDocument.
+	 * C++ default constructor.
+	 * @param aApp Application creating this document.
+	 */
+	Ct_oomtestappDocument(CEikApplication& aApp);
+
+	};
+
+#endif // __T_OOMTESTAPPDOCUMENT_h__
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomtestapp/src/t_oomtestappapplication.cpp	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,68 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+// INCLUDE FILES
+#include <eikstart.h>
+#include "t_oomtestappDocument.h"
+#include "t_oomtestappApplication.h"
+#include "t_oomtestapp.hrh"
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+Ct_oomtestappApplication::Ct_oomtestappApplication()
+	{
+	}
+
+// -----------------------------------------------------------------------------
+// Ct_oomtestappApplication::CreateDocumentL()
+// Creates CApaDocument object
+// -----------------------------------------------------------------------------
+//
+CApaDocument* Ct_oomtestappApplication::CreateDocumentL()
+	{
+	return Ct_oomtestappDocument::NewL(*this);
+	}
+
+Ct_oomtestappApplication::~Ct_oomtestappApplication()
+	{
+	}
+
+// -----------------------------------------------------------------------------
+// Ct_oomtestappApplication::AppDllUid()
+// Returns application UID
+// -----------------------------------------------------------------------------
+//
+TUid Ct_oomtestappApplication::AppDllUid() const
+	{
+	// Return the UID for the t_oomtestapp application
+	return TUid::Uid( T_OOM_TESTAPP_UID );
+	}
+
+EXPORT_C CApaApplication* NewApplication()
+    {
+	return new Ct_oomtestappApplication;
+    }
+
+GLDEF_C TInt E32Main()
+	{
+	return EikStart::RunApplication(NewApplication);
+	}
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomtestapp/src/t_oomtestappappui.cpp	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,259 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+// INCLUDE FILES
+#include <avkon.hrh>
+#include <aknquerydialog.h>
+#include <commondialogs.hrh>
+#include <akncommondialogsdynmem.h>
+#include <t_oomtestapp.rsg>
+#include "t_oomtestappcmd.hrh"
+#include "t_oomtestappApplication.h"
+#include "t_oomtestappAppUi.h"
+#include "t_oomtestappAppView.h"
+
+_LIT( KOomConfigTargetFile, "c:\\private\\10207218\\oomconfig.xml" );
+_LIT( KOomPriorityNormal, "normal" );
+_LIT( KOomPriorityHigh, "high" );
+_LIT( KOomPriorityBusy, "busy" );
+const TInt KInitialAllocSize = 2048;
+
+// ---------------------------------------------------------------------------
+// AskPathL
+// ---------------------------------------------------------------------------
+//
+static TBool AskPathL( TDes& aPath )
+    {
+    TParsePtr parse( aPath );
+    TPtrC rootFolder = parse.DriveAndPath();
+    TBool ret = AknCommonDialogsDynMem::RunSelectDlgLD(
+        AknCommonDialogsDynMem::EMemoryTypePhone |
+        AknCommonDialogsDynMem::EMemoryTypeMMC,
+        aPath,
+        rootFolder,
+        R_MEMORY_SELECTION,
+        R_FILE_SELECTION );
+    return ret;
+    }
+
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+
+// -----------------------------------------------------------------------------
+// Ct_oomtestappAppUi::ConstructL()
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void Ct_oomtestappAppUi::ConstructL()
+	{
+	// Initialise app UI with standard value.
+	BaseConstructL(CAknAppUi::EAknEnableSkin);
+
+	User::LeaveIfError( iOomSession.Connect() );
+
+	// Create view object
+	iAppView = Ct_oomtestappAppView::NewL(ClientRect(), *this);
+	
+	}
+
+// -----------------------------------------------------------------------------
+// Ct_oomtestappAppUi::Ct_oomtestappAppUi()
+// C++ default constructor can NOT contain any code, that might leave.
+// -----------------------------------------------------------------------------
+//
+Ct_oomtestappAppUi::Ct_oomtestappAppUi()
+	{
+	}
+
+// -----------------------------------------------------------------------------
+// Ct_oomtestappAppUi::~Ct_oomtestappAppUi()
+// Destructor.
+// -----------------------------------------------------------------------------
+//
+Ct_oomtestappAppUi::~Ct_oomtestappAppUi()
+	{
+    delete iAppView;
+    iOomSession.Close();
+    User::Free(iMem);
+	}
+
+// -----------------------------------------------------------------------------
+// Ct_oomtestappAppUi::HandleCommandL()
+// Takes care of command handling.
+// -----------------------------------------------------------------------------
+//
+void Ct_oomtestappAppUi::HandleCommandL(TInt aCommand)
+	{
+	switch (aCommand)
+		{
+        case EOomTestAppSelectConfig:
+            {
+            TFileName fileName;
+            if ( AskPathL( fileName ) )
+                {
+                RFs& fs( iEikonEnv->FsSession() );
+                fs.MkDirAll( KOomConfigTargetFile ); // Ignore error
+                CFileMan* fileMan = CFileMan::NewL( fs );
+                CleanupStack::PushL( fileMan );
+                User::LeaveIfError( fileMan->Copy( fileName, KOomConfigTargetFile ) );
+                CleanupStack::PopAndDestroy( fileMan );
+                }
+            break;
+            }
+        case EOomTestAppToggleSystem:
+            {
+            iEikonEnv->SetSystem( !(iEikonEnv->IsSystem()) );
+            iAppView->DrawDeferred();
+            break;
+            }
+        case EOomTestAppAllocMemory:
+            {
+            TInt size(KInitialAllocSize);
+            CAknNumberQueryDialog* query = CAknNumberQueryDialog::NewL(size);
+            if ( query->ExecuteLD( R_ALLOC_QUERY ) )
+                {
+                User::Free(iMem);
+                iMem = NULL;
+                size *= KKiloByte;
+                iMem = User::AllocL(size);
+                iAppView->DrawDeferred();
+                }
+            break;
+            }
+        case EOomTestAppFreeMemory:
+            {
+            User::Free(iMem);
+            iMem = NULL;
+            iAppView->DrawDeferred();
+            break;
+            }
+        case EOomTestAppAllocMemWithPermission:
+            {
+            TInt size(KInitialAllocSize);
+            CAknNumberQueryDialog* query = CAknNumberQueryDialog::NewL(size);
+            if ( query->ExecuteLD( R_ALLOC_QUERY ) )
+                {
+                User::Free(iMem);
+                iMem = NULL;
+                size *= KKiloByte;
+                if ( iPriority != ROomMonitorSession::EOomPriorityBusy )
+                    {
+                    // Prevent OOM to close this app while it is freeing memory
+                    iOomSession.SetOomPriority(ROomMonitorSession::EOomPriorityBusy);
+                    }
+                iOomSession.RequestFreeMemory( size );
+                if ( iPriority != ROomMonitorSession::EOomPriorityBusy )
+                    {
+                    // Allow OOM to close this app again
+                    iOomSession.SetOomPriority(iPriority);
+                    }
+                iMem = User::AllocL(size);
+                iAppView->DrawDeferred();
+                }
+            break;
+            }
+        case EOomTestAppSetPriorityNormal:
+            {
+            iPriority = ROomMonitorSession::EOomPriorityNormal;
+            iOomSession.SetOomPriority(iPriority);
+            iAppView->DrawDeferred();
+            break;
+            }
+        case EOomTestAppSetPriorityHigh:
+            {
+            iPriority = ROomMonitorSession::EOomPriorityHigh;
+            iOomSession.SetOomPriority(iPriority);
+            iAppView->DrawDeferred();
+            break;
+            }
+        case EOomTestAppSetPriorityBusy:
+            {
+            iPriority = ROomMonitorSession::EOomPriorityBusy;
+            iOomSession.SetOomPriority(iPriority);
+            iAppView->DrawDeferred();
+            break;
+            }    
+		case EEikCmdExit:
+		case EAknSoftkeyExit: // Fall through
+		    {
+			Exit();
+			break;
+		    }
+		default:
+		    {
+			break;
+		    }
+		}
+	}
+
+// -----------------------------------------------------------------------------
+//  Called by the framework when the application status pane
+//  size is changed.  Passes the new client rectangle to the
+//  AppView
+// -----------------------------------------------------------------------------
+//
+void Ct_oomtestappAppUi::HandleStatusPaneSizeChange()
+	{
+	iAppView->SetRect(ClientRect());
+	}
+
+// -----------------------------------------------------------------------------
+// Ct_oomtestappAppUi::AllocatedHeap
+// -----------------------------------------------------------------------------
+//
+TInt Ct_oomtestappAppUi::AllocatedHeap() const
+    {
+    TInt ret( 0 );
+    RHeap& heap( User::Heap() );
+    heap.AllocSize( ret );
+    return ret;
+    }
+
+// -----------------------------------------------------------------------------
+// Ct_oomtestappAppUi::Priority
+// -----------------------------------------------------------------------------
+//
+TPtrC Ct_oomtestappAppUi::Priority() const
+    {
+    switch ( iPriority )
+        {
+        case ROomMonitorSession::EOomPriorityNormal:
+            {
+            return KOomPriorityNormal();
+            }
+        case ROomMonitorSession::EOomPriorityHigh:
+            {
+            return KOomPriorityHigh();
+            }
+        case ROomMonitorSession::EOomPriorityBusy:
+            {
+            return KOomPriorityBusy();
+            }
+        default:
+            {
+            break;
+            }
+        }
+    return KNullDesC();
+    }
+        
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomtestapp/src/t_oomtestappappview.cpp	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,134 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+// INCLUDE FILES
+#include <coemain.h>
+#include <eikenv.h>
+#include <aknutils.h>
+#include "t_oomtestappAppUi.h"
+#include "t_oomtestappAppView.h"
+
+_LIT( KTextSystemOn, "System on" );
+_LIT( KTextSystemOff, "System off" );
+const TInt KTextBufferSize = 100;
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// Ct_oomtestappAppView::NewL()
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+Ct_oomtestappAppView* Ct_oomtestappAppView::NewL(const TRect& aRect, Ct_oomtestappAppUi& aAppUi)
+	{
+	Ct_oomtestappAppView* self = new ( ELeave ) Ct_oomtestappAppView( aAppUi );
+	CleanupStack::PushL(self);
+	self->ConstructL( aRect );
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+// -----------------------------------------------------------------------------
+// Ct_oomtestappAppView::ConstructL()
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void Ct_oomtestappAppView::ConstructL(const TRect& aRect)
+	{
+	// Create a window for this application view
+	CreateWindowL();
+
+	// Set the windows size
+	SetRect(aRect);
+
+    iFont = AknLayoutUtils::FontFromId( EAknLogicalFontPrimarySmallFont );
+
+	// Activate the window, which makes it ready to be drawn
+	ActivateL();
+	}
+
+// -----------------------------------------------------------------------------
+// Ct_oomtestappAppView::Ct_oomtestappAppView()
+// C++ default constructor can NOT contain any code, that might leave.
+// -----------------------------------------------------------------------------
+//
+Ct_oomtestappAppView::Ct_oomtestappAppView( Ct_oomtestappAppUi& aAppUi ) :
+    iAppUi( aAppUi )
+	{
+	// No implementation required
+	}
+
+// -----------------------------------------------------------------------------
+// Ct_oomtestappAppView::~Ct_oomtestappAppView()
+// Destructor.
+// -----------------------------------------------------------------------------
+//
+Ct_oomtestappAppView::~Ct_oomtestappAppView()
+	{
+	// No implementation required
+	}
+
+// -----------------------------------------------------------------------------
+// Ct_oomtestappAppView::Draw()
+// Draws the display.
+// -----------------------------------------------------------------------------
+//
+void Ct_oomtestappAppView::Draw(const TRect& /*aRect*/) const
+	{
+	// Get the standard graphics context
+	CWindowGc& gc = SystemGc();
+
+	// Gets the control's extent
+	TRect drawRect(Rect());
+
+	// Clears the screen
+	gc.Clear(drawRect);
+	
+    gc.UseFont(iFont);
+    
+    TBuf<KTextBufferSize> buffer;
+    TInt allocSize( iAppUi.AllocatedHeap() / KKiloByte );
+    TPtrC priority( iAppUi.Priority() );
+	if ( CEikonEnv::Static()->IsSystem() )
+	    {
+        buffer.Format( _L("%S : Heap %d KB : Priority %S"),
+            &(KTextSystemOn()), allocSize, &priority );
+	    }
+    else
+        {
+        buffer.Format( _L("%S : Heap %d KB : Priority %S"),
+            &(KTextSystemOff()), allocSize, &priority );
+        }
+    TPoint textPos( 0, drawRect.Height() / 2 );
+    gc.DrawText( buffer, textPos );
+    gc.DiscardFont();
+	}
+
+// -----------------------------------------------------------------------------
+// Ct_oomtestappAppView::SizeChanged()
+// Called by framework when the view size is changed.
+// -----------------------------------------------------------------------------
+//
+void Ct_oomtestappAppView::SizeChanged()
+	{
+	DrawDeferred();
+	}
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomtestapp/src/t_oomtestappdocument.cpp	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,96 @@
+/*
+* 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 "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+
+// INCLUDE FILES
+#include "t_oomtestappAppUi.h"
+#include "t_oomtestappDocument.h"
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// Ct_oomtestappDocument::NewL()
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+Ct_oomtestappDocument* Ct_oomtestappDocument::NewL(CEikApplication& aApp)
+	{
+	Ct_oomtestappDocument* self = NewLC(aApp);
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+// -----------------------------------------------------------------------------
+// Ct_oomtestappDocument::NewLC()
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+Ct_oomtestappDocument* Ct_oomtestappDocument::NewLC(CEikApplication& aApp)
+	{
+	Ct_oomtestappDocument* self = new (ELeave) Ct_oomtestappDocument(aApp);
+
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	return self;
+	}
+
+// -----------------------------------------------------------------------------
+// Ct_oomtestappDocument::ConstructL()
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void Ct_oomtestappDocument::ConstructL()
+	{
+	// No implementation required
+	}
+
+// -----------------------------------------------------------------------------
+// Ct_oomtestappDocument::Ct_oomtestappDocument()
+// C++ default constructor can NOT contain any code, that might leave.
+// -----------------------------------------------------------------------------
+//
+Ct_oomtestappDocument::Ct_oomtestappDocument(CEikApplication& aApp) :
+	CAknDocument(aApp)
+	{
+	// No implementation required
+	}
+
+// ---------------------------------------------------------------------------
+// Ct_oomtestappDocument::~Ct_oomtestappDocument()
+// Destructor.
+// ---------------------------------------------------------------------------
+//
+Ct_oomtestappDocument::~Ct_oomtestappDocument()
+	{
+	// No implementation required
+	}
+
+// ---------------------------------------------------------------------------
+// Ct_oomtestappDocument::CreateAppUiL()
+// Constructs CreateAppUi.
+// ---------------------------------------------------------------------------
+//
+CEikAppUi* Ct_oomtestappDocument::CreateAppUiL()
+	{
+	// Create the application user interface, and return a pointer to it;
+	// the framework takes ownership of this object
+	return new (ELeave) Ct_oomtestappAppUi;
+	}
+
+// End of File
--- a/sysresmonitoring/oommonitor/tsrc/public/basic/BWINS/MT_OomMonitorU.DEF	Tue Jun 15 16:07:48 2010 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,2 +0,0 @@
-EXPORTS
-	?CreateTestSuiteL@@YAPAVMEUnitTest@@XZ @ 1 NONAME ; class MEUnitTest * __cdecl CreateTestSuiteL(void)
--- a/sysresmonitoring/oommonitor/tsrc/public/basic/EABI/MT_OomMonitorU.DEF	Tue Jun 15 16:07:48 2010 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,3 +0,0 @@
-EXPORTS
-	_Z16CreateTestSuiteLv @ 1 NONAME
-
--- a/sysresmonitoring/oommonitor/tsrc/public/basic/MT_OomMonitor/MT_COomMonitorPlugin.cpp	Tue Jun 15 16:07:48 2010 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,180 +0,0 @@
-/*
-* Copyright (c) 2002 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"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:
-*
-*/
-
-
-//  CLASS HEADER
-#include "MT_COomMonitorPlugin.h"
-
-//  EXTERNAL INCLUDES
-#include <EUnitMacros.h>
-#include <EUnitDecorators.h>
-#include <oommonitorplugin.h>
-#include <oommonitor.h>
-
-
-
-MT_COomMonitorPlugin* MT_COomMonitorPlugin::NewL()
-    {
-    MT_COomMonitorPlugin* self = MT_COomMonitorPlugin::NewLC();
-    CleanupStack::Pop();
-
-    return self;
-    }
-
-MT_COomMonitorPlugin* MT_COomMonitorPlugin::NewLC()
-    {
-    MT_COomMonitorPlugin* self = new( ELeave ) MT_COomMonitorPlugin();
-    CleanupStack::PushL( self );
-
-    self->ConstructL();
-
-    return self;
-    }
-
-// Destructor (virtual by CBase)
-MT_COomMonitorPlugin::~MT_COomMonitorPlugin()
-    {
-    }
-
-// Default constructor
-MT_COomMonitorPlugin::MT_COomMonitorPlugin()
-    {
-    }
-
-// Second phase construct
-void MT_COomMonitorPlugin::ConstructL()
-    {
-    // The ConstructL from the base class CEUnitTestSuiteClass must be called.
-    // It generates the test case table.
-    CEUnitTestSuiteClass::ConstructL();
-    }
-
-//  METHODS
-
-void MT_COomMonitorPlugin::BasicSetupL(  )
-    {
-    iMonitor = CMemoryMonitor::NewL();
-    }
-    
-
-void MT_COomMonitorPlugin::BasicTeardown(  )
-    {
-    delete iMonitor;
-    iMonitor = NULL; 
-    }
-    
-void MT_COomMonitorPlugin::SetupL(  )
-    {
-    BasicSetupL();
-    
-    const TUid KMyAppUid = { 0x01234567};
-    iCOomMonitorPlugin = CAppOomMonitorPlugin::NewL( KMyAppUid );
-    }
-    
-
-void MT_COomMonitorPlugin::Teardown(  )
-    {
-    BasicTeardown();
-    
-    delete iCOomMonitorPlugin; 
-    iCOomMonitorPlugin = NULL;
-    }
-    
-    
-void MT_COomMonitorPlugin::T_CAppOomMonitorPlugin_NewLL(  )
-    {
-    const TUid KMyAppUid = { 0x01234567};
-    CAppOomMonitorPlugin* plugin = CAppOomMonitorPlugin::NewL( KMyAppUid );
-    CleanupStack::PushL( plugin );
-    
-    EUNIT_ASSERT_DESC( plugin, "CAppOomMonitorPlugin instance not created!" );
-    CleanupStack::PopAndDestroy( plugin );
-    }
-    
-void MT_COomMonitorPlugin::T_COomMonitorPlugin_FreeRamL(  )
-    {
-    // private function in CAppOomMonitorPlugin, couldn't be tested
-    //iCOomMonitorPlugin->FreeRam( );
-    }
-    
-void MT_COomMonitorPlugin::T_COomMonitorPlugin_MemoryGoodL(  )
-    {
-    // private function in CAppOomMonitorPlugin, couldn't be tested
-    //iCOomMonitorPlugin->MemoryGood( );
-    }
-    
-void MT_COomMonitorPlugin::T_COomMonitorPlugin_FsSessionL(  )
-    {
-    iCOomMonitorPlugin->FsSession( );
-    }
-    
-void MT_COomMonitorPlugin::T_COomMonitorPlugin_WsSessionL(  )
-    {
-    iCOomMonitorPlugin->WsSession( );
-    }
-
-void MT_COomMonitorPlugin::T_COomMonitorPlugin_ExtensionInterfaceL(  )
-    {
-	CTestOomMonitorPlugin* plugin = new(ELeave) CTestOomMonitorPlugin;
-	CleanupStack::PushL(plugin);
-	plugin->ConstructL();
-	
-	const TUid KTestUid = { 0x01234567 };      // a nonsense UID for testing
-	TAny* any = NULL;
-	plugin->ExtensionInterface( KTestUid, any );
-	
-	CleanupStack::PopAndDestroy(plugin);
-    }
-    
-
-//  TEST TABLE
-EUNIT_BEGIN_TEST_TABLE(
-    MT_COomMonitorPlugin,
-    "COomMonitorPlugin test suite",
-    "MODULE" )
-
-EUNIT_TEST(
-    "NewL - test",
-    "COomMonitorPlugin",
-    "CAppOomMonitorPlugin NewL and COomMonitorPlugin Constructor, Destructor",
-    "FUNCTIONALITY",
-    BasicSetupL, T_CAppOomMonitorPlugin_NewLL, BasicTeardown)
-    
-EUNIT_TEST(
-    "FsSession - test",
-    "COomMonitorPlugin",
-    "FsSession",
-    "FUNCTIONALITY",
-    SetupL, T_COomMonitorPlugin_FsSessionL, Teardown)
-    
-EUNIT_TEST(
-    "WsSession - test",
-    "COomMonitorPlugin",
-    "WsSession",
-    "FUNCTIONALITY",
-    SetupL, T_COomMonitorPlugin_WsSessionL, Teardown)
-    
-EUNIT_TEST(
-    "ExtensionInterface - test",
-    "COomMonitorPlugin",
-    "ExtensionInterface",
-    "FUNCTIONALITY",
-    SetupL, T_COomMonitorPlugin_ExtensionInterfaceL, Teardown)    
-
-EUNIT_END_TEST_TABLE
-
-//  END OF FILE
--- a/sysresmonitoring/oommonitor/tsrc/public/basic/MT_OomMonitor/MT_COomMonitorPlugin.h	Tue Jun 15 16:07:48 2010 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,122 +0,0 @@
-/*
-* Copyright (c) 2002 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"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:
-*
-*/
-
-
-#ifndef __MT_COOMMONITORPLUGIN_H__
-#define __MT_COOMMONITORPLUGIN_H__
-
-//  EXTERNAL INCLUDES
-#include <CEUnitTestSuiteClass.h>
-#include <EUnitDecorators.h>
-#include <oommonitorplugin.h>
-
-//  INTERNAL INCLUDES
-
-
-//  FORWARD DECLARATIONS
-
-
-//  CLASS DEFINITION
-NONSHARABLE_CLASS( MT_COomMonitorPlugin )
-	: public CEUnitTestSuiteClass
-    {
-    public:     // Constructors and destructors
-
-        /**
-         * Two phase construction
-         */
-        static MT_COomMonitorPlugin* NewL();
-        static MT_COomMonitorPlugin* NewLC();
-        /**
-         * Destructor
-         */
-        ~MT_COomMonitorPlugin();
-
-    private:    // Constructors and destructors
-
-        MT_COomMonitorPlugin();
-        void ConstructL();
-
-    private:    // New methods
-
-
-         void SetupL();
-        
-         void Teardown();
-         
-         void BasicSetupL();
-        
-         void BasicTeardown();         
-        
-         void T_CAppOomMonitorPlugin_NewLL();
-        
-         void T_COomMonitorPlugin_FreeRamL();
-        
-         void T_COomMonitorPlugin_MemoryGoodL();
-        
-         void T_COomMonitorPlugin_FsSessionL();
-        
-         void T_COomMonitorPlugin_WsSessionL();
-         
-         void T_COomMonitorPlugin_ExtensionInterfaceL();
-        
-
-    private:    // Data
-		
-        CAppOomMonitorPlugin* iCOomMonitorPlugin;
-        CMemoryMonitor* iMonitor;
-        
-        EUNIT_DECLARE_TEST_TABLE; 
-
-    };
-   
-    
-NONSHARABLE_CLASS( CTestOomMonitorPlugin ) : public COomMonitorPlugin
-	{
-public:
-	CTestOomMonitorPlugin()
-		{
-		}
-		
-	~CTestOomMonitorPlugin()
-		{
-		}
-		
-	void ConstructL()
-		{
-		COomMonitorPlugin::ConstructL();
-		}
-		
-public:
-	void FreeRam()
-		{
-		}
-		
-	void MemoryGood()
-		{
-		}
-
-	void ExtensionInterface(TUid aInterfaceId, TAny*& aImplementaion)
-		{
-		COomMonitorPlugin::ExtensionInterface(aInterfaceId, aImplementaion);
-		}
-	};
-    
-
-#endif      //  __MT_COOMMONITORPLUGIN_H__
-
-// End of file
--- a/sysresmonitoring/oommonitor/tsrc/public/basic/MT_OomMonitor/MT_OomMonitor.cpp	Tue Jun 15 16:07:48 2010 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,167 +0,0 @@
-/*
-* Copyright (c) 2006 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"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:
-*
-*/
-
-
-//  CLASS HEADER
-#include "MT_OomMonitor.h"
-
-//  EXTERNAL INCLUDES
-#include <EUnitMacros.h>
-#include <EUnitDecorators.h>
-#include <oommonitorsession.h>
-
-//  INTERNAL INCLUDES
-
-
-// CONSTRUCTION
-MT_OomMonitor* MT_OomMonitor::NewL()
-    {
-    MT_OomMonitor* self = MT_OomMonitor::NewLC();
-    CleanupStack::Pop();
-
-    return self;
-    }
-
-MT_OomMonitor* MT_OomMonitor::NewLC()
-    {
-    MT_OomMonitor* self = new( ELeave ) MT_OomMonitor();
-    CleanupStack::PushL( self );
-
-    self->ConstructL();
-
-    return self;
-    }
-
-// Destructor (virtual by CBase)
-MT_OomMonitor::~MT_OomMonitor()
-    {
-    }
-
-// Default constructor
-MT_OomMonitor::MT_OomMonitor()
-    {
-    }
-
-// Second phase construct
-void MT_OomMonitor::ConstructL()
-    {
-    // The ConstructL from the base class CEUnitTestSuiteClass must be called.
-    // It generates the test case table.
-    CEUnitTestSuiteClass::ConstructL();
-    }
-
-//  METHODS
-
-void MT_OomMonitor::EmptySetupL(  )
-    {
-    }
-
-void MT_OomMonitor::EmptyTeardown(  )
-    {
-    }
-
-void MT_OomMonitor::SetupL(  )
-    {
-    iROomMonitorSession.Connect();
-    }
-    
-
-void MT_OomMonitor::Teardown(  )
-    {
-    iROomMonitorSession.Close(); 
-    }
-    
-
-void MT_OomMonitor::T_ROomMonitorSession_ConnectL(  )
-    {
-    EUNIT_ASSERT_DESC( iROomMonitorSession.Connect( ) == KErrNone, "Session should have been connected");
-    iROomMonitorSession.Close();
-    }
-    
-void MT_OomMonitor::T_ROomMonitorSession_RequestFreeMemoryL(  )
-    {
-    TInt rtn = iROomMonitorSession.RequestFreeMemory( 1024 );
-    EUNIT_ASSERT_DESC( rtn == KErrNone || rtn == KErrNoMemory, "OOM monitor should free 1024 bytes");
-    }
-    
-void MT_OomMonitor::T_ROomMonitorSession_RequestFreeMemory2L(  )
-    {
-    TRequestStatus status;    
-    iROomMonitorSession.RequestFreeMemory( 1024, status );
-    User::WaitForRequest( status );
-    EUNIT_ASSERT_DESC( status == KErrNone || status == KErrNoMemory, "OOM monitor should free 1024 bytes");
-    }
-    
-void MT_OomMonitor::T_ROomMonitorSession_CancelRequestFreeMemoryL(  )
-    {
-    TRequestStatus status;    
-    iROomMonitorSession.RequestFreeMemory( 1024, status );
-    iROomMonitorSession.CancelRequestFreeMemory( );
-    User::WaitForRequest( status );
-    }
-    
-void MT_OomMonitor::T_ROomMonitorSession_ThisAppIsNotExitingL(  )
-    {
-    iROomMonitorSession.ThisAppIsNotExiting( 1 );
-    }
-    
-
-//  TEST TABLE
-EUNIT_BEGIN_TEST_TABLE(
-    MT_OomMonitor,
-    "ROomMonitorSession test suite",
-    "MODULE" )
-
-EUNIT_TEST(
-    "Connect - test",
-    "ROomMonitorSession",
-    "Connect",
-    "FUNCTIONALITY",
-    EmptySetupL, T_ROomMonitorSession_ConnectL, EmptyTeardown)
-    
-EUNIT_TEST(
-    "RequestFreeMemory -synchronous test",
-    "ROomMonitorSession",
-    "RequestFreeMemory - synchronous version",
-    "FUNCTIONALITY",
-    SetupL, T_ROomMonitorSession_RequestFreeMemoryL, Teardown)
-    
-EUNIT_TEST(
-    "RequestFreeMemory - asynchronous test",
-    "ROomMonitorSession",
-    "RequestFreeMemory - asynchronous version",
-    "FUNCTIONALITY",
-    SetupL, T_ROomMonitorSession_RequestFreeMemory2L, Teardown)
-    
-EUNIT_TEST(
-    "CancelRequestFreeMemory - test",
-    "ROomMonitorSession",
-    "CancelRequestFreeMemory",
-    "FUNCTIONALITY",
-    SetupL, T_ROomMonitorSession_CancelRequestFreeMemoryL, Teardown)
-    
-EUNIT_TEST(
-    "ThisAppIsNotExiting -test",
-    "ROomMonitorSession",
-    "ThisAppIsNotExiting",
-    "FUNCTIONALITY",
-    SetupL, T_ROomMonitorSession_ThisAppIsNotExitingL, Teardown)
-    
-
-EUNIT_END_TEST_TABLE
-
-//  END OF FILE
--- a/sysresmonitoring/oommonitor/tsrc/public/basic/MT_OomMonitor/MT_OomMonitor.h	Tue Jun 15 16:07:48 2010 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,88 +0,0 @@
-/*
-* Copyright (c) 2006 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"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:
-*
-*/
-
-
-#ifndef __MT_OOMMONITOR_H__
-#define __MT_OOMMONITOR_H__
-
-//  EXTERNAL INCLUDES
-#include <CEUnitTestSuiteClass.h>
-#include <EUnitDecorators.h>
-#include <oommonitorsession.h>
-
-//  INTERNAL INCLUDES
-
-
-//  FORWARD DECLARATIONS
-
-
-//  CLASS DEFINITION
-/**
- * Auto-generated EUnit test suite
- *
- */
-NONSHARABLE_CLASS( MT_OomMonitor )
-	: public CEUnitTestSuiteClass
-    {
-    public:     // Constructors and destructors
-
-        /**
-         * Two phase construction
-         */
-        static MT_OomMonitor* NewL();
-        static MT_OomMonitor* NewLC();
-        /**
-         * Destructor
-         */
-        ~MT_OomMonitor();
-
-    private:    // Constructors and destructors
-
-        MT_OomMonitor();
-        void ConstructL();
-
-    private:    // New methods
-
-     	 void EmptySetupL();
-    
-    	 void EmptyTeardown();
-    
-         void SetupL();
-        
-         void Teardown();
-        
-         void T_ROomMonitorSession_ConnectL();
-        
-         void T_ROomMonitorSession_RequestFreeMemoryL();
-        
-         void T_ROomMonitorSession_RequestFreeMemory2L();
-        
-         void T_ROomMonitorSession_CancelRequestFreeMemoryL();
-        
-         void T_ROomMonitorSession_ThisAppIsNotExitingL();
-        
-
-    private:    // Data
-		
-        ROomMonitorSession iROomMonitorSession;
-        EUNIT_DECLARE_TEST_TABLE; 
-
-    };
-
-#endif      //  __MT_OOMMONITOR_H__
-
-// End of file
--- a/sysresmonitoring/oommonitor/tsrc/public/basic/MT_OomMonitor/MT_OomMonitor_DllMain.cpp	Tue Jun 15 16:07:48 2010 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,47 +0,0 @@
-/*
-* Copyright (c) 2006 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"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:
-*
-*/
-
-
-//  CLASS HEADER
-#include "MT_OomMonitor.h"
-#include "MT_COomMonitorPlugin.h"
-
-//  EXTERNAL INCLUDES
-#include <CEUnitTestSuite.h>
-
-EXPORT_C MEUnitTest* CreateTestSuiteL()
-    {
-    CEUnitTestSuite* rootSuite = CEUnitTestSuite::NewLC( _L("OomMonitor API tests") );
-
-    rootSuite->AddL( MT_OomMonitor::NewLC() );
-    CleanupStack::Pop();
-
-    rootSuite->AddL( MT_COomMonitorPlugin::NewLC() );
-    CleanupStack::Pop();
-
-    CleanupStack::Pop( rootSuite );
-    return rootSuite;    
-    }
-/*
-#ifndef EKA2
-GLDEF_C TInt E32Dll( TDllReason )
-	{
-	return KErrNone;
-	}
-#endif
-*/
-//  END OF FILE
--- a/sysresmonitoring/oommonitor/tsrc/public/basic/MT_OomMonitor/stub_MemoryMonitor.cpp	Tue Jun 15 16:07:48 2010 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,43 +0,0 @@
-/*
-* Copyright (c) 2009 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"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:
-*
-*/
-
-
-#include <oommonitor.h>
-#include <oommonitorplugin.h>
-
-CMemoryMonitor* CMemoryMonitor::NewL()
-	{
-    CMemoryMonitor* self = new(ELeave) CMemoryMonitor();
-    CleanupStack::PushL(self);
-    self->ConstructL();
-    CleanupStack::Pop(self);
-    return self;		
-	}
-
-CMemoryMonitor::CMemoryMonitor():iCurrentTask(iWs)
-    {
-    SetMemoryMonitorTls(this);
-    }
-
-void CMemoryMonitor::ConstructL()
-	{
-	
-	}
-
-CMemoryMonitor::~CMemoryMonitor()
-    {
-    }
--- a/sysresmonitoring/oommonitor/tsrc/public/basic/group/MT_OomMonitor.mmp	Tue Jun 15 16:07:48 2010 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,56 +0,0 @@
-/*
-* Copyright (c) 2006 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"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:
-*
-*/
-
-
-#include <platform_paths.hrh>
-
-TARGET          MT_OomMonitor.dll
-TARGETTYPE      dll
-UID             0x1000af5a 0x01700000
-
-CAPABILITY              ALL -TCB -DRM
-VENDORID                VID_DEFAULT
-
-SOURCEPATH              ../MT_OomMonitor
-SOURCE                  MT_OomMonitor.cpp
-SOURCE                  MT_COomMonitorPlugin.cpp
-SOURCE                  stub_MemoryMonitor.cpp
-
-// Sources required by the test suite
-SOURCEPATH              ../MT_OomMonitor
-SOURCE                  MT_OomMonitor_DllMain.cpp
-
-USERINCLUDE             ../MT_OomMonitor
-
-MW_LAYER_SYSTEMINCLUDE
-
-SYSTEMINCLUDE           /epoc32/include/Digia/EUnit
-
-// System include folders required by the tested code
-
-
-LIBRARY                 EUnit.lib
-LIBRARY                 EUnitUtil.lib
-LIBRARY                 euser.lib
-LIBRARY                 oommonitor.lib
-LIBRARY        			ws32.lib
-LIBRARY         		apgrfx.lib	// TApaTask
-
-
-SMPSAFE
-// End of file
-
--- a/sysresmonitoring/oommonitor/tsrc/public/basic/group/bld.inf	Tue Jun 15 16:07:48 2010 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,31 +0,0 @@
-/*
-* Copyright (c) 2004 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"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:
-*
-*/
-
-
-PRJ_PLATFORMS
-    ARMV5 GCCE WINSCW
-
-PRJ_EXPORTS
-
-PRJ_MMPFILES
-
-
-PRJ_TESTMMPFILES
-MT_OomMonitor.mmp
-
-
-// End of file
--- a/sysresmonitoring/oommonitor/tsrc/public/basic/test.xml	Tue Jun 15 16:07:48 2010 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,111 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<test>
-    <name>oommonitor Automated Tests</name>
-    <target>
-        <device rank="none" alias="DEFAULT">
-            <property name="HARNESS" value="EUNIT" />
-            <property name="TYPE" value="Ariane" />
-        </device>
-    </target>
-    <plan name="oommonitor Automated Test Plan" harness="EUNIT" enabled="true" passrate="100">
-        <session name="session" harness="EUNIT" enabled="true" passrate="100">
-            <set name="set" harness="EUNIT" enabled="true" passrate="100">
-                <target>
-                    <device rank="master" alias="DEFAULT"/>
-                </target>
-                <case name="Test Case 1" harness="EUNIT" enabled="true" passrate="100">
-                    <flash target-alias="DEFAULT" images="ATS3Drop/images/sydo_oommonitor_ats3_image.fpsx" />
-                    <flash target-alias="DEFAULT" images="ATS3Drop/images/sydo_oommonitor_ats3_image_udaerase.fpsx" />
-                    
-                    <!-- Create CTC coverage result folder -->
-                    <step name="Create CTC log dir" harness="EUNIT" enabled="true" passrate="100" significant="false">
-                        <command>makedir</command>
-                        <params>
-                            <param dir="c:\data\ctc\"/>
-                        </params>
-                    </step>
-                    
-                    
-                    <!-- Install testmodule MT_OomMonitor -->
-                    <step name="Install testmodule MT_OomMonitor DLL" harness="EUNIT" enabled="true" passrate="100" significant="false">
-                        <command>install</command>
-                        <params>
-                            <param component-path="ATS3Drop"/>
-                            <param type="binary"/>
-                            <param src="MT_OomMonitor.dll"/>
-                            <param dst="c:\sys\bin\MT_OomMonitor.dll"/>
-                        </params> 
-                    </step>
-
-                    <!-- Start CTC manager -->
-                    <step name="CTC start" harness="EUNIT" enabled="true" passrate="100" significant="false">
-                        <command>execute</command>
-                        <params>
-                            <param file="z:\sys\bin\ctcman.exe"/>
-                        </params>
-                    </step>
-
-                    <!-- Create EUnit log dir -->
-                    <step name="Create EUnit log dir" harness="EUNIT" enabled="true" passrate="100" significant="false">
-                        <command>makedir</command>
-                        <params>
-                            <param dir="c:\shared\eunit\logs\"/>
-                        </params>
-                    </step>
-
-                    <!-- Execute tests -->
-                    <step name="Execute tests" harness="EUNIT" enabled="true" passrate="100" significant="true">
-                        <command>execute</command>
-                        <params>
-                            <param parameters="/l xml MT_OomMonitor"/>
-                            <param timeout="360"/>
-                            <param result-file="c:\shared\eunit\logs\EUnit_log.xml"/>
-                            <param file="z:\sys\bin\EUNITEXERUNNER.EXE"/>
-                        </params>
-                    </step>
-                    
-                    <!-- Save CTC coverage data -->
-                    <step name="Save CTC data" harness="EUNIT" enabled="true" passrate="100" significant="false">
-                        <command>execute</command>
-                        <params>
-                            <param parameters="writefile"/>
-                            <param file="z:\sys\bin\ctcman.exe"/>
-                        </params>
-                    </step>
-                    
-                    <!-- Fetch and clean CTC data -->
-                    <step name="Fetch and clean CTC data" harness="EUNIT" enabled="true" passrate="100" significant="false">
-                        <command>fetch-log</command>
-                        <params>
-                            <param delete="true"/>
-                            <param path="c:\data\ctc\ctcdata.txt"/>
-                        </params>
-                    </step>
-                </case>
-            </set>
-        </session>
-    </plan>
-    <files>
-        <file>ATS3Drop/images/sydo_oommonitor_ats3_image.fpsx</file>
-        <file>ATS3Drop/images/sydo_oommonitor_ats3_image_udaerase.fpsx</file>
-        
-        <file>ATS3Drop/armv5_urel/MT_OomMonitor.dll</file>
-    </files>
-    
-    <postAction>
-        <type>SendEmailAction</type>
-        <params>
-            <param name="type" value="ATS3_REPORT"/>
-            <param name="to" value="ext-yang.1.lu@nokia.com"/>
-            <param name="subject" value="ATS3 report for §RUN_NAME§ §RUN_START_DATE§ §RUN_START_TIME§"/>
-            <param name="send-files" value="true"/>
-        </params>
-    </postAction>
-    
-    <postAction>
-        <type>FileStoreAction</type>
-        <params>
-            <param name="to-folder" value="\\ousrv058\data$\ATS3Reports\S60_5_0\SyDo\appexts\oommonitor\"/>
-        </params>
-    </postAction>
-</test>
--- a/systemsettings/GSAccessoryPlugin/group/bld.inf	Tue Jun 15 16:07:48 2010 +0100
+++ b/systemsettings/GSAccessoryPlugin/group/bld.inf	Thu Jul 22 16:35:22 2010 +0100
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2005-2008 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 "Eclipse Public License v1.0"
@@ -23,9 +23,9 @@
 
 PRJ_EXPORTS
 ../cenrep/AccessoriesCRKeys.h    MW_LAYER_PLATFORM_EXPORT_PATH( accessoriescrkeys.h )
-../rom/GSAccsPlugin.iby 	     CORE_MW_LAYER_IBY_EXPORT_PATH( gsaccsplugin.iby )
-../rom/GSAccsPluginResources.iby LANGUAGE_MW_LAYER_IBY_EXPORT_PATH( gsaccspluginresources.iby )
-../loc/GSAccsPlugin.loc 	     MW_LAYER_LOC_EXPORT_PATH( gsaccsplugin.loc )
+// ../rom/GSAccsPlugin.iby 	     CORE_MW_LAYER_IBY_EXPORT_PATH( gsaccsplugin.iby )
+// ../rom/GSAccsPluginResources.iby LANGUAGE_MW_LAYER_IBY_EXPORT_PATH( gsaccspluginresources.iby )
+// ../loc/GSAccsPlugin.loc 	     MW_LAYER_LOC_EXPORT_PATH( gsaccsplugin.loc )
 
 // Configurations
 ../conf/GSAccessoriesPlugin.confml            MW_LAYER_CONFML(gsaccessoriesplugin.confml)
@@ -35,7 +35,7 @@
 ../conf/GSAccessoriesPlugin_10207194.crml     MW_LAYER_CRML(gsaccessoriesplugin_10207194.crml)
 
 PRJ_MMPFILES
-GSAccessoryPlugin.mmp
+// GSAccessoryPlugin.mmp
 
 PRJ_EXTENSIONS
 START EXTENSION s60/mifconv
--- a/systemsettings/accindicatorplugin/inc/accindicator.h	Tue Jun 15 16:07:48 2010 +0100
+++ b/systemsettings/accindicatorplugin/inc/accindicator.h	Thu Jul 22 16:35:22 2010 +0100
@@ -48,8 +48,7 @@
 public:
     //from HbIndicatorPluginInterface
     QStringList indicatorTypes() const;
-    bool accessAllowed(const QString &indicatorType,
-                               const HbSecurityInfo *securityInfo) const;   
+    bool accessAllowed(const QString &indicatorType, const QVariantMap &securityInfo) const;   
     HbIndicatorInterface* createIndicator(const QString &indicatorType);
     int error() const;
 
--- a/systemsettings/accindicatorplugin/src/accindicator.cpp	Tue Jun 15 16:07:48 2010 +0100
+++ b/systemsettings/accindicatorplugin/src/accindicator.cpp	Thu Jul 22 16:35:22 2010 +0100
@@ -27,7 +27,7 @@
 
 AccIndicatorPlugin::AccIndicatorPlugin() :
 HbIndicatorInterface(IndicatorType,
-        HbIndicatorInterface::GroupPriorityLow,
+        HbIndicatorInterface::SettingCategory,
         InteractionActivated)
     {
     mIndicatorTypes << "com.nokia.accessory.indicatorplugin/1.0";
@@ -75,8 +75,7 @@
 // this plugin it always returns true.
 // ----------------------------------------------------------------------------
 
-bool AccIndicatorPlugin::accessAllowed(const QString &indicatorType,
-    const HbSecurityInfo *securityInfo) const
+bool AccIndicatorPlugin::accessAllowed(const QString &indicatorType,const QVariantMap &securityInfo) const
     {
     Q_UNUSED(indicatorType)
     Q_UNUSED(securityInfo)
@@ -129,7 +128,7 @@
             return type;
             }
         //for displaying the icon in indicator.
-        case DecorationNameRole:
+        case MonoDecorationNameRole:
             {
             QString iconName;
             if(mAccType == KPCWired || mAccType == KPCUSB)
--- a/systemsettings/group/bld.inf	Tue Jun 15 16:07:48 2010 +0100
+++ b/systemsettings/group/bld.inf	Thu Jul 22 16:35:22 2010 +0100
@@ -24,7 +24,6 @@
 PRJ_MMPFILES
 
 #include "../gssensorplugin/group/bld.inf"
-#include "../GSAccessoryPlugin/group/bld.inf"
 
 PRJ_TESTMMPFILES
 
--- a/systemsettings/gssensorplugin/group/bld.inf	Tue Jun 15 16:07:48 2010 +0100
+++ b/systemsettings/gssensorplugin/group/bld.inf	Thu Jul 22 16:35:22 2010 +0100
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2006-2008 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 "Eclipse Public License v1.0"
@@ -25,14 +25,14 @@
 ../conf/sensorplugin.confml         MW_LAYER_CONFML(sensorplugin.confml)
 ../conf/sensorplugin_10282DF0.crml  MW_LAYER_CRML(sensorplugin_10282DF0.crml)
 
-../loc/gssensorplugin.loc           MW_LAYER_LOC_EXPORT_PATH(gssensorplugin.loc)
+// ../loc/gssensorplugin.loc           MW_LAYER_LOC_EXPORT_PATH(gssensorplugin.loc)
 
 // Iby file exports
-../rom/gssensorplugin.iby           CORE_MW_LAYER_IBY_EXPORT_PATH(gssensorplugin.iby)
-../rom/gssenpluginresources.iby     LANGUAGE_MW_LAYER_IBY_EXPORT_PATH(gssenpluginresources.iby)
+// ../rom/gssensorplugin.iby           CORE_MW_LAYER_IBY_EXPORT_PATH(gssensorplugin.iby)
+// ../rom/gssenpluginresources.iby     LANGUAGE_MW_LAYER_IBY_EXPORT_PATH(gssenpluginresources.iby)
 
 PRJ_MMPFILES
-gssensorplugin.mmp
+// gssensorplugin.mmp
 
 PRJ_EXTENSIONS
 
--- a/systemsettings/gssensorplugin/src/gssenbasecontainer.cpp	Tue Jun 15 16:07:48 2010 +0100
+++ b/systemsettings/gssensorplugin/src/gssenbasecontainer.cpp	Thu Jul 22 16:35:22 2010 +0100
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2006-2008 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 "Eclipse Public License v1.0"
@@ -189,7 +189,11 @@
     // cleanup checkboxOnIcon, checkboxOffIcon, iconArray
     CleanupStack::Pop( checkboxOffIcon );
     CleanupStack::Pop( checkboxOnIcon );
-    CleanupStack::Pop( iconArray );
+	
+	if(iconArray)
+		{
+		CleanupStack::Pop( iconArray );
+		}
 
     TRACE_( "[GSSensorPlugin] CGSSenBaseContainer::AddCheckboxIconsL() - return" );
     }
--- a/systemsettings/gssensorplugin/src/gssensorplugin.cpp	Tue Jun 15 16:07:48 2010 +0100
+++ b/systemsettings/gssensorplugin/src/gssensorplugin.cpp	Thu Jul 22 16:35:22 2010 +0100
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2006 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 "Eclipse Public License v1.0"
@@ -235,8 +235,8 @@
         case EGSSenMenuExit:
             {
             CheckExitStatusL();
-            // Proceed with the command
-            aCommand = EAknCmdExit;
+			aCommand = EAknCmdExit; //"break" is removed to continue the flow to default case with the exit command
+			// coverity[MISSING_BREAK] 
             }
         default:
             iAppUi->HandleCommandL( aCommand );
--- a/tzpcside/tzcompiler/group/BLD.INF	Tue Jun 15 16:07:48 2010 +0100
+++ b/tzpcside/tzcompiler/group/BLD.INF	Thu Jul 22 16:35:22 2010 +0100
@@ -1,4 +1,4 @@
-// Copyright (c) 1999-2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 1999-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"
@@ -30,7 +30,7 @@
 ../Release/TzIdentities.ini		/epoc32/tools/tz/tzidentities.ini
 
 // TzCompiler User Documentation
-"../documentation/SGL.GT0197.232 App-Services Tz  9.1 How-To Create the Tz Database.doc"	"/epoc32/tools/tz/sgl.gt0197.232 app-services tz  9.1 how-to create the tz database.doc"
+"../doc_pub/SGL.GT0197.232 App-Services Tz  9.1 How-To Create the Tz Database.doc"	"/epoc32/tools/tz/sgl.gt0197.232 app-services tz  9.1 how-to create the tz database.doc"
 
 // Sample Olson's Tz Database Source Files
 ../Release/Data/africa			/epoc32/tools/tz/data/africa
--- a/tzpcside/tzcompiler/group/app-services_tzcompiler.mrp	Tue Jun 15 16:07:48 2010 +0100
+++ b/tzpcside/tzcompiler/group/app-services_tzcompiler.mrp	Thu Jul 22 16:35:22 2010 +0100
@@ -1,19 +1,3 @@
-#
-# Copyright (c) 2009 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"
-# which accompanies this distribution, and is available
-# at the URL "http://www.eclipse.org/legal/epl-v10.html".
-#
-# Initial Contributors:
-# Nokia Corporation - initial contribution.
-#
-# Contributors:
-#
-# Description: 
-#
-
 component	app-services_tzcompiler
 source	\sf\mw\appsupport\tzpcside\tzcompiler
 binary	\sf\mw\appsupport\tzpcside\tzcompiler\group	all
--- a/tzservices/tzdatabase/group/app-services_tzdb.mrp	Tue Jun 15 16:07:48 2010 +0100
+++ b/tzservices/tzdatabase/group/app-services_tzdb.mrp	Thu Jul 22 16:35:22 2010 +0100
@@ -1,19 +1,3 @@
-#
-# Copyright (c) 2009 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"
-# which accompanies this distribution, and is available
-# at the URL "http://www.eclipse.org/legal/epl-v10.html".
-#
-# Initial Contributors:
-# Nokia Corporation - initial contribution.
-#
-# Contributors:
-#
-# Description: 
-#
-
 component	app-services_tzdb
 source	\sf\mw\appsupport\tzservices\tzdatabase
 binary	\sf\mw\appsupport\tzservices\tzdatabase\group	all
--- a/tzservices/tzloc/group/app-services_timezonelocalization.mrp	Tue Jun 15 16:07:48 2010 +0100
+++ b/tzservices/tzloc/group/app-services_timezonelocalization.mrp	Thu Jul 22 16:35:22 2010 +0100
@@ -1,19 +1,3 @@
-#
-# Copyright (c) 2009 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"
-# which accompanies this distribution, and is available
-# at the URL "http://www.eclipse.org/legal/epl-v10.html".
-#
-# Initial Contributors:
-# Nokia Corporation - initial contribution.
-#
-# Contributors:
-#
-# Description: 
-#
-
 component	app-services_TimeZoneLocalization
 source	\sf\mw\appsupport\tzservices\tzloc
 binary	\sf\mw\appsupport\tzservices\tzloc\group	all
--- a/tzservices/tzloc/src/TzLocalizationDbAccessor.cpp	Tue Jun 15 16:07:48 2010 +0100
+++ b/tzservices/tzloc/src/TzLocalizationDbAccessor.cpp	Thu Jul 22 16:35:22 2010 +0100
@@ -1,4 +1,4 @@
-// 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 "Eclipse Public License v1.0"
@@ -99,7 +99,31 @@
 	User::LeaveIfError(iDbsSession.Connect());
 	//Attempt to open the database
 	TInt error = iLocalizedTimeZoneDb.Open(iDbsSession,KTzLocalizationDbName,KTzLocalizationDbSecurityPolicy);
+	if (error == KErrNotFound)
+		{
+		//Database file doesn't exist.  Attempt to create a new one.
+		error = iLocalizedTimeZoneDb.Create(iDbsSession,KTzLocalizationDbName,KTzLocalizationDbSecurityPolicy);
+		if (error == KErrNone)
+			{
+			User::LeaveIfError(CreateFrequentlyUsedZoneTableL());
+			User::LeaveIfError(CreateUserCityTableL());
+			}
+		}
 	User::LeaveIfError(error);
+	// Check if both tables are created.
+	CDbColSet *colSet = NULL;
+	TRAP(error, colSet = iLocalizedTimeZoneDb.ColSetL(KCZTableName));
+	delete colSet;
+	if (error)
+		{
+		User::LeaveIfError(CreateFrequentlyUsedZoneTableL());
+		}
+	TRAP(error, colSet = iLocalizedTimeZoneDb.ColSetL(KUCTableName));
+	delete colSet;
+	if (error)
+	        {
+		User::LeaveIfError(CreateUserCityTableL());
+		}
 	}
 
 /**
--- a/tzservices/tzlocrscfactory/group/app-services_tzlocalizationrscfactory.mrp	Tue Jun 15 16:07:48 2010 +0100
+++ b/tzservices/tzlocrscfactory/group/app-services_tzlocalizationrscfactory.mrp	Thu Jul 22 16:35:22 2010 +0100
@@ -1,19 +1,3 @@
-#
-# Copyright (c) 2009 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"
-# which accompanies this distribution, and is available
-# at the URL "http://www.eclipse.org/legal/epl-v10.html".
-#
-# Initial Contributors:
-# Nokia Corporation - initial contribution.
-#
-# Contributors:
-#
-# Description: 
-#
-
 component	app-services_tzlocalizationrscfactory
 source	\sf\mw\appsupport\tzservices\tzlocrscfactory
 binary	\sf\mw\appsupport\tzservices\tzlocrscfactory\group	all
--- a/tzservices/tzserver/Client/Source/timezoneuserdata.cpp	Tue Jun 15 16:07:48 2010 +0100
+++ b/tzservices/tzserver/Client/Source/timezoneuserdata.cpp	Thu Jul 22 16:35:22 2010 +0100
@@ -1,4 +1,4 @@
-// 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"
@@ -523,7 +523,6 @@
 	iTzServer.DeleteUserTimeZoneL(aTzId);
 	}
 
-
 /**
 Returns the time zone identifiers for all existing user-defined time zones.
 
@@ -533,5 +532,19 @@
 */	
 EXPORT_C void CTzUserData::GetTzIdsL(RPointerArray<CTzId>& aTzIds) const
 	{
+	CleanupStack::PushL( TCleanupItem(CleanupPointerArray, &aTzIds) );
 	iTzServer.GetUserTimeZoneIdsL(aTzIds);
+	CleanupStack::Pop();
 	}
+
+void CTzUserData::CleanupPointerArray(TAny* aArray)
+    {
+    RPointerArray<CTzId>* array = static_cast<RPointerArray<CTzId>* >(aArray);
+    if (array)
+        {
+        array->ResetAndDestroy();
+        array->Close();
+        }
+    }
+ 
+
--- a/tzservices/tzserver/Include/tzuserdefineddata.h	Tue Jun 15 16:07:48 2010 +0100
+++ b/tzservices/tzserver/Include/tzuserdefineddata.h	Thu Jul 22 16:35:22 2010 +0100
@@ -1,4 +1,4 @@
-// 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 "Eclipse Public License v1.0"
@@ -53,7 +53,8 @@
 
 private:
     CTzUserData(RTz& aTzServer);
-	
+    static void CleanupPointerArray(TAny* aArray);
+    	
 private:
     RTz& iTzServer;
 	};
--- a/tzservices/tzserver/Server/Source/timezonesession.cpp	Tue Jun 15 16:07:48 2010 +0100
+++ b/tzservices/tzserver/Server/Source/timezonesession.cpp	Thu Jul 22 16:35:22 2010 +0100
@@ -1,4 +1,4 @@
-// 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 "Eclipse Public License v1.0"
@@ -698,19 +698,23 @@
  TInt CTzServerSession::doGetUserTimeZoneNamesL(const RMessage2& aMessage)
 	{
 	TInt size = iTzUserDataCache->SizeOfNames();
-	CBufFlat* buffer = CBufFlat::NewL(size);
-	CleanupStack::PushL(buffer);
-	buffer->ExpandL(0,size);
-	
-	RBufWriteStream writeStream;
-	CleanupClosePushL(writeStream);
-	writeStream.Open(*buffer);
-	const CTzUserNames& names = iTzUserDataCache->GetNames();
-	writeStream << names;
-	writeStream.CommitL();
-	aMessage.WriteL(0, buffer->Ptr(0));
-	CleanupStack::PopAndDestroy(2, buffer);
-	return KErrNone;
+	if ( size > 0 )
+		{
+		CBufFlat* buffer = CBufFlat::NewL(size);
+		CleanupStack::PushL(buffer);
+		buffer->ExpandL(0,size);
+		
+		RBufWriteStream writeStream;
+		CleanupClosePushL(writeStream);
+		writeStream.Open(*buffer);
+		const CTzUserNames& names = iTzUserDataCache->GetNames();
+		writeStream << names;
+		writeStream.CommitL();
+		aMessage.WriteL(0, buffer->Ptr(0));
+		CleanupStack::PopAndDestroy(2, buffer);
+		return KErrNone;
+		}
+	return KErrArgument;
 	}
 	
 /**
--- a/tzservices/tzserver/group/app-services_tz.mrp	Tue Jun 15 16:07:48 2010 +0100
+++ b/tzservices/tzserver/group/app-services_tz.mrp	Thu Jul 22 16:35:22 2010 +0100
@@ -1,19 +1,3 @@
-#
-# Copyright (c) 2009 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"
-# which accompanies this distribution, and is available
-# at the URL "http://www.eclipse.org/legal/epl-v10.html".
-#
-# Initial Contributors:
-# Nokia Corporation - initial contribution.
-#
-# Contributors:
-#
-# Description: 
-#
-
 component	app-services_tz
 source	\sf\mw\appsupport\tzservices\tzserver
 binary	\sf\mw\appsupport\tzservices\tzserver\group	all
--- a/tzservices/tzserver/group/release.txt	Tue Jun 15 16:07:48 2010 +0100
+++ b/tzservices/tzserver/group/release.txt	Thu Jul 22 16:35:22 2010 +0100
@@ -300,6 +300,6 @@
 Title : First Release of Timezone Server
 
 * First release of the new Time Zone Server.
-* see ..\tz\documentation folder for how-to use the new component
+* see ..\tzserver\doc_pub folder for how-to use the new component
 ============================
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tzservices/tzserver/group/timezonetests.pkg	Thu Jul 22 16:35:22 2010 +0100
@@ -0,0 +1,41 @@
+;
+; Copyright (c) 2009 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"
+; which accompanies this distribution, and is available
+; at the URL "http://www.eclipse.org/legal/epl-v10.html".
+;
+; Initial Contributors:
+; Nokia Corporation - initial contribution.
+;
+; Contributors:
+;
+; Description:
+;
+
+;Languages
+&EN
+
+
+;Localised Vendor name
+%{"timezonetests.pkg EN"}
+
+; Vendor name
+: "timezonetests"
+
+"\epoc32\data\c\dstscripts\LocationTest.script"-"c:\Dstscripts\LocationTest.script"
+"\epoc32\data\c\dstscripts\ConversionTest.script"-"c:\Dstscripts\ConversionTest.script"
+"\epoc32\data\c\dstscripts\VCalTest.script"-"c:\Dstscripts\VCalTest.script"
+"\epoc32\data\c\dstscripts\PerformanceTest.script"-"c:\Dstscripts\PerformanceTest.script"
+"\epoc32\data\c\dstscripts\autoupdatetest.script"-"c:\Dstscripts\autoupdatetest.script"
+"\epoc32\data\c\dstscripts\utcoffsettest.script"-"c:\Dstscripts\utcoffsettest.script"
+"\epoc32\data\c\dstscripts\autoupdatenotificationtest.script"-"c:\Dstscripts\autoupdatenotificationtest.script"
+"\epoc32\data\c\dstscripts\utcalarmtest.script"-"c:\Dstscripts\utcalarmtest.script"
+"\epoc32\data\c\dstscripts\isdaylightsavingontest.script"-"c:\Dstscripts\isdaylightsavingontest.script"
+"\epoc32\data\c\dstscripts\ServerMsgSender.script"-"c:\Dstscripts\ServerMsgSender.script"
+"\epoc32\data\c\dstscripts\BackupRestore.script"-"c:\Dstscripts\BackupRestore.script"
+"\epoc32\data\c\dstscripts\TimeZoneOffsetCheck.script"-"c:\Dstscripts\TimeZoneOffsetCheck.script"
+"\epoc32\data\c\Dstscripts\unittest.script"-"c:\Dstscripts\unittest.script"
+"\epoc32\data\c\dstscripts\NextDSTChange.script"-"c:\Dstscripts\NextDSTChange.script"
+"\epoc32\data\c\dstscripts\UnknownZoneTime.script"-"c:\Dstscripts\UnknownZoneTime.script"
\ No newline at end of file