Revision: 201016
authorDremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Mon, 03 May 2010 12:32:02 +0300
changeset 15 e11368ed4880
parent 11 4df3a095718c
child 17 4f2773374eff
Revision: 201016 Kit: 201018
group/bld.inf
layers.sysdef.xml
perfmon/engine/inc/perfmon.hrh
perfmon/engine/inc/perfmon_engine.h
perfmon/engine/src/perfmon_engine.cpp
perfmon/group/bld.inf
perfmon/group/bld_generic.inf
perfmon/group/group.pro
perfmon/group/perfmon.mmp
perfmon/inc/perfmon.hrh
perfmon/inc/perfmon_app.h
perfmon/inc/perfmon_appui.h
perfmon/inc/perfmon_datapopupcontainer.h
perfmon/inc/perfmon_document.h
perfmon/inc/perfmon_drawcallback.h
perfmon/inc/perfmon_graphscontainer.h
perfmon/inc/perfmon_graphsview.h
perfmon/inc/perfmon_model.h
perfmon/inc/perfmon_settingsviewdlg.h
perfmon/inc/perfmon_std.h
perfmon/inc/perfmon_valuescontainer.h
perfmon/inc/perfmon_valuesview.h
perfmon/perfmon.pro
perfmon/rom/perfmon.iby
perfmon/rom/perfmon_datapopup.iby
perfmon/src/perfmon_app.cpp
perfmon/src/perfmon_appui.cpp
perfmon/src/perfmon_datapopupcontainer.cpp
perfmon/src/perfmon_document.cpp
perfmon/src/perfmon_graphscontainer.cpp
perfmon/src/perfmon_graphsview.cpp
perfmon/src/perfmon_model.cpp
perfmon/src/perfmon_settingsviewdlg.cpp
perfmon/src/perfmon_valuescontainer.cpp
perfmon/src/perfmon_valuesview.cpp
perfmon/ui/avkon/group/bld.inf
perfmon/ui/avkon/group/perfmon.mmp
perfmon/ui/avkon/inc/perfmon_app.h
perfmon/ui/avkon/inc/perfmon_appui.h
perfmon/ui/avkon/inc/perfmon_datapopupcontainer.h
perfmon/ui/avkon/inc/perfmon_document.h
perfmon/ui/avkon/inc/perfmon_drawcallback.h
perfmon/ui/avkon/inc/perfmon_graphscontainer.h
perfmon/ui/avkon/inc/perfmon_graphsview.h
perfmon/ui/avkon/inc/perfmon_model.h
perfmon/ui/avkon/inc/perfmon_settingsviewdlg.h
perfmon/ui/avkon/inc/perfmon_std.h
perfmon/ui/avkon/inc/perfmon_valuescontainer.h
perfmon/ui/avkon/inc/perfmon_valuesview.h
perfmon/ui/avkon/src/perfmon_app.cpp
perfmon/ui/avkon/src/perfmon_appui.cpp
perfmon/ui/avkon/src/perfmon_datapopupcontainer.cpp
perfmon/ui/avkon/src/perfmon_document.cpp
perfmon/ui/avkon/src/perfmon_graphscontainer.cpp
perfmon/ui/avkon/src/perfmon_graphsview.cpp
perfmon/ui/avkon/src/perfmon_model.cpp
perfmon/ui/avkon/src/perfmon_settingsviewdlg.cpp
perfmon/ui/avkon/src/perfmon_valuescontainer.cpp
perfmon/ui/avkon/src/perfmon_valuesview.cpp
perfmon/ui/hb/app/app.pro
perfmon/ui/hb/app/inc/application.h
perfmon/ui/hb/app/inc/datacontainer.h
perfmon/ui/hb/app/inc/datapopup.h
perfmon/ui/hb/app/inc/enginewrapper.h
perfmon/ui/hb/app/inc/graphdatacontainer.h
perfmon/ui/hb/app/inc/mainview.h
perfmon/ui/hb/app/inc/mainwindow.h
perfmon/ui/hb/app/inc/popupdatacontainer.h
perfmon/ui/hb/app/inc/settingsview.h
perfmon/ui/hb/app/inc/valuedatacontainer.h
perfmon/ui/hb/app/src/application.cpp
perfmon/ui/hb/app/src/datapopup.cpp
perfmon/ui/hb/app/src/enginewrapper.cpp
perfmon/ui/hb/app/src/graphdatacontainer.cpp
perfmon/ui/hb/app/src/main.cpp
perfmon/ui/hb/app/src/mainview.cpp
perfmon/ui/hb/app/src/mainwindow.cpp
perfmon/ui/hb/app/src/popupdatacontainer.cpp
perfmon/ui/hb/app/src/settingsview.cpp
perfmon/ui/hb/app/src/valuedatacontainer.cpp
perfmon/ui/hb/datapopup/datapopup.pro
perfmon/ui/hb/datapopup/inc/perfmondatapopupdialog_p.h
perfmon/ui/hb/datapopup/inc/perfmondatapopupplugin_p.h
perfmon/ui/hb/datapopup/inc/perfmondatapopuppluginerrors_p.h
perfmon/ui/hb/datapopup/inc/perfmondatapopupwidget_p.h
perfmon/ui/hb/datapopup/src/perfmondatapopupdialog.cpp
perfmon/ui/hb/datapopup/src/perfmondatapopupplugin.cpp
perfmon/ui/hb/datapopup/src/perfmondatapopupwidget.cpp
perfmon/ui/hb/win/enginewrapper.cpp
perfmon/ui/hb/win/enginewrapper.h
perfmon/ui/hb/win/win.pro
screengrabber/ReleaseNotes_ScreenGrabber.txt
screengrabber/data/screengrabber.rss
screengrabber/data/screengrabber_reg.rss
screengrabber/envpatcher/EnvPatcher.pl
screengrabber/envpatcher/ReadMe.txt
screengrabber/group/ReleaseNotes_ScreenGrabber.txt
screengrabber/group/backup_registration.xml
screengrabber/group/bld.inf
screengrabber/group/screengrabber.mmp
screengrabber/group/screengrabber_icons_aif.mk
screengrabber/group/screengrabber_stub_sis.mk
screengrabber/inc/SG.hrh
screengrabber/inc/SGApp.h
screengrabber/inc/SGAppUi.h
screengrabber/inc/SGDocument.h
screengrabber/inc/SGGifAnimator.h
screengrabber/inc/SGMainContainer.h
screengrabber/inc/SGMainView.h
screengrabber/inc/SGModel.h
screengrabber/inc/SGSettingListContainer.h
screengrabber/inc/SGSettingListView.h
screengrabber/inc/SGStd.h
screengrabber/inc/application.h
screengrabber/inc/enginewrapper.h
screengrabber/inc/gifanimator.h
screengrabber/inc/mainview.h
screengrabber/inc/notifications.h
screengrabber/inc/settingsview.h
screengrabber/inc/sgengine.h
screengrabber/rom/screengrabber.iby
screengrabber/screengrabber.pro
screengrabber/src/SGApp.cpp
screengrabber/src/SGAppUi.cpp
screengrabber/src/SGDocument.cpp
screengrabber/src/SGGifAnimator.cpp
screengrabber/src/SGMainContainer.cpp
screengrabber/src/SGMainView.cpp
screengrabber/src/SGModel.cpp
screengrabber/src/SGSettingListContainer.cpp
screengrabber/src/SGSettingListView.cpp
screengrabber/src/application.cpp
screengrabber/src/enginewrapper.cpp
screengrabber/src/gifanimator.cpp
screengrabber/src/main.cpp
screengrabber/src/mainview.cpp
screengrabber/src/notifications.cpp
screengrabber/src/settingsview.cpp
screengrabber/src/sgengine.cpp
sysdef_1_5_1.dtd
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/group/bld.inf	Mon May 03 12:32:02 2010 +0300
@@ -0,0 +1,30 @@
+/*
+* 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:  
+
+    bld.inf Top-level build information for rndtools
+
+-----------------------------------------------------------------------------
+*/
+
+
+#include "../creator/group/bld.inf"
+#include "../filebrowser/group/bld.inf"
+#include "../launcher/group/bld.inf"
+#include "../loadgen/group/bld.inf"
+//Orbit version added #include "../perfmon/group/bld.inf"
+//Orbit version added #include "../screengrabber/group/bld.inf"
+#include "../stifui/group/bld.inf"
+#include "../memspyui/group/bld.inf"
+#include "../htiui/group/bld.inf"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/layers.sysdef.xml	Mon May 03 12:32:02 2010 +0300
@@ -0,0 +1,20 @@
+<?xml version="1.0"?>
+<!DOCTYPE SystemDefinition SYSTEM "sysdef_1_5_1.dtd" [
+  <!ENTITY layer_real_source_path "sf/app/rndtools" >
+]>
+
+<SystemDefinition name="rndtools" schema="1.5.1">
+  <systemModel>
+    <layer name="app_layer">
+      <module name="rndtools">
+        <unit unitID="tools.rndtools" mrp="" bldFile="&layer_real_source_path;/group" name="rndtools" />
+      </module>
+      <module name="screengrabber">
+				<unit unitID="tools.screengrabberqt" mrp="" bldFile="&layer_real_source_path;/screengrabber" name="screengrabber" proFile="screengrabber.pro" />
+			</module>
+			<module name="perfmon">
+				<unit unitID="tools.perfmonqt" mrp="" bldFile="&layer_real_source_path;/perfmon" name="perfmon" proFile="perfmon.pro" />
+			</module>
+    </layer>
+  </systemModel>
+</SystemDefinition>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/perfmon/engine/inc/perfmon.hrh	Mon May 03 12:32:02 2010 +0300
@@ -0,0 +1,126 @@
+/*
+* 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:  
+*
+*/
+
+
+#ifndef PERFMON_HRH
+#define PERFMON_HRH
+
+enum TPerfMonCommandIds
+    {
+    EPerfMonCmdEnableLogging = 1,
+    EPerfMonCmdDisableLogging,
+    EPerfMonCmdSettings,
+    EPerfMonCmdAbout,
+
+    EPerfMonCmdSettingsChange,
+    EPerfMonCmdSettingsExit,
+    EPerfMonCmdSettingsBack,
+    
+    EPerfMonSettingItemList = 1000
+    };
+
+enum TPerfMonMainViewTabs
+    {
+    ETabMainViewValues = 1,
+    ETabMainViewGraphs    
+    };
+               
+enum TPerfMonSettingListTabs
+    {
+    ETabSettingsGeneral = 0,
+    ETabSettingsDataPopup,    
+    ETabSettingsGraphs,    
+    ETabSettingsLogging    
+    };
+    
+enum TPerfMonSettingListIds
+    {
+    ESettingListItemHeartBeat = 0,
+    ESettingListItemMaxSamples,
+    ESettingListItemPriority,
+    ESettingListItemCPUMode,
+    ESettingListItemKeepBackLightOn,
+
+    ESettingListItemDataPopupVisbility,
+    ESettingListItemDataPopupLocation,
+    ESettingListItemDataPopupSources,
+
+    ESettingListItemGraphsVerticalBarPeriod,
+    ESettingListItemGraphsSources,
+
+    ESettingListItemLoggingMode,
+    ESettingListItemLoggingFilePath,
+    ESettingListItemLoggingSources
+    };
+
+enum TPerfMonSettingThreadPriorityTypes
+    {
+    EThreadPriorityTypeMuchLess = 0,    
+    EThreadPriorityTypeLess,    
+    EThreadPriorityTypeNormal,    
+    EThreadPriorityTypeMore,    
+    EThreadPriorityTypeMuchMore,    
+    EThreadPriorityTypeRealTime,    
+    EThreadPriorityTypeAbsoluteVeryLow,    
+    EThreadPriorityTypeAbsoluteLow,    
+    EThreadPriorityTypeAbsoluteBackground,    
+    EThreadPriorityTypeAbsoluteForeground,    
+    EThreadPriorityTypeAbsoluteHigh
+    };
+
+enum TPerfMonSettingCPUModes
+    {
+    ECPUModeNotSet = -1,
+    ECPUModeCPUTime,
+    ECPUModeNOPs
+    };
+
+enum TPerfMonSettingDataPopupVisbilities
+    {
+    EDataPopupVisbilityAlwaysOn = 0,
+    EDataPopupVisbilityBackgroundOnly,
+    EDataPopupVisbilityAlwaysAlwaysOff
+    };
+
+enum TPerfMonSettingDataPopupLocations
+    {
+    EDataPopupLocationTopRight = 0,
+    EDataPopupLocationBottomMiddle
+    };
+        
+enum TPerfMonSettingSources
+    {
+    ESourceCPU = 0,
+    ESourceRAM,
+    ESourceC,
+    ESourceD,
+    ESourceE,
+    ESourceF,
+    ESourceG,
+    ESourceH,
+    ESourceI,
+    ESourcesLength // this should be always the last!
+    };
+    
+enum TPerfMonSettingLoggingMode
+    {
+    ELoggingModeRDebug = 0,
+    ELoggingModeLogFile,
+    ELoggingModeRDebugLogFile
+    };
+
+#endif      // PERFMON_HRH
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/perfmon/engine/inc/perfmon_engine.h	Mon May 03 12:32:02 2010 +0300
@@ -0,0 +1,224 @@
+/*
+* 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:  
+*
+*/
+
+
+#ifndef PERFMON_ENGINE_H
+#define PERFMON_ENGINE_H
+
+// INCLUDES
+#include <e32std.h>
+#include <e32base.h>
+#include <apgcli.h>
+#include <gdi.h>
+
+#include "perfmon.hrh"
+
+
+// setting keys (do not change uids of existing keys to maintain compatibility to older versions!)
+const TUid KPMSettingHeartBeat                              = { 0x00 };
+const TUid KPMSettingMaxSamples                             = { 0x01 };
+const TUid KPMSettingPriority                               = { 0x02 };
+const TUid KPMSettingCPUMode                                = { 0x03 };
+const TUid KPMSettingKeepBackLightOn                        = { 0x04 };
+
+const TUid KPMSettingDataPopupVisbility                     = { 0x05 };
+const TUid KPMSettingDataPopupLocation                      = { 0x06 };
+const TUid KPMSettingDataPopupSources                       = { 0x07 };
+
+const TUid KPMSettingGraphsVerticalBarPeriod                = { 0x08 };
+const TUid KPMSettingGraphsSources                          = { 0x09 };
+
+const TUid KPMSettingLoggingMode                            = { 0x0A };
+const TUid KPMSettingLoggingFilePath                        = { 0x0B };
+const TUid KPMSettingLoggingSources                         = { 0x0C };
+
+// FORWARD DECLARATIONS
+class CPerfMonValuesContainer;
+class CPerfMonGraphsContainer;
+class CPerfMonDataPopupContainer;
+class CEikonEnv;
+class CCoeControl;
+class CDictionaryFileStore;
+
+
+// CLASS DECLARATIONS
+
+
+class TPerfMonSources
+    {
+public:
+    TBool iSrcEnabled[ESourcesLength];
+
+public:
+    inline void SetDefaults1()
+        {
+        iSrcEnabled[ESourceCPU] = ETrue;
+        iSrcEnabled[ESourceRAM] = ETrue;
+        iSrcEnabled[ESourceC]   = ETrue;
+        iSrcEnabled[ESourceD]   = EFalse;
+        iSrcEnabled[ESourceE]   = EFalse;
+        iSrcEnabled[ESourceF]   = EFalse;
+        iSrcEnabled[ESourceG]   = EFalse;
+        iSrcEnabled[ESourceH]   = EFalse;
+        iSrcEnabled[ESourceI]   = EFalse;        
+        }
+    inline void SetDefaults2()
+        {
+        iSrcEnabled[ESourceCPU] = ETrue;
+        iSrcEnabled[ESourceRAM] = ETrue;
+        iSrcEnabled[ESourceC]   = EFalse;
+        iSrcEnabled[ESourceD]   = EFalse;
+        iSrcEnabled[ESourceE]   = EFalse;
+        iSrcEnabled[ESourceF]   = EFalse;
+        iSrcEnabled[ESourceG]   = EFalse;
+        iSrcEnabled[ESourceH]   = EFalse;
+        iSrcEnabled[ESourceI]   = EFalse;        
+        }
+    TInt EnabledSourcesCount()
+        {
+        TInt srcCount(0);
+        
+        for (TInt i=0; i<ESourcesLength; i++)
+            {
+            if (iSrcEnabled[i])
+                srcCount++;
+            }
+        
+        return srcCount;
+        }
+    };
+    
+
+class TPerfMonSettings
+    {
+public:
+    TInt                iHeartBeat;
+    TInt                iMaxSamples;
+    TInt                iPriority;
+    TInt                iCPUMode;
+    TBool               iKeepBacklightOn;
+
+    TInt                iDataPopupVisibility;
+    TInt                iDataPopupLocation;
+    TPerfMonSources     iDataPopupSources;
+
+    TInt                iGraphsVerticalBarPeriod;
+    TPerfMonSources     iGraphsSources;
+
+    TInt                iLoggingMode;
+    TFileName           iLoggingFilePath;
+    TPerfMonSources     iLoggingSources;
+    
+    TBool               iLoggingEnabled;
+    };
+
+
+class TSampleData
+	{
+public:
+    TInt64                          iFree;
+    TInt64                          iSize;
+    TTimeIntervalMicroSeconds       iTimeFromStart;
+	}; 
+
+typedef CArrayFixSeg<TSampleData> CSampleDataArray;
+
+
+class TSampleEntry
+	{
+public:
+    TBuf<16>            iDescription;
+    TBuf<16>            iUnitTypeShort; //eg. b
+    TBuf<16>            iUnitTypeLong;  //eg. bytes
+    TInt                iDriveNumber;   //used only for disk drives
+    TRgb                iGraphColor;
+    CSampleDataArray*   iSampleDataArray;
+	}; 
+	
+typedef CArrayFixSeg<TSampleEntry> CSampleEntryArray;
+
+
+
+class CPerfMonEngine : public CActive
+	{
+public:
+	~CPerfMonEngine();
+	void ActivateEngineL();
+	void DeActivateEngineL();
+    void EnableLogging(TBool aEnable);
+
+private:
+	void RunL();
+	void DoCancel();
+
+protected:
+	CPerfMonEngine();
+	void ConstructL();
+    void LoadSettingsL();
+    void SaveSettingsL();
+    void OpenLogFile(TBool aOpen);
+    void CreateSamplesDataArrayL();
+    void UpdateSamplesDataL();
+    void AppendLatestSamplesToLogsL();
+    void ActivateCPUMonitoringL();
+    TBool OpenHandleToNullThread();
+    void DeActivateCPUMonitoring();
+    TBool CPUTimeSupported();
+    TThreadPriority SettingItemToThreadPriority(TInt aIndex);
+    void LoadDFSValueL(CDictionaryFileStore* aDicFS, const TUid& aUid, TInt& aValue);
+    void LoadDFSValueL(CDictionaryFileStore* aDicFS, const TUid& aUid, TDes& aValue);
+    void LoadDFSValueL(CDictionaryFileStore* aDicFS, const TUid& aUid, TPerfMonSources& aValue);
+    void SaveDFSValueL(CDictionaryFileStore* aDicFS, const TUid& aUid, const TInt& aValue);
+    void SaveDFSValueL(CDictionaryFileStore* aDicFS, const TUid& aUid, const TDes& aValue);
+    void SaveDFSValueL(CDictionaryFileStore* aDicFS, const TUid& aUid, const TPerfMonSources& aValue);
+    
+protected:
+    virtual void SendDrawEventToContainersL() = 0;
+    virtual void HandleSettingsChangeL();
+    
+public:
+    inline TPerfMonSettings& Settings() { return iSettings; }
+    inline CEikonEnv* EikonEnv() { return iEnv; }
+    inline RApaLsSession& LsSession() { return iLs; }
+
+    inline CSampleEntryArray* SampleEntryArray() { return iSampleEntryArray; } 
+
+protected:
+    RTimer                          iTimer;
+    CEikonEnv*                      iEnv;
+    TPerfMonSettings                iSettings;
+    RApaLsSession                   iLs;
+    CSampleEntryArray*              iSampleEntryArray;
+    TTime                           iStartTime;
+
+    TInt                            iCurrentCPUMode;
+
+    RThread                         iNullThread;
+    RThread                         iCPULoadThread;
+	TBool                           iCPULoadCalibrating;
+	TInt                            iCPULoadCalibrationCounter;
+	TInt64                          iCPULoadMaxValue;
+	TInt64                          iCPULoadPreviousValue;    
+	TInt64                          iCPULoadCounter;
+    TTime                           iPreviousTime;
+    
+    TBool                           iLogFileInitialized;
+    RFile                           iLogFile;
+    };
+ 
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/perfmon/engine/src/perfmon_engine.cpp	Mon May 03 12:32:02 2010 +0300
@@ -0,0 +1,926 @@
+/*
+ * 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 FILES
+#include "perfmon_engine.h"
+#include <coeutils.h>
+#include <bautils.h>
+#include <eikenv.h>
+#include <e32hal.h>
+#include <u32std.h>
+#include <s32file.h>
+#include <akntitle.h> 
+#include <eikspane.h>
+#include <aknnotewrappers.h>  
+_LIT(KDefaultLogFilePath, "c:\\data\\PerfMon.log");
+
+const TInt KCalibrationLength = 2;
+const TInt KMinimumSamplesLength = 16;
+const TInt KCPUTimeMultiplier = 1000000; // used to avoid TReal conversions
+
+const TInt KSettingsDrive = EDriveC;
+_LIT(KSettingsFileName, "perfmon_settings.ini");
+
+// --------------------------------------------------------------------------------------------
+
+TInt CPULoadCount(TAny* aInt)
+    {
+    // increase the counter
+    (*(TUint*) aInt)++;
+    return 1;
+    }
+
+TInt CPULoadNOPThread(TAny* aParam)
+    {
+    CTrapCleanup* pC = CTrapCleanup::New();
+    CActiveScheduler* pS = new CActiveScheduler;
+    CActiveScheduler::Install(pS);
+
+    CIdle* idle = CIdle::NewL(CActive::EPriorityStandard);
+    TCallBack cb(CPULoadCount, aParam);
+    idle->Start(cb);
+
+    pS->Start();
+
+    delete idle;
+    delete pS;
+    delete pC;
+
+    return 0;
+    }
+
+// ===================================== MEMBER FUNCTIONS =====================================
+
+CPerfMonEngine::CPerfMonEngine() :
+    CActive(EPriorityUserInput)
+    {
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CPerfMonEngine::ConstructL()
+    {
+    iCurrentCPUMode = ECPUModeNotSet;
+    iLogFileInitialized = EFalse;
+
+    iEnv = CEikonEnv::Static();
+    User::LeaveIfError(iLs.Connect());
+
+    User::LeaveIfError(iTimer.CreateLocal());
+    CActiveScheduler::Add(this);
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CPerfMonEngine::ActivateEngineL()
+    {
+    // load settings
+    TRAP_IGNORE(LoadSettingsL());
+
+    // create data storages for the samples
+    CreateSamplesDataArrayL();
+
+    // set default modes
+    HandleSettingsChangeL();
+
+    // start sampling data immediately (jump to RunL)    
+    iTimer.After(iStatus, 100);
+    SetActive();
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CPerfMonEngine::DeActivateEngineL()
+    {
+    Cancel();
+
+    DeActivateCPUMonitoring();
+
+    // close log file
+    OpenLogFile(EFalse);
+    }
+
+// --------------------------------------------------------------------------------------------
+
+CPerfMonEngine::~CPerfMonEngine()
+    {
+    iTimer.Close();
+
+    // clear data storages
+    if (iSampleEntryArray)
+        {
+        for (TInt i = 0; i < iSampleEntryArray->Count(); i++)
+            {
+            delete iSampleEntryArray->At(i).iSampleDataArray;
+            }
+
+        delete iSampleEntryArray;
+        }
+
+    iLs.Close();
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CPerfMonEngine::DoCancel()
+    {
+    iTimer.Cancel();
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CPerfMonEngine::RunL()
+    {
+    // calculate new values 
+    UpdateSamplesDataL();
+
+    // log changes
+    AppendLatestSamplesToLogsL();
+
+    // redraw views
+    SendDrawEventToContainersL();
+
+    // continue
+    iTimer.After(iStatus, iSettings.iHeartBeat * 1000); // convert from milliseconds to microseconds
+    SetActive();
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CPerfMonEngine::HandleSettingsChangeL()
+    {
+    // set priority of the thread
+    RThread().SetPriority(SettingItemToThreadPriority(iSettings.iPriority));
+
+    // init cpu monitor if setting has been changed
+    if (iCurrentCPUMode != iSettings.iCPUMode)
+        {
+        DeActivateCPUMonitoring();
+        ActivateCPUMonitoringL();
+        }
+
+    // close log file
+    OpenLogFile(EFalse);
+
+    // enable log file
+    if (iSettings.iLoggingEnabled && (iSettings.iLoggingMode
+            == ELoggingModeLogFile || iSettings.iLoggingMode
+            == ELoggingModeRDebugLogFile))
+        OpenLogFile(ETrue);
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CPerfMonEngine::EnableLogging(TBool aEnable)
+    {
+    if (aEnable)
+        {
+        if (iSettings.iLoggingMode == ELoggingModeLogFile
+                || iSettings.iLoggingMode == ELoggingModeRDebugLogFile)
+            OpenLogFile(ETrue);
+
+        iSettings.iLoggingEnabled = ETrue;
+        }
+    else // disable
+        {
+        iSettings.iLoggingEnabled = EFalse;
+        OpenLogFile(EFalse);
+        }
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CPerfMonEngine::OpenLogFile(TBool aOpen)
+    {
+    // open log file for writing
+    if (aOpen)
+        {
+        if (!iLogFileInitialized)
+            {
+            TInt err(KErrNone);
+
+            // open the log file for writing
+            if (iLogFile.Open(iEnv->FsSession(), iSettings.iLoggingFilePath,
+                    EFileWrite) != KErrNone)
+                {
+                iEnv->FsSession().MkDirAll(iSettings.iLoggingFilePath);
+                err = iLogFile.Replace(iEnv->FsSession(),
+                        iSettings.iLoggingFilePath, EFileWrite);
+                }
+            else
+                {
+                // file opens correctly, seek to the end
+                TInt fileSize = 0;
+                iLogFile.Size(fileSize);
+                err = iLogFile.Seek(ESeekCurrent, fileSize);
+                }
+
+            if (err == KErrNone)
+                {
+                iLogFileInitialized = ETrue;
+                }
+            else
+                {
+                // show error
+                CAknErrorNote* note = new (ELeave) CAknErrorNote();
+                note->ExecuteLD(_L("Unable to create log file, check settings"));
+                }
+            }
+        }
+
+    // close handle to log file
+    else
+        {
+        if (iLogFileInitialized)
+            {
+            iLogFile.Flush();
+            iLogFile.Close();
+
+            iLogFileInitialized = EFalse;
+            }
+        }
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CPerfMonEngine::ActivateCPUMonitoringL()
+    {
+    // reset counter variables
+    iCPULoadCalibrating = ETrue;
+    iCPULoadCalibrationCounter = 0;
+    iCPULoadMaxValue = 999999999;
+    iCPULoadPreviousValue = 1;
+    iCPULoadCounter = 0;
+
+    // use null thread is cpu time is supported and the setting is on
+    if (CPUTimeSupported() && iSettings.iCPUMode == ECPUModeCPUTime)
+        {
+        // try to open handle to null thread
+        if (OpenHandleToNullThread())
+            {
+            // handle is open, get initial value
+            TTimeIntervalMicroSeconds time;
+            iNullThread.GetCpuTime(time);
+            iCPULoadPreviousValue = time.Int64();
+            iPreviousTime.HomeTime();
+
+            iCurrentCPUMode = ECPUModeCPUTime;
+            return; // cpu time is succesfully in use           
+            }
+        }
+
+    // otherwise use normal sampling with nops    
+    iCurrentCPUMode = ECPUModeNotSet;
+
+    // show a warning if cpu time cannot be taken in use
+    if (iSettings.iCPUMode == ECPUModeCPUTime)
+        {
+        CAknInformationNote* note = new (ELeave) CAknInformationNote();
+        note->ExecuteLD(
+                _L("CPU Time not supported in this system, using NOPs sampling"));
+        }
+
+    // create a thread for CPU load monitoring
+    User::LeaveIfError(iCPULoadThread.Create(_L("PerfMonCPULoad"),
+            CPULoadNOPThread, 0x1000, 0x1000, 0x100000, &iCPULoadCounter));
+    iCPULoadThread.SetPriority(EPriorityLess);
+    iCPULoadThread.Resume();
+
+    iCurrentCPUMode = ECPUModeNOPs; // NOPs taken succesfully in use
+    }
+
+// --------------------------------------------------------------------------------------------
+
+TBool CPerfMonEngine::OpenHandleToNullThread()
+    {
+    // find the kernel process and then the null thread
+    TFindProcess fp(_L("ekern.exe*"));
+
+    TFullName kernelName;
+    if (fp.Next(kernelName) == KErrNone)
+        {
+        // process found, append null thread identifier
+        kernelName.Append(_L("::Null"));
+
+        // find the thread
+        TFindThread ft(kernelName);
+
+        TFullName threadName;
+        if (ft.Next(threadName) == KErrNone)
+            {
+            // open instance to the thread
+            if (iNullThread.Open(threadName) != KErrNone)
+                return EFalse;
+            }
+        }
+
+    // process not found
+    else
+        return EFalse;
+
+    // success!
+    return ETrue;
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CPerfMonEngine::DeActivateCPUMonitoring()
+    {
+    if (iCurrentCPUMode == ECPUModeCPUTime)
+        {
+        iNullThread.Close();
+        }
+
+    else if (iCurrentCPUMode == ECPUModeNOPs)
+        {
+        // kill the cpu load thread
+        iCPULoadThread.Kill(0);
+        iCPULoadThread.Close();
+        }
+    }
+
+// --------------------------------------------------------------------------------------------
+
+TBool CPerfMonEngine::CPUTimeSupported()
+    {
+    TTimeIntervalMicroSeconds time;
+    TInt err = RThread().GetCpuTime(time);
+
+    if (err == KErrNone && time.Int64() > 0)
+        return ETrue;
+    else
+        return EFalse;
+    }
+
+// --------------------------------------------------------------------------------------------
+
+TThreadPriority CPerfMonEngine::SettingItemToThreadPriority(TInt aIndex)
+    {
+    TThreadPriority threadPriority = EPriorityNull;
+
+    switch (aIndex)
+        {
+        case EThreadPriorityTypeMuchLess:
+            {
+            threadPriority = EPriorityMuchLess;
+            break;
+            }
+        case EThreadPriorityTypeLess:
+            {
+            threadPriority = EPriorityLess;
+            break;
+            }
+        case EThreadPriorityTypeNormal:
+            {
+            threadPriority = EPriorityNormal;
+            break;
+            }
+        case EThreadPriorityTypeMore:
+            {
+            threadPriority = EPriorityMore;
+            break;
+            }
+        case EThreadPriorityTypeMuchMore:
+            {
+            threadPriority = EPriorityMuchMore;
+            break;
+            }
+        case EThreadPriorityTypeRealTime:
+            {
+            threadPriority = EPriorityRealTime;
+            break;
+            }
+        case EThreadPriorityTypeAbsoluteVeryLow:
+            {
+            threadPriority = EPriorityAbsoluteVeryLow;
+            break;
+            }
+        case EThreadPriorityTypeAbsoluteLow:
+            {
+            threadPriority = EPriorityAbsoluteLow;
+            break;
+            }
+        case EThreadPriorityTypeAbsoluteBackground:
+            {
+            threadPriority = EPriorityAbsoluteBackground;
+            break;
+            }
+        case EThreadPriorityTypeAbsoluteForeground:
+            {
+            threadPriority = EPriorityAbsoluteForeground;
+            break;
+            }
+        case EThreadPriorityTypeAbsoluteHigh:
+            {
+            threadPriority = EPriorityAbsoluteHigh;
+            break;
+            }
+
+        default:
+            {
+            User::Panic(_L("Wrong tp index"), 276);
+            break;
+            }
+        }
+
+    return threadPriority;
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CPerfMonEngine::CreateSamplesDataArrayL()
+    {
+    TInt
+            maxSamples =
+                    iSettings.iMaxSamples >= KMinimumSamplesLength ? iSettings.iMaxSamples
+                            : KMinimumSamplesLength;
+
+    // create the data structure to store all samples
+    iSampleEntryArray = new (ELeave) CSampleEntryArray(16);
+
+    // add all source entries
+    for (TInt i = 0; i < ESourcesLength; i++)
+        {
+        TSampleEntry newSampleEntry;
+
+        if (i == ESourceCPU)
+            {
+            newSampleEntry.iDescription.Copy(_L("CPU"));
+            newSampleEntry.iUnitTypeShort.Copy(KNullDesC);
+            newSampleEntry.iUnitTypeLong.Copy(KNullDesC);
+            newSampleEntry.iDriveNumber = -1;
+            newSampleEntry.iGraphColor = KRgbYellow;
+            }
+
+        else if (i == ESourceRAM)
+            {
+            newSampleEntry.iDescription.Copy(_L("RAM"));
+            newSampleEntry.iUnitTypeShort.Copy(_L("b"));
+            newSampleEntry.iUnitTypeLong.Copy(_L("bytes"));
+            newSampleEntry.iDriveNumber = -1;
+            newSampleEntry.iGraphColor = KRgbGreen;
+            }
+
+        else //drives
+            {
+            TChar driveLetter = 'C' + i - ESourceC; // C is the first drive
+
+            newSampleEntry.iDescription.Append(driveLetter);
+            newSampleEntry.iDescription.Append(_L(":"));
+            newSampleEntry.iUnitTypeShort.Copy(_L("b"));
+            newSampleEntry.iUnitTypeLong.Copy(_L("bytes"));
+
+            iEnv->FsSession().CharToDrive(driveLetter,
+                    newSampleEntry.iDriveNumber);
+
+            newSampleEntry.iGraphColor = KRgbCyan;
+            newSampleEntry.iGraphColor.SetGreen(255 - (i - ESourceC) * 30);
+            newSampleEntry.iGraphColor.SetRed(i * 30);
+            }
+
+        newSampleEntry.iSampleDataArray = new (ELeave) CSampleDataArray(
+                maxSamples);
+
+        iSampleEntryArray->AppendL(newSampleEntry);
+        }
+
+    // save current time as start time
+    iStartTime.HomeTime();
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CPerfMonEngine::UpdateSamplesDataL()
+    {
+    // reset inactivity timers
+    if (iSettings.iKeepBacklightOn)
+        User::ResetInactivityTime();
+
+    // get current time
+    TTime currentTime;
+    currentTime.HomeTime();
+
+    // calculate time difference
+    TTimeIntervalMicroSeconds timeDeltaFromPreviousSample =
+            currentTime.MicroSecondsFrom(iPreviousTime);
+
+    // remember current time as previous
+    iPreviousTime = currentTime;
+
+    // get CPU
+    TInt64 cpuLoadDelta(0);
+    TInt64 cpuLoadFree(0);
+    TInt64 cpuLoadSize(0);
+    TInt64 currentCPUValue(0);
+
+    if (iCurrentCPUMode == ECPUModeCPUTime || iCurrentCPUMode == ECPUModeNOPs)
+        {
+        if (iCurrentCPUMode == ECPUModeCPUTime)
+            {
+            TTimeIntervalMicroSeconds time;
+            iNullThread.GetCpuTime(time);
+            currentCPUValue = time.Int64();
+            }
+        else if (iCurrentCPUMode == ECPUModeNOPs)
+            {
+            currentCPUValue = iCPULoadCounter;
+            }
+
+        // get delta and store the previous value
+        cpuLoadDelta = currentCPUValue - iCPULoadPreviousValue;
+        iCPULoadPreviousValue = currentCPUValue;
+
+        // velocity = distance / time
+        cpuLoadFree = cpuLoadDelta * KCPUTimeMultiplier
+                / timeDeltaFromPreviousSample.Int64();
+
+        // detect maximum value
+        if (cpuLoadFree > iCPULoadMaxValue)
+            iCPULoadMaxValue = cpuLoadFree;
+
+        // check calibration status      
+        if (iCPULoadCalibrating)
+            {
+            iCPULoadCalibrationCounter++;
+            cpuLoadSize = cpuLoadFree;
+
+            // check if need to calibrate anymore
+            if (iCPULoadCalibrationCounter > KCalibrationLength)
+                {
+                iCPULoadCalibrating = EFalse;
+
+                // from the samples, get the minimum value, and let it be the max value 
+                for (TInt i = 0; i
+                        < iSampleEntryArray->At(0).iSampleDataArray->Count(); i++)
+                    {
+                    TInt64 newCPULoadMaxValue = iCPULoadMaxValue;
+
+                    if (iSampleEntryArray->At(0).iSampleDataArray->At(i).iFree
+                            < newCPULoadMaxValue)
+                        {
+                        newCPULoadMaxValue
+                                = iSampleEntryArray->At(0).iSampleDataArray->At(
+                                        i).iFree;
+                        }
+
+                    iCPULoadMaxValue = newCPULoadMaxValue;
+                    }
+
+                // adjust priority of the poller thread
+                if (iCurrentCPUMode == ECPUModeNOPs)
+                    {
+                    iCPULoadThread.SetPriority(EPriorityAbsoluteVeryLow);
+                    }
+                }
+
+            }
+        else
+            {
+            cpuLoadSize = iCPULoadMaxValue;
+            }
+        }
+
+    // save cpu sample data    
+    TSampleData cpuSample;
+    cpuSample.iFree = cpuLoadFree;
+    cpuSample.iSize = cpuLoadSize;
+    cpuSample.iTimeFromStart = currentTime.MicroSecondsFrom(iStartTime);
+
+    iSampleEntryArray->At(0).iSampleDataArray->InsertL(0, cpuSample);
+
+    // get ram memory
+    TMemoryInfoV1Buf ramMemory;
+    UserHal::MemoryInfo(ramMemory);
+
+    TSampleData memorySample;
+    memorySample.iFree = ramMemory().iFreeRamInBytes;
+    memorySample.iSize = ramMemory().iMaxFreeRamInBytes;
+    memorySample.iTimeFromStart = currentTime.MicroSecondsFrom(iStartTime);
+
+    iSampleEntryArray->At(1).iSampleDataArray->InsertL(0, memorySample);
+
+    // all drives
+    for (TInt i = 2; i < iSampleEntryArray->Count(); i++)
+        {
+        TSampleData driveSample;
+
+        // get volume info from RFs
+        TVolumeInfo volumeInfo;
+        if (iEnv->FsSession().Volume(volumeInfo,
+                iSampleEntryArray->At(i).iDriveNumber) == KErrNone)
+            {
+            driveSample.iFree = volumeInfo.iFree;
+            driveSample.iSize = volumeInfo.iSize;
+            }
+        else
+            {
+            driveSample.iFree = 0;
+            driveSample.iSize = 0;
+            }
+
+        driveSample.iTimeFromStart = currentTime.MicroSecondsFrom(iStartTime);
+
+        iSampleEntryArray->At(i).iSampleDataArray->InsertL(0, driveSample);
+        }
+
+    // compress sample data arrays to save memory
+    TInt curLength(iSampleEntryArray->At(0).iSampleDataArray->Count());
+
+    TInt
+            maxSamples =
+                    iSettings.iMaxSamples >= KMinimumSamplesLength ? iSettings.iMaxSamples
+                            : KMinimumSamplesLength;
+
+    if (curLength > maxSamples && curLength % 5 == 0)
+        {
+        for (TInt i = 0; i < iSampleEntryArray->Count(); i++)
+            {
+            iSampleEntryArray->At(i).iSampleDataArray->ResizeL(maxSamples); // looses old samples
+            iSampleEntryArray->At(i).iSampleDataArray->Compress();
+            }
+        }
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CPerfMonEngine::AppendLatestSamplesToLogsL()
+    {
+    if (iSettings.iLoggingEnabled && SampleEntryArray())
+        {
+        // loop all sources
+        for (TInt i = 0; i < SampleEntryArray()->Count(); i++)
+            {
+            // check if this setting has been enabled and it has some data
+            if (iSettings.iLoggingSources.iSrcEnabled[i]
+                    && SampleEntryArray()->At(i).iSampleDataArray->Count() > 0)
+                {
+                // get current sample
+                TSampleData& currentSample =
+                        SampleEntryArray()->At(i).iSampleDataArray->At(0);
+
+                TBuf<128> buf;
+                buf.Append(_L("PERFMON;"));
+                buf.Append(SampleEntryArray()->At(i).iDescription);
+                buf.Append(_L(";"));
+                buf.AppendNum(currentSample.iTimeFromStart.Int64());
+                buf.Append(_L(";"));
+                buf.AppendNum(currentSample.iFree);
+                buf.Append(_L(";"));
+                buf.AppendNum(currentSample.iSize);
+
+                // print to RDebug
+                if (iSettings.iLoggingMode == ELoggingModeRDebug
+                        || iSettings.iLoggingMode == ELoggingModeRDebugLogFile)
+                    {
+                    RDebug::Print(buf);
+                    }
+
+                // print to log file
+                if (iSettings.iLoggingMode == ELoggingModeLogFile
+                        || iSettings.iLoggingMode == ELoggingModeRDebugLogFile)
+                    {
+                    buf.Append(_L("\r\n"));
+
+                    TBuf8<128> buf8;
+                    buf8.Copy(buf);
+
+                    iLogFile.Write(buf8);
+                    }
+                }
+            }
+        }
+    }
+
+void CPerfMonEngine::LoadSettingsL()
+    {
+    // set defaults
+    iSettings.iHeartBeat = 600;
+    iSettings.iMaxSamples = 64;
+    iSettings.iPriority = EThreadPriorityTypeNormal;
+    iSettings.iCPUMode = ECPUModeCPUTime;
+    iSettings.iKeepBacklightOn = ETrue;
+
+    iSettings.iDataPopupVisibility = EDataPopupVisbilityAlwaysOn;
+    // TODO: remove the next line once data popup is working
+    iSettings.iDataPopupVisibility = EDataPopupVisbilityAlwaysAlwaysOff;
+    iSettings.iDataPopupLocation = EDataPopupLocationTopRight;
+    iSettings.iDataPopupSources.SetDefaults1();
+
+    iSettings.iGraphsVerticalBarPeriod = 5;
+    iSettings.iGraphsSources.SetDefaults2();
+
+    iSettings.iLoggingMode = ELoggingModeRDebug;
+    iSettings.iLoggingFilePath.Copy(KDefaultLogFilePath);
+    iSettings.iLoggingSources.SetDefaults2();
+
+    iSettings.iLoggingEnabled = EFalse;
+
+    // make sure that the private path of this app in c-drive exists
+    iEnv->FsSession().CreatePrivatePath(KSettingsDrive); // c:\\private\\20011385\\
+    
+    // handle settings always in the private directory 
+    if (iEnv->FsSession().SetSessionToPrivate(KSettingsDrive) == KErrNone)
+        {
+        const TUid KUidPerfMon =
+            {
+            0x20011385
+            };
+        // open or create a dictionary file store
+        CDictionaryFileStore* settingsStore = CDictionaryFileStore::OpenLC(
+                iEnv->FsSession(), KSettingsFileName, KUidPerfMon);
+
+        LoadDFSValueL(settingsStore, KPMSettingHeartBeat, iSettings.iHeartBeat);
+        LoadDFSValueL(settingsStore, KPMSettingMaxSamples,
+                iSettings.iMaxSamples);
+        LoadDFSValueL(settingsStore, KPMSettingPriority, iSettings.iPriority);
+        
+        // TODO: enable next line when NOPs will be working
+        //LoadDFSValueL(settingsStore, KPMSettingCPUMode, iSettings.iCPUMode);
+        
+        LoadDFSValueL(settingsStore, KPMSettingKeepBackLightOn,
+                iSettings.iKeepBacklightOn);
+
+        LoadDFSValueL(settingsStore, KPMSettingDataPopupVisbility,
+                iSettings.iDataPopupVisibility);
+        LoadDFSValueL(settingsStore, KPMSettingDataPopupLocation,
+                iSettings.iDataPopupLocation);
+        LoadDFSValueL(settingsStore, KPMSettingDataPopupSources,
+                iSettings.iDataPopupSources);
+
+        LoadDFSValueL(settingsStore, KPMSettingGraphsVerticalBarPeriod,
+                iSettings.iGraphsVerticalBarPeriod);
+        LoadDFSValueL(settingsStore, KPMSettingGraphsSources,
+                iSettings.iGraphsSources);
+
+        LoadDFSValueL(settingsStore, KPMSettingLoggingMode,
+                iSettings.iLoggingMode);
+        LoadDFSValueL(settingsStore, KPMSettingLoggingFilePath,
+                iSettings.iLoggingFilePath);
+        LoadDFSValueL(settingsStore, KPMSettingLoggingSources,
+                iSettings.iLoggingSources);
+
+        CleanupStack::PopAndDestroy(); // settingsStore         
+        }
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CPerfMonEngine::SaveSettingsL()
+    {
+    // handle settings always in c:\\private\\20011385\\
+    if (iEnv->FsSession().SetSessionToPrivate( KSettingsDrive ) == KErrNone)
+        {
+        // delete existing store to make sure that it is clean and not eg corrupted
+        if (BaflUtils::FileExists(iEnv->FsSession(), KSettingsFileName))
+            {
+            iEnv->FsSession().Delete(KSettingsFileName);
+            }
+
+        const TUid KUidPerfMon =
+            {
+            0x20011385
+            };
+        // create a dictionary file store
+        CDictionaryFileStore* settingsStore = CDictionaryFileStore::OpenLC(
+                iEnv->FsSession(), KSettingsFileName, KUidPerfMon);
+
+        SaveDFSValueL(settingsStore, KPMSettingHeartBeat, iSettings.iHeartBeat);
+        SaveDFSValueL(settingsStore, KPMSettingMaxSamples,
+                iSettings.iMaxSamples);
+        SaveDFSValueL(settingsStore, KPMSettingPriority, iSettings.iPriority);
+        SaveDFSValueL(settingsStore, KPMSettingCPUMode, iSettings.iCPUMode);
+        SaveDFSValueL(settingsStore, KPMSettingKeepBackLightOn,
+                iSettings.iKeepBacklightOn);
+
+        SaveDFSValueL(settingsStore, KPMSettingDataPopupVisbility,
+                iSettings.iDataPopupVisibility);
+        SaveDFSValueL(settingsStore, KPMSettingDataPopupLocation,
+                iSettings.iDataPopupLocation);
+        SaveDFSValueL(settingsStore, KPMSettingDataPopupSources,
+                iSettings.iDataPopupSources);
+
+        SaveDFSValueL(settingsStore, KPMSettingGraphsVerticalBarPeriod,
+                iSettings.iGraphsVerticalBarPeriod);
+        SaveDFSValueL(settingsStore, KPMSettingGraphsSources,
+                iSettings.iGraphsSources);
+
+        SaveDFSValueL(settingsStore, KPMSettingLoggingMode,
+                iSettings.iLoggingMode);
+        SaveDFSValueL(settingsStore, KPMSettingLoggingFilePath,
+                iSettings.iLoggingFilePath);
+        SaveDFSValueL(settingsStore, KPMSettingLoggingSources,
+                iSettings.iLoggingSources);
+
+        settingsStore->CommitL();
+        CleanupStack::PopAndDestroy(); // settingsStore             
+        }
+    }
+
+// ---------------------------------------------------------------------------
+
+void CPerfMonEngine::LoadDFSValueL(CDictionaryFileStore* aDicFS,
+        const TUid& aUid, TInt& aValue)
+    {
+    if (aDicFS->IsPresentL(aUid))
+        {
+        RDictionaryReadStream in;
+        in.OpenLC(*aDicFS, aUid);
+        aValue = in.ReadInt16L();
+        CleanupStack::PopAndDestroy(); // in        
+        }
+    }
+
+// ---------------------------------------------------------------------------
+
+void CPerfMonEngine::LoadDFSValueL(CDictionaryFileStore* aDicFS,
+        const TUid& aUid, TDes& aValue)
+    {
+    if (aDicFS->IsPresentL(aUid))
+        {
+        RDictionaryReadStream in;
+        in.OpenLC(*aDicFS, aUid);
+        TInt bufLength = in.ReadInt16L(); // get length of descriptor
+        in.ReadL(aValue, bufLength); // get the descriptor itself
+        CleanupStack::PopAndDestroy(); // in
+        }
+    }
+
+// ---------------------------------------------------------------------------
+
+void CPerfMonEngine::LoadDFSValueL(CDictionaryFileStore* aDicFS,
+        const TUid& aUid, TPerfMonSources& aValue)
+    {
+    if (aDicFS->IsPresentL(aUid))
+        {
+        RDictionaryReadStream in;
+        in.OpenLC(*aDicFS, aUid);
+        TInt bufLength = in.ReadInt16L(); // get length of the array
+
+        if (bufLength < 0 || bufLength > ESourcesLength) // check for validaty
+            User::Leave(KErrNotSupported);
+
+        for (TInt i = 0; i < bufLength; i++) // get all items
+            aValue.iSrcEnabled[i] = in.ReadInt16L();
+
+        CleanupStack::PopAndDestroy(); // in
+        }
+    }
+
+// ---------------------------------------------------------------------------
+
+void CPerfMonEngine::SaveDFSValueL(CDictionaryFileStore* aDicFS,
+        const TUid& aUid, const TInt& aValue)
+    {
+    RDictionaryWriteStream out;
+    out.AssignLC(*aDicFS, aUid);
+    out.WriteInt16L(aValue);
+    out.CommitL();
+    CleanupStack::PopAndDestroy(); // out
+    }
+
+// ---------------------------------------------------------------------------
+
+void CPerfMonEngine::SaveDFSValueL(CDictionaryFileStore* aDicFS,
+        const TUid& aUid, const TDes& aValue)
+    {
+    RDictionaryWriteStream out;
+    out.AssignLC(*aDicFS, aUid);
+    out.WriteInt16L(aValue.Length()); // write length of the descriptor
+    out.WriteL(aValue, aValue.Length()); // write the descriptor itself
+    out.CommitL();
+    CleanupStack::PopAndDestroy(); // out
+    }
+
+// ---------------------------------------------------------------------------
+
+void CPerfMonEngine::SaveDFSValueL(CDictionaryFileStore* aDicFS,
+        const TUid& aUid, const TPerfMonSources& aValue)
+    {
+    RDictionaryWriteStream out;
+    out.AssignLC(*aDicFS, aUid);
+
+    out.WriteInt16L(ESourcesLength); // write length of the array
+
+    for (TInt i = 0; i < ESourcesLength; i++) // write all items
+        out.WriteInt16L(aValue.iSrcEnabled[i]);
+
+    out.CommitL();
+    CleanupStack::PopAndDestroy(); // out
+    }
+
+// ---------------------------------------------------------------------------
+
+// End of File
--- a/perfmon/group/bld.inf	Fri Apr 16 14:59:17 2010 +0300
+++ b/perfmon/group/bld.inf	Mon May 03 12:32:02 2010 +0300
@@ -15,38 +15,16 @@
 *
 */
 
-
 #include <platform_paths.hrh>
 
-PRJ_EXPORTS
-../group/backup_registration.xml    Z:/private/20011385/backup_registration.xml
-../rom/perfmon.iby CORE_IBY_EXPORT_PATH(tools,perfmon.iby)
-
+prj_platforms
 
-PRJ_MMPFILES
-#if defined(__SERIES60_30__) || defined(__SERIES60_31__) || defined(__S60_32__)
-  gnumakefile perfmon_icons_aif.mk
+WINSCW GCCE ARMV5 ARMV6
 
-  #ifdef MARM
-  gnumakefile perfmon_stub_sis.mk
-  #endif
-#endif
-
-perfmon.mmp
+#include "bld_generic.inf"
 
+#include "../ui/avkon/group/bld.inf"
 
-#if(!defined __SERIES60_30__ && !defined __SERIES60_31__ && !defined __S60_32__)
-  PRJ_EXTENSIONS
-  START EXTENSION s60/mifconv
-  OPTION TARGETFILE perfmon_aif.mif
-  OPTION SOURCEDIR ../icons
-  OPTION SOURCES -c8,8 qgn_menu_perfmon
-  END
+prj_mmpfiles
 
-  #ifdef MARM
-  START EXTENSION app-services/buildstubsis
-  OPTION SRCDIR ../sis
-  OPTION SISNAME PerfMon_stub
-  END
-  #endif  
-#endif
+prj_extensions
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/perfmon/group/bld_generic.inf	Mon May 03 12:32:02 2010 +0300
@@ -0,0 +1,47 @@
+/*
+* 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 <platform_paths.hrh>
+
+PRJ_EXPORTS
+../group/backup_registration.xml    Z:/private/20011385/backup_registration.xml
+../rom/perfmon.iby CORE_IBY_EXPORT_PATH(tools,perfmon.iby)
+
+PRJ_MMPFILES
+#if defined(__SERIES60_30__) || defined(__SERIES60_31__) || defined(__S60_32__)
+  gnumakefile perfmon_icons_aif.mk
+
+  #ifdef MARM
+  gnumakefile perfmon_stub_sis.mk
+  #endif
+#endif
+
+#if(!defined __SERIES60_30__ && !defined __SERIES60_31__ && !defined __S60_32__)
+  PRJ_EXTENSIONS
+  START EXTENSION s60/mifconv
+  OPTION TARGETFILE perfmon_aif.mif
+  OPTION SOURCEDIR ../icons
+  OPTION SOURCES -c8,8 qgn_menu_perfmon
+  END
+
+  #ifdef MARM
+  START EXTENSION app-services/buildstubsis
+  OPTION SRCDIR ../sis
+  OPTION SISNAME PerfMon_stub
+  END
+  #endif  
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/perfmon/group/group.pro	Mon May 03 12:32:02 2010 +0300
@@ -0,0 +1,21 @@
+#
+# 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 = subdirs
+
+BLD_INF_RULES.prj_platforms += "$${LITERAL_HASH}include \"bld_generic.inf\""
+BLD_INF_RULES.prj_exports += "../rom/perfmon_datapopup.iby CORE_IBY_EXPORT_PATH(tools,perfmon_datapopup.iby)"
\ No newline at end of file
--- a/perfmon/group/perfmon.mmp	Fri Apr 16 14:59:17 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,79 +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 <data_caging_paths.hrh>
-#include <platform_paths.hrh>
-
-
-TARGET            PerfMon.exe
-TARGETTYPE        exe
-EPOCSTACKSIZE     0x5000
-EPOCHEAPSIZE      0x10000 0x1000000  // Min 64Kb, Max 16Mb
-
-UID               0x100039CE 0x20011385
-
-VENDORID          VID_DEFAULT
-CAPABILITY        WriteDeviceData
-
-SMPSAFE
-
-LANG              SC
-
-
-START RESOURCE    ../data/perfmon.rss
-HEADER
-TARGETPATH        APP_RESOURCE_DIR
-END
-
-START RESOURCE    ../data/perfmon_reg.rss
-DEPENDS           perfmon.rsg
-TARGETPATH        /private/10003a3f/apps
-END
-
-APP_LAYER_SYSTEMINCLUDE
-USERINCLUDE       ../inc
-SOURCEPATH        ../src
-
-
-SOURCE            perfmon_app.cpp
-SOURCE            perfmon_document.cpp 
-SOURCE            perfmon_appui.cpp
-SOURCE            perfmon_model.cpp
-SOURCE            perfmon_valuesview.cpp 
-SOURCE            perfmon_valuescontainer.cpp 
-SOURCE            perfmon_graphsview.cpp 
-SOURCE            perfmon_graphscontainer.cpp 
-SOURCE            perfmon_settingsviewdlg.cpp
-SOURCE            perfmon_datapopupcontainer.cpp 
-
-LIBRARY           euser.lib
-LIBRARY           commonengine.lib
-LIBRARY           apparc.lib
-LIBRARY           cone.lib 
-LIBRARY           eikcore.lib
-LIBRARY           eikcoctl.lib
-LIBRARY           eikdlg.lib  
-LIBRARY           avkon.lib 
-LIBRARY           ws32.lib 
-LIBRARY           apgrfx.lib
-LIBRARY           efsrv.lib
-LIBRARY           bafl.lib
-LIBRARY           gdi.lib
-LIBRARY           estor.lib
-
-// End of File
--- a/perfmon/inc/perfmon.hrh	Fri Apr 16 14:59:17 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,126 +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:  
-*
-*/
-
-
-#ifndef PERFMON_HRH
-#define PERFMON_HRH
-
-enum TPerfMonCommandIds
-    {
-    EPerfMonCmdEnableLogging = 1,
-    EPerfMonCmdDisableLogging,
-    EPerfMonCmdSettings,
-    EPerfMonCmdAbout,
-
-    EPerfMonCmdSettingsChange,
-    EPerfMonCmdSettingsExit,
-    EPerfMonCmdSettingsBack,
-    
-    EPerfMonSettingItemList = 1000
-    };
-
-enum TPerfMonMainViewTabs
-    {
-    ETabMainViewValues = 1,
-    ETabMainViewGraphs    
-    };
-               
-enum TPerfMonSettingListTabs
-    {
-    ETabSettingsGeneral = 0,
-    ETabSettingsDataPopup,    
-    ETabSettingsGraphs,    
-    ETabSettingsLogging    
-    };
-    
-enum TPerfMonSettingListIds
-    {
-    ESettingListItemHeartBeat = 0,
-    ESettingListItemMaxSamples,
-    ESettingListItemPriority,
-    ESettingListItemCPUMode,
-    ESettingListItemKeepBackLightOn,
-
-    ESettingListItemDataPopupVisbility,
-    ESettingListItemDataPopupLocation,
-    ESettingListItemDataPopupSources,
-
-    ESettingListItemGraphsVerticalBarPeriod,
-    ESettingListItemGraphsSources,
-
-    ESettingListItemLoggingMode,
-    ESettingListItemLoggingFilePath,
-    ESettingListItemLoggingSources
-    };
-
-enum TPerfMonSettingThreadPriorityTypes
-    {
-    EThreadPriorityTypeMuchLess = 0,    
-    EThreadPriorityTypeLess,    
-    EThreadPriorityTypeNormal,    
-    EThreadPriorityTypeMore,    
-    EThreadPriorityTypeMuchMore,    
-    EThreadPriorityTypeRealTime,    
-    EThreadPriorityTypeAbsoluteVeryLow,    
-    EThreadPriorityTypeAbsoluteLow,    
-    EThreadPriorityTypeAbsoluteBackground,    
-    EThreadPriorityTypeAbsoluteForeground,    
-    EThreadPriorityTypeAbsoluteHigh
-    };
-
-enum TPerfMonSettingCPUModes
-    {
-    ECPUModeNotSet = -1,
-    ECPUModeCPUTime,
-    ECPUModeNOPs
-    };
-
-enum TPerfMonSettingDataPopupVisbilities
-    {
-    EDataPopupVisbilityAlwaysOn = 0,
-    EDataPopupVisbilityBackgroundOnly,
-    EDataPopupVisbilityAlwaysAlwaysOff
-    };
-
-enum TPerfMonSettingDataPopupLocations
-    {
-    EDataPopupLocationTopRight = 0,
-    EDataPopupLocationBottomMiddle
-    };
-        
-enum TPerfMonSettingSources
-    {
-    ESourceCPU = 0,
-    ESourceRAM,
-    ESourceC,
-    ESourceD,
-    ESourceE,
-    ESourceF,
-    ESourceG,
-    ESourceH,
-    ESourceI,
-    ESourcesLength // this should be always the last!
-    };
-    
-enum TPerfMonSettingLoggingMode
-    {
-    ELoggingModeRDebug = 0,
-    ELoggingModeLogFile,
-    ELoggingModeRDebugLogFile
-    };
-
-#endif      // PERFMON_HRH
--- a/perfmon/inc/perfmon_app.h	Fri Apr 16 14:59:17 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,64 +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:  
-*
-*/
-
-
-#ifndef PERFMON_APP_H
-#define PERFMON_APP_H
-
-
-// INCLUDES
-#include <aknapp.h>
-
-// CONSTANTS
-// UID of the application
-const TUid KUidPerfMon = { 0x20011385 };
-
-// CLASS DECLARATION
-
-/**
-* CPerfMonApp application class.
-* Provides factory to create concrete document object.
-* 
-*/
-class CPerfMonApp : public CAknApplication
-    {
-    
-    public: // Functions from base classes
-        /**
-        * From CApaApplication, overridden to enable INI file support.
-        * @return A pointer to the dictionary store
-        */
-    CDictionaryStore* OpenIniFileLC(RFs& aFs) const;
-    private:
-
-        /**
-        * From CApaApplication, creates CPerfMonDocument document object.
-        * @return A pointer to the created document object.
-        */
-        CApaDocument* CreateDocumentL();
-        
-        /**
-        * From CApaApplication, returns application's UID (KUidPerfMon).
-        * @return The value of KUidPerfMon.
-        */
-        TUid AppDllUid() const;
-    };
-
-#endif
-
-// End of File
-
--- a/perfmon/inc/perfmon_appui.h	Fri Apr 16 14:59:17 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,74 +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:  
-*
-*/
-
-
-#ifndef PERFMON_APPUI_H
-#define PERFMON_APPUI_H
-
-// INCLUDES
-#include <eikapp.h>
-#include <eikdoc.h>
-#include <e32std.h>
-#include <coeccntx.h>
-#include <aknViewAppUi.h>
-#include <akntabgrp.h>
-#include <aknnavide.h>
-#include "perfmon_std.h"
-
-// FORWARD DECLARATIONS
-class CPerfMonModel;
-class CAknNavigationControlContainer;
-class CAknTabGroup;
-class CAknNavigationDecorator;
-
-
-// CLASS DECLARATIONS
-
-class CPerfMonAppUi : public CAknViewAppUi
-    {
-    public: // // Constructors and destructor
-
-        void ConstructL();
-
-        ~CPerfMonAppUi();
-        
-    public: // New functions
-
-    private:
-        // From MEikMenuObserver
-        void DynInitMenuPaneL(TInt aResourceId,CEikMenuPane* aMenuPane);
-
-    private:
-        void HandleForegroundEventL(TBool aForeground); 
-
-        void HandleCommandL(TInt aCommand);
-
-        void HandleResourceChangeL(TInt aType);
-
-        virtual TKeyResponse HandleKeyEventL(
-            const TKeyEvent& aKeyEvent,TEventCode aType);
-
-    private: //Data
-        CPerfMonModel*                  iModel;
-        CAknNavigationControlContainer* iNaviPane;
-        CAknTabGroup*                   iTabGroup;
-        CAknNavigationDecorator*        iDecoratedTabGroup;
-    };
-
-#endif
-
-// End of File
--- a/perfmon/inc/perfmon_datapopupcontainer.h	Fri Apr 16 14:59:17 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,60 +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:  
-*
-*/
-
-
-#ifndef PERFMON_DATAPOPUPCONTAINER_H
-#define PERFMON_DATAPOPUPCONTAINER_H
-
-// INCLUDES
-#include <coecntrl.h>
-
-#include "perfmon_drawcallback.h"
-
-
-// FORWARD DECLARATIONS
-class CPerfMonModel;
-
-
-// CLASS DECLARATIONS
-
-class CPerfMonDataPopupContainer : public CCoeControl, public MDrawUpdateCallback
-    {
-public:
-    void ConstructL(const TRect& aRect);
-    ~CPerfMonDataPopupContainer();
-
-protected:
-    void Draw(const TRect& aRect) const;
-    virtual void SizeChanged();    
-
-public:
-    void SetPositionAndSize();
-    void UpdateVisibility(TBool aForeground=ETrue);
-
-public: // from MDrawUpdateCallback
-    void DrawUpdate();
-
-private:
-    CPerfMonModel*                      iModel;
-    RWindowGroup                        iWindowGroup;
-    const CFont*                        iFont; 
-    TInt                                iFontSize;
-    };
-    
-#endif
-
-// End of File
--- a/perfmon/inc/perfmon_document.h	Fri Apr 16 14:59:17 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,77 +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:  
-*
-*/
-
-
-#ifndef PERFMON_DOCUMENT_H
-#define PERFMON_DOCUMENT_H
-
-// INCLUDES
-#include <AknDoc.h>
-   
-// CONSTANTS
-
-// FORWARD DECLARATIONS
-class CEikAppUi;
-class CPerfMonModel;
-
-
-// CLASS DECLARATION
-
-/**
-*  CPerfMonDocument application class.
-*/
-class CPerfMonDocument : public CAknDocument
-    {
-    public: // Constructors and destructor
-        static CPerfMonDocument* NewL(CEikApplication& aApp);
-        virtual ~CPerfMonDocument();
-
-    public: // New functions
-
-    public:	// from CEikDocument
-	    CFileStore* OpenFileL(TBool aDoOpen,const TDesC& aFilename,RFs& aFs);
-    protected:  // New functions
-
-    protected:  // Functions from base classes
-
-    private:
-
-        /**
-        * EPOC default constructor.
-        */
-        CPerfMonDocument(CEikApplication& aApp);
-        void ConstructL();
-
-    private:
-
-        /**
-        * From CEikDocument, create CPerfMonAppUi "App UI" object.
-        */
-        CEikAppUi* CreateAppUiL();
-
-    public:
-        inline CPerfMonModel* Model() { return iModel; }
-
-    private:
-        CPerfMonModel* iModel;
-
-    };
-
-#endif
-
-// End of File
-
--- a/perfmon/inc/perfmon_drawcallback.h	Fri Apr 16 14:59:17 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,31 +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:  
-*
-*/
-
-
-#ifndef PERFMON_DRAWCALLBACK_H
-#define PERFMON_DRAWCALLBACK_H
-
-class MDrawUpdateCallback
-    {
-public:
-    virtual void DrawUpdate() = 0;    
-    };
-
-#endif
-
-// End of File
-
--- a/perfmon/inc/perfmon_graphscontainer.h	Fri Apr 16 14:59:17 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,57 +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:  
-*
-*/
-
-
-#ifndef PERFMON_GRAPHSCONTAINER_H
-#define PERFMON_GRAPHSCONTAINER_H
-
-// INCLUDES
-#include <coecntrl.h>
-
-#include "perfmon_drawcallback.h"
-
-
-// FORWARD DECLARATIONS
-class CPerfMonModel;
-
-
-// CLASS DECLARATIONS
-
-class CPerfMonGraphsContainer : public CCoeControl, public MDrawUpdateCallback
-    {
-public:
-    void ConstructL(const TRect& aRect);
-    ~CPerfMonGraphsContainer();
-
-private:
-    void Draw(const TRect& aRect) const;
-    void HandleResourceChange(TInt aType);
-
-public:
-	TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode /*aType*/);
-
-public: // from MDrawUpdateCallback
-    void DrawUpdate();
-
-private:
-    CPerfMonModel*                      iModel;
-    const CFont*                        iFont;
-    };
-    
-#endif
-
-// End of File
--- a/perfmon/inc/perfmon_graphsview.h	Fri Apr 16 14:59:17 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,70 +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:  
-*
-*/
-
-
-#ifndef PERFMON_GRAPHSVIEW_H
-#define PERFMON_GRAPHSVIEW_H
-
-// INCLUDES
-#include <aknview.h>
-
-#include "perfmon_std.h"
-
-
-
-// CONSTANTS
-// UID of view
-const TUid KGraphsViewUID = {2};
-
-
-// FORWARD DECLARATIONS
-class CPerfMonGraphsContainer;
-class CPerfMonModel;
-
-
-// CLASS DECLARATION
-
-/**
-*  CPerfMonGraphsView view class.
-* 
-*/
-class CPerfMonGraphsView : public CAknView
-    {
-    public: // Constructors and destructor
-        void ConstructL();
-        ~CPerfMonGraphsView();
-
-    public: // Functions from base classes
-        TUid Id() const;
-        void HandleCommandL(TInt aCommand);
-        void HandleClientRectChange();
-
-    private: // From MEikMenuObserver
-        void DynInitMenuPaneL(TInt aResourceId, CEikMenuPane* aMenuPane);
-
-    private: // From AknView
-        void DoActivateL(const TVwsViewId& aPrevViewId, TUid aCustomMessageId, const TDesC8& aCustomMessage);
-        void DoDeactivate();
-
-    private: // Data
-        CPerfMonGraphsContainer*        iContainer;
-        CPerfMonModel*                  iModel;
-    };
-
-#endif
-
-// End of File
--- a/perfmon/inc/perfmon_model.h	Fri Apr 16 14:59:17 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,246 +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:  
-*
-*/
-
-
-#ifndef PERFMON_MODEL_H
-#define PERFMON_MODEL_H
-
-// INCLUDES
-#include <e32std.h>
-#include <e32base.h>
-#include <apgcli.h>
-#include <gdi.h>
-
-#include "perfmon.hrh"
-
-
-// setting keys (do not change uids of existing keys to maintain compatibility to older versions!)
-const TUid KPMSettingHeartBeat                              = { 0x00 };
-const TUid KPMSettingMaxSamples                             = { 0x01 };
-const TUid KPMSettingPriority                               = { 0x02 };
-const TUid KPMSettingCPUMode                                = { 0x03 };
-const TUid KPMSettingKeepBackLightOn                        = { 0x04 };
-
-const TUid KPMSettingDataPopupVisbility                     = { 0x05 };
-const TUid KPMSettingDataPopupLocation                      = { 0x06 };
-const TUid KPMSettingDataPopupSources                       = { 0x07 };
-
-const TUid KPMSettingGraphsVerticalBarPeriod                = { 0x08 };
-const TUid KPMSettingGraphsSources                          = { 0x09 };
-
-const TUid KPMSettingLoggingMode                            = { 0x0A };
-const TUid KPMSettingLoggingFilePath                        = { 0x0B };
-const TUid KPMSettingLoggingSources                         = { 0x0C };
-
-
-
-// FORWARD DECLARATIONS
-class CPerfMonValuesContainer;
-class CPerfMonGraphsContainer;
-class CPerfMonDataPopupContainer;
-class CEikonEnv;
-class CCoeControl;
-class CDictionaryFileStore;
-
-
-// CLASS DECLARATIONS
-
-
-class TPerfMonSources
-    {
-public:
-    TBool iSrcEnabled[ESourcesLength];
-
-public:
-    inline void SetDefaults1()
-        {
-        iSrcEnabled[ESourceCPU] = ETrue;
-        iSrcEnabled[ESourceRAM] = ETrue;
-        iSrcEnabled[ESourceC]   = ETrue;
-        iSrcEnabled[ESourceD]   = EFalse;
-        iSrcEnabled[ESourceE]   = EFalse;
-        iSrcEnabled[ESourceF]   = EFalse;
-        iSrcEnabled[ESourceG]   = EFalse;
-        iSrcEnabled[ESourceH]   = EFalse;
-        iSrcEnabled[ESourceI]   = EFalse;        
-        }
-    inline void SetDefaults2()
-        {
-        iSrcEnabled[ESourceCPU] = ETrue;
-        iSrcEnabled[ESourceRAM] = ETrue;
-        iSrcEnabled[ESourceC]   = EFalse;
-        iSrcEnabled[ESourceD]   = EFalse;
-        iSrcEnabled[ESourceE]   = EFalse;
-        iSrcEnabled[ESourceF]   = EFalse;
-        iSrcEnabled[ESourceG]   = EFalse;
-        iSrcEnabled[ESourceH]   = EFalse;
-        iSrcEnabled[ESourceI]   = EFalse;        
-        }
-    TInt EnabledSourcesCount()
-        {
-        TInt srcCount(0);
-        
-        for (TInt i=0; i<ESourcesLength; i++)
-            {
-            if (iSrcEnabled[i])
-                srcCount++;
-            }
-        
-        return srcCount;
-        }
-    };
-    
-
-class TPerfMonSettings
-    {
-public:
-    TInt                iHeartBeat;
-    TInt                iMaxSamples;
-    TInt                iPriority;
-    TInt                iCPUMode;
-    TBool               iKeepBacklightOn;
-
-    TInt                iDataPopupVisibility;
-    TInt                iDataPopupLocation;
-    TPerfMonSources     iDataPopupSources;
-
-    TInt                iGraphsVerticalBarPeriod;
-    TPerfMonSources     iGraphsSources;
-
-    TInt                iLoggingMode;
-    TFileName           iLoggingFilePath;
-    TPerfMonSources     iLoggingSources;
-    
-    TBool               iLoggingEnabled;
-    };
-
-
-class TSampleData
-	{
-public:
-    TInt64                          iFree;
-    TInt64                          iSize;
-    TTimeIntervalMicroSeconds       iTimeFromStart;
-	}; 
-
-typedef CArrayFixSeg<TSampleData> CSampleDataArray;
-
-
-class TSampleEntry
-	{
-public:
-    TBuf<16>            iDescription;
-    TBuf<16>            iUnitTypeShort; //eg. b
-    TBuf<16>            iUnitTypeLong;  //eg. bytes
-    TInt                iDriveNumber;   //used only for disk drives
-    TRgb                iGraphColor;
-    CSampleDataArray*   iSampleDataArray;
-	}; 
-	
-typedef CArrayFixSeg<TSampleEntry> CSampleEntryArray;
-
-
-
-class CPerfMonModel : public CActive
-	{
-private:
-    enum TContainerDrawState
-    	{
-    	EDrawStateInvalid = -1,
-    	EDrawStateValues,
-    	EDrawStateGraphs
-    	};
-
-public:
-	static CPerfMonModel* NewL();
-	~CPerfMonModel();
-	void ActivateModelL();
-	void DeActivateModelL();
-    void EnableLogging(TBool aEnable);
-
-private:
-	void RunL();
-	void DoCancel();
-
-private:
-	CPerfMonModel();
-	void ConstructL();
-    void LoadSettingsL();
-    void SaveSettingsL();
-    void HandleSettingsChangeL();
-    void OpenLogFile(TBool aOpen);
-    void SendDrawEventToContainersL();
-    void CreateSamplesDataArrayL();
-    void UpdateSamplesDataL();
-    void AppendLatestSamplesToLogsL();
-    void ActivateCPUMonitoringL();
-    TBool OpenHandleToNullThread();
-    void DeActivateCPUMonitoring();
-    TBool CPUTimeSupported();
-    TThreadPriority SettingItemToThreadPriority(TInt aIndex);
-    void LoadDFSValueL(CDictionaryFileStore* aDicFS, const TUid& aUid, TInt& aValue);
-    void LoadDFSValueL(CDictionaryFileStore* aDicFS, const TUid& aUid, TDes& aValue);
-    void LoadDFSValueL(CDictionaryFileStore* aDicFS, const TUid& aUid, TPerfMonSources& aValue);
-    void SaveDFSValueL(CDictionaryFileStore* aDicFS, const TUid& aUid, const TInt& aValue);
-    void SaveDFSValueL(CDictionaryFileStore* aDicFS, const TUid& aUid, const TDes& aValue);
-    void SaveDFSValueL(CDictionaryFileStore* aDicFS, const TUid& aUid, const TPerfMonSources& aValue);
-    
-public:
-    void SetValuesContainer(CPerfMonValuesContainer* aValuesContainer);
-    void SetGraphsContainer(CPerfMonGraphsContainer* aGraphsContainer);
-    TInt LaunchSettingsDialogL();
-
-    inline TPerfMonSettings& Settings() { return iSettings; }
-    inline CEikonEnv* EikonEnv() { return iEnv; }
-    inline RApaLsSession& LsSession() { return iLs; }
-
-    inline CPerfMonValuesContainer*     ValuesContainer()       { return iValuesContainer; }
-    inline CPerfMonGraphsContainer*     GraphsContainer()       { return iGraphsContainer; }
-    inline CPerfMonDataPopupContainer*  DataPopupContainer()    { return iDataPopupContainer; }
-
-
-    inline CSampleEntryArray* SampleEntryArray() { return iSampleEntryArray; } 
-
-private:
-    RTimer                          iTimer;
-    CPerfMonValuesContainer*        iValuesContainer;
-    CPerfMonGraphsContainer*        iGraphsContainer;
-    CPerfMonDataPopupContainer*     iDataPopupContainer;
-    CEikonEnv*                      iEnv;
-    TPerfMonSettings                iSettings;
-    RApaLsSession                   iLs;
-    TInt                            iDrawState;
-    CSampleEntryArray*              iSampleEntryArray;
-    TTime                           iStartTime;
-
-    TInt                            iCurrentCPUMode;
-
-    RThread                         iNullThread;
-    RThread                         iCPULoadThread;
-	TBool                           iCPULoadCalibrating;
-	TInt                            iCPULoadCalibrationCounter;
-	TInt64                          iCPULoadMaxValue;
-	TInt64                          iCPULoadPreviousValue;    
-	TInt64                          iCPULoadCounter;
-    TTime                           iPreviousTime;
-    
-    TBool                           iLogFileInitialized;
-    RFile                           iLogFile;
-    };
- 
-
-#endif
--- a/perfmon/inc/perfmon_settingsviewdlg.h	Fri Apr 16 14:59:17 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,121 +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:  
-*
-*/
-
-
-#ifndef PERFMON_SETTINGSVIEWDLG_H
-#define PERFMON_SETTINGSVIEWDLG_H
-
-//  INCLUDES
-#include <AknDialog.h>
-#include <eiklbo.h>
-#include <AknTabObserver.h> 
-#include <akntabgrp.h>
-#include <aknsettingitemlist.h> 
-#include <akncheckboxsettingpage.h> 
-
-#include "perfmon_model.h"
-
-
-//  FORWARD DECLARATIONS
-class CAknSettingItemArray;
-class CAknSettingStyleListBox;
-class CAknNavigationControlContainer;
-class CAknNavigationDecorator;
-class CAknTabGroup; 
-class TPerfMonSettings;
-class CSelectionItemList;
-
-
-//  CLASS DEFINITIONS
-
-class CPerfMonSettingsViewDlg : public CAknDialog, public MEikListBoxObserver, public MAknTabObserver
-    {
-public:
-    static CPerfMonSettingsViewDlg* NewL(TPerfMonSettings& aSettings);
-    virtual ~CPerfMonSettingsViewDlg();
-
-public: // From MEikListBoxObserver
-    void HandleListBoxEventL(CEikListBox* aListBox, TListBoxEvent aEventType);
-
-public: // From MAknTabObserver
-    void TabChangedL(TInt aIndex); 
-
-public: // From CAknDialog
-    void ProcessCommandL(TInt aCommandId);
-
-protected: // From CEikDialog
-    TKeyResponse OfferKeyEventL(const TKeyEvent &aKeyEvent, TEventCode aType);
-    void PreLayoutDynInitL();
-    TBool OkToExitL(TInt aButtonId);    
-
-private: // New methods
-    void ShowSettingPageL(TBool aCalledFromMenu);
-    void SetVisibilitiesOfSettingItemsL();
-    void UpdateListBoxL();
-    void AddSettingItemL(TInt aId, TInt aTitleResource, TInt aSettingPageResource, TInt aAssociatedResource, TInt aOrdinal);
-
-private: // Constructors
-    CPerfMonSettingsViewDlg(TPerfMonSettings& aSettings);
-    void ConstructL();        
-
-private: // Data
-    CAknSettingItemArray*               iSettingItemArray;
-    CAknSettingStyleListBox*            iListBox;
-    CAknNavigationControlContainer*     iNaviContainer;
-    CAknNavigationDecorator*            iDecoratedTabGroup;
-    CAknTabGroup*                       iTabGroup;
-    TPerfMonSettings&               iSettings;
-    };
-
-
-class CSourceSelectionCheckBoxSettingItem : public CAknSettingItem
-    {
-public:
-    CSourceSelectionCheckBoxSettingItem( TInt aIdentifier, TPerfMonSources& aMemoryInUse );
-	virtual ~CSourceSelectionCheckBoxSettingItem();
-
-protected:
-	void CompleteConstructionL();
-	void StoreL();
-	void LoadL();
-	const TDesC& SettingTextL();
-	void EditItemL( TBool aCalledFromMenu );
-    void HandleSettingPageEventL( CAknSettingPage* aSettingPage, TAknSettingPageEvent aEventType );
-
-private:
-    void AddNewItemToArrayL(const TDesC& aLabel); 
-
-private:
-    CSelectionItemList*     iItemArray;
-    HBufC*                  iSettingText;
-    TPerfMonSources&        iExternalSources;
-    };
-
-
-class CSourceSelectionCheckBoxSettingPage : public CAknCheckBoxSettingPage
-	{
-	public:
-        CSourceSelectionCheckBoxSettingPage( TInt aResourceID, CSelectionItemList* aItemArray );
-	public:		// New functions
-		void UpdateCba();
-	};
-	
-
-#endif
-
-// End of File
-
--- a/perfmon/inc/perfmon_std.h	Fri Apr 16 14:59:17 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,27 +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:  
-*
-*/
-
-
-#ifndef PERFMON_STD_H
-#define PERFMON_STD_H
-
-
-
-#endif
-
-// End of File
-
--- a/perfmon/inc/perfmon_valuescontainer.h	Fri Apr 16 14:59:17 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,57 +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:  
-*
-*/
-
-
-#ifndef PERFMON_VALUESCONTAINER_H
-#define PERFMON_VALUESCONTAINER_H
-
-// INCLUDES
-#include <coecntrl.h>
-
-#include "perfmon_drawcallback.h"
-
-
-// FORWARD DECLARATIONS
-class CPerfMonModel;
-
-
-// CLASS DECLARATIONS
-
-class CPerfMonValuesContainer : public CCoeControl, public MDrawUpdateCallback
-    {
-public:
-    void ConstructL(const TRect& aRect);
-    ~CPerfMonValuesContainer();
-
-private:
-    void Draw(const TRect& aRect) const;
-    void HandleResourceChange(TInt aType);
-
-public:
-	TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode /*aType*/);
-
-public: // from MDrawUpdateCallback
-    void DrawUpdate();
-    
-private:
-    CPerfMonModel*                      iModel;
-    const CFont*                        iFont; 
-    };
-    
-#endif
-
-// End of File
--- a/perfmon/inc/perfmon_valuesview.h	Fri Apr 16 14:59:17 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,70 +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:  
-*
-*/
-
-
-#ifndef PERFMON_VALUESVIEW_H
-#define PERFMON_VALUESVIEW_H
-
-// INCLUDES
-#include <aknview.h>
-
-#include "perfmon_std.h"
-
-
-
-// CONSTANTS
-// UID of view
-const TUid KValuesViewUID = {1};
-
-
-// FORWARD DECLARATIONS
-class CPerfMonValuesContainer;
-class CPerfMonModel;
-
-
-// CLASS DECLARATION
-
-/**
-*  CPerfMonValuesView view class.
-* 
-*/
-class CPerfMonValuesView : public CAknView
-    {
-    public: // Constructors and destructor
-        void ConstructL();
-        ~CPerfMonValuesView();
-
-    public: // Functions from base classes
-        TUid Id() const;
-        void HandleCommandL(TInt aCommand);
-        void HandleClientRectChange();
-
-    private: // From MEikMenuObserver
-        void DynInitMenuPaneL(TInt aResourceId, CEikMenuPane* aMenuPane);
-
-    private: // From AknView
-        void DoActivateL(const TVwsViewId& aPrevViewId, TUid aCustomMessageId, const TDesC8& aCustomMessage);
-        void DoDeactivate();
-
-    private: // Data
-        CPerfMonValuesContainer*        iContainer;
-        CPerfMonModel*                  iModel;
-    };
-
-#endif
-
-// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/perfmon/perfmon.pro	Mon May 03 12:32:02 2010 +0300
@@ -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: 
+#
+#
+
+TEMPLATE = subdirs
+
+DEFINES += QT_NO_DEBUG_OUTPUT QT_NO_WARNING_OUTPUT QT_NO_DEBUG
+
+SUBDIRS = group \
+          ui/hb/datapopup \
+          ui/hb/app
--- a/perfmon/rom/perfmon.iby	Fri Apr 16 14:59:17 2010 +0300
+++ b/perfmon/rom/perfmon.iby	Mon May 03 12:32:02 2010 +0300
@@ -22,11 +22,8 @@
 S60_APP_EXE(PerfMon)
 S60_APP_AIF_ICONS(PerfMon)
 S60_APP_RESOURCE(PerfMon)
-#ifdef S60_UPGRADABLE_APP_REG_RSC
-  S60_UPGRADABLE_APP_REG_RSC(PerfMon)
-#else
-  S60_APP_AIF_RSC(PerfMon)
-#endif
+SCALABLE_IMAGE(APP_BITMAP_DIR,APP_BITMAP_DIR,PerfMon)
+data=ZPRIVATE\10003a3f\import\APPS\PerfMon_reg.RSC Private\10003a3f\import\Apps\PerfMon_reg.rsc
 
 data=ZPRIVATE\20011385\backup_registration.xml        	private\20011385\backup_registration.xml
 data=ZSYSTEM\Install\PerfMon_stub.sis                   \system\install\PerfMon_stub.sis
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/perfmon/rom/perfmon_datapopup.iby	Mon May 03 12:32:02 2010 +0300
@@ -0,0 +1,25 @@
+/*
+* 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:  
+*
+*/
+
+
+#ifndef __PERFMON_DATAPOPUP_IBY__
+#define __PERFMON_DATAPOPUP_IBY__
+
+file=ABI_DIR\BUILD_DIR\PerfMonDataPopupPlugin.dll       SHARED_LIB_DIR\PerfMonDataPopupPlugin.dll
+data=DATAZ_\PRIVATE\20011385\PerfMonDataPopupPlugin.qtplugin PRIVATE\20011385\PerfMonDataPopupPlugin.qtplugin
+
+#endif // __PERFMON_DATAPOPUP_IBY__
--- a/perfmon/src/perfmon_app.cpp	Fri Apr 16 14:59:17 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,73 +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 FILES
-#include "perfmon_app.h"
-#include "perfmon_document.h"
-
-#include <eikstart.h>
-
-
-// ================= MEMBER FUNCTIONS =======================
-
-// ---------------------------------------------------------
-// CPerfMonApp::AppDllUid()
-// Returns application UID
-// ---------------------------------------------------------
-//
-TUid CPerfMonApp::AppDllUid() const
-    {
-    return KUidPerfMon;
-    }
-
-// ---------------------------------------------------------
-// CDictionaryStore* CPerfMonApp::OpenIniFileLC(RFs& aFs) const
-// overrides CAknApplication::OpenIniFileLC to enable INI file support
-// ---------------------------------------------------------
-//
-CDictionaryStore* CPerfMonApp::OpenIniFileLC(RFs& aFs) const
-    {
-    return CEikApplication::OpenIniFileLC(aFs);
-    }
-   
-// ---------------------------------------------------------
-// CPerfMonApp::CreateDocumentL()
-// Creates CPerfMonDocument object
-// ---------------------------------------------------------
-//
-CApaDocument* CPerfMonApp::CreateDocumentL()
-    {
-    return CPerfMonDocument::NewL( *this );
-    }
-
-// ================= OTHER EXPORTED FUNCTIONS ==============
-
-LOCAL_C CApaApplication* NewApplication()
-    {
-    return new CPerfMonApp;
-    }
-
-
-GLDEF_C TInt E32Main()
-    {
-    return EikStart::RunApplication(NewApplication);
-    }
-   
-
-// End of File  
-
--- a/perfmon/src/perfmon_appui.cpp	Fri Apr 16 14:59:17 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,228 +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 FILES
-#include "perfmon_appui.h"
-#include "perfmon_valuesview.h"
-#include "perfmon_graphsview.h"
-#include "perfmon_datapopupcontainer.h"
-#include "perfmon.hrh"
-#include "perfmon_model.h"
-#include "perfmon_document.h"
-#include <perfmon.rsg>
-
-#include <avkon.hrh>
-#include <AknQueryDialog.h>
-#include <aknmessagequerydialog.h> 
-
-
-// ================= MEMBER FUNCTIONS =======================
-
-// --------------------------------------------------------------------------------------------
-
-void CPerfMonAppUi::ConstructL()
-    {
-    // disable window server priority control for this application
-    iEikonEnv->WsSession().ComputeMode( RWsSession::EPriorityControlDisabled );
-
-    // set as system application to prevent getting shut down events 
-    iEikonEnv->SetSystem(ETrue);
-    
-    BaseConstructL(EAknEnableSkin);
-
-    iModel = static_cast<CPerfMonDocument*>(reinterpret_cast<CEikAppUi*>(iEikonEnv->AppUi())->Document())->Model();
-
-    // Show tabs for main views from resources
-    CEikStatusPane* sp = StatusPane();
-
-    // Fetch pointer to the default navi pane control
-    iNaviPane = (CAknNavigationControlContainer*)sp->ControlL( 
-        TUid::Uid(EEikStatusPaneUidNavi));
-
-    // Tabgroup has been read from resource and it were pushed to the navi pane. 
-    // Get pointer to the navigation decorator with the ResourceDecorator() function. 
-    // Application owns the decorator and it has responsibility to delete the object.
-    iDecoratedTabGroup = iNaviPane->ResourceDecorator();
-    if (iDecoratedTabGroup)
-        {
-        iTabGroup = (CAknTabGroup*) iDecoratedTabGroup->DecoratedControl();
-        }
-        
-    CPerfMonValuesView* valuesView = new(ELeave) CPerfMonValuesView;
-    CleanupStack::PushL(valuesView);
-    valuesView->ConstructL();
-    AddViewL(valuesView);           // transfer ownership to CAknViewAppUi
-    CleanupStack::Pop();            // valuesView
-
-    CPerfMonGraphsView* graphsView = new(ELeave) CPerfMonGraphsView;
-    CleanupStack::PushL(graphsView);
-    graphsView->ConstructL();
-    AddViewL(graphsView);           // transfer ownership to CAknViewAppUi
-    CleanupStack::Pop();            // graphsView
-    
-    // set the default view
-    SetDefaultViewL(*valuesView);
-
-    // notify the model that everything has been constructed
-    iModel->ActivateModelL();
-    }
-
-// --------------------------------------------------------------------------------------------
-
-CPerfMonAppUi::~CPerfMonAppUi()
-    {
-    // notify the model that the application is closing
-    if (iModel)    
-        TRAP_IGNORE(iModel->DeActivateModelL());
-    
-    delete iDecoratedTabGroup;
-    }
-
-// --------------------------------------------------------------------------------------------
-
-void CPerfMonAppUi::DynInitMenuPaneL(TInt aResourceId, CEikMenuPane* aMenuPane)
-    {
-    if (aResourceId == R_PERFMON_APP_MENU)
-        {
-        aMenuPane->SetItemDimmed(EPerfMonCmdEnableLogging, iModel->Settings().iLoggingEnabled);
-        aMenuPane->SetItemDimmed(EPerfMonCmdDisableLogging, !iModel->Settings().iLoggingEnabled);
-        }
-    }
-
-// --------------------------------------------------------------------------------------------
-
-TKeyResponse CPerfMonAppUi::HandleKeyEventL(const TKeyEvent& aKeyEvent, TEventCode /*aType*/)
-    {
-    if ( iTabGroup == NULL )
-        {
-        return EKeyWasNotConsumed;
-        }
-
-    TInt active = iTabGroup->ActiveTabIndex();
-    TInt count = iTabGroup->TabCount();
-
-    switch ( aKeyEvent.iCode )
-        {
-        case EKeyLeftArrow:
-            if (active > 0)
-                {
-                active--;
-                iTabGroup->SetActiveTabByIndex( active );
-                ActivateLocalViewL(TUid::Uid(iTabGroup->TabIdFromIndex(active)));
-                }
-            break;
-        case EKeyRightArrow:
-            if((active + 1) < count)
-                {
-                active++;
-                iTabGroup->SetActiveTabByIndex( active );
-                ActivateLocalViewL(TUid::Uid(iTabGroup->TabIdFromIndex(active)));
-                }
-            break;
-        default:
-            return EKeyWasNotConsumed;
-        }
-
-    return EKeyWasConsumed;
-    }
-
-
-// --------------------------------------------------------------------------------------------
-
-void CPerfMonAppUi::HandleCommandL(TInt aCommand)
-    {
-    switch ( aCommand )
-        {
-        case EPerfMonCmdEnableLogging:
-            {
-            iModel->EnableLogging(ETrue);
-            break;
-            }
-
-        case EPerfMonCmdDisableLogging:
-            {
-            iModel->EnableLogging(EFalse);
-            break;
-            }
-                        
-        case EPerfMonCmdSettings:
-            {
-            if (iModel->LaunchSettingsDialogL() == EAknCmdExit)
-                Exit();
-            break;
-            }
-
-        case EPerfMonCmdAbout:
-            {
-	        CAknMessageQueryDialog* dialog = new(ELeave) CAknMessageQueryDialog;
-            dialog->ExecuteLD(R_PERFMON_ABOUT_DIALOG);
-            }
-            break;
-            
-        // a normal way to close an application
-        case EAknCmdExit:
-        case EEikCmdExit:
-        case EAknSoftkeyExit: 
-			{
-            Exit();
-			}
-            break;
-
-        default:
-            break;      
-        }
-    }
-
-// --------------------------------------------------------------------------------------------
-
-void CPerfMonAppUi::HandleForegroundEventL(TBool aForeground)
-    {
-    // handle visibility of the data popup container
-    if (iModel && iModel->DataPopupContainer())
-        {
-        iModel->DataPopupContainer()->UpdateVisibility(aForeground);
-        }
-    
-    // call the base class
-    CAknAppUi::HandleForegroundEventL(aForeground); 
-    }
-
-// --------------------------------------------------------------------------------------------
-
-void CPerfMonAppUi::HandleResourceChangeL(TInt aType)
-    {
-    CAknAppUi::HandleResourceChangeL(aType);
-
-    // update size of the data popup container (implemented here because data popup container
-    // does not get HandleResourceChangeL events)
-    if (aType == KEikDynamicLayoutVariantSwitch)
-        {
-        if (iModel)
-            {
-            if (iModel->DataPopupContainer())
-                {
-                iModel->DataPopupContainer()->SetPositionAndSize();
-                }
-            
-            }
-        }
-    }
-
-// --------------------------------------------------------------------------------------------
-
-// End of File  
--- a/perfmon/src/perfmon_datapopupcontainer.cpp	Fri Apr 16 14:59:17 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,210 +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 FILES
-#include "perfmon_datapopupcontainer.h"
-#include "perfmon.hrh"
-#include "perfmon_document.h"
-#include "perfmon_appui.h"
-#include "perfmon_model.h"
-
-#include <AknUtils.h>
-
-_LIT(KPercentageFormat,"%S %d%%");
-_LIT(KFreeFormat,"%S free %S%S");
-
-const TInt KLeftMargin = 2;
- 
-
-// ===================================== MEMBER FUNCTIONS =====================================
-
-void CPerfMonDataPopupContainer::ConstructL(const TRect& /*aRect*/)
-    {
-    iModel = static_cast<CPerfMonDocument*>(reinterpret_cast<CEikAppUi*>(iEikonEnv->AppUi())->Document())->Model();
-    iFont = LatinPlain12();
-    iFontSize = iFont->FontMaxHeight();
- 
-    // set windowgroup so that it always on top and does not receive focus
-    iWindowGroup = RWindowGroup(iCoeEnv->WsSession());
-    User::LeaveIfError(iWindowGroup.Construct((TUint32)&iWindowGroup));
-    iWindowGroup.SetOrdinalPosition(0, ECoeWinPriorityAlwaysAtFront);
-    iWindowGroup.EnableReceiptOfFocus(EFalse);
-    
-    CreateWindowL(&iWindowGroup);
-    //SetRect(aRect);
-    SetPositionAndSize();
-    SetBlank();
-
-    ActivateL();
-    }
-
-// --------------------------------------------------------------------------------------------
-
-CPerfMonDataPopupContainer::~CPerfMonDataPopupContainer()
-    {
-    iWindowGroup.Close();    
-    }
-    
-// --------------------------------------------------------------------------------------------
-
-void CPerfMonDataPopupContainer::Draw(const TRect& aRect) const
-    {
-    CWindowGc& gc = SystemGc();
-    gc.SetBrushColor(KRgbWhite);
-    gc.Clear(aRect);
-    
-    // check if sample array has been constructed
-    if (iModel->SampleEntryArray())
-        {
-        // init font
-        gc.SetPenColor(KRgbBlack);
-        gc.UseFont( iFont );
-        
-        // draw a rect around the popup
-        gc.DrawRect(aRect);
-        
-        TInt posCounter(1);
-        
-        for (TInt i=0; i<iModel->SampleEntryArray()->Count(); i++)
-            {
-            // check if this setting has been enabled and it has some data
-            if (iModel->Settings().iDataPopupSources.iSrcEnabled[i] && iModel->SampleEntryArray()->At(i).iSampleDataArray->Count() > 0)
-                {
-                TSampleData& currentSample = iModel->SampleEntryArray()->At(i).iSampleDataArray->At(0);    
-                TBuf<32> buf;
-
-                // for CPU draw %, other amount of free memory
-                if (i == ESourceCPU)
-                    {
-                    buf.Format(KPercentageFormat, &iModel->SampleEntryArray()->At(i).iDescription, currentSample.iSize > 0 ? TInt( (1 - ((TReal)(currentSample.iFree) / (TReal)currentSample.iSize)) * 100) : 0 );
-                    gc.DrawText(buf, TPoint(KLeftMargin, iFontSize*posCounter));
-                    }
-                else
-                    {
-                    TBuf<32> freeBuf;
-                    freeBuf.AppendNum(currentSample.iFree, TRealFormat(KDefaultRealWidth, 0));
-
-                    TBuf<32> buf;
-                    buf.Format(KFreeFormat, &iModel->SampleEntryArray()->At(i).iDescription, &freeBuf, &iModel->SampleEntryArray()->At(i).iUnitTypeShort);
-                    gc.DrawText(buf, TPoint(KLeftMargin, iFontSize*posCounter));                    
-                    }    
-                
-                posCounter++;
-                }
-            }
-            
-        gc.DiscardFont();        
-        }
-    }
-
-// --------------------------------------------------------------------------------------------
-
-void CPerfMonDataPopupContainer::SizeChanged()
-    {
-    DrawNow();
-    }   
-
-// --------------------------------------------------------------------------------------------
-
-void CPerfMonDataPopupContainer::SetPositionAndSize()
-    {
-    CWsScreenDevice* screenDevice = iEikonEnv->ScreenDevice();
-
-    // top right
-    if (iModel->Settings().iDataPopupLocation == EDataPopupLocationTopRight)
-        {
-        // screen orientation is landscape with softkeys on right
-        if (AknLayoutUtils::CbaLocation()==AknLayoutUtils::EAknCbaLocationRight)
-            {
-            SetRect(
-                TRect(
-                    screenDevice->SizeInPixels().iWidth-102-15,
-                    0,
-                    screenDevice->SizeInPixels().iWidth-15,
-                    iModel->Settings().iDataPopupSources.EnabledSourcesCount()*iFontSize + 3
-                    ));
-            }
-
-        // any other orientation
-        else
-            {
-            SetRect(
-                TRect(
-                    screenDevice->SizeInPixels().iWidth-102,
-                    0,
-                    screenDevice->SizeInPixels().iWidth,
-                    iModel->Settings().iDataPopupSources.EnabledSourcesCount()*iFontSize + 3
-                    ));
-            }        
-        }
-
-    // bottom middle
-    else if (iModel->Settings().iDataPopupLocation == EDataPopupLocationBottomMiddle)
-        {
-        SetRect(
-            TRect(
-                screenDevice->SizeInPixels().iWidth/2-102/2,
-                screenDevice->SizeInPixels().iHeight - iModel->Settings().iDataPopupSources.EnabledSourcesCount()*iFontSize - 3,
-                screenDevice->SizeInPixels().iWidth/2+102/2,
-                screenDevice->SizeInPixels().iHeight
-                ));
-        }
-    }
-
-// --------------------------------------------------------------------------------------------
-
-void CPerfMonDataPopupContainer::UpdateVisibility(TBool aForeground)
-    {
-    // application has been brought to foregound
-    if (aForeground)
-        {
-        if (iModel->Settings().iDataPopupVisibility==EDataPopupVisbilityAlwaysOn)
-            {
-            MakeVisible(ETrue);
-            }
-        else
-            {
-            MakeVisible(EFalse);
-            }    
-        }
-    
-    // application has been sent to background
-    else
-        {
-        if (iModel->Settings().iDataPopupVisibility==EDataPopupVisbilityAlwaysOn
-            || iModel->Settings().iDataPopupVisibility==EDataPopupVisbilityBackgroundOnly)
-            {
-            MakeVisible(ETrue);
-            }
-        else
-            {
-            MakeVisible(EFalse);
-            }              
-        }    
-    }
-            
-// --------------------------------------------------------------------------------------------
-
-void CPerfMonDataPopupContainer::DrawUpdate()
-    {
-    DrawDeferred(); 
-    }
-    
-// --------------------------------------------------------------------------------------------
-       
-// End of File  
--- a/perfmon/src/perfmon_document.cpp	Fri Apr 16 14:59:17 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,83 +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 FILES
-#include "perfmon_document.h"
-#include "perfmon_appui.h"
-#include "perfmon_model.h"
-
-// ================= MEMBER FUNCTIONS =======================
-
-// constructor
-CPerfMonDocument::CPerfMonDocument(CEikApplication& aApp)
-: CAknDocument(aApp)    
-    {
-    }
-
-// ----------------------------------------------------
-
-// destructor
-CPerfMonDocument::~CPerfMonDocument()
-    {
-    delete iModel;
-    }
-
-// ----------------------------------------------------
-
-// EPOC default constructor can leave.
-void CPerfMonDocument::ConstructL()
-    {
-    iModel = CPerfMonModel::NewL();
-    }
-
-// ----------------------------------------------------
-
-// Two-phased constructor.
-CPerfMonDocument* CPerfMonDocument::NewL(CEikApplication& aApp)
-    {
-    CPerfMonDocument* self = new(ELeave) CPerfMonDocument(aApp);
-    CleanupStack::PushL(self);
-    self->ConstructL();
-    CleanupStack::Pop();
-
-    return self;
-    }
-    
-// ----------------------------------------------------
-// CPerfMonDocument::CreateAppUiL()
-// constructs CPerfMonAppUi
-// ----------------------------------------------------
-//
-CEikAppUi* CPerfMonDocument::CreateAppUiL()
-    {
-    return new (ELeave) CPerfMonAppUi;
-    }
-
-// ----------------------------------------------------
-// CPerfMonDocument::OpenFileL
-// Overrides CAknDocument::OpenFileL to support document file
-// ----------------------------------------------------
-//
-CFileStore* CPerfMonDocument::OpenFileL(TBool aDoOpen,const TDesC& aFilename,RFs& aFs)
-    {
-    return CEikDocument::OpenFileL(aDoOpen, aFilename, aFs);
-    }
-
-// ----------------------------------------------------
-
-// End of File  
--- a/perfmon/src/perfmon_graphscontainer.cpp	Fri Apr 16 14:59:17 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,233 +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 FILES
-#include "perfmon_graphscontainer.h"
-#include "perfmon.hrh"
-#include "perfmon_document.h"
-#include "perfmon_appui.h"
-#include "perfmon_model.h"
-
-#include <AknUtils.h>
-
-const TInt KAmountOfMicroSecondsFitsScreen = 20 * 1000000;
-#define KRgbCustomGrey TRgb(0x808080)
-
-_LIT(K100p, "100%"); 
-_LIT(K50p, "50%"); 
-_LIT(K0p, "0%"); 
-
-_LIT(KPercentageFormat,"%S %d%%");
-
-const TInt KMicroToSecondMultiplier = 1000000;
-
-// ===================================== MEMBER FUNCTIONS =====================================
-
-void CPerfMonGraphsContainer::ConstructL(const TRect& aRect)
-    {
-    iModel = static_cast<CPerfMonDocument*>(reinterpret_cast<CEikAppUi*>(iEikonEnv->AppUi())->Document())->Model();
-    //iFont = AknLayoutUtils::FontFromId(EAknLogicalFontPrimarySmallFont);
-    iFont = LatinBold12();
-
-    CreateWindowL();
-    SetRect(aRect);
-    SetBlank();
-
-    ActivateL();
-    }
-
-// --------------------------------------------------------------------------------------------
-
-CPerfMonGraphsContainer::~CPerfMonGraphsContainer()
-    {
-    }
-    
-// --------------------------------------------------------------------------------------------
-
-void CPerfMonGraphsContainer::Draw(const TRect& aRect) const
-    {
-    // draw black background
-    CWindowGc& gc = SystemGc();
-    gc.SetBrushColor(KRgbBlack);
-    gc.Clear(aRect);
-    
-    // activate font and get size
-    gc.UseFont(iFont);
-    TUint fontSize = iFont->FontMaxHeight();
-    //TInt fontBaseOffset = iFont->DescentInPixels();
-    
-
-    // calculate time factor
-    TReal scaleFactor = (TReal) aRect.Width() / (TReal) KAmountOfMicroSecondsFitsScreen;
-
-    // calculate area height which is used to draw the grpahs
-    TInt drawAreaHeight = aRect.Height() - fontSize - fontSize;
-        
-    
-    // check if sample array has been constructed
-    if (iModel->SampleEntryArray())
-        {
-        
-        // draw vertical time lines first
-        TInt verticalBarPeriodInSecs = iModel->Settings().iGraphsVerticalBarPeriod;
-        
-        if (verticalBarPeriodInSecs >= 1 && iModel->SampleEntryArray()->At(0).iSampleDataArray->Count() > 0)
-            {
-            // get time from the first sample
-            TSampleData& firstSample = iModel->SampleEntryArray()->At(0).iSampleDataArray->At(0);
-            TInt64 currentMicroSeconds = firstSample.iTimeFromStart.Int64();
-            
-            // calculate amount of microseconds exceeding value by using the modulo operator
-            TInt remainderInMicroSeconds = currentMicroSeconds % (verticalBarPeriodInSecs * 1000000); 
-            
-            // calculate first x pos
-            TInt vbarXpos = aRect.Width() - (remainderInMicroSeconds * scaleFactor);
-            
-            // calculate the amount in seconds
-            TInt barSeconds = (currentMicroSeconds - remainderInMicroSeconds) / KMicroToSecondMultiplier;
-
-            
-            // continue drawing periodically the vertical lines
-            while (vbarXpos >= 0 && barSeconds >= 0)
-                {
-                // draw vertical line    
-                gc.SetPenColor(KRgbDarkRed);
-                gc.DrawLine(TPoint(vbarXpos,fontSize+1), TPoint(vbarXpos,aRect.Height()-fontSize));
-                
-                // draw seconds value
-                gc.SetPenColor(KRgbCustomGrey);
-                TBuf<16> secsBuf;
-                secsBuf.AppendNum(barSeconds);    
-                secsBuf.Append(_L("s"));
-                gc.DrawText(secsBuf, TPoint(vbarXpos-(iFont->TextWidthInPixels(secsBuf)/2), aRect.Height()));    
-
-                // calculate new position
-                vbarXpos -= verticalBarPeriodInSecs * 1000000 * scaleFactor;
-                barSeconds -= verticalBarPeriodInSecs;
-                }
-            }
-        
-        // draw the basic grid
-        gc.SetPenColor(KRgbCustomGrey);
-    
-        gc.DrawLine(TPoint(0,fontSize), TPoint(aRect.Width(),fontSize));  // upper line
-        gc.DrawText(K100p, TPoint(0,fontSize));
-    
-        gc.DrawLine(TPoint(0,aRect.Height()/2), TPoint(aRect.Width(),aRect.Height()/2));  // mid line
-        gc.DrawText(K50p, TPoint(0,aRect.Height()/2));
-    
-        gc.DrawLine(TPoint(0,aRect.Height()-fontSize), TPoint(aRect.Width(),aRect.Height()-fontSize));  // bottom line
-        gc.DrawText(K0p, TPoint(0,aRect.Height()-fontSize));
-
-        TInt c(0);
-            
-        // draw graphs for each sampled type
-        for (TInt i=0; i<iModel->SampleEntryArray()->Count(); i++)
-            {
-            // check if this setting has been enabled and it has some data
-            if (iModel->Settings().iGraphsSources.iSrcEnabled[i] && iModel->SampleEntryArray()->At(i).iSampleDataArray->Count() > 0)
-                {
-                // set pen color for the graph
-                gc.SetPenColor(iModel->SampleEntryArray()->At(i).iGraphColor);
-                
-                // remember the position where drawing started
-                /*TReal*/TInt currentXPos(aRect.Width()); // start drawing from right            
-                /*TReal*/TInt currentYPos(0);
-                
-                // draw samples
-                for (TInt j=0; j<iModel->SampleEntryArray()->At(i).iSampleDataArray->Count() - 1; j++)
-                    {
-                    TSampleData& currentSample = iModel->SampleEntryArray()->At(i).iSampleDataArray->At(j);
-                    TSampleData& previousSample = iModel->SampleEntryArray()->At(i).iSampleDataArray->At(j+1);
-                    
-                    // calculate X position for previous (j+1)
-                    /*TReal*/TInt previousXPos = currentXPos -
-                        ( (Abs(previousSample.iTimeFromStart.Int64() - currentSample.iTimeFromStart.Int64())) * scaleFactor );
-                    
-
-                    // calculate initial Y position
-                    if (j==0)
-                        {
-                        currentYPos = currentSample.iSize > 0 ? (TReal)(currentSample.iFree) / (TReal)currentSample.iSize * drawAreaHeight + fontSize : aRect.Height()-fontSize;
-                        }
-
-                    // calculate Y position for previous (j+1)
-                    /*TReal*/TInt previousYPos = previousSample.iSize > 0 ? (TReal)(previousSample.iFree) / (TReal)previousSample.iSize * drawAreaHeight + fontSize : aRect.Height()-fontSize; 
-                    
-                    
-                    // draw a line between the previous and current
-                    gc.DrawLine(TPoint((TInt)previousXPos,(TInt)previousYPos), TPoint((TInt)currentXPos,(TInt)currentYPos));
-                    
-                    
-                    // draw current value in %
-                    if (j==0) // draw the value of first sample
-                        {
-                        TBuf<16> buf;
-                        buf.Format(KPercentageFormat, &iModel->SampleEntryArray()->At(i).iDescription, currentSample.iSize > 0 ? TInt( (1 - ((TReal)(currentSample.iFree) / (TReal)currentSample.iSize)) * 100) : 0 );
-      
-                        gc.DrawText(buf, TPoint(0,fontSize+fontSize+c*fontSize));
-                        c++;                    
-                        }
-                    
-                    
-                    // stop drawing if we have run out of space
-                    if (previousXPos < 0)
-                        break;
-                    
-                    // remeber previous values
-                    currentXPos = previousXPos;
-                    currentYPos = previousYPos;
-                    }
-                }
-            }
-        }
-
-    gc.DiscardFont();        
-    }
-
-// --------------------------------------------------------------------------------------------
-
-TKeyResponse CPerfMonGraphsContainer::OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType)
-    {
-    return CCoeControl::OfferKeyEventL(aKeyEvent, aType);
-    }
-        
-// --------------------------------------------------------------------------------------------
-
-void CPerfMonGraphsContainer::HandleResourceChange(TInt aType)
-    {
-    if (aType == KEikDynamicLayoutVariantSwitch)
-        {
-        TRect mainPaneRect;
-        AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, mainPaneRect);
-        SetRect(mainPaneRect);
-        }
-    else
-        CCoeControl::HandleResourceChange(aType);    
-    }
-
-// --------------------------------------------------------------------------------------------
-
-void CPerfMonGraphsContainer::DrawUpdate()
-    {
-    DrawDeferred();    
-    }
-    
-// --------------------------------------------------------------------------------------------
-            
-// End of File  
--- a/perfmon/src/perfmon_graphsview.cpp	Fri Apr 16 14:59:17 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,147 +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 FILES
-#include "perfmon.hrh"
-#include "perfmon_graphsview.h"
-#include "perfmon_graphscontainer.h"
-#include "perfmon_document.h" 
-#include "perfmon_model.h"
-#include <perfmon.rsg>
-
-#include <eikenv.h>
-#include <aknViewAppUi.h> 
-
-
-// ================= MEMBER FUNCTIONS =======================
-
-// ---------------------------------------------------------
-// CPerfMonGraphsView::ConstructL(const TRect& aRect)
-// EPOC two-phased constructor
-// ---------------------------------------------------------
-//
-void CPerfMonGraphsView::ConstructL()
-    {
-    BaseConstructL( R_PERFMON_VIEW_GRAPHS );
-    iModel = static_cast<CPerfMonDocument*>(reinterpret_cast<CEikAppUi*>(iEikonEnv->AppUi())->Document())->Model();
-    }
-
-// ---------------------------------------------------------
-// CPerfMonGraphsView::~CPerfMonGraphsView()
-// ---------------------------------------------------------
-//
-CPerfMonGraphsView::~CPerfMonGraphsView()
-    {
-    if (iContainer)
-        {
-        AppUi()->RemoveFromViewStack( *this, iContainer );
-        delete iContainer;
-        iContainer = NULL;
-        }
-    }
-
-// ---------------------------------------------------------
-// TUid CPerfMonGraphsView::Id()
-// ---------------------------------------------------------
-//
-TUid CPerfMonGraphsView::Id() const
-    {
-    return KGraphsViewUID;
-    }
-
-// ---------------------------------------------------------
-// TUid CPerfMonGraphsView::DynInitMenuPaneL(TInt aResourceId, CEikMenuPane* aMenuPane)
-// ---------------------------------------------------------
-//
-void CPerfMonGraphsView::DynInitMenuPaneL(TInt aResourceId, CEikMenuPane* aMenuPane)
-    {
-    AppUi()->DynInitMenuPaneL(aResourceId, aMenuPane);
-    }
-
-  
-// ---------------------------------------------------------
-// CPerfMonGraphsView::HandleCommandL(TInt aCommand)
-// ---------------------------------------------------------
-//
-void CPerfMonGraphsView::HandleCommandL(TInt aCommand)
-    {   
-/*
-    switch ( aCommand )
-        {
-        case EPerfMonCmdFileBack:
-            {
-            iModel->FileUtils()->MoveUpOneLevelL();
-            break;
-            }
-
-        default:
-            {
-*/
-            AppUi()->HandleCommandL( aCommand );
-/*
-            break;
-            }
-        }
-*/
-    }
-
-// ---------------------------------------------------------
-// CPerfMonGraphsView::HandleClientRectChange()
-// ---------------------------------------------------------
-//
-void CPerfMonGraphsView::HandleClientRectChange()
-    {
-    if ( iContainer )
-        {
-        iContainer->SetRect( ClientRect() );
-        }
-    }
-
-// ---------------------------------------------------------
-// CPerfMonGraphsView::DoActivateL(...)
-// ---------------------------------------------------------
-//
-void CPerfMonGraphsView::DoActivateL(
-   const TVwsViewId& /*aPrevViewId*/,TUid /*aCustomMessageId*/,
-   const TDesC8& /*aCustomMessage*/)
-    {
-    if (!iContainer)
-        {
-        iContainer = new (ELeave) CPerfMonGraphsContainer;
-        iModel->SetGraphsContainer(iContainer);
-        iContainer->SetMopParent(this);
-        iContainer->ConstructL( ClientRect() );
-        AppUi()->AddToStackL( *this, iContainer );
-        } 
-   }
-
-// ---------------------------------------------------------
-// CPerfMonGraphsView::DoDeactivate()
-// ---------------------------------------------------------
-//
-void CPerfMonGraphsView::DoDeactivate()
-    {
-    if (iContainer)
-        {
-        AppUi()->RemoveFromViewStack( *this, iContainer );
-        delete iContainer;
-        iContainer = NULL;
-        }
-    }
-
-// End of File
--- a/perfmon/src/perfmon_model.cpp	Fri Apr 16 14:59:17 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,951 +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 FILES
-
-#include "perfmon_model.h"
-#include "perfmon_app.h"
-#include "perfmon_settingsviewdlg.h"
-#include "perfmon.hrh"
-#include "perfmon_valuescontainer.h"
-#include "perfmon_graphscontainer.h"
-#include "perfmon_datapopupcontainer.h"
-#include <perfmon.rsg>
-
-#include <coeutils.h>
-#include <bautils.h>
-#include <eikenv.h>
-#include <e32hal.h>
-#include <u32std.h>
-#include <s32file.h>
-#include <akntitle.h> 
-#include <eikspane.h>
-#include <aknnotewrappers.h>  
-
-_LIT(KAppName, "PerfMon");
-_LIT(KDefaultLogFilePath, "c:\\data\\PerfMon.log");
-
-const TInt KCalibrationLength = 2;
-const TInt KMinimumSamplesLength = 16;
-const TInt KCPUTimeMultiplier = 1000000; // used to avoid TReal conversions
-
-const TInt KSettingsDrive = EDriveC;
-_LIT(KSettingsFileName, "perfmon_settings.ini");
-
-
-// --------------------------------------------------------------------------------------------
-
-TInt CPULoadCount(TAny* aInt)
-	{
-	// increase the counter
-	(*(TUint*)aInt)++;
-	return 1;
-	}
-
-TInt CPULoadNOPThread(TAny* aParam)
-	{
-	CTrapCleanup* pC = CTrapCleanup::New();
-	CActiveScheduler* pS = new CActiveScheduler;
-	CActiveScheduler::Install(pS);
-
-	CIdle* idle = CIdle::NewL(CActive::EPriorityStandard);
-	TCallBack cb(CPULoadCount, aParam);
-	idle->Start(cb);
-
-	pS->Start();
-
-	delete idle;
-	delete pS;
-	delete pC;
-
-	return 0;
-	}
-
-// ===================================== MEMBER FUNCTIONS =====================================
-
-CPerfMonModel* CPerfMonModel::NewL()
-	{
-	CPerfMonModel* self = new(ELeave) CPerfMonModel;
-	CleanupStack::PushL(self);
-	self->ConstructL();
-	CleanupStack::Pop();
-	return self;
-	}
-
-// --------------------------------------------------------------------------------------------
-
-CPerfMonModel::CPerfMonModel() : CActive(EPriorityUserInput)
-	{
-	}
-
-// --------------------------------------------------------------------------------------------
-
-void CPerfMonModel::ConstructL()
-	{
-	iDrawState = EDrawStateInvalid;
-	iCurrentCPUMode = ECPUModeNotSet;
-	iLogFileInitialized = EFalse;
-	
-    iEnv = CEikonEnv::Static();
-    User::LeaveIfError(iLs.Connect());
-
-    User::LeaveIfError(iTimer.CreateLocal());
-	CActiveScheduler::Add(this);
-	}
-
-// --------------------------------------------------------------------------------------------
-
-void CPerfMonModel::ActivateModelL()
-	{
-    // load settings
-    TRAP_IGNORE(LoadSettingsL());
-
-	// create data storages for the samples
-	CreateSamplesDataArrayL();
-	
-	// initialize the data popup container in top-right corner
-	iDataPopupContainer = new(ELeave) CPerfMonDataPopupContainer;
-	iDataPopupContainer->ConstructL(TRect(0,0,1,1));
-	
-	// set default modes
-	HandleSettingsChangeL();
-
-    // start sampling data immediately (jump to RunL)    
-    iTimer.After(iStatus, 100);
-    SetActive();
-	}
-
-// --------------------------------------------------------------------------------------------
-
-void CPerfMonModel::DeActivateModelL()
-	{
-	Cancel();
-	
-	DeActivateCPUMonitoring();
-
-	if (iDataPopupContainer)
-	    {
-	    delete iDataPopupContainer;
-	    iDataPopupContainer = NULL;
-	    }
-
-    // close log file
-	OpenLogFile(EFalse);
-	}
-	
-// --------------------------------------------------------------------------------------------
-
-CPerfMonModel::~CPerfMonModel()
-	{
-	iTimer.Close();
-
-    // clear data storages
-	if (iSampleEntryArray)
-	    {
-        for (TInt i=0; i<iSampleEntryArray->Count(); i++)
-            {
-            delete iSampleEntryArray->At(i).iSampleDataArray;
-            }
-	    
-	    delete iSampleEntryArray;
-	    }
-
-	    
-	iLs.Close();
-    }
-
-// --------------------------------------------------------------------------------------------
-
-void CPerfMonModel::DoCancel()
-	{
-    iTimer.Cancel();
-	}
-
-// --------------------------------------------------------------------------------------------
-
-void CPerfMonModel::RunL()
-	{
-	// calculate new values 
-	UpdateSamplesDataL();
-	
-	// log changes
-	AppendLatestSamplesToLogsL();
-	
-	// redraw views
-	SendDrawEventToContainersL();  
-
-    // continue
-    iTimer.After(iStatus, iSettings.iHeartBeat * 1000); // convert from milliseconds to microseconds
-    SetActive();
-	}
-
-// --------------------------------------------------------------------------------------------
-
-void CPerfMonModel::HandleSettingsChangeL()
-    {
-    // set priority of the thread
-    RThread().SetPriority(SettingItemToThreadPriority(iSettings.iPriority));
-    
-    // set visibility and location of the data popup
-    iDataPopupContainer->UpdateVisibility();
-    iDataPopupContainer->SetPositionAndSize();
-    
-    // init cpu monitor if setting has been changed
-    if (iCurrentCPUMode != iSettings.iCPUMode)
-        {
-        DeActivateCPUMonitoring();
-        ActivateCPUMonitoringL();
-        }
-    
-    // close log file
-    OpenLogFile(EFalse);
-    
-    // enable log file
-    if (iSettings.iLoggingEnabled && (iSettings.iLoggingMode == ELoggingModeLogFile || iSettings.iLoggingMode == ELoggingModeRDebugLogFile))
-        OpenLogFile(ETrue);
-    }
-
-// --------------------------------------------------------------------------------------------
-
-void CPerfMonModel::EnableLogging(TBool aEnable)
-    {
-    if (aEnable)
-        {
-        if (iSettings.iLoggingMode == ELoggingModeLogFile || iSettings.iLoggingMode == ELoggingModeRDebugLogFile)
-            OpenLogFile(ETrue);
-        
-        iSettings.iLoggingEnabled = ETrue;
-        }
-    else // disable
-        {
-        iSettings.iLoggingEnabled = EFalse;
-        OpenLogFile(EFalse);
-        }
-    }
-
-// --------------------------------------------------------------------------------------------
-
-void CPerfMonModel::OpenLogFile(TBool aOpen)
-    {
-    // open log file for writing
-    if (aOpen)
-        {
-        if (!iLogFileInitialized)
-            {
-            TInt err(KErrNone);
-            
-            // open the log file for writing
-            if (iLogFile.Open(iEnv->FsSession(), iSettings.iLoggingFilePath, EFileWrite) != KErrNone)
-                {
-                iEnv->FsSession().MkDirAll(iSettings.iLoggingFilePath);
-                err = iLogFile.Replace(iEnv->FsSession(), iSettings.iLoggingFilePath, EFileWrite);
-                }
-            else
-                {
-                // file opens correctly, seek to the end
-                TInt fileSize=0;
-                iLogFile.Size(fileSize);
-                err = iLogFile.Seek(ESeekCurrent, fileSize);
-                }
-            
-            if (err == KErrNone)
-                {
-                iLogFileInitialized = ETrue;
-                }
-            else
-                {
-                // show error
-                CAknErrorNote* note = new(ELeave) CAknErrorNote();
-                note->ExecuteLD(_L("Unable to create log file, check settings"));                
-                }
-            }        
-        }
-
-    // close handle to log file
-    else 
-        {
-        if (iLogFileInitialized)
-            {
-            iLogFile.Flush();
-            iLogFile.Close();
-            
-            iLogFileInitialized = EFalse;
-            }
-        }
-    }
-    
-// --------------------------------------------------------------------------------------------
-
-void CPerfMonModel::ActivateCPUMonitoringL()
-    {
-    // reset counter variables
-	iCPULoadCalibrating = ETrue;
-	iCPULoadCalibrationCounter = 0;
-	iCPULoadMaxValue = 999999999;
-	iCPULoadPreviousValue = 1;
-	iCPULoadCounter = 0;
-
-    // use null thread is cpu time is supported and the setting is on
-    if (CPUTimeSupported() && iSettings.iCPUMode == ECPUModeCPUTime) 
-        {
-        // try to open handle to null thread
-        if (OpenHandleToNullThread())
-            {
-            // handle is open, get initial value
-            TTimeIntervalMicroSeconds time;
-            iNullThread.GetCpuTime(time);
-            iCPULoadPreviousValue = time.Int64();
-            iPreviousTime.HomeTime();
-            
-            iCurrentCPUMode = ECPUModeCPUTime;
-            return; // cpu time is succesfully in use           
-            }
-        }
-
-    // otherwise use normal sampling with nops    
-    iCurrentCPUMode = ECPUModeNotSet;
-
-    // show a warning if cpu time cannot be taken in use
-    if (iSettings.iCPUMode == ECPUModeCPUTime)
-        {
-        CAknInformationNote* note = new(ELeave) CAknInformationNote();
-        note->ExecuteLD(_L("CPU Time not supported in this system, using NOPs sampling"));
-        }
-        
-    // create a thread for CPU load monitoring
-    User::LeaveIfError(iCPULoadThread.Create(_L("PerfMonCPULoad"), CPULoadNOPThread, 0x1000, 0x1000, 0x100000, &iCPULoadCounter));
-    iCPULoadThread.SetPriority(EPriorityLess);
-    iCPULoadThread.Resume();    
-    
-    iCurrentCPUMode = ECPUModeNOPs; // NOPs taken succesfully in use
-    }
-
-// --------------------------------------------------------------------------------------------
-
-TBool CPerfMonModel::OpenHandleToNullThread()
-    {
-    // find the kernel process and then the null thread
-    TFindProcess fp(_L("ekern.exe*"));
-    
-    TFullName kernelName;
-    if (fp.Next(kernelName) == KErrNone)
-        {
-        // process found, append null thread identifier
-        kernelName.Append(_L("::Null"));
-        
-        // find the thread
-        TFindThread ft(kernelName);
-
-        TFullName threadName;
-        if (ft.Next(threadName) == KErrNone)
-            {
-            // open instance to the thread
-            if (iNullThread.Open(threadName) != KErrNone)
-                return EFalse;                
-            }
-        }
-    
-    // process not found
-    else
-        return EFalse;
-    
-    // success!
-    return ETrue;        
-    }
-
-// --------------------------------------------------------------------------------------------
-
-void CPerfMonModel::DeActivateCPUMonitoring()
-    {
-    if (iCurrentCPUMode == ECPUModeCPUTime)
-        {
-        iNullThread.Close();
-        }
-    
-    else if (iCurrentCPUMode == ECPUModeNOPs)    
-        {
-        // kill the cpu load thread
-        iCPULoadThread.Kill(0);
-        iCPULoadThread.Close();        
-        } 
-    }
-
-// --------------------------------------------------------------------------------------------
-
-TBool CPerfMonModel::CPUTimeSupported()
-    {
-    TTimeIntervalMicroSeconds time;
-    TInt err = RThread().GetCpuTime(time);
-    
-    if (err == KErrNone && time.Int64() > 0)
-        return ETrue;
-    else
-        return EFalse;
-    }
-
-// --------------------------------------------------------------------------------------------
-
-TThreadPriority CPerfMonModel::SettingItemToThreadPriority(TInt aIndex)
-    {
-    TThreadPriority threadPriority = EPriorityNull;
-    
-    switch ( aIndex )
-        {
-        case EThreadPriorityTypeMuchLess:
-            {
-            threadPriority = EPriorityMuchLess; break;
-            }
-        case EThreadPriorityTypeLess:
-            {
-            threadPriority = EPriorityLess; break;
-            }
-        case EThreadPriorityTypeNormal:
-            {
-            threadPriority = EPriorityNormal; break;
-            }
-        case EThreadPriorityTypeMore:
-            {
-            threadPriority = EPriorityMore; break;
-            }
-        case EThreadPriorityTypeMuchMore:
-            {
-            threadPriority = EPriorityMuchMore; break;
-            }
-        case EThreadPriorityTypeRealTime:
-            {
-            threadPriority = EPriorityRealTime; break;
-            }
-        case EThreadPriorityTypeAbsoluteVeryLow:
-            {
-            threadPriority = EPriorityAbsoluteVeryLow; break;
-            }
-        case EThreadPriorityTypeAbsoluteLow:
-            {
-            threadPriority = EPriorityAbsoluteLow; break;
-            }
-        case EThreadPriorityTypeAbsoluteBackground:
-            {
-            threadPriority = EPriorityAbsoluteBackground; break;
-            }
-        case EThreadPriorityTypeAbsoluteForeground:
-            {
-            threadPriority = EPriorityAbsoluteForeground; break;
-            }
-        case EThreadPriorityTypeAbsoluteHigh:
-            {
-            threadPriority = EPriorityAbsoluteHigh; break;
-            }
-
-        default:
-            {
-            User::Panic(_L("Wrong tp index"), 276);
-            break;
-            }
-        }
-
-    return threadPriority;
-    }
-
-// --------------------------------------------------------------------------------------------
-
-void CPerfMonModel::CreateSamplesDataArrayL()
-    {
-    TInt maxSamples = iSettings.iMaxSamples >= KMinimumSamplesLength ? iSettings.iMaxSamples : KMinimumSamplesLength;
-
-    // create the data structure to store all samples
-    iSampleEntryArray = new(ELeave) CSampleEntryArray(16);
-
-    // add all source entries
-    for (TInt i=0; i<ESourcesLength; i++)
-        {
-        TSampleEntry newSampleEntry;
-        
-        if (i == ESourceCPU)
-            {
-            newSampleEntry.iDescription.Copy(_L("CPU"));
-            newSampleEntry.iUnitTypeShort.Copy(KNullDesC);
-            newSampleEntry.iUnitTypeLong.Copy(KNullDesC);
-            newSampleEntry.iDriveNumber = -1;
-            newSampleEntry.iGraphColor = KRgbYellow;            
-            }
-        
-        else if (i == ESourceRAM)
-            {
-            newSampleEntry.iDescription.Copy(_L("RAM"));
-            newSampleEntry.iUnitTypeShort.Copy(_L("b"));
-            newSampleEntry.iUnitTypeLong.Copy(_L("bytes"));
-            newSampleEntry.iDriveNumber = -1;
-            newSampleEntry.iGraphColor = KRgbGreen;            
-            }        
-        
-        else //drives
-            {
-            TChar driveLetter = 'C' + i-ESourceC; // C is the first drive
-
-            newSampleEntry.iDescription.Append(driveLetter);
-            newSampleEntry.iDescription.Append(_L(":"));
-            newSampleEntry.iUnitTypeShort.Copy(_L("b"));
-            newSampleEntry.iUnitTypeLong.Copy(_L("bytes"));
-            
-            iEnv->FsSession().CharToDrive(driveLetter, newSampleEntry.iDriveNumber);
-            
-            newSampleEntry.iGraphColor = KRgbCyan;
-            newSampleEntry.iGraphColor.SetGreen(255-(i-ESourceC)*30);
-            newSampleEntry.iGraphColor.SetRed(i*30);
-            }
-        
-        newSampleEntry.iSampleDataArray = new(ELeave) CSampleDataArray(maxSamples); 
-        
-        iSampleEntryArray->AppendL(newSampleEntry);        
-        }
-
-    // save current time as start time
-    iStartTime.HomeTime();
-    }
-	
-// --------------------------------------------------------------------------------------------
-
-void CPerfMonModel::UpdateSamplesDataL()
-    {
-    // reset inactivity timers
-    if (iSettings.iKeepBacklightOn)
-        User::ResetInactivityTime();
-   
-    // get current time
-    TTime currentTime;
-    currentTime.HomeTime();
-    
-    // calculate time difference
-    TTimeIntervalMicroSeconds timeDeltaFromPreviousSample = currentTime.MicroSecondsFrom(iPreviousTime);
-    
-    // remember current time as previous
-    iPreviousTime = currentTime;
-    
-    
-    // get CPU
-    TInt64 cpuLoadDelta(0);
-    TInt64 cpuLoadFree(0);
-    TInt64 cpuLoadSize(0);
-    TInt64 currentCPUValue(0);
-    
-    if (iCurrentCPUMode == ECPUModeCPUTime || iCurrentCPUMode == ECPUModeNOPs)
-        {
-        if (iCurrentCPUMode == ECPUModeCPUTime)
-            {
-            TTimeIntervalMicroSeconds time;
-            iNullThread.GetCpuTime(time);
-            currentCPUValue = time.Int64();
-            }
-        else if (iCurrentCPUMode == ECPUModeNOPs)
-            {
-            currentCPUValue = iCPULoadCounter;
-            }    
-            
-        // get delta and store the previous value
-        cpuLoadDelta = currentCPUValue - iCPULoadPreviousValue;
-        iCPULoadPreviousValue = currentCPUValue;
-        
-        // velocity = distance / time
-        cpuLoadFree = cpuLoadDelta * KCPUTimeMultiplier / timeDeltaFromPreviousSample.Int64();
-        
-
-        // detect maximum value
-        if (cpuLoadFree > iCPULoadMaxValue)
-            iCPULoadMaxValue = cpuLoadFree;
-     
-        
-        // check calibration status      
-    	if (iCPULoadCalibrating)
-    	    {
-    	    iCPULoadCalibrationCounter++;        
-            cpuLoadSize = cpuLoadFree;
-            
-            // check if need to calibrate anymore
-     	    if (iCPULoadCalibrationCounter > KCalibrationLength)
-    	        {
-    	        iCPULoadCalibrating = EFalse;
-    	        
-                // from the samples, get the minimum value, and let it be the max value 
-        		for (TInt i=0; i<iSampleEntryArray->At(0).iSampleDataArray->Count(); i++)
-        		    {
-        		    TInt64 newCPULoadMaxValue = iCPULoadMaxValue;
-        		    
-        		    if (iSampleEntryArray->At(0).iSampleDataArray->At(i).iFree < newCPULoadMaxValue)
-        		        {
-        		        newCPULoadMaxValue = iSampleEntryArray->At(0).iSampleDataArray->At(i).iFree;
-        		        }
-        		    
-        		    iCPULoadMaxValue = newCPULoadMaxValue;     		    
-        		    }	        
-    	        
-    	        // adjust priority of the poller thread
-                if (iCurrentCPUMode == ECPUModeNOPs)
-                    {
-                    iCPULoadThread.SetPriority(EPriorityAbsoluteVeryLow);
-                    }    	        
-    	        }
-
-    	    }
-    	else
-    	    {
-            cpuLoadSize = iCPULoadMaxValue;
-    	    }            
-        }
-
-	
-	// save cpu sample data    
-    TSampleData cpuSample;
-    cpuSample.iFree = cpuLoadFree;
-    cpuSample.iSize = cpuLoadSize;
-    cpuSample.iTimeFromStart = currentTime.MicroSecondsFrom(iStartTime);
-
-    iSampleEntryArray->At(0).iSampleDataArray->InsertL(0, cpuSample);
-    
- 
-    
-    // get ram memory
-    TMemoryInfoV1Buf ramMemory;
-    UserHal::MemoryInfo(ramMemory);
-    
-    TSampleData memorySample;
-    memorySample.iFree = ramMemory().iFreeRamInBytes;
-    memorySample.iSize = ramMemory().iMaxFreeRamInBytes;
-    memorySample.iTimeFromStart = currentTime.MicroSecondsFrom(iStartTime);
-
-    iSampleEntryArray->At(1).iSampleDataArray->InsertL(0, memorySample); 
-    
-    
-    // all drives
-    for (TInt i=2; i<iSampleEntryArray->Count(); i++)
-        {
-        TSampleData driveSample;
-        
-        // get volume info from RFs
-        TVolumeInfo volumeInfo;
-        if (iEnv->FsSession().Volume(volumeInfo, iSampleEntryArray->At(i).iDriveNumber) == KErrNone)
-            {
-            driveSample.iFree = volumeInfo.iFree;
-            driveSample.iSize = volumeInfo.iSize;
-            }
-        else
-            {
-            driveSample.iFree = 0;
-            driveSample.iSize = 0;
-            }    
-
-        driveSample.iTimeFromStart = currentTime.MicroSecondsFrom(iStartTime);
-    
-        iSampleEntryArray->At(i).iSampleDataArray->InsertL(0, driveSample); 
-        }
-    
-    
-    // compress sample data arrays to save memory
-    TInt curLength(iSampleEntryArray->At(0).iSampleDataArray->Count());
-    
-    TInt maxSamples = iSettings.iMaxSamples >= KMinimumSamplesLength ? iSettings.iMaxSamples : KMinimumSamplesLength;
-    
-    if (curLength > maxSamples && curLength % 5 == 0)
-        {
-        for (TInt i=0; i<iSampleEntryArray->Count(); i++)
-            {
-            iSampleEntryArray->At(i).iSampleDataArray->ResizeL(maxSamples); // looses old samples
-            iSampleEntryArray->At(i).iSampleDataArray->Compress();
-            }         
-        }
-    }
-
-// --------------------------------------------------------------------------------------------
-    
-void CPerfMonModel::AppendLatestSamplesToLogsL()
-    {
-    if (iSettings.iLoggingEnabled && SampleEntryArray())
-        {
-        // loop all sources
-        for (TInt i=0; i<SampleEntryArray()->Count(); i++)
-            {
-            // check if this setting has been enabled and it has some data
-            if (iSettings.iLoggingSources.iSrcEnabled[i] && SampleEntryArray()->At(i).iSampleDataArray->Count() > 0)
-                {
-                // get current sample
-                TSampleData& currentSample = SampleEntryArray()->At(i).iSampleDataArray->At(0);
-                
-                TBuf<128> buf;
-                buf.Append(_L("PERFMON;"));
-                buf.Append(SampleEntryArray()->At(i).iDescription);
-                buf.Append(_L(";"));
-                buf.AppendNum(currentSample.iTimeFromStart.Int64());
-                buf.Append(_L(";"));
-                buf.AppendNum(currentSample.iFree);
-                buf.Append(_L(";"));
-                buf.AppendNum(currentSample.iSize);
-
-                // print to RDebug
-                if (iSettings.iLoggingMode == ELoggingModeRDebug || iSettings.iLoggingMode == ELoggingModeRDebugLogFile)
-                    {
-                    RDebug::Print(buf);
-                    }
-                
-                // print to log file
-                if (iSettings.iLoggingMode == ELoggingModeLogFile || iSettings.iLoggingMode == ELoggingModeRDebugLogFile)
-                    {
-                    buf.Append(_L("\r\n"));
-                    
-                    TBuf8<128> buf8;
-                    buf8.Copy(buf);
-                    
-                    iLogFile.Write(buf8);
-                    }        
-                }
-            }
-        }
-    }
-
-// --------------------------------------------------------------------------------------------
-
-void CPerfMonModel::SetValuesContainer(CPerfMonValuesContainer* aContainer)
-    {
-    iValuesContainer = aContainer;
-    iDrawState = EDrawStateValues;
-    }
-
-// --------------------------------------------------------------------------------------------
-
-void CPerfMonModel::SetGraphsContainer(CPerfMonGraphsContainer* aContainer)
-    {
-    iGraphsContainer = aContainer;
-    iDrawState = EDrawStateGraphs;
-    }
-    
-// --------------------------------------------------------------------------------------------
-
-void CPerfMonModel::SendDrawEventToContainersL()
-    {
-    if (iDrawState == EDrawStateValues && iValuesContainer)
-        iValuesContainer->DrawUpdate();
-    else if (iDrawState == EDrawStateGraphs && iGraphsContainer)
-        iGraphsContainer->DrawUpdate();
-           
-    if (iDataPopupContainer)
-        iDataPopupContainer->DrawUpdate();
-    }
-            
-// --------------------------------------------------------------------------------------------
-
-void CPerfMonModel::LoadSettingsL()
-    {
-    // set defaults
-    iSettings.iHeartBeat = 600;
-    iSettings.iMaxSamples = 64;
-    iSettings.iPriority = EThreadPriorityTypeNormal;
-    iSettings.iCPUMode = ECPUModeCPUTime;
-    iSettings.iKeepBacklightOn = ETrue;
-
-    iSettings.iDataPopupVisibility = EDataPopupVisbilityAlwaysAlwaysOff;
-    iSettings.iDataPopupLocation = EDataPopupLocationTopRight;
-    iSettings.iDataPopupSources.SetDefaults1();
-
-    iSettings.iGraphsVerticalBarPeriod = 5;
-    iSettings.iGraphsSources.SetDefaults2();
-
-    iSettings.iLoggingMode = ELoggingModeRDebug;
-    iSettings.iLoggingFilePath.Copy(KDefaultLogFilePath);
-    iSettings.iLoggingSources.SetDefaults2();
-    
-    iSettings.iLoggingEnabled = EFalse;
-
-
-    // make sure that the private path of this app in c-drive exists
-    iEnv->FsSession().CreatePrivatePath( KSettingsDrive ); // c:\\private\\20011385\\
-    
-    // handle settings always in the private directory 
-    if (iEnv->FsSession().SetSessionToPrivate( KSettingsDrive ) == KErrNone)
-        {
-        // open or create a dictionary file store
-        CDictionaryFileStore* settingsStore = CDictionaryFileStore::OpenLC(iEnv->FsSession(), KSettingsFileName, KUidPerfMon);
-
-        LoadDFSValueL(settingsStore, KPMSettingHeartBeat,                   iSettings.iHeartBeat);
-        LoadDFSValueL(settingsStore, KPMSettingMaxSamples,                  iSettings.iMaxSamples);
-        LoadDFSValueL(settingsStore, KPMSettingPriority,                    iSettings.iPriority);
-        LoadDFSValueL(settingsStore, KPMSettingCPUMode,                     iSettings.iCPUMode);
-        LoadDFSValueL(settingsStore, KPMSettingKeepBackLightOn,             iSettings.iKeepBacklightOn);
-
-        LoadDFSValueL(settingsStore, KPMSettingDataPopupVisbility,          iSettings.iDataPopupVisibility);
-        LoadDFSValueL(settingsStore, KPMSettingDataPopupLocation,           iSettings.iDataPopupLocation);
-        LoadDFSValueL(settingsStore, KPMSettingDataPopupSources,            iSettings.iDataPopupSources);
-
-        LoadDFSValueL(settingsStore, KPMSettingGraphsVerticalBarPeriod,     iSettings.iGraphsVerticalBarPeriod);
-        LoadDFSValueL(settingsStore, KPMSettingGraphsSources,               iSettings.iGraphsSources);
-
-        LoadDFSValueL(settingsStore, KPMSettingLoggingMode,                 iSettings.iLoggingMode);
-        LoadDFSValueL(settingsStore, KPMSettingLoggingFilePath,             iSettings.iLoggingFilePath);
-        LoadDFSValueL(settingsStore, KPMSettingLoggingSources,              iSettings.iLoggingSources);
-
-        CleanupStack::PopAndDestroy(); // settingsStore         
-        }
-    }
-
-// --------------------------------------------------------------------------------------------
-
-void CPerfMonModel::SaveSettingsL()
-    {
-    // handle settings always in c:\\private\\20011385\\
-    if (iEnv->FsSession().SetSessionToPrivate( KSettingsDrive ) == KErrNone)
-        {
-        // delete existing store to make sure that it is clean and not eg corrupted
-        if (BaflUtils::FileExists(iEnv->FsSession(), KSettingsFileName))
-            {
-            iEnv->FsSession().Delete(KSettingsFileName);
-            }
-        
-        // create a dictionary file store
-        CDictionaryFileStore* settingsStore = CDictionaryFileStore::OpenLC(iEnv->FsSession(), KSettingsFileName, KUidPerfMon);
-
-        SaveDFSValueL(settingsStore, KPMSettingHeartBeat,                   iSettings.iHeartBeat);
-        SaveDFSValueL(settingsStore, KPMSettingMaxSamples,                  iSettings.iMaxSamples);
-        SaveDFSValueL(settingsStore, KPMSettingPriority,                    iSettings.iPriority);
-        SaveDFSValueL(settingsStore, KPMSettingCPUMode,                     iSettings.iCPUMode);
-        SaveDFSValueL(settingsStore, KPMSettingKeepBackLightOn,             iSettings.iKeepBacklightOn);
-
-        SaveDFSValueL(settingsStore, KPMSettingDataPopupVisbility,          iSettings.iDataPopupVisibility);
-        SaveDFSValueL(settingsStore, KPMSettingDataPopupLocation,           iSettings.iDataPopupLocation);
-        SaveDFSValueL(settingsStore, KPMSettingDataPopupSources,            iSettings.iDataPopupSources);
-
-        SaveDFSValueL(settingsStore, KPMSettingGraphsVerticalBarPeriod,     iSettings.iGraphsVerticalBarPeriod);
-        SaveDFSValueL(settingsStore, KPMSettingGraphsSources,               iSettings.iGraphsSources);
-
-        SaveDFSValueL(settingsStore, KPMSettingLoggingMode,                 iSettings.iLoggingMode);
-        SaveDFSValueL(settingsStore, KPMSettingLoggingFilePath,             iSettings.iLoggingFilePath);
-        SaveDFSValueL(settingsStore, KPMSettingLoggingSources,              iSettings.iLoggingSources);
-       
-        settingsStore->CommitL();
-        CleanupStack::PopAndDestroy(); // settingsStore             
-        }
-    }
-    	
-// --------------------------------------------------------------------------------------------
-
-TInt CPerfMonModel::LaunchSettingsDialogL()
-    {
-    // launch the settings dialog
-    TPerfMonSettings newSettings = iSettings;
-    
-    CPerfMonSettingsViewDlg* dlg = CPerfMonSettingsViewDlg::NewL(newSettings);
-    TInt returnValue = dlg->ExecuteLD(R_PERFMON_SETTINGS_DIALOG);
-    
-    // always save settings since the settings dialog does not provide a possibility to cancel
-    iSettings = newSettings;
-    SaveSettingsL();
-    HandleSettingsChangeL();
-
-    // make sure that the title of the application is correct
-    CEikStatusPane* sp = iEnv->AppUiFactory()->StatusPane();
-    CAknTitlePane* tp = static_cast<CAknTitlePane*>( sp->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) );
-    tp->SetTextL(KAppName);
-    
-    return returnValue;
-    }
-	
-// ---------------------------------------------------------------------------
-
-void CPerfMonModel::LoadDFSValueL(CDictionaryFileStore* aDicFS, const TUid& aUid, TInt& aValue)
-    {
-    if (aDicFS->IsPresentL(aUid))
-        {
-        RDictionaryReadStream in;
-        in.OpenLC(*aDicFS, aUid);
-        aValue = in.ReadInt16L();
-        CleanupStack::PopAndDestroy(); // in        
-        }
-    }
-
-// ---------------------------------------------------------------------------
-
-void CPerfMonModel::LoadDFSValueL(CDictionaryFileStore* aDicFS, const TUid& aUid, TDes& aValue)
-    {
-    if (aDicFS->IsPresentL(aUid))
-        {
-        RDictionaryReadStream in;
-        in.OpenLC(*aDicFS, aUid);
-        TInt bufLength = in.ReadInt16L();   // get length of descriptor
-        in.ReadL(aValue, bufLength);        // get the descriptor itself
-        CleanupStack::PopAndDestroy(); // in
-        }
-    }
-
-// ---------------------------------------------------------------------------
-
-void CPerfMonModel::LoadDFSValueL(CDictionaryFileStore* aDicFS, const TUid& aUid, TPerfMonSources& aValue)
-    {
-    if (aDicFS->IsPresentL(aUid))
-        {
-        RDictionaryReadStream in;
-        in.OpenLC(*aDicFS, aUid);
-        TInt bufLength = in.ReadInt16L();   // get length of the array
-        
-        if (bufLength < 0 || bufLength > ESourcesLength)     // check for validaty
-            User::Leave(KErrNotSupported);
-        
-        for (TInt i=0; i<bufLength; i++)    // get all items
-            aValue.iSrcEnabled[i] = in.ReadInt16L();
-        
-        CleanupStack::PopAndDestroy(); // in
-        }
-    }
-    
-// ---------------------------------------------------------------------------
-
-void CPerfMonModel::SaveDFSValueL(CDictionaryFileStore* aDicFS, const TUid& aUid, const TInt& aValue)
-    {
-    RDictionaryWriteStream out;
-    out.AssignLC(*aDicFS, aUid);
-    out.WriteInt16L(aValue);
-    out.CommitL(); 	
-    CleanupStack::PopAndDestroy(); // out
-    }
-
-// ---------------------------------------------------------------------------
-
-void CPerfMonModel::SaveDFSValueL(CDictionaryFileStore* aDicFS, const TUid& aUid, const TDes& aValue)
-    {
-    RDictionaryWriteStream out;
-    out.AssignLC(*aDicFS, aUid);
-    out.WriteInt16L(aValue.Length());       // write length of the descriptor
-    out.WriteL(aValue, aValue.Length());    // write the descriptor itself
-    out.CommitL(); 	
-    CleanupStack::PopAndDestroy(); // out
-    }
-
-// ---------------------------------------------------------------------------
-
-void CPerfMonModel::SaveDFSValueL(CDictionaryFileStore* aDicFS, const TUid& aUid, const TPerfMonSources& aValue)
-    {
-    RDictionaryWriteStream out;
-    out.AssignLC(*aDicFS, aUid);
-    
-    out.WriteInt16L(ESourcesLength);        // write length of the array
-    
-    for (TInt i=0; i<ESourcesLength; i++)   // write all items
-        out.WriteInt16L(aValue.iSrcEnabled[i]);
-    
-    out.CommitL(); 	
-    CleanupStack::PopAndDestroy(); // out
-    }
-    
-// ---------------------------------------------------------------------------
-    
-// End of File
--- a/perfmon/src/perfmon_settingsviewdlg.cpp	Fri Apr 16 14:59:17 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,681 +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 FILES
-#include "perfmon_settingsviewdlg.h"
-#include "perfmon_model.h"
-#include "perfmon.hrh"
-#include "perfmon_std.h"
-#include <perfmon.rsg>
-
-#include <aknsettingitemlist.h>
-#include <CAknMemorySelectionSettingItem.h> 
-#include <aknlists.h>
-#include <akntitle.h>
-#include <aknnavi.h>
-#include <aknnavide.h>
-#include <StringLoader.h>
-#include <aknnotewrappers.h> 
-
-// ===================================== MEMBER FUNCTIONS =====================================
-
-CPerfMonSettingsViewDlg* CPerfMonSettingsViewDlg::NewL(TPerfMonSettings& aSettings)
-    {
-    CPerfMonSettingsViewDlg* self = new(ELeave) CPerfMonSettingsViewDlg(aSettings);
-    CleanupStack::PushL(self);
-    self->ConstructL();
-    CleanupStack::Pop(self);
-    return self;    
-    }
-
-// --------------------------------------------------------------------------------------------
-
-CPerfMonSettingsViewDlg::~CPerfMonSettingsViewDlg()
-    {
-    // restore default navi pane by popping the tab group from stack
-    if (iNaviContainer)
-        iNaviContainer->Pop();
-    
-    if (iSettingItemArray)
-        {
-        iSettingItemArray->ResetAndDestroy();
-        delete iSettingItemArray; 
-        }
-    
-    delete iDecoratedTabGroup;   
-    }
-
-// --------------------------------------------------------------------------------------------
-
-CPerfMonSettingsViewDlg::CPerfMonSettingsViewDlg(TPerfMonSettings& aSettings) : iSettings(aSettings)
-    {
-    }
-
-// --------------------------------------------------------------------------------------------
-
-void CPerfMonSettingsViewDlg::ConstructL()
-    {
-    // construct a menu bar
-    CAknDialog::ConstructL(R_PERFMON_SETTINGS_MENUBAR);
-
-    // get pointer to status pane   
-    CEikStatusPane* sp = iEikonEnv->AppUiFactory()->StatusPane();
-    
-    // set title text
-    CAknTitlePane* tp = static_cast<CAknTitlePane*>( sp->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) );
-    tp->SetTextL( _L("Settings") );
-    
-    // create a new tab group
-    iNaviContainer = static_cast<CAknNavigationControlContainer*>(sp->ControlL(TUid::Uid(EEikStatusPaneUidNavi)));
-    iDecoratedTabGroup = iNaviContainer->CreateTabGroupL(this);
-    iTabGroup = static_cast<CAknTabGroup*>(iDecoratedTabGroup->DecoratedControl());
-    iTabGroup->SetTabFixedWidthL(KTabWidthWithTwoLongTabs); 
-    
-    // add tabs
-    iTabGroup->AddTabL(ETabSettingsGeneral, _L("General"));
-    iTabGroup->AddTabL(ETabSettingsDataPopup, _L("Data popup"));
-    iTabGroup->AddTabL(ETabSettingsGraphs, _L("Graphs"));
-    iTabGroup->AddTabL(ETabSettingsLogging, _L("Logging"));
-    iTabGroup->SetActiveTabByIndex(ETabSettingsGeneral);
-    
-    // add new tab group to stack
-    iNaviContainer->PushL( *iDecoratedTabGroup );
-    }
-
-// --------------------------------------------------------------------------------------------
-
-void CPerfMonSettingsViewDlg::HandleListBoxEventL(CEikListBox* /*aListBox*/, TListBoxEvent aEventType)
-    {
-    switch (aEventType)
-        {
-        case EEventEnterKeyPressed:
-        case EEventItemDoubleClicked:
-            ShowSettingPageL(EFalse);
-            break;
-        default:
-            break;
-        }
-    }
-
-// --------------------------------------------------------------------------------------------
-
-void CPerfMonSettingsViewDlg::TabChangedL(TInt /*aIndex*/)
-    {
-    iListBox->SetCurrentItemIndex(0);
-
-    SetVisibilitiesOfSettingItemsL();   
-    }
-
-// --------------------------------------------------------------------------------------------
-
-void CPerfMonSettingsViewDlg::ProcessCommandL(TInt aCommandId)
-    {
-    CAknDialog::ProcessCommandL(aCommandId);
-
-    switch (aCommandId)
-        {
-        case EPerfMonCmdSettingsChange:
-            ShowSettingPageL(ETrue);
-            break;
-        case EPerfMonCmdSettingsExit:
-            TryExitL(EAknCmdExit);
-            break;
-        default:
-            break;
-        }
-    }
-
-// --------------------------------------------------------------------------------------------
-
-TKeyResponse CPerfMonSettingsViewDlg::OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType)
-    {
-    if (iTabGroup == NULL)
-        {
-        return EKeyWasNotConsumed;
-        }
-
-    TInt active = iTabGroup->ActiveTabIndex();
-    TInt count = iTabGroup->TabCount();
-
-    switch ( aKeyEvent.iCode )
-        {
-        case EKeyLeftArrow:
-            if (active > 0)
-                {
-                active--;
-                iTabGroup->SetActiveTabByIndex(active);
-                TabChangedL(active); 
-                }
-            break;
-        
-        case EKeyRightArrow:
-            if((active + 1) < count)
-                {
-                active++;
-                iTabGroup->SetActiveTabByIndex(active);
-                TabChangedL(active); 
-                }
-            break;
-        }
-
-    return CAknDialog::OfferKeyEventL(aKeyEvent, aType);
-    }    
-
-// --------------------------------------------------------------------------------------------
-
-void CPerfMonSettingsViewDlg::PreLayoutDynInitL()
-    {
-    iListBox = static_cast<CAknSettingStyleListBox*>( Control(EPerfMonSettingItemList) );
-    iListBox->SetMopParent(this);
-    iListBox->CreateScrollBarFrameL(ETrue);
-    iListBox->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto);
-    iListBox->SetListBoxObserver(this);
-
-    iSettingItemArray = new(ELeave) CAknSettingItemArray(16, EFalse, 0);
-
-    CTextListBoxModel* model = iListBox->Model();
-    model->SetItemTextArray(iSettingItemArray);
-    model->SetOwnershipType(ELbmDoesNotOwnItemArray);
-
-    UpdateListBoxL();    
-    }
-
-// --------------------------------------------------------------------------------------------
-
-TBool CPerfMonSettingsViewDlg::OkToExitL(TInt aButtonId)
-    {
-    return CAknDialog::OkToExitL(aButtonId);
-    }
-
-// --------------------------------------------------------------------------------------------
-
-void CPerfMonSettingsViewDlg::ShowSettingPageL(TInt aCalledFromMenu)
-    {
-    TInt listIndex = iListBox->CurrentItemIndex();
-    TInt realIndex = iSettingItemArray->ItemIndexFromVisibleIndex(listIndex);
-    CAknSettingItem* item = iSettingItemArray->At(realIndex);
-    item->EditItemL(aCalledFromMenu);
-    item->StoreL();
-    SetVisibilitiesOfSettingItemsL();
-    DrawNow();
-    }
-
-// --------------------------------------------------------------------------------------------
-
-void CPerfMonSettingsViewDlg::SetVisibilitiesOfSettingItemsL()
-    {
-    if (iSettingItemArray->Count() > 0)
-        {
-        switch (iTabGroup->ActiveTabIndex())
-            {
-            case ETabSettingsGeneral:
-                {
-                ((*iSettingItemArray)[ESettingListItemHeartBeat])->SetHidden(EFalse);
-                ((*iSettingItemArray)[ESettingListItemMaxSamples])->SetHidden(EFalse);
-                ((*iSettingItemArray)[ESettingListItemPriority])->SetHidden(EFalse);
-                ((*iSettingItemArray)[ESettingListItemCPUMode])->SetHidden(EFalse);
-                ((*iSettingItemArray)[ESettingListItemKeepBackLightOn])->SetHidden(EFalse);
-
-                ((*iSettingItemArray)[ESettingListItemDataPopupVisbility])->SetHidden(ETrue);
-                ((*iSettingItemArray)[ESettingListItemDataPopupLocation])->SetHidden(ETrue);
-                ((*iSettingItemArray)[ESettingListItemDataPopupSources])->SetHidden(ETrue);
-
-                ((*iSettingItemArray)[ESettingListItemGraphsVerticalBarPeriod])->SetHidden(ETrue);
-                ((*iSettingItemArray)[ESettingListItemGraphsSources])->SetHidden(ETrue);
-
-                ((*iSettingItemArray)[ESettingListItemLoggingMode])->SetHidden(ETrue);
-                ((*iSettingItemArray)[ESettingListItemLoggingFilePath])->SetHidden(ETrue);
-                ((*iSettingItemArray)[ESettingListItemLoggingSources])->SetHidden(ETrue);
-
-                break;
-                }
-            
-            case ETabSettingsDataPopup:
-                {
-                ((*iSettingItemArray)[ESettingListItemHeartBeat])->SetHidden(ETrue);
-                ((*iSettingItemArray)[ESettingListItemMaxSamples])->SetHidden(ETrue);
-                ((*iSettingItemArray)[ESettingListItemPriority])->SetHidden(ETrue);
-                ((*iSettingItemArray)[ESettingListItemCPUMode])->SetHidden(ETrue);
-                ((*iSettingItemArray)[ESettingListItemKeepBackLightOn])->SetHidden(ETrue);
-
-                ((*iSettingItemArray)[ESettingListItemDataPopupVisbility])->SetHidden(EFalse);
-                ((*iSettingItemArray)[ESettingListItemDataPopupLocation])->SetHidden(EFalse);
-                ((*iSettingItemArray)[ESettingListItemDataPopupSources])->SetHidden(EFalse);
-
-                ((*iSettingItemArray)[ESettingListItemGraphsVerticalBarPeriod])->SetHidden(ETrue);
-                ((*iSettingItemArray)[ESettingListItemGraphsSources])->SetHidden(ETrue);
-
-                ((*iSettingItemArray)[ESettingListItemLoggingMode])->SetHidden(ETrue);
-                ((*iSettingItemArray)[ESettingListItemLoggingFilePath])->SetHidden(ETrue);
-                ((*iSettingItemArray)[ESettingListItemLoggingSources])->SetHidden(ETrue);
-
-                break;
-                }
-
-            case ETabSettingsGraphs:
-                {
-                ((*iSettingItemArray)[ESettingListItemHeartBeat])->SetHidden(ETrue);
-                ((*iSettingItemArray)[ESettingListItemMaxSamples])->SetHidden(ETrue);
-                ((*iSettingItemArray)[ESettingListItemPriority])->SetHidden(ETrue);
-                ((*iSettingItemArray)[ESettingListItemCPUMode])->SetHidden(ETrue);
-                ((*iSettingItemArray)[ESettingListItemKeepBackLightOn])->SetHidden(ETrue);
-
-                ((*iSettingItemArray)[ESettingListItemDataPopupVisbility])->SetHidden(ETrue);
-                ((*iSettingItemArray)[ESettingListItemDataPopupLocation])->SetHidden(ETrue);
-                ((*iSettingItemArray)[ESettingListItemDataPopupSources])->SetHidden(ETrue);
-
-                ((*iSettingItemArray)[ESettingListItemGraphsVerticalBarPeriod])->SetHidden(EFalse);
-                ((*iSettingItemArray)[ESettingListItemGraphsSources])->SetHidden(EFalse);
-
-                ((*iSettingItemArray)[ESettingListItemLoggingMode])->SetHidden(ETrue);
-                ((*iSettingItemArray)[ESettingListItemLoggingFilePath])->SetHidden(ETrue);
-                ((*iSettingItemArray)[ESettingListItemLoggingSources])->SetHidden(ETrue);
-
-                break;
-                }
-
-            case ETabSettingsLogging:
-                {
-                ((*iSettingItemArray)[ESettingListItemHeartBeat])->SetHidden(ETrue);
-                ((*iSettingItemArray)[ESettingListItemMaxSamples])->SetHidden(ETrue);
-                ((*iSettingItemArray)[ESettingListItemPriority])->SetHidden(ETrue);
-                ((*iSettingItemArray)[ESettingListItemCPUMode])->SetHidden(ETrue);
-                ((*iSettingItemArray)[ESettingListItemKeepBackLightOn])->SetHidden(ETrue);
-
-                ((*iSettingItemArray)[ESettingListItemDataPopupVisbility])->SetHidden(ETrue);
-                ((*iSettingItemArray)[ESettingListItemDataPopupLocation])->SetHidden(ETrue);
-                ((*iSettingItemArray)[ESettingListItemDataPopupSources])->SetHidden(ETrue);
-
-                ((*iSettingItemArray)[ESettingListItemGraphsVerticalBarPeriod])->SetHidden(ETrue);
-                ((*iSettingItemArray)[ESettingListItemGraphsSources])->SetHidden(ETrue);
-
-                ((*iSettingItemArray)[ESettingListItemLoggingMode])->SetHidden(EFalse);
-                
-                if (iSettings.iLoggingMode == ELoggingModeLogFile || iSettings.iLoggingMode == ELoggingModeRDebugLogFile)
-                    ((*iSettingItemArray)[ESettingListItemLoggingFilePath])->SetHidden(EFalse);
-                else
-                    ((*iSettingItemArray)[ESettingListItemLoggingFilePath])->SetHidden(ETrue);
-                
-                ((*iSettingItemArray)[ESettingListItemLoggingSources])->SetHidden(EFalse);
-
-                break;
-                }                
-
-            default:
-                User::Panic(_L("TabIOOB"), 50);
-                break;
-            }
-
-        iSettingItemArray->RecalculateVisibleIndicesL();
-        iListBox->HandleItemAdditionL();
-        iListBox->UpdateScrollBarsL();
-        }
-    }   
-
-// --------------------------------------------------------------------------------------------
-
-void CPerfMonSettingsViewDlg::UpdateListBoxL()
-    {
-    iSettingItemArray->ResetAndDestroy();
-
-    // create items
-    TInt ordinal(0);
-
-    AddSettingItemL(ESettingListItemHeartBeat,
-                    R_HEARTBEAT_SETTING_TITLE,
-                    R_HEARTBEAT_SETTING_PAGE,
-                    NULL,
-                    ordinal++);    
-    
-    AddSettingItemL(ESettingListItemMaxSamples,
-                    R_MAXSAMPLES_SETTING_TITLE,
-                    R_MAXSAMPLES_SETTING_PAGE,
-                    NULL,
-                    ordinal++);
-
-    AddSettingItemL(ESettingListItemPriority,
-                    R_PRIORITY_SETTING_TITLE,
-                    R_PRIORITY_SETTING_PAGE,
-                    R_PRIORITY_SETTING_TEXTS,
-                    ordinal++);
-
-    AddSettingItemL(ESettingListItemCPUMode,
-                    R_CPUMODE_SETTING_TITLE,
-                    R_CPUMODE_SETTING_PAGE,
-                    R_CPUMODE_SETTING_TEXTS,
-                    ordinal++);
-
-    AddSettingItemL(ESettingListItemKeepBackLightOn,
-                    R_KEEPBACKLIGHTON_SETTING_TITLE,
-                    R_BINARY_SETTING_PAGE,
-                    R_YESNO_BINARYSELECTION_TEXTS,
-                    ordinal++);
-//
-    AddSettingItemL(ESettingListItemDataPopupVisbility,
-                    R_DATAPOPUPVISIBILITY_SETTING_TITLE,
-                    R_DATAPOPUPVISIBILITY_SETTING_PAGE,
-                    R_DATAPOPUPVISIBILITY_SETTING_TEXTS,
-                    ordinal++);
-
-    AddSettingItemL(ESettingListItemDataPopupLocation,
-                    R_DATAPOPUPLOCATION_SETTING_TITLE,
-                    R_DATAPOPUPLOCATION_SETTING_PAGE,
-                    R_DATAPOPUPLOCATION_SETTING_TEXTS,
-                    ordinal++);
-
-    AddSettingItemL(ESettingListItemDataPopupSources,
-                    R_SOURCES_SETTING_TITLE,
-                    R_SOURCES_SETTING_PAGE,
-                    NULL,
-                    ordinal++);                    
-//
-    AddSettingItemL(ESettingListItemGraphsVerticalBarPeriod,
-                    R_GRAPHSVERTICALBAR_SETTING_TITLE,
-                    R_GRAPHSVERTICALBAR_SETTING_PAGE,
-                    NULL,
-                    ordinal++);
-    
-    AddSettingItemL(ESettingListItemGraphsSources,
-                    R_SOURCES_SETTING_TITLE,
-                    R_SOURCES_SETTING_PAGE,
-                    NULL,
-                    ordinal++);                    
-//
-    AddSettingItemL(ESettingListItemLoggingMode,
-                    R_LOGGINGMODE_SETTING_TITLE,
-                    R_LOGGINGMODE_SETTING_PAGE,
-                    R_LOGGINGMODE_SETTING_TEXTS,
-                    ordinal++);
-
-     AddSettingItemL(ESettingListItemLoggingFilePath,
-                    R_LOGGINGFILEPATH_SETTING_TITLE,
-                    R_LOGGINGFILEPATH_SETTING_PAGE,
-                    NULL,
-                    ordinal++);
-    
-    AddSettingItemL(ESettingListItemLoggingSources,
-                    R_SOURCES_SETTING_TITLE,
-                    R_SOURCES_SETTING_PAGE,
-                    NULL,
-                    ordinal++);                    
-                                                             
-    SetVisibilitiesOfSettingItemsL(); 
-    }
-
-// --------------------------------------------------------------------------------------------
-
-void CPerfMonSettingsViewDlg::AddSettingItemL(TInt aId,
-                                                 TInt aTitleResource,
-                                                 TInt aSettingPageResource,
-                                                 TInt aAssociatedResource,
-                                                 TInt aOrdinal)
-    {
-    // create a setting item
-    CAknSettingItem* settingItem = NULL;
-    
-    switch (aId)
-        {
-        case ESettingListItemHeartBeat:
-            settingItem = new(ELeave) CAknIntegerEdwinSettingItem(aId, iSettings.iHeartBeat);
-            break;
-
-        case ESettingListItemMaxSamples:
-            settingItem = new(ELeave) CAknIntegerEdwinSettingItem(aId, iSettings.iMaxSamples);
-            break;
-
-        case ESettingListItemPriority:
-            settingItem = new(ELeave) CAknEnumeratedTextPopupSettingItem(aId, iSettings.iPriority);
-            break;
-
-        case ESettingListItemCPUMode:
-            settingItem = new(ELeave) CAknEnumeratedTextPopupSettingItem(aId, iSettings.iCPUMode);
-            break;
-
-        case ESettingListItemKeepBackLightOn:
-            settingItem = new(ELeave) CAknBinaryPopupSettingItem(aId, iSettings.iKeepBacklightOn);
-            break;
-
-        case ESettingListItemDataPopupVisbility:
-            settingItem = new(ELeave) CAknEnumeratedTextPopupSettingItem(aId, iSettings.iDataPopupVisibility);
-            break;
-
-        case ESettingListItemDataPopupLocation:
-            settingItem = new(ELeave) CAknEnumeratedTextPopupSettingItem(aId, iSettings.iDataPopupLocation);
-            break;
-
-        case ESettingListItemDataPopupSources:
-            settingItem = new(ELeave) CSourceSelectionCheckBoxSettingItem(aId, iSettings.iDataPopupSources);
-            break;
-
-        case ESettingListItemGraphsVerticalBarPeriod:
-            settingItem = new(ELeave) CAknIntegerEdwinSettingItem(aId, iSettings.iGraphsVerticalBarPeriod);
-            break;
-
-        case ESettingListItemGraphsSources:
-            settingItem = new(ELeave) CSourceSelectionCheckBoxSettingItem(aId, iSettings.iGraphsSources);
-            break;
-
-        case ESettingListItemLoggingMode:
-            settingItem = new(ELeave) CAknEnumeratedTextPopupSettingItem(aId, iSettings.iLoggingMode);
-            break;
-
-        case ESettingListItemLoggingFilePath:
-            settingItem = new(ELeave) CAknTextSettingItem(aId, iSettings.iLoggingFilePath);
-            break;
-
-        case ESettingListItemLoggingSources:
-            settingItem = new(ELeave) CSourceSelectionCheckBoxSettingItem(aId, iSettings.iLoggingSources);
-            break;
-
-        default:
-            User::Panic(_L("NotSetItem"), 50);
-            break;
-        }
-        
-    CleanupStack::PushL(settingItem);
-
-    // get title text
-    HBufC* itemTitle = StringLoader::LoadLC(aTitleResource);
-
-    // construct the setting item
-    settingItem->ConstructL(EFalse, aOrdinal, *itemTitle, NULL, aSettingPageResource,
-                            EAknCtPopupSettingList, NULL, aAssociatedResource);
-
-    // append the setting item to settingitem array
-    iSettingItemArray->InsertL(aOrdinal, settingItem);
-
-    CleanupStack::PopAndDestroy(); //itemTitle
-    CleanupStack::Pop(); //settingItem
-    }
-
-
-// --------------------------------------------------------------------------------------------
-// --------------------------------------------------------------------------------------------
-	
-CSourceSelectionCheckBoxSettingItem::CSourceSelectionCheckBoxSettingItem( TInt aIdentifier, TPerfMonSources& aMemoryInUse ): 
-	CAknSettingItem(aIdentifier), iExternalSources( aMemoryInUse ) 
-	{
-	}	
-
-CSourceSelectionCheckBoxSettingItem::~CSourceSelectionCheckBoxSettingItem()
-	{
-	delete iSettingText;
-
-    if( iItemArray )
-        {
-        iItemArray->ResetAndDestroy();
-        delete iItemArray;
-        }
-	}
-
-void CSourceSelectionCheckBoxSettingItem::AddNewItemToArrayL(const TDesC& aLabel)
-	{
-	TBuf<64> buf;
-	buf.Copy(aLabel);
-	
-    CSelectableItem* item = new(ELeave) CSelectableItem(buf, EFalse);
-    CleanupStack::PushL(item);
-    item->ConstructL();
-    iItemArray->AppendL(item); // Ownership is transferred
-    CleanupStack::Pop(); // item	
-	}
-	
-void CSourceSelectionCheckBoxSettingItem::CompleteConstructionL()
-	{
-    SetEmptyItemTextL(_L("Nothing selected"));
-
-    iItemArray = new(ELeave) CSelectionItemList(16);
-    AddNewItemToArrayL(_L("CPU"));
-    AddNewItemToArrayL(_L("RAM"));
-    AddNewItemToArrayL(_L("C:"));
-    AddNewItemToArrayL(_L("D:"));
-    AddNewItemToArrayL(_L("E:"));
-    AddNewItemToArrayL(_L("F:"));
-    AddNewItemToArrayL(_L("G:"));
-    AddNewItemToArrayL(_L("H:"));
-    AddNewItemToArrayL(_L("I:"));
-
-	__ASSERT_ALWAYS(ESourcesLength==iItemArray->Count(), User::Panic(_L("Src.mismatch"),443));
-    }
-
-// transfer settings to the variables defined in the constructor    	
-void CSourceSelectionCheckBoxSettingItem::StoreL()
-	{
-	for (TInt i=0; i<ESourcesLength; i++)
-	    {
-        iExternalSources.iSrcEnabled[i] = iItemArray->At(i)->SelectionStatus();
-	    }
-	}
-
-// load settings from the variables defined in the constructor to our internal variables
-void CSourceSelectionCheckBoxSettingItem::LoadL()
-	{
-	for (TInt i=0; i<ESourcesLength; i++)
-	    {
-        iItemArray->At(i)->SetSelectionStatus( iExternalSources.iSrcEnabled[i] );
-	    }
-	}
-
-// returns the text shown in the setting item list
-const TDesC& CSourceSelectionCheckBoxSettingItem::SettingTextL()
-	{
-    TBuf<32> settingText;
-
-    if (iItemArray->At(ESourceCPU)->SelectionStatus())
-        settingText.Append(_L("CPU "));
-    if (iItemArray->At(ESourceRAM)->SelectionStatus())
-        settingText.Append(_L("RAM "));
-    if (iItemArray->At(ESourceC)->SelectionStatus())
-        settingText.Append(_L("C: "));
-    if (iItemArray->At(ESourceD)->SelectionStatus())
-        settingText.Append(_L("D: "));
-    if (iItemArray->At(ESourceE)->SelectionStatus())
-        settingText.Append(_L("E: "));
-    if (iItemArray->At(ESourceF)->SelectionStatus())
-        settingText.Append(_L("F: "));
-    if (iItemArray->At(ESourceG)->SelectionStatus())
-        settingText.Append(_L("G: "));
-    if (iItemArray->At(ESourceH)->SelectionStatus())
-        settingText.Append(_L("H: "));
-    if (iItemArray->At(ESourceI)->SelectionStatus())
-        settingText.Append(_L("I: "));
-    settingText.TrimAll();
-
-    if (iSettingText)
-        {
-        delete iSettingText;
-        iSettingText = NULL;
-        }
-
-    iSettingText = HBufC::NewL(settingText.Length());
-    iSettingText->Des().Copy(settingText);
-
-	if ( iSettingText->Length() > 0 )
-		return *iSettingText;
-	else
-		return EmptyItemText();
-	}
-
-
-// launches the setting page
-void CSourceSelectionCheckBoxSettingItem::EditItemL(TBool /*aCalledFromMenu*/)
-	{
-	CSourceSelectionCheckBoxSettingPage* dlg = new(ELeave) CSourceSelectionCheckBoxSettingPage(SettingPageResourceId(), iItemArray);
-
-	SetSettingPage( dlg );
-	SettingPage()->SetSettingPageObserver(this);
-
-	SettingPage()->ExecuteLD(CAknSettingPage::EUpdateWhenChanged);
-	SetSettingPage(0); // it is deleted now
-	}
-
-
-// handles setting page events
-void CSourceSelectionCheckBoxSettingItem::HandleSettingPageEventL( CAknSettingPage* aSettingPage, TAknSettingPageEvent aEventType )
-    {
-    switch( aEventType )
-        {
-        case EEventSettingCancelled:
-            {
-            // If setting is cancelled, load old values
-            LoadL();
-            break;
-            }
-        case EEventSettingChanged:
-            {
-            // If setting has changed, update CBA visibility
-            static_cast<CSourceSelectionCheckBoxSettingPage*>( aSettingPage )->UpdateCba();
-            break;
-            }
-        default:
-            {
-            break;
-            }
-        }
-    CAknSettingItem::HandleSettingPageEventL( aSettingPage, aEventType );
-    }
-
-// --------------------------------------------------------------------------------------------
-// --------------------------------------------------------------------------------------------
-
-CSourceSelectionCheckBoxSettingPage::CSourceSelectionCheckBoxSettingPage(TInt aResourceID, CSelectionItemList* aItemArray )
-    : CAknCheckBoxSettingPage( aResourceID, aItemArray )
-	{
-	}
-
-void CSourceSelectionCheckBoxSettingPage::UpdateCba()
-	{
-	// Cache the pointer to button group container
-	CEikButtonGroupContainer* cba = Cba();
-	// Left softkey should be visible if there are items selected,
-	// i.e. the selection index array has items.
-	TBool visible( ListBoxControl()->View()->SelectionIndexes()->Count() > 0 );
-	// Resolve left softkey command id
-	TInt leftId( cba->ButtonGroup()->CommandId( 0 ) );
-	// Check if left softkey visibility has changed
-	if( visible != cba->IsCommandVisible( leftId ) )
-		{
-		// Left softkey visibility has changed, update it
-		cba->MakeCommandVisible( leftId, visible );
-		}
-	}
-
-// --------------------------------------------------------------------------------------------
-// --------------------------------------------------------------------------------------------
-    
-// End of File
--- a/perfmon/src/perfmon_valuescontainer.cpp	Fri Apr 16 14:59:17 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,143 +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 FILES
-#include "perfmon_valuescontainer.h"
-#include "perfmon.hrh"
-#include "perfmon_document.h"
-#include "perfmon_appui.h"
-#include "perfmon_model.h"
-
-#include <AknUtils.h>
-
-_LIT(KPercentageFormat,"%S %d%%");
-_LIT(KFreeFormat,"%S free %S%S"); 
-_LIT(KSizeFormat,"%S size %S%S"); 
-
-const TInt KLeftMargin = 2;
-
-
-// ===================================== MEMBER FUNCTIONS =====================================
-
-void CPerfMonValuesContainer::ConstructL(const TRect& aRect)
-    {
-    iModel = static_cast<CPerfMonDocument*>(reinterpret_cast<CEikAppUi*>(iEikonEnv->AppUi())->Document())->Model();
-    iFont = AknLayoutUtils::FontFromId(EAknLogicalFontSecondaryFont);
- 
-    CreateWindowL();
-    SetRect(aRect);
-    SetBlank();
-
-    ActivateL();
-    }
-
-// --------------------------------------------------------------------------------------------
-
-CPerfMonValuesContainer::~CPerfMonValuesContainer()
-    {
-    }
-    
-// --------------------------------------------------------------------------------------------
-
-void CPerfMonValuesContainer::Draw(const TRect& aRect) const
-    {
-    CWindowGc& gc = SystemGc();
-    gc.SetBrushColor(KRgbWhite);
-    gc.Clear(aRect);
-    
-    // check if sample array has been constructed
-    if (iModel->SampleEntryArray())
-        {
-        // init font
-        gc.SetPenColor(KRgbBlack);
-        gc.UseFont( iFont );
-        TUint separator = iFont->HeightInPixels()-2;
-
-        TInt c(1);
-
-        // draw all entries
-        for (TInt i=0; i<iModel->SampleEntryArray()->Count(); i++)
-            {
-            // check if data available
-            if (iModel->SampleEntryArray()->At(i).iSampleDataArray->Count() > 0)
-                {
-                TSampleData& currentSample = iModel->SampleEntryArray()->At(i).iSampleDataArray->At(0);
-                
-                if (i == ESourceCPU) // for CPU draw %
-                    {
-                    TBuf<16> buf;
-                    buf.Format(KPercentageFormat, &iModel->SampleEntryArray()->At(i).iDescription, currentSample.iSize > 0 ? TInt( (1 - ((TReal)(currentSample.iFree) / (TReal)currentSample.iSize)) * 100) : 0 );
-                    gc.DrawText(buf, TPoint(KLeftMargin,separator*c));
-                    c++;
-                    }
-                
-                else if (currentSample.iSize > 0) // ram+drives, ignore absent drives
-                    {
-                    TBuf<32> amountBuf;
-                    amountBuf.AppendNum(currentSample.iFree, TRealFormat(KDefaultRealWidth, 0));
-        
-                    TBuf<32> buf;
-                    buf.Format(KFreeFormat, &iModel->SampleEntryArray()->At(i).iDescription, &amountBuf, &iModel->SampleEntryArray()->At(i).iUnitTypeShort);
-                    gc.DrawText(buf, TPoint(KLeftMargin,separator*c));
-                    c++;
-                    
-                    amountBuf.Copy(KNullDesC);
-                    amountBuf.AppendNum(currentSample.iSize, TRealFormat(KDefaultRealWidth, 0));
-        
-                    buf.Format(KSizeFormat, &iModel->SampleEntryArray()->At(i).iDescription, &amountBuf, &iModel->SampleEntryArray()->At(i).iUnitTypeShort);
-                    gc.DrawText(buf, TPoint(KLeftMargin,separator*c));
-                    c++;            
-                    }                    
-                }
-            }
-           
-        gc.DiscardFont();        
-        }
-    }
-
-// --------------------------------------------------------------------------------------------
-
-TKeyResponse CPerfMonValuesContainer::OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType)
-    {
-    return CCoeControl::OfferKeyEventL(aKeyEvent, aType);
-    }
-        
-// --------------------------------------------------------------------------------------------
-
-void CPerfMonValuesContainer::HandleResourceChange(TInt aType)
-    {
-    if (aType == KEikDynamicLayoutVariantSwitch)
-        {
-        TRect mainPaneRect;
-        AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, mainPaneRect);
-        SetRect(mainPaneRect);
-        }
-    else
-        CCoeControl::HandleResourceChange(aType);    
-    }
-
-// --------------------------------------------------------------------------------------------
-
-void CPerfMonValuesContainer::DrawUpdate()
-    {
-    DrawDeferred(); 
-    }
-    
-// --------------------------------------------------------------------------------------------
-       
-// End of File  
--- a/perfmon/src/perfmon_valuesview.cpp	Fri Apr 16 14:59:17 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,147 +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 FILES
-#include "perfmon.hrh"
-#include "perfmon_valuesview.h"
-#include "perfmon_valuescontainer.h"
-#include "perfmon_document.h" 
-#include "perfmon_model.h"
-#include <perfmon.rsg>
-
-#include <eikenv.h>
-#include <aknViewAppUi.h> 
-
-
-// ================= MEMBER FUNCTIONS =======================
-
-// ---------------------------------------------------------
-// CPerfMonValuesView::ConstructL(const TRect& aRect)
-// EPOC two-phased constructor
-// ---------------------------------------------------------
-//
-void CPerfMonValuesView::ConstructL()
-    {
-    BaseConstructL( R_PERFMON_VIEW_VALUES );
-    iModel = static_cast<CPerfMonDocument*>(reinterpret_cast<CEikAppUi*>(iEikonEnv->AppUi())->Document())->Model();
-    }
-
-// ---------------------------------------------------------
-// CPerfMonValuesView::~CPerfMonValuesView()
-// ---------------------------------------------------------
-//
-CPerfMonValuesView::~CPerfMonValuesView()
-    {
-    if (iContainer)
-        {
-        AppUi()->RemoveFromViewStack( *this, iContainer );
-        delete iContainer;
-        iContainer = NULL;
-        }
-    }
-
-// ---------------------------------------------------------
-// TUid CPerfMonValuesView::Id()
-// ---------------------------------------------------------
-//
-TUid CPerfMonValuesView::Id() const
-    {
-    return KValuesViewUID;
-    }
-
-// ---------------------------------------------------------
-// TUid CPerfMonValuesView::DynInitMenuPaneL(TInt aResourceId, CEikMenuPane* aMenuPane)
-// ---------------------------------------------------------
-//
-void CPerfMonValuesView::DynInitMenuPaneL(TInt aResourceId, CEikMenuPane* aMenuPane)
-    {
-    AppUi()->DynInitMenuPaneL(aResourceId, aMenuPane);
-    }
-
-  
-// ---------------------------------------------------------
-// CPerfMonValuesView::HandleCommandL(TInt aCommand)
-// ---------------------------------------------------------
-//
-void CPerfMonValuesView::HandleCommandL(TInt aCommand)
-    {   
-/*
-    switch ( aCommand )
-        {
-        case EPerfMonCmdFileBack:
-            {
-            iModel->FileUtils()->MoveUpOneLevelL();
-            break;
-            }
-
-        default:
-            {
-*/
-            AppUi()->HandleCommandL( aCommand );
-/*
-            break;
-            }
-        }
-*/
-    }
-
-// ---------------------------------------------------------
-// CPerfMonValuesView::HandleClientRectChange()
-// ---------------------------------------------------------
-//
-void CPerfMonValuesView::HandleClientRectChange()
-    {
-    if ( iContainer )
-        {
-        iContainer->SetRect( ClientRect() );
-        }
-    }
-
-// ---------------------------------------------------------
-// CPerfMonValuesView::DoActivateL(...)
-// ---------------------------------------------------------
-//
-void CPerfMonValuesView::DoActivateL(
-   const TVwsViewId& /*aPrevViewId*/,TUid /*aCustomMessageId*/,
-   const TDesC8& /*aCustomMessage*/)
-    {
-    if (!iContainer)
-        {
-        iContainer = new (ELeave) CPerfMonValuesContainer;
-        iModel->SetValuesContainer(iContainer);
-        iContainer->SetMopParent(this);
-        iContainer->ConstructL( ClientRect() );
-        AppUi()->AddToStackL( *this, iContainer );
-        } 
-   }
-
-// ---------------------------------------------------------
-// CPerfMonValuesView::DoDeactivate()
-// ---------------------------------------------------------
-//
-void CPerfMonValuesView::DoDeactivate()
-    {
-    if (iContainer)
-        {
-        AppUi()->RemoveFromViewStack( *this, iContainer );
-        delete iContainer;
-        iContainer = NULL;
-        }
-    }
-
-// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/perfmon/ui/avkon/group/bld.inf	Mon May 03 12:32:02 2010 +0300
@@ -0,0 +1,21 @@
+/*
+* 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 <platform_paths.hrh>
+
+PRJ_MMPFILES
+perfmon.mmp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/perfmon/ui/avkon/group/perfmon.mmp	Mon May 03 12:32:02 2010 +0300
@@ -0,0 +1,82 @@
+/*
+* 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 <data_caging_paths.hrh>
+#include <platform_paths.hrh>
+
+
+TARGET            PerfMon.exe
+TARGETTYPE        exe
+EPOCSTACKSIZE     0x5000
+EPOCHEAPSIZE      0x10000 0x1000000  // Min 64Kb, Max 16Mb
+
+UID               0x100039CE 0x20011385
+
+VENDORID          VID_DEFAULT
+CAPABILITY        WriteDeviceData
+
+SMPSAFE
+
+LANG              SC
+
+
+START RESOURCE    ../../../data/perfmon.rss
+HEADER
+TARGETPATH        APP_RESOURCE_DIR
+END
+
+START RESOURCE    ../../../data/perfmon_reg.rss
+DEPENDS           perfmon.rsg
+TARGETPATH        /private/10003a3f/apps
+END
+
+APP_LAYER_SYSTEMINCLUDE
+USERINCLUDE       ../inc
+SOURCEPATH        ../src
+
+SOURCE            perfmon_app.cpp
+SOURCE            perfmon_document.cpp 
+SOURCE            perfmon_appui.cpp
+SOURCE            perfmon_model.cpp
+SOURCE            perfmon_valuesview.cpp 
+SOURCE            perfmon_valuescontainer.cpp 
+SOURCE            perfmon_graphsview.cpp 
+SOURCE            perfmon_graphscontainer.cpp 
+SOURCE            perfmon_settingsviewdlg.cpp
+SOURCE            perfmon_datapopupcontainer.cpp 
+
+USERINCLUDE       ../../../engine/inc
+SOURCEPATH        ../../../engine/src
+SOURCE            perfmon_engine.cpp
+
+LIBRARY           euser.lib
+LIBRARY           commonengine.lib
+LIBRARY           apparc.lib
+LIBRARY           cone.lib 
+LIBRARY           eikcore.lib
+LIBRARY           eikcoctl.lib
+LIBRARY           eikdlg.lib  
+LIBRARY           avkon.lib 
+LIBRARY           ws32.lib 
+LIBRARY           apgrfx.lib
+LIBRARY           efsrv.lib
+LIBRARY           bafl.lib
+LIBRARY           gdi.lib
+LIBRARY           estor.lib
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/perfmon/ui/avkon/inc/perfmon_app.h	Mon May 03 12:32:02 2010 +0300
@@ -0,0 +1,64 @@
+/*
+* 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:  
+*
+*/
+
+
+#ifndef PERFMON_APP_H
+#define PERFMON_APP_H
+
+
+// INCLUDES
+#include <aknapp.h>
+
+// CONSTANTS
+// UID of the application
+const TUid KUidPerfMon = { 0x20011385 };
+
+// CLASS DECLARATION
+
+/**
+* CPerfMonApp application class.
+* Provides factory to create concrete document object.
+* 
+*/
+class CPerfMonApp : public CAknApplication
+    {
+    
+    public: // Functions from base classes
+        /**
+        * From CApaApplication, overridden to enable INI file support.
+        * @return A pointer to the dictionary store
+        */
+    CDictionaryStore* OpenIniFileLC(RFs& aFs) const;
+    private:
+
+        /**
+        * From CApaApplication, creates CPerfMonDocument document object.
+        * @return A pointer to the created document object.
+        */
+        CApaDocument* CreateDocumentL();
+        
+        /**
+        * From CApaApplication, returns application's UID (KUidPerfMon).
+        * @return The value of KUidPerfMon.
+        */
+        TUid AppDllUid() const;
+    };
+
+#endif
+
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/perfmon/ui/avkon/inc/perfmon_appui.h	Mon May 03 12:32:02 2010 +0300
@@ -0,0 +1,74 @@
+/*
+* 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:  
+*
+*/
+
+
+#ifndef PERFMON_APPUI_H
+#define PERFMON_APPUI_H
+
+// INCLUDES
+#include <eikapp.h>
+#include <eikdoc.h>
+#include <e32std.h>
+#include <coeccntx.h>
+#include <aknViewAppUi.h>
+#include <akntabgrp.h>
+#include <aknnavide.h>
+#include "perfmon_std.h"
+
+// FORWARD DECLARATIONS
+class CPerfMonModel;
+class CAknNavigationControlContainer;
+class CAknTabGroup;
+class CAknNavigationDecorator;
+
+
+// CLASS DECLARATIONS
+
+class CPerfMonAppUi : public CAknViewAppUi
+    {
+    public: // // Constructors and destructor
+
+        void ConstructL();
+
+        ~CPerfMonAppUi();
+        
+    public: // New functions
+
+    private:
+        // From MEikMenuObserver
+        void DynInitMenuPaneL(TInt aResourceId,CEikMenuPane* aMenuPane);
+
+    private:
+        void HandleForegroundEventL(TBool aForeground); 
+
+        void HandleCommandL(TInt aCommand);
+
+        void HandleResourceChangeL(TInt aType);
+
+        virtual TKeyResponse HandleKeyEventL(
+            const TKeyEvent& aKeyEvent,TEventCode aType);
+
+    private: //Data
+        CPerfMonModel*                  iModel;
+        CAknNavigationControlContainer* iNaviPane;
+        CAknTabGroup*                   iTabGroup;
+        CAknNavigationDecorator*        iDecoratedTabGroup;
+    };
+
+#endif
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/perfmon/ui/avkon/inc/perfmon_datapopupcontainer.h	Mon May 03 12:32:02 2010 +0300
@@ -0,0 +1,60 @@
+/*
+* 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:  
+*
+*/
+
+
+#ifndef PERFMON_DATAPOPUPCONTAINER_H
+#define PERFMON_DATAPOPUPCONTAINER_H
+
+// INCLUDES
+#include <coecntrl.h>
+
+#include "perfmon_drawcallback.h"
+
+
+// FORWARD DECLARATIONS
+class CPerfMonModel;
+
+
+// CLASS DECLARATIONS
+
+class CPerfMonDataPopupContainer : public CCoeControl, public MDrawUpdateCallback
+    {
+public:
+    void ConstructL(const TRect& aRect);
+    ~CPerfMonDataPopupContainer();
+
+protected:
+    void Draw(const TRect& aRect) const;
+    virtual void SizeChanged();    
+
+public:
+    void SetPositionAndSize();
+    void UpdateVisibility(TBool aForeground=ETrue);
+
+public: // from MDrawUpdateCallback
+    void DrawUpdate();
+
+private:
+    CPerfMonModel*                      iModel;
+    RWindowGroup                        iWindowGroup;
+    const CFont*                        iFont; 
+    TInt                                iFontSize;
+    };
+    
+#endif
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/perfmon/ui/avkon/inc/perfmon_document.h	Mon May 03 12:32:02 2010 +0300
@@ -0,0 +1,77 @@
+/*
+* 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:  
+*
+*/
+
+
+#ifndef PERFMON_DOCUMENT_H
+#define PERFMON_DOCUMENT_H
+
+// INCLUDES
+#include <AknDoc.h>
+   
+// CONSTANTS
+
+// FORWARD DECLARATIONS
+class CEikAppUi;
+class CPerfMonModel;
+
+
+// CLASS DECLARATION
+
+/**
+*  CPerfMonDocument application class.
+*/
+class CPerfMonDocument : public CAknDocument
+    {
+    public: // Constructors and destructor
+        static CPerfMonDocument* NewL(CEikApplication& aApp);
+        virtual ~CPerfMonDocument();
+
+    public: // New functions
+
+    public:	// from CEikDocument
+	    CFileStore* OpenFileL(TBool aDoOpen,const TDesC& aFilename,RFs& aFs);
+    protected:  // New functions
+
+    protected:  // Functions from base classes
+
+    private:
+
+        /**
+        * EPOC default constructor.
+        */
+        CPerfMonDocument(CEikApplication& aApp);
+        void ConstructL();
+
+    private:
+
+        /**
+        * From CEikDocument, create CPerfMonAppUi "App UI" object.
+        */
+        CEikAppUi* CreateAppUiL();
+
+    public:
+        inline CPerfMonModel* Model() { return iModel; }
+
+    private:
+        CPerfMonModel* iModel;
+
+    };
+
+#endif
+
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/perfmon/ui/avkon/inc/perfmon_drawcallback.h	Mon May 03 12:32:02 2010 +0300
@@ -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:  
+*
+*/
+
+
+#ifndef PERFMON_DRAWCALLBACK_H
+#define PERFMON_DRAWCALLBACK_H
+
+class MDrawUpdateCallback
+    {
+public:
+    virtual void DrawUpdate() = 0;    
+    };
+
+#endif
+
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/perfmon/ui/avkon/inc/perfmon_graphscontainer.h	Mon May 03 12:32:02 2010 +0300
@@ -0,0 +1,57 @@
+/*
+* 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:  
+*
+*/
+
+
+#ifndef PERFMON_GRAPHSCONTAINER_H
+#define PERFMON_GRAPHSCONTAINER_H
+
+// INCLUDES
+#include <coecntrl.h>
+
+#include "perfmon_drawcallback.h"
+
+
+// FORWARD DECLARATIONS
+class CPerfMonModel;
+
+
+// CLASS DECLARATIONS
+
+class CPerfMonGraphsContainer : public CCoeControl, public MDrawUpdateCallback
+    {
+public:
+    void ConstructL(const TRect& aRect);
+    ~CPerfMonGraphsContainer();
+
+private:
+    void Draw(const TRect& aRect) const;
+    void HandleResourceChange(TInt aType);
+
+public:
+	TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode /*aType*/);
+
+public: // from MDrawUpdateCallback
+    void DrawUpdate();
+
+private:
+    CPerfMonModel*                      iModel;
+    const CFont*                        iFont;
+    };
+    
+#endif
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/perfmon/ui/avkon/inc/perfmon_graphsview.h	Mon May 03 12:32:02 2010 +0300
@@ -0,0 +1,70 @@
+/*
+* 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:  
+*
+*/
+
+
+#ifndef PERFMON_GRAPHSVIEW_H
+#define PERFMON_GRAPHSVIEW_H
+
+// INCLUDES
+#include <aknview.h>
+
+#include "perfmon_std.h"
+
+
+
+// CONSTANTS
+// UID of view
+const TUid KGraphsViewUID = {2};
+
+
+// FORWARD DECLARATIONS
+class CPerfMonGraphsContainer;
+class CPerfMonModel;
+
+
+// CLASS DECLARATION
+
+/**
+*  CPerfMonGraphsView view class.
+* 
+*/
+class CPerfMonGraphsView : public CAknView
+    {
+    public: // Constructors and destructor
+        void ConstructL();
+        ~CPerfMonGraphsView();
+
+    public: // Functions from base classes
+        TUid Id() const;
+        void HandleCommandL(TInt aCommand);
+        void HandleClientRectChange();
+
+    private: // From MEikMenuObserver
+        void DynInitMenuPaneL(TInt aResourceId, CEikMenuPane* aMenuPane);
+
+    private: // From AknView
+        void DoActivateL(const TVwsViewId& aPrevViewId, TUid aCustomMessageId, const TDesC8& aCustomMessage);
+        void DoDeactivate();
+
+    private: // Data
+        CPerfMonGraphsContainer*        iContainer;
+        CPerfMonModel*                  iModel;
+    };
+
+#endif
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/perfmon/ui/avkon/inc/perfmon_model.h	Mon May 03 12:32:02 2010 +0300
@@ -0,0 +1,72 @@
+/*
+* 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:  
+*
+*/
+
+
+#ifndef PERFMON_MODEL_H
+#define PERFMON_MODEL_H
+
+// INCLUDES
+#include <e32std.h>
+#include <e32base.h>
+#include <apgcli.h>
+#include <gdi.h>
+
+#include "perfmon_engine.h"
+
+// FORWARD DECLARATIONS
+class CPerfMonValuesContainer;
+class CPerfMonGraphsContainer;
+class CPerfMonDataPopupContainer;
+
+class CPerfMonModel : public CPerfMonEngine
+	{
+private:
+    enum TContainerDrawState
+    	{
+    	EDrawStateInvalid = -1,
+    	EDrawStateValues,
+    	EDrawStateGraphs
+    	};
+
+public:
+	static CPerfMonModel* NewL();
+	void ActivateModelL();
+	void DeActivateModelL();
+
+private:
+	void ConstructL();
+	void SendDrawEventToContainersL();
+	void HandleSettingsChangeL();
+    
+public:
+    void SetValuesContainer(CPerfMonValuesContainer* aValuesContainer);
+    void SetGraphsContainer(CPerfMonGraphsContainer* aGraphsContainer);
+    TInt LaunchSettingsDialogL();
+
+    inline CPerfMonValuesContainer*     ValuesContainer()       { return iValuesContainer; }
+    inline CPerfMonGraphsContainer*     GraphsContainer()       { return iGraphsContainer; }
+    inline CPerfMonDataPopupContainer*  DataPopupContainer()    { return iDataPopupContainer; } 
+
+private:
+    CPerfMonValuesContainer*        iValuesContainer;
+    CPerfMonGraphsContainer*        iGraphsContainer;
+    CPerfMonDataPopupContainer*     iDataPopupContainer;
+    TInt                            iDrawState;
+    };
+ 
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/perfmon/ui/avkon/inc/perfmon_settingsviewdlg.h	Mon May 03 12:32:02 2010 +0300
@@ -0,0 +1,121 @@
+/*
+* 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:  
+*
+*/
+
+
+#ifndef PERFMON_SETTINGSVIEWDLG_H
+#define PERFMON_SETTINGSVIEWDLG_H
+
+//  INCLUDES
+#include <AknDialog.h>
+#include <eiklbo.h>
+#include <AknTabObserver.h> 
+#include <akntabgrp.h>
+#include <aknsettingitemlist.h> 
+#include <akncheckboxsettingpage.h> 
+
+#include "perfmon_model.h"
+
+
+//  FORWARD DECLARATIONS
+class CAknSettingItemArray;
+class CAknSettingStyleListBox;
+class CAknNavigationControlContainer;
+class CAknNavigationDecorator;
+class CAknTabGroup; 
+class TPerfMonSettings;
+class CSelectionItemList;
+
+
+//  CLASS DEFINITIONS
+
+class CPerfMonSettingsViewDlg : public CAknDialog, public MEikListBoxObserver, public MAknTabObserver
+    {
+public:
+    static CPerfMonSettingsViewDlg* NewL(TPerfMonSettings& aSettings);
+    virtual ~CPerfMonSettingsViewDlg();
+
+public: // From MEikListBoxObserver
+    void HandleListBoxEventL(CEikListBox* aListBox, TListBoxEvent aEventType);
+
+public: // From MAknTabObserver
+    void TabChangedL(TInt aIndex); 
+
+public: // From CAknDialog
+    void ProcessCommandL(TInt aCommandId);
+
+protected: // From CEikDialog
+    TKeyResponse OfferKeyEventL(const TKeyEvent &aKeyEvent, TEventCode aType);
+    void PreLayoutDynInitL();
+    TBool OkToExitL(TInt aButtonId);    
+
+private: // New methods
+    void ShowSettingPageL(TBool aCalledFromMenu);
+    void SetVisibilitiesOfSettingItemsL();
+    void UpdateListBoxL();
+    void AddSettingItemL(TInt aId, TInt aTitleResource, TInt aSettingPageResource, TInt aAssociatedResource, TInt aOrdinal);
+
+private: // Constructors
+    CPerfMonSettingsViewDlg(TPerfMonSettings& aSettings);
+    void ConstructL();        
+
+private: // Data
+    CAknSettingItemArray*               iSettingItemArray;
+    CAknSettingStyleListBox*            iListBox;
+    CAknNavigationControlContainer*     iNaviContainer;
+    CAknNavigationDecorator*            iDecoratedTabGroup;
+    CAknTabGroup*                       iTabGroup;
+    TPerfMonSettings&               iSettings;
+    };
+
+
+class CSourceSelectionCheckBoxSettingItem : public CAknSettingItem
+    {
+public:
+    CSourceSelectionCheckBoxSettingItem( TInt aIdentifier, TPerfMonSources& aMemoryInUse );
+	virtual ~CSourceSelectionCheckBoxSettingItem();
+
+protected:
+	void CompleteConstructionL();
+	void StoreL();
+	void LoadL();
+	const TDesC& SettingTextL();
+	void EditItemL( TBool aCalledFromMenu );
+    void HandleSettingPageEventL( CAknSettingPage* aSettingPage, TAknSettingPageEvent aEventType );
+
+private:
+    void AddNewItemToArrayL(const TDesC& aLabel); 
+
+private:
+    CSelectionItemList*     iItemArray;
+    HBufC*                  iSettingText;
+    TPerfMonSources&        iExternalSources;
+    };
+
+
+class CSourceSelectionCheckBoxSettingPage : public CAknCheckBoxSettingPage
+	{
+	public:
+        CSourceSelectionCheckBoxSettingPage( TInt aResourceID, CSelectionItemList* aItemArray );
+	public:		// New functions
+		void UpdateCba();
+	};
+	
+
+#endif
+
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/perfmon/ui/avkon/inc/perfmon_std.h	Mon May 03 12:32:02 2010 +0300
@@ -0,0 +1,27 @@
+/*
+* 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:  
+*
+*/
+
+
+#ifndef PERFMON_STD_H
+#define PERFMON_STD_H
+
+
+
+#endif
+
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/perfmon/ui/avkon/inc/perfmon_valuescontainer.h	Mon May 03 12:32:02 2010 +0300
@@ -0,0 +1,57 @@
+/*
+* 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:  
+*
+*/
+
+
+#ifndef PERFMON_VALUESCONTAINER_H
+#define PERFMON_VALUESCONTAINER_H
+
+// INCLUDES
+#include <coecntrl.h>
+
+#include "perfmon_drawcallback.h"
+
+
+// FORWARD DECLARATIONS
+class CPerfMonModel;
+
+
+// CLASS DECLARATIONS
+
+class CPerfMonValuesContainer : public CCoeControl, public MDrawUpdateCallback
+    {
+public:
+    void ConstructL(const TRect& aRect);
+    ~CPerfMonValuesContainer();
+
+private:
+    void Draw(const TRect& aRect) const;
+    void HandleResourceChange(TInt aType);
+
+public:
+	TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode /*aType*/);
+
+public: // from MDrawUpdateCallback
+    void DrawUpdate();
+    
+private:
+    CPerfMonModel*                      iModel;
+    const CFont*                        iFont; 
+    };
+    
+#endif
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/perfmon/ui/avkon/inc/perfmon_valuesview.h	Mon May 03 12:32:02 2010 +0300
@@ -0,0 +1,70 @@
+/*
+* 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:  
+*
+*/
+
+
+#ifndef PERFMON_VALUESVIEW_H
+#define PERFMON_VALUESVIEW_H
+
+// INCLUDES
+#include <aknview.h>
+
+#include "perfmon_std.h"
+
+
+
+// CONSTANTS
+// UID of view
+const TUid KValuesViewUID = {1};
+
+
+// FORWARD DECLARATIONS
+class CPerfMonValuesContainer;
+class CPerfMonModel;
+
+
+// CLASS DECLARATION
+
+/**
+*  CPerfMonValuesView view class.
+* 
+*/
+class CPerfMonValuesView : public CAknView
+    {
+    public: // Constructors and destructor
+        void ConstructL();
+        ~CPerfMonValuesView();
+
+    public: // Functions from base classes
+        TUid Id() const;
+        void HandleCommandL(TInt aCommand);
+        void HandleClientRectChange();
+
+    private: // From MEikMenuObserver
+        void DynInitMenuPaneL(TInt aResourceId, CEikMenuPane* aMenuPane);
+
+    private: // From AknView
+        void DoActivateL(const TVwsViewId& aPrevViewId, TUid aCustomMessageId, const TDesC8& aCustomMessage);
+        void DoDeactivate();
+
+    private: // Data
+        CPerfMonValuesContainer*        iContainer;
+        CPerfMonModel*                  iModel;
+    };
+
+#endif
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/perfmon/ui/avkon/src/perfmon_app.cpp	Mon May 03 12:32:02 2010 +0300
@@ -0,0 +1,73 @@
+/*
+* 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 FILES
+#include "perfmon_app.h"
+#include "perfmon_document.h"
+
+#include <eikstart.h>
+
+
+// ================= MEMBER FUNCTIONS =======================
+
+// ---------------------------------------------------------
+// CPerfMonApp::AppDllUid()
+// Returns application UID
+// ---------------------------------------------------------
+//
+TUid CPerfMonApp::AppDllUid() const
+    {
+    return KUidPerfMon;
+    }
+
+// ---------------------------------------------------------
+// CDictionaryStore* CPerfMonApp::OpenIniFileLC(RFs& aFs) const
+// overrides CAknApplication::OpenIniFileLC to enable INI file support
+// ---------------------------------------------------------
+//
+CDictionaryStore* CPerfMonApp::OpenIniFileLC(RFs& aFs) const
+    {
+    return CEikApplication::OpenIniFileLC(aFs);
+    }
+   
+// ---------------------------------------------------------
+// CPerfMonApp::CreateDocumentL()
+// Creates CPerfMonDocument object
+// ---------------------------------------------------------
+//
+CApaDocument* CPerfMonApp::CreateDocumentL()
+    {
+    return CPerfMonDocument::NewL( *this );
+    }
+
+// ================= OTHER EXPORTED FUNCTIONS ==============
+
+LOCAL_C CApaApplication* NewApplication()
+    {
+    return new CPerfMonApp;
+    }
+
+
+GLDEF_C TInt E32Main()
+    {
+    return EikStart::RunApplication(NewApplication);
+    }
+   
+
+// End of File  
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/perfmon/ui/avkon/src/perfmon_appui.cpp	Mon May 03 12:32:02 2010 +0300
@@ -0,0 +1,228 @@
+/*
+* 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 FILES
+#include "perfmon_appui.h"
+#include "perfmon_valuesview.h"
+#include "perfmon_graphsview.h"
+#include "perfmon_datapopupcontainer.h"
+#include "perfmon.hrh"
+#include "perfmon_model.h"
+#include "perfmon_document.h"
+#include <perfmon.rsg>
+
+#include <avkon.hrh>
+#include <AknQueryDialog.h>
+#include <aknmessagequerydialog.h> 
+
+
+// ================= MEMBER FUNCTIONS =======================
+
+// --------------------------------------------------------------------------------------------
+
+void CPerfMonAppUi::ConstructL()
+    {
+    // disable window server priority control for this application
+    iEikonEnv->WsSession().ComputeMode( RWsSession::EPriorityControlDisabled );
+
+    // set as system application to prevent getting shut down events 
+    iEikonEnv->SetSystem(ETrue);
+    
+    BaseConstructL(EAknEnableSkin);
+
+    iModel = static_cast<CPerfMonDocument*>(reinterpret_cast<CEikAppUi*>(iEikonEnv->AppUi())->Document())->Model();
+
+    // Show tabs for main views from resources
+    CEikStatusPane* sp = StatusPane();
+
+    // Fetch pointer to the default navi pane control
+    iNaviPane = (CAknNavigationControlContainer*)sp->ControlL( 
+        TUid::Uid(EEikStatusPaneUidNavi));
+
+    // Tabgroup has been read from resource and it were pushed to the navi pane. 
+    // Get pointer to the navigation decorator with the ResourceDecorator() function. 
+    // Application owns the decorator and it has responsibility to delete the object.
+    iDecoratedTabGroup = iNaviPane->ResourceDecorator();
+    if (iDecoratedTabGroup)
+        {
+        iTabGroup = (CAknTabGroup*) iDecoratedTabGroup->DecoratedControl();
+        }
+        
+    CPerfMonValuesView* valuesView = new(ELeave) CPerfMonValuesView;
+    CleanupStack::PushL(valuesView);
+    valuesView->ConstructL();
+    AddViewL(valuesView);           // transfer ownership to CAknViewAppUi
+    CleanupStack::Pop();            // valuesView
+
+    CPerfMonGraphsView* graphsView = new(ELeave) CPerfMonGraphsView;
+    CleanupStack::PushL(graphsView);
+    graphsView->ConstructL();
+    AddViewL(graphsView);           // transfer ownership to CAknViewAppUi
+    CleanupStack::Pop();            // graphsView
+    
+    // set the default view
+    SetDefaultViewL(*valuesView);
+
+    // notify the model that everything has been constructed
+    iModel->ActivateModelL();
+    }
+
+// --------------------------------------------------------------------------------------------
+
+CPerfMonAppUi::~CPerfMonAppUi()
+    {
+    // notify the model that the application is closing
+    if (iModel)    
+        TRAP_IGNORE(iModel->DeActivateModelL());
+    
+    delete iDecoratedTabGroup;
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CPerfMonAppUi::DynInitMenuPaneL(TInt aResourceId, CEikMenuPane* aMenuPane)
+    {
+    if (aResourceId == R_PERFMON_APP_MENU)
+        {
+        aMenuPane->SetItemDimmed(EPerfMonCmdEnableLogging, iModel->Settings().iLoggingEnabled);
+        aMenuPane->SetItemDimmed(EPerfMonCmdDisableLogging, !iModel->Settings().iLoggingEnabled);
+        }
+    }
+
+// --------------------------------------------------------------------------------------------
+
+TKeyResponse CPerfMonAppUi::HandleKeyEventL(const TKeyEvent& aKeyEvent, TEventCode /*aType*/)
+    {
+    if ( iTabGroup == NULL )
+        {
+        return EKeyWasNotConsumed;
+        }
+
+    TInt active = iTabGroup->ActiveTabIndex();
+    TInt count = iTabGroup->TabCount();
+
+    switch ( aKeyEvent.iCode )
+        {
+        case EKeyLeftArrow:
+            if (active > 0)
+                {
+                active--;
+                iTabGroup->SetActiveTabByIndex( active );
+                ActivateLocalViewL(TUid::Uid(iTabGroup->TabIdFromIndex(active)));
+                }
+            break;
+        case EKeyRightArrow:
+            if((active + 1) < count)
+                {
+                active++;
+                iTabGroup->SetActiveTabByIndex( active );
+                ActivateLocalViewL(TUid::Uid(iTabGroup->TabIdFromIndex(active)));
+                }
+            break;
+        default:
+            return EKeyWasNotConsumed;
+        }
+
+    return EKeyWasConsumed;
+    }
+
+
+// --------------------------------------------------------------------------------------------
+
+void CPerfMonAppUi::HandleCommandL(TInt aCommand)
+    {
+    switch ( aCommand )
+        {
+        case EPerfMonCmdEnableLogging:
+            {
+            iModel->EnableLogging(ETrue);
+            break;
+            }
+
+        case EPerfMonCmdDisableLogging:
+            {
+            iModel->EnableLogging(EFalse);
+            break;
+            }
+                        
+        case EPerfMonCmdSettings:
+            {
+            if (iModel->LaunchSettingsDialogL() == EAknCmdExit)
+                Exit();
+            break;
+            }
+
+        case EPerfMonCmdAbout:
+            {
+	        CAknMessageQueryDialog* dialog = new(ELeave) CAknMessageQueryDialog;
+            dialog->ExecuteLD(R_PERFMON_ABOUT_DIALOG);
+            }
+            break;
+            
+        // a normal way to close an application
+        case EAknCmdExit:
+        case EEikCmdExit:
+        case EAknSoftkeyExit: 
+			{
+            Exit();
+			}
+            break;
+
+        default:
+            break;      
+        }
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CPerfMonAppUi::HandleForegroundEventL(TBool aForeground)
+    {
+    // handle visibility of the data popup container
+    if (iModel && iModel->DataPopupContainer())
+        {
+        iModel->DataPopupContainer()->UpdateVisibility(aForeground);
+        }
+    
+    // call the base class
+    CAknAppUi::HandleForegroundEventL(aForeground); 
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CPerfMonAppUi::HandleResourceChangeL(TInt aType)
+    {
+    CAknAppUi::HandleResourceChangeL(aType);
+
+    // update size of the data popup container (implemented here because data popup container
+    // does not get HandleResourceChangeL events)
+    if (aType == KEikDynamicLayoutVariantSwitch)
+        {
+        if (iModel)
+            {
+            if (iModel->DataPopupContainer())
+                {
+                iModel->DataPopupContainer()->SetPositionAndSize();
+                }
+            
+            }
+        }
+    }
+
+// --------------------------------------------------------------------------------------------
+
+// End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/perfmon/ui/avkon/src/perfmon_datapopupcontainer.cpp	Mon May 03 12:32:02 2010 +0300
@@ -0,0 +1,210 @@
+/*
+* 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 FILES
+#include "perfmon_datapopupcontainer.h"
+#include "perfmon.hrh"
+#include "perfmon_document.h"
+#include "perfmon_appui.h"
+#include "perfmon_model.h"
+
+#include <AknUtils.h>
+
+_LIT(KPercentageFormat,"%S %d%%");
+_LIT(KFreeFormat,"%S free %S%S");
+
+const TInt KLeftMargin = 2;
+ 
+
+// ===================================== MEMBER FUNCTIONS =====================================
+
+void CPerfMonDataPopupContainer::ConstructL(const TRect& /*aRect*/)
+    {
+    iModel = static_cast<CPerfMonDocument*>(reinterpret_cast<CEikAppUi*>(iEikonEnv->AppUi())->Document())->Model();
+    iFont = LatinPlain12();
+    iFontSize = iFont->FontMaxHeight();
+ 
+    // set windowgroup so that it always on top and does not receive focus
+    iWindowGroup = RWindowGroup(iCoeEnv->WsSession());
+    User::LeaveIfError(iWindowGroup.Construct((TUint32)&iWindowGroup));
+    iWindowGroup.SetOrdinalPosition(0, ECoeWinPriorityAlwaysAtFront);
+    iWindowGroup.EnableReceiptOfFocus(EFalse);
+    
+    CreateWindowL(&iWindowGroup);
+    //SetRect(aRect);
+    SetPositionAndSize();
+    SetBlank();
+
+    ActivateL();
+    }
+
+// --------------------------------------------------------------------------------------------
+
+CPerfMonDataPopupContainer::~CPerfMonDataPopupContainer()
+    {
+    iWindowGroup.Close();    
+    }
+    
+// --------------------------------------------------------------------------------------------
+
+void CPerfMonDataPopupContainer::Draw(const TRect& aRect) const
+    {
+    CWindowGc& gc = SystemGc();
+    gc.SetBrushColor(KRgbWhite);
+    gc.Clear(aRect);
+    
+    // check if sample array has been constructed
+    if (iModel->SampleEntryArray())
+        {
+        // init font
+        gc.SetPenColor(KRgbBlack);
+        gc.UseFont( iFont );
+        
+        // draw a rect around the popup
+        gc.DrawRect(aRect);
+        
+        TInt posCounter(1);
+        
+        for (TInt i=0; i<iModel->SampleEntryArray()->Count(); i++)
+            {
+            // check if this setting has been enabled and it has some data
+            if (iModel->Settings().iDataPopupSources.iSrcEnabled[i] && iModel->SampleEntryArray()->At(i).iSampleDataArray->Count() > 0)
+                {
+                TSampleData& currentSample = iModel->SampleEntryArray()->At(i).iSampleDataArray->At(0);    
+                TBuf<32> buf;
+
+                // for CPU draw %, other amount of free memory
+                if (i == ESourceCPU)
+                    {
+                    buf.Format(KPercentageFormat, &iModel->SampleEntryArray()->At(i).iDescription, currentSample.iSize > 0 ? TInt( (1 - ((TReal)(currentSample.iFree) / (TReal)currentSample.iSize)) * 100) : 0 );
+                    gc.DrawText(buf, TPoint(KLeftMargin, iFontSize*posCounter));
+                    }
+                else
+                    {
+                    TBuf<32> freeBuf;
+                    freeBuf.AppendNum(currentSample.iFree, TRealFormat(KDefaultRealWidth, 0));
+
+                    TBuf<32> buf;
+                    buf.Format(KFreeFormat, &iModel->SampleEntryArray()->At(i).iDescription, &freeBuf, &iModel->SampleEntryArray()->At(i).iUnitTypeShort);
+                    gc.DrawText(buf, TPoint(KLeftMargin, iFontSize*posCounter));                    
+                    }    
+                
+                posCounter++;
+                }
+            }
+            
+        gc.DiscardFont();        
+        }
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CPerfMonDataPopupContainer::SizeChanged()
+    {
+    DrawNow();
+    }   
+
+// --------------------------------------------------------------------------------------------
+
+void CPerfMonDataPopupContainer::SetPositionAndSize()
+    {
+    CWsScreenDevice* screenDevice = iEikonEnv->ScreenDevice();
+
+    // top right
+    if (iModel->Settings().iDataPopupLocation == EDataPopupLocationTopRight)
+        {
+        // screen orientation is landscape with softkeys on right
+        if (AknLayoutUtils::CbaLocation()==AknLayoutUtils::EAknCbaLocationRight)
+            {
+            SetRect(
+                TRect(
+                    screenDevice->SizeInPixels().iWidth-102-15,
+                    0,
+                    screenDevice->SizeInPixels().iWidth-15,
+                    iModel->Settings().iDataPopupSources.EnabledSourcesCount()*iFontSize + 3
+                    ));
+            }
+
+        // any other orientation
+        else
+            {
+            SetRect(
+                TRect(
+                    screenDevice->SizeInPixels().iWidth-102,
+                    0,
+                    screenDevice->SizeInPixels().iWidth,
+                    iModel->Settings().iDataPopupSources.EnabledSourcesCount()*iFontSize + 3
+                    ));
+            }        
+        }
+
+    // bottom middle
+    else if (iModel->Settings().iDataPopupLocation == EDataPopupLocationBottomMiddle)
+        {
+        SetRect(
+            TRect(
+                screenDevice->SizeInPixels().iWidth/2-102/2,
+                screenDevice->SizeInPixels().iHeight - iModel->Settings().iDataPopupSources.EnabledSourcesCount()*iFontSize - 3,
+                screenDevice->SizeInPixels().iWidth/2+102/2,
+                screenDevice->SizeInPixels().iHeight
+                ));
+        }
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CPerfMonDataPopupContainer::UpdateVisibility(TBool aForeground)
+    {
+    // application has been brought to foregound
+    if (aForeground)
+        {
+        if (iModel->Settings().iDataPopupVisibility==EDataPopupVisbilityAlwaysOn)
+            {
+            MakeVisible(ETrue);
+            }
+        else
+            {
+            MakeVisible(EFalse);
+            }    
+        }
+    
+    // application has been sent to background
+    else
+        {
+        if (iModel->Settings().iDataPopupVisibility==EDataPopupVisbilityAlwaysOn
+            || iModel->Settings().iDataPopupVisibility==EDataPopupVisbilityBackgroundOnly)
+            {
+            MakeVisible(ETrue);
+            }
+        else
+            {
+            MakeVisible(EFalse);
+            }              
+        }    
+    }
+            
+// --------------------------------------------------------------------------------------------
+
+void CPerfMonDataPopupContainer::DrawUpdate()
+    {
+    DrawDeferred(); 
+    }
+    
+// --------------------------------------------------------------------------------------------
+       
+// End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/perfmon/ui/avkon/src/perfmon_document.cpp	Mon May 03 12:32:02 2010 +0300
@@ -0,0 +1,83 @@
+/*
+* 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 FILES
+#include "perfmon_document.h"
+#include "perfmon_appui.h"
+#include "perfmon_model.h"
+
+// ================= MEMBER FUNCTIONS =======================
+
+// constructor
+CPerfMonDocument::CPerfMonDocument(CEikApplication& aApp)
+: CAknDocument(aApp)    
+    {
+    }
+
+// ----------------------------------------------------
+
+// destructor
+CPerfMonDocument::~CPerfMonDocument()
+    {
+    delete iModel;
+    }
+
+// ----------------------------------------------------
+
+// EPOC default constructor can leave.
+void CPerfMonDocument::ConstructL()
+    {
+    iModel = CPerfMonModel::NewL();
+    }
+
+// ----------------------------------------------------
+
+// Two-phased constructor.
+CPerfMonDocument* CPerfMonDocument::NewL(CEikApplication& aApp)
+    {
+    CPerfMonDocument* self = new(ELeave) CPerfMonDocument(aApp);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop();
+
+    return self;
+    }
+    
+// ----------------------------------------------------
+// CPerfMonDocument::CreateAppUiL()
+// constructs CPerfMonAppUi
+// ----------------------------------------------------
+//
+CEikAppUi* CPerfMonDocument::CreateAppUiL()
+    {
+    return new (ELeave) CPerfMonAppUi;
+    }
+
+// ----------------------------------------------------
+// CPerfMonDocument::OpenFileL
+// Overrides CAknDocument::OpenFileL to support document file
+// ----------------------------------------------------
+//
+CFileStore* CPerfMonDocument::OpenFileL(TBool aDoOpen,const TDesC& aFilename,RFs& aFs)
+    {
+    return CEikDocument::OpenFileL(aDoOpen, aFilename, aFs);
+    }
+
+// ----------------------------------------------------
+
+// End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/perfmon/ui/avkon/src/perfmon_graphscontainer.cpp	Mon May 03 12:32:02 2010 +0300
@@ -0,0 +1,233 @@
+/*
+* 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 FILES
+#include "perfmon_graphscontainer.h"
+#include "perfmon.hrh"
+#include "perfmon_document.h"
+#include "perfmon_appui.h"
+#include "perfmon_model.h"
+
+#include <AknUtils.h>
+
+const TInt KAmountOfMicroSecondsFitsScreen = 20 * 1000000;
+#define KRgbCustomGrey TRgb(0x808080)
+
+_LIT(K100p, "100%"); 
+_LIT(K50p, "50%"); 
+_LIT(K0p, "0%"); 
+
+_LIT(KPercentageFormat,"%S %d%%");
+
+const TInt KMicroToSecondMultiplier = 1000000;
+
+// ===================================== MEMBER FUNCTIONS =====================================
+
+void CPerfMonGraphsContainer::ConstructL(const TRect& aRect)
+    {
+    iModel = static_cast<CPerfMonDocument*>(reinterpret_cast<CEikAppUi*>(iEikonEnv->AppUi())->Document())->Model();
+    //iFont = AknLayoutUtils::FontFromId(EAknLogicalFontPrimarySmallFont);
+    iFont = LatinBold12();
+
+    CreateWindowL();
+    SetRect(aRect);
+    SetBlank();
+
+    ActivateL();
+    }
+
+// --------------------------------------------------------------------------------------------
+
+CPerfMonGraphsContainer::~CPerfMonGraphsContainer()
+    {
+    }
+    
+// --------------------------------------------------------------------------------------------
+
+void CPerfMonGraphsContainer::Draw(const TRect& aRect) const
+    {
+    // draw black background
+    CWindowGc& gc = SystemGc();
+    gc.SetBrushColor(KRgbBlack);
+    gc.Clear(aRect);
+    
+    // activate font and get size
+    gc.UseFont(iFont);
+    TUint fontSize = iFont->FontMaxHeight();
+    //TInt fontBaseOffset = iFont->DescentInPixels();
+    
+
+    // calculate time factor
+    TReal scaleFactor = (TReal) aRect.Width() / (TReal) KAmountOfMicroSecondsFitsScreen;
+
+    // calculate area height which is used to draw the grpahs
+    TInt drawAreaHeight = aRect.Height() - fontSize - fontSize;
+        
+    
+    // check if sample array has been constructed
+    if (iModel->SampleEntryArray())
+        {
+        
+        // draw vertical time lines first
+        TInt verticalBarPeriodInSecs = iModel->Settings().iGraphsVerticalBarPeriod;
+        
+        if (verticalBarPeriodInSecs >= 1 && iModel->SampleEntryArray()->At(0).iSampleDataArray->Count() > 0)
+            {
+            // get time from the first sample
+            TSampleData& firstSample = iModel->SampleEntryArray()->At(0).iSampleDataArray->At(0);
+            TInt64 currentMicroSeconds = firstSample.iTimeFromStart.Int64();
+            
+            // calculate amount of microseconds exceeding value by using the modulo operator
+            TInt remainderInMicroSeconds = currentMicroSeconds % (verticalBarPeriodInSecs * 1000000); 
+            
+            // calculate first x pos
+            TInt vbarXpos = aRect.Width() - (remainderInMicroSeconds * scaleFactor);
+            
+            // calculate the amount in seconds
+            TInt barSeconds = (currentMicroSeconds - remainderInMicroSeconds) / KMicroToSecondMultiplier;
+
+            
+            // continue drawing periodically the vertical lines
+            while (vbarXpos >= 0 && barSeconds >= 0)
+                {
+                // draw vertical line    
+                gc.SetPenColor(KRgbDarkRed);
+                gc.DrawLine(TPoint(vbarXpos,fontSize+1), TPoint(vbarXpos,aRect.Height()-fontSize));
+                
+                // draw seconds value
+                gc.SetPenColor(KRgbCustomGrey);
+                TBuf<16> secsBuf;
+                secsBuf.AppendNum(barSeconds);    
+                secsBuf.Append(_L("s"));
+                gc.DrawText(secsBuf, TPoint(vbarXpos-(iFont->TextWidthInPixels(secsBuf)/2), aRect.Height()));    
+
+                // calculate new position
+                vbarXpos -= verticalBarPeriodInSecs * 1000000 * scaleFactor;
+                barSeconds -= verticalBarPeriodInSecs;
+                }
+            }
+        
+        // draw the basic grid
+        gc.SetPenColor(KRgbCustomGrey);
+    
+        gc.DrawLine(TPoint(0,fontSize), TPoint(aRect.Width(),fontSize));  // upper line
+        gc.DrawText(K100p, TPoint(0,fontSize));
+    
+        gc.DrawLine(TPoint(0,aRect.Height()/2), TPoint(aRect.Width(),aRect.Height()/2));  // mid line
+        gc.DrawText(K50p, TPoint(0,aRect.Height()/2));
+    
+        gc.DrawLine(TPoint(0,aRect.Height()-fontSize), TPoint(aRect.Width(),aRect.Height()-fontSize));  // bottom line
+        gc.DrawText(K0p, TPoint(0,aRect.Height()-fontSize));
+
+        TInt c(0);
+            
+        // draw graphs for each sampled type
+        for (TInt i=0; i<iModel->SampleEntryArray()->Count(); i++)
+            {
+            // check if this setting has been enabled and it has some data
+            if (iModel->Settings().iGraphsSources.iSrcEnabled[i] && iModel->SampleEntryArray()->At(i).iSampleDataArray->Count() > 0)
+                {
+                // set pen color for the graph
+                gc.SetPenColor(iModel->SampleEntryArray()->At(i).iGraphColor);
+                
+                // remember the position where drawing started
+                /*TReal*/TInt currentXPos(aRect.Width()); // start drawing from right            
+                /*TReal*/TInt currentYPos(0);
+                
+                // draw samples
+                for (TInt j=0; j<iModel->SampleEntryArray()->At(i).iSampleDataArray->Count() - 1; j++)
+                    {
+                    TSampleData& currentSample = iModel->SampleEntryArray()->At(i).iSampleDataArray->At(j);
+                    TSampleData& previousSample = iModel->SampleEntryArray()->At(i).iSampleDataArray->At(j+1);
+                    
+                    // calculate X position for previous (j+1)
+                    /*TReal*/TInt previousXPos = currentXPos -
+                        ( (Abs(previousSample.iTimeFromStart.Int64() - currentSample.iTimeFromStart.Int64())) * scaleFactor );
+                    
+
+                    // calculate initial Y position
+                    if (j==0)
+                        {
+                        currentYPos = currentSample.iSize > 0 ? (TReal)(currentSample.iFree) / (TReal)currentSample.iSize * drawAreaHeight + fontSize : aRect.Height()-fontSize;
+                        }
+
+                    // calculate Y position for previous (j+1)
+                    /*TReal*/TInt previousYPos = previousSample.iSize > 0 ? (TReal)(previousSample.iFree) / (TReal)previousSample.iSize * drawAreaHeight + fontSize : aRect.Height()-fontSize; 
+                    
+                    
+                    // draw a line between the previous and current
+                    gc.DrawLine(TPoint((TInt)previousXPos,(TInt)previousYPos), TPoint((TInt)currentXPos,(TInt)currentYPos));
+                    
+                    
+                    // draw current value in %
+                    if (j==0) // draw the value of first sample
+                        {
+                        TBuf<16> buf;
+                        buf.Format(KPercentageFormat, &iModel->SampleEntryArray()->At(i).iDescription, currentSample.iSize > 0 ? TInt( (1 - ((TReal)(currentSample.iFree) / (TReal)currentSample.iSize)) * 100) : 0 );
+      
+                        gc.DrawText(buf, TPoint(0,fontSize+fontSize+c*fontSize));
+                        c++;                    
+                        }
+                    
+                    
+                    // stop drawing if we have run out of space
+                    if (previousXPos < 0)
+                        break;
+                    
+                    // remeber previous values
+                    currentXPos = previousXPos;
+                    currentYPos = previousYPos;
+                    }
+                }
+            }
+        }
+
+    gc.DiscardFont();        
+    }
+
+// --------------------------------------------------------------------------------------------
+
+TKeyResponse CPerfMonGraphsContainer::OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType)
+    {
+    return CCoeControl::OfferKeyEventL(aKeyEvent, aType);
+    }
+        
+// --------------------------------------------------------------------------------------------
+
+void CPerfMonGraphsContainer::HandleResourceChange(TInt aType)
+    {
+    if (aType == KEikDynamicLayoutVariantSwitch)
+        {
+        TRect mainPaneRect;
+        AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, mainPaneRect);
+        SetRect(mainPaneRect);
+        }
+    else
+        CCoeControl::HandleResourceChange(aType);    
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CPerfMonGraphsContainer::DrawUpdate()
+    {
+    DrawDeferred();    
+    }
+    
+// --------------------------------------------------------------------------------------------
+            
+// End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/perfmon/ui/avkon/src/perfmon_graphsview.cpp	Mon May 03 12:32:02 2010 +0300
@@ -0,0 +1,147 @@
+/*
+* 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 FILES
+#include "perfmon.hrh"
+#include "perfmon_graphsview.h"
+#include "perfmon_graphscontainer.h"
+#include "perfmon_document.h" 
+#include "perfmon_model.h"
+#include <perfmon.rsg>
+
+#include <eikenv.h>
+#include <aknViewAppUi.h> 
+
+
+// ================= MEMBER FUNCTIONS =======================
+
+// ---------------------------------------------------------
+// CPerfMonGraphsView::ConstructL(const TRect& aRect)
+// EPOC two-phased constructor
+// ---------------------------------------------------------
+//
+void CPerfMonGraphsView::ConstructL()
+    {
+    BaseConstructL( R_PERFMON_VIEW_GRAPHS );
+    iModel = static_cast<CPerfMonDocument*>(reinterpret_cast<CEikAppUi*>(iEikonEnv->AppUi())->Document())->Model();
+    }
+
+// ---------------------------------------------------------
+// CPerfMonGraphsView::~CPerfMonGraphsView()
+// ---------------------------------------------------------
+//
+CPerfMonGraphsView::~CPerfMonGraphsView()
+    {
+    if (iContainer)
+        {
+        AppUi()->RemoveFromViewStack( *this, iContainer );
+        delete iContainer;
+        iContainer = NULL;
+        }
+    }
+
+// ---------------------------------------------------------
+// TUid CPerfMonGraphsView::Id()
+// ---------------------------------------------------------
+//
+TUid CPerfMonGraphsView::Id() const
+    {
+    return KGraphsViewUID;
+    }
+
+// ---------------------------------------------------------
+// TUid CPerfMonGraphsView::DynInitMenuPaneL(TInt aResourceId, CEikMenuPane* aMenuPane)
+// ---------------------------------------------------------
+//
+void CPerfMonGraphsView::DynInitMenuPaneL(TInt aResourceId, CEikMenuPane* aMenuPane)
+    {
+    AppUi()->DynInitMenuPaneL(aResourceId, aMenuPane);
+    }
+
+  
+// ---------------------------------------------------------
+// CPerfMonGraphsView::HandleCommandL(TInt aCommand)
+// ---------------------------------------------------------
+//
+void CPerfMonGraphsView::HandleCommandL(TInt aCommand)
+    {   
+/*
+    switch ( aCommand )
+        {
+        case EPerfMonCmdFileBack:
+            {
+            iModel->FileUtils()->MoveUpOneLevelL();
+            break;
+            }
+
+        default:
+            {
+*/
+            AppUi()->HandleCommandL( aCommand );
+/*
+            break;
+            }
+        }
+*/
+    }
+
+// ---------------------------------------------------------
+// CPerfMonGraphsView::HandleClientRectChange()
+// ---------------------------------------------------------
+//
+void CPerfMonGraphsView::HandleClientRectChange()
+    {
+    if ( iContainer )
+        {
+        iContainer->SetRect( ClientRect() );
+        }
+    }
+
+// ---------------------------------------------------------
+// CPerfMonGraphsView::DoActivateL(...)
+// ---------------------------------------------------------
+//
+void CPerfMonGraphsView::DoActivateL(
+   const TVwsViewId& /*aPrevViewId*/,TUid /*aCustomMessageId*/,
+   const TDesC8& /*aCustomMessage*/)
+    {
+    if (!iContainer)
+        {
+        iContainer = new (ELeave) CPerfMonGraphsContainer;
+        iModel->SetGraphsContainer(iContainer);
+        iContainer->SetMopParent(this);
+        iContainer->ConstructL( ClientRect() );
+        AppUi()->AddToStackL( *this, iContainer );
+        } 
+   }
+
+// ---------------------------------------------------------
+// CPerfMonGraphsView::DoDeactivate()
+// ---------------------------------------------------------
+//
+void CPerfMonGraphsView::DoDeactivate()
+    {
+    if (iContainer)
+        {
+        AppUi()->RemoveFromViewStack( *this, iContainer );
+        delete iContainer;
+        iContainer = NULL;
+        }
+    }
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/perfmon/ui/avkon/src/perfmon_model.cpp	Mon May 03 12:32:02 2010 +0300
@@ -0,0 +1,147 @@
+/*
+* 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 FILES
+
+#include "perfmon_model.h"
+#include "perfmon_app.h"
+#include "perfmon_settingsviewdlg.h"
+#include "perfmon.hrh"
+#include "perfmon_valuescontainer.h"
+#include "perfmon_graphscontainer.h"
+#include "perfmon_datapopupcontainer.h"
+#include <perfmon.rsg>
+
+#include <coeutils.h>
+#include <bautils.h>
+#include <eikenv.h>
+#include <e32hal.h>
+#include <u32std.h>
+#include <s32file.h>
+#include <akntitle.h> 
+#include <eikspane.h>
+#include <aknnotewrappers.h>  
+
+_LIT(KAppName, "PerfMon");
+
+// ===================================== MEMBER FUNCTIONS =====================================
+
+CPerfMonModel* CPerfMonModel::NewL()
+	{
+	CPerfMonModel* self = new(ELeave) CPerfMonModel;
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop();
+	return self;
+	}
+
+// --------------------------------------------------------------------------------------------
+
+void CPerfMonModel::ConstructL()
+	{
+	iDrawState = EDrawStateInvalid;
+	CPerfMonEngine::ConstructL();
+	}
+
+// --------------------------------------------------------------------------------------------
+
+void CPerfMonModel::ActivateModelL()
+	{
+	// initialize the data popup container in top-right corner
+	iDataPopupContainer = new(ELeave) CPerfMonDataPopupContainer;
+	iDataPopupContainer->ConstructL(TRect(0,0,1,1));
+    
+	ActivateEngineL();
+	}
+
+// --------------------------------------------------------------------------------------------
+
+void CPerfMonModel::DeActivateModelL()
+	{
+	DeActivateEngineL();
+	
+	if (iDataPopupContainer)
+		{
+		delete iDataPopupContainer;
+		iDataPopupContainer = NULL;
+		}
+	}
+
+// --------------------------------------------------------------------------------------------
+
+void CPerfMonModel::SetValuesContainer(CPerfMonValuesContainer* aContainer)
+    {
+    iValuesContainer = aContainer;
+    iDrawState = EDrawStateValues;
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CPerfMonModel::SetGraphsContainer(CPerfMonGraphsContainer* aContainer)
+    {
+    iGraphsContainer = aContainer;
+    iDrawState = EDrawStateGraphs;
+    }
+    
+// --------------------------------------------------------------------------------------------
+
+void CPerfMonModel::SendDrawEventToContainersL()
+    {
+    if (iDrawState == EDrawStateValues && iValuesContainer)
+        iValuesContainer->DrawUpdate();
+    else if (iDrawState == EDrawStateGraphs && iGraphsContainer)
+        iGraphsContainer->DrawUpdate();
+           
+    if (iDataPopupContainer)
+        iDataPopupContainer->DrawUpdate();
+    }
+
+void CPerfMonModel::HandleSettingsChangeL()
+    {
+    // set visibility and location of the data popup
+    iDataPopupContainer->UpdateVisibility();
+    iDataPopupContainer->SetPositionAndSize();
+    CPerfMonEngine::HandleSettingsChangeL();
+    }
+            
+// --------------------------------------------------------------------------------------------
+
+TInt CPerfMonModel::LaunchSettingsDialogL()
+    {
+    // launch the settings dialog
+    TPerfMonSettings newSettings = iSettings;
+    
+    CPerfMonSettingsViewDlg* dlg = CPerfMonSettingsViewDlg::NewL(newSettings);
+    TInt returnValue = dlg->ExecuteLD(R_PERFMON_SETTINGS_DIALOG);
+    
+    // always save settings since the settings dialog does not provide a possibility to cancel
+    iSettings = newSettings;
+    SaveSettingsL();
+    HandleSettingsChangeL();
+
+    // make sure that the title of the application is correct
+    CEikStatusPane* sp = iEnv->AppUiFactory()->StatusPane();
+    CAknTitlePane* tp = static_cast<CAknTitlePane*>( sp->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) );
+    tp->SetTextL(KAppName);
+    
+    return returnValue;
+    }
+	
+// ---------------------------------------------------------------------------
+    
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/perfmon/ui/avkon/src/perfmon_settingsviewdlg.cpp	Mon May 03 12:32:02 2010 +0300
@@ -0,0 +1,681 @@
+/*
+* 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 FILES
+#include "perfmon_settingsviewdlg.h"
+#include "perfmon_model.h"
+#include "perfmon.hrh"
+#include "perfmon_std.h"
+#include <perfmon.rsg>
+
+#include <aknsettingitemlist.h>
+#include <CAknMemorySelectionSettingItem.h> 
+#include <aknlists.h>
+#include <akntitle.h>
+#include <aknnavi.h>
+#include <aknnavide.h>
+#include <StringLoader.h>
+#include <aknnotewrappers.h> 
+
+// ===================================== MEMBER FUNCTIONS =====================================
+
+CPerfMonSettingsViewDlg* CPerfMonSettingsViewDlg::NewL(TPerfMonSettings& aSettings)
+    {
+    CPerfMonSettingsViewDlg* self = new(ELeave) CPerfMonSettingsViewDlg(aSettings);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;    
+    }
+
+// --------------------------------------------------------------------------------------------
+
+CPerfMonSettingsViewDlg::~CPerfMonSettingsViewDlg()
+    {
+    // restore default navi pane by popping the tab group from stack
+    if (iNaviContainer)
+        iNaviContainer->Pop();
+    
+    if (iSettingItemArray)
+        {
+        iSettingItemArray->ResetAndDestroy();
+        delete iSettingItemArray; 
+        }
+    
+    delete iDecoratedTabGroup;   
+    }
+
+// --------------------------------------------------------------------------------------------
+
+CPerfMonSettingsViewDlg::CPerfMonSettingsViewDlg(TPerfMonSettings& aSettings) : iSettings(aSettings)
+    {
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CPerfMonSettingsViewDlg::ConstructL()
+    {
+    // construct a menu bar
+    CAknDialog::ConstructL(R_PERFMON_SETTINGS_MENUBAR);
+
+    // get pointer to status pane   
+    CEikStatusPane* sp = iEikonEnv->AppUiFactory()->StatusPane();
+    
+    // set title text
+    CAknTitlePane* tp = static_cast<CAknTitlePane*>( sp->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) );
+    tp->SetTextL( _L("Settings") );
+    
+    // create a new tab group
+    iNaviContainer = static_cast<CAknNavigationControlContainer*>(sp->ControlL(TUid::Uid(EEikStatusPaneUidNavi)));
+    iDecoratedTabGroup = iNaviContainer->CreateTabGroupL(this);
+    iTabGroup = static_cast<CAknTabGroup*>(iDecoratedTabGroup->DecoratedControl());
+    iTabGroup->SetTabFixedWidthL(KTabWidthWithTwoLongTabs); 
+    
+    // add tabs
+    iTabGroup->AddTabL(ETabSettingsGeneral, _L("General"));
+    iTabGroup->AddTabL(ETabSettingsDataPopup, _L("Data popup"));
+    iTabGroup->AddTabL(ETabSettingsGraphs, _L("Graphs"));
+    iTabGroup->AddTabL(ETabSettingsLogging, _L("Logging"));
+    iTabGroup->SetActiveTabByIndex(ETabSettingsGeneral);
+    
+    // add new tab group to stack
+    iNaviContainer->PushL( *iDecoratedTabGroup );
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CPerfMonSettingsViewDlg::HandleListBoxEventL(CEikListBox* /*aListBox*/, TListBoxEvent aEventType)
+    {
+    switch (aEventType)
+        {
+        case EEventEnterKeyPressed:
+        case EEventItemDoubleClicked:
+            ShowSettingPageL(EFalse);
+            break;
+        default:
+            break;
+        }
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CPerfMonSettingsViewDlg::TabChangedL(TInt /*aIndex*/)
+    {
+    iListBox->SetCurrentItemIndex(0);
+
+    SetVisibilitiesOfSettingItemsL();   
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CPerfMonSettingsViewDlg::ProcessCommandL(TInt aCommandId)
+    {
+    CAknDialog::ProcessCommandL(aCommandId);
+
+    switch (aCommandId)
+        {
+        case EPerfMonCmdSettingsChange:
+            ShowSettingPageL(ETrue);
+            break;
+        case EPerfMonCmdSettingsExit:
+            TryExitL(EAknCmdExit);
+            break;
+        default:
+            break;
+        }
+    }
+
+// --------------------------------------------------------------------------------------------
+
+TKeyResponse CPerfMonSettingsViewDlg::OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType)
+    {
+    if (iTabGroup == NULL)
+        {
+        return EKeyWasNotConsumed;
+        }
+
+    TInt active = iTabGroup->ActiveTabIndex();
+    TInt count = iTabGroup->TabCount();
+
+    switch ( aKeyEvent.iCode )
+        {
+        case EKeyLeftArrow:
+            if (active > 0)
+                {
+                active--;
+                iTabGroup->SetActiveTabByIndex(active);
+                TabChangedL(active); 
+                }
+            break;
+        
+        case EKeyRightArrow:
+            if((active + 1) < count)
+                {
+                active++;
+                iTabGroup->SetActiveTabByIndex(active);
+                TabChangedL(active); 
+                }
+            break;
+        }
+
+    return CAknDialog::OfferKeyEventL(aKeyEvent, aType);
+    }    
+
+// --------------------------------------------------------------------------------------------
+
+void CPerfMonSettingsViewDlg::PreLayoutDynInitL()
+    {
+    iListBox = static_cast<CAknSettingStyleListBox*>( Control(EPerfMonSettingItemList) );
+    iListBox->SetMopParent(this);
+    iListBox->CreateScrollBarFrameL(ETrue);
+    iListBox->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto);
+    iListBox->SetListBoxObserver(this);
+
+    iSettingItemArray = new(ELeave) CAknSettingItemArray(16, EFalse, 0);
+
+    CTextListBoxModel* model = iListBox->Model();
+    model->SetItemTextArray(iSettingItemArray);
+    model->SetOwnershipType(ELbmDoesNotOwnItemArray);
+
+    UpdateListBoxL();    
+    }
+
+// --------------------------------------------------------------------------------------------
+
+TBool CPerfMonSettingsViewDlg::OkToExitL(TInt aButtonId)
+    {
+    return CAknDialog::OkToExitL(aButtonId);
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CPerfMonSettingsViewDlg::ShowSettingPageL(TInt aCalledFromMenu)
+    {
+    TInt listIndex = iListBox->CurrentItemIndex();
+    TInt realIndex = iSettingItemArray->ItemIndexFromVisibleIndex(listIndex);
+    CAknSettingItem* item = iSettingItemArray->At(realIndex);
+    item->EditItemL(aCalledFromMenu);
+    item->StoreL();
+    SetVisibilitiesOfSettingItemsL();
+    DrawNow();
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CPerfMonSettingsViewDlg::SetVisibilitiesOfSettingItemsL()
+    {
+    if (iSettingItemArray->Count() > 0)
+        {
+        switch (iTabGroup->ActiveTabIndex())
+            {
+            case ETabSettingsGeneral:
+                {
+                ((*iSettingItemArray)[ESettingListItemHeartBeat])->SetHidden(EFalse);
+                ((*iSettingItemArray)[ESettingListItemMaxSamples])->SetHidden(EFalse);
+                ((*iSettingItemArray)[ESettingListItemPriority])->SetHidden(EFalse);
+                ((*iSettingItemArray)[ESettingListItemCPUMode])->SetHidden(EFalse);
+                ((*iSettingItemArray)[ESettingListItemKeepBackLightOn])->SetHidden(EFalse);
+
+                ((*iSettingItemArray)[ESettingListItemDataPopupVisbility])->SetHidden(ETrue);
+                ((*iSettingItemArray)[ESettingListItemDataPopupLocation])->SetHidden(ETrue);
+                ((*iSettingItemArray)[ESettingListItemDataPopupSources])->SetHidden(ETrue);
+
+                ((*iSettingItemArray)[ESettingListItemGraphsVerticalBarPeriod])->SetHidden(ETrue);
+                ((*iSettingItemArray)[ESettingListItemGraphsSources])->SetHidden(ETrue);
+
+                ((*iSettingItemArray)[ESettingListItemLoggingMode])->SetHidden(ETrue);
+                ((*iSettingItemArray)[ESettingListItemLoggingFilePath])->SetHidden(ETrue);
+                ((*iSettingItemArray)[ESettingListItemLoggingSources])->SetHidden(ETrue);
+
+                break;
+                }
+            
+            case ETabSettingsDataPopup:
+                {
+                ((*iSettingItemArray)[ESettingListItemHeartBeat])->SetHidden(ETrue);
+                ((*iSettingItemArray)[ESettingListItemMaxSamples])->SetHidden(ETrue);
+                ((*iSettingItemArray)[ESettingListItemPriority])->SetHidden(ETrue);
+                ((*iSettingItemArray)[ESettingListItemCPUMode])->SetHidden(ETrue);
+                ((*iSettingItemArray)[ESettingListItemKeepBackLightOn])->SetHidden(ETrue);
+
+                ((*iSettingItemArray)[ESettingListItemDataPopupVisbility])->SetHidden(EFalse);
+                ((*iSettingItemArray)[ESettingListItemDataPopupLocation])->SetHidden(EFalse);
+                ((*iSettingItemArray)[ESettingListItemDataPopupSources])->SetHidden(EFalse);
+
+                ((*iSettingItemArray)[ESettingListItemGraphsVerticalBarPeriod])->SetHidden(ETrue);
+                ((*iSettingItemArray)[ESettingListItemGraphsSources])->SetHidden(ETrue);
+
+                ((*iSettingItemArray)[ESettingListItemLoggingMode])->SetHidden(ETrue);
+                ((*iSettingItemArray)[ESettingListItemLoggingFilePath])->SetHidden(ETrue);
+                ((*iSettingItemArray)[ESettingListItemLoggingSources])->SetHidden(ETrue);
+
+                break;
+                }
+
+            case ETabSettingsGraphs:
+                {
+                ((*iSettingItemArray)[ESettingListItemHeartBeat])->SetHidden(ETrue);
+                ((*iSettingItemArray)[ESettingListItemMaxSamples])->SetHidden(ETrue);
+                ((*iSettingItemArray)[ESettingListItemPriority])->SetHidden(ETrue);
+                ((*iSettingItemArray)[ESettingListItemCPUMode])->SetHidden(ETrue);
+                ((*iSettingItemArray)[ESettingListItemKeepBackLightOn])->SetHidden(ETrue);
+
+                ((*iSettingItemArray)[ESettingListItemDataPopupVisbility])->SetHidden(ETrue);
+                ((*iSettingItemArray)[ESettingListItemDataPopupLocation])->SetHidden(ETrue);
+                ((*iSettingItemArray)[ESettingListItemDataPopupSources])->SetHidden(ETrue);
+
+                ((*iSettingItemArray)[ESettingListItemGraphsVerticalBarPeriod])->SetHidden(EFalse);
+                ((*iSettingItemArray)[ESettingListItemGraphsSources])->SetHidden(EFalse);
+
+                ((*iSettingItemArray)[ESettingListItemLoggingMode])->SetHidden(ETrue);
+                ((*iSettingItemArray)[ESettingListItemLoggingFilePath])->SetHidden(ETrue);
+                ((*iSettingItemArray)[ESettingListItemLoggingSources])->SetHidden(ETrue);
+
+                break;
+                }
+
+            case ETabSettingsLogging:
+                {
+                ((*iSettingItemArray)[ESettingListItemHeartBeat])->SetHidden(ETrue);
+                ((*iSettingItemArray)[ESettingListItemMaxSamples])->SetHidden(ETrue);
+                ((*iSettingItemArray)[ESettingListItemPriority])->SetHidden(ETrue);
+                ((*iSettingItemArray)[ESettingListItemCPUMode])->SetHidden(ETrue);
+                ((*iSettingItemArray)[ESettingListItemKeepBackLightOn])->SetHidden(ETrue);
+
+                ((*iSettingItemArray)[ESettingListItemDataPopupVisbility])->SetHidden(ETrue);
+                ((*iSettingItemArray)[ESettingListItemDataPopupLocation])->SetHidden(ETrue);
+                ((*iSettingItemArray)[ESettingListItemDataPopupSources])->SetHidden(ETrue);
+
+                ((*iSettingItemArray)[ESettingListItemGraphsVerticalBarPeriod])->SetHidden(ETrue);
+                ((*iSettingItemArray)[ESettingListItemGraphsSources])->SetHidden(ETrue);
+
+                ((*iSettingItemArray)[ESettingListItemLoggingMode])->SetHidden(EFalse);
+                
+                if (iSettings.iLoggingMode == ELoggingModeLogFile || iSettings.iLoggingMode == ELoggingModeRDebugLogFile)
+                    ((*iSettingItemArray)[ESettingListItemLoggingFilePath])->SetHidden(EFalse);
+                else
+                    ((*iSettingItemArray)[ESettingListItemLoggingFilePath])->SetHidden(ETrue);
+                
+                ((*iSettingItemArray)[ESettingListItemLoggingSources])->SetHidden(EFalse);
+
+                break;
+                }                
+
+            default:
+                User::Panic(_L("TabIOOB"), 50);
+                break;
+            }
+
+        iSettingItemArray->RecalculateVisibleIndicesL();
+        iListBox->HandleItemAdditionL();
+        iListBox->UpdateScrollBarsL();
+        }
+    }   
+
+// --------------------------------------------------------------------------------------------
+
+void CPerfMonSettingsViewDlg::UpdateListBoxL()
+    {
+    iSettingItemArray->ResetAndDestroy();
+
+    // create items
+    TInt ordinal(0);
+
+    AddSettingItemL(ESettingListItemHeartBeat,
+                    R_HEARTBEAT_SETTING_TITLE,
+                    R_HEARTBEAT_SETTING_PAGE,
+                    NULL,
+                    ordinal++);    
+    
+    AddSettingItemL(ESettingListItemMaxSamples,
+                    R_MAXSAMPLES_SETTING_TITLE,
+                    R_MAXSAMPLES_SETTING_PAGE,
+                    NULL,
+                    ordinal++);
+
+    AddSettingItemL(ESettingListItemPriority,
+                    R_PRIORITY_SETTING_TITLE,
+                    R_PRIORITY_SETTING_PAGE,
+                    R_PRIORITY_SETTING_TEXTS,
+                    ordinal++);
+
+    AddSettingItemL(ESettingListItemCPUMode,
+                    R_CPUMODE_SETTING_TITLE,
+                    R_CPUMODE_SETTING_PAGE,
+                    R_CPUMODE_SETTING_TEXTS,
+                    ordinal++);
+
+    AddSettingItemL(ESettingListItemKeepBackLightOn,
+                    R_KEEPBACKLIGHTON_SETTING_TITLE,
+                    R_BINARY_SETTING_PAGE,
+                    R_YESNO_BINARYSELECTION_TEXTS,
+                    ordinal++);
+//
+    AddSettingItemL(ESettingListItemDataPopupVisbility,
+                    R_DATAPOPUPVISIBILITY_SETTING_TITLE,
+                    R_DATAPOPUPVISIBILITY_SETTING_PAGE,
+                    R_DATAPOPUPVISIBILITY_SETTING_TEXTS,
+                    ordinal++);
+
+    AddSettingItemL(ESettingListItemDataPopupLocation,
+                    R_DATAPOPUPLOCATION_SETTING_TITLE,
+                    R_DATAPOPUPLOCATION_SETTING_PAGE,
+                    R_DATAPOPUPLOCATION_SETTING_TEXTS,
+                    ordinal++);
+
+    AddSettingItemL(ESettingListItemDataPopupSources,
+                    R_SOURCES_SETTING_TITLE,
+                    R_SOURCES_SETTING_PAGE,
+                    NULL,
+                    ordinal++);                    
+//
+    AddSettingItemL(ESettingListItemGraphsVerticalBarPeriod,
+                    R_GRAPHSVERTICALBAR_SETTING_TITLE,
+                    R_GRAPHSVERTICALBAR_SETTING_PAGE,
+                    NULL,
+                    ordinal++);
+    
+    AddSettingItemL(ESettingListItemGraphsSources,
+                    R_SOURCES_SETTING_TITLE,
+                    R_SOURCES_SETTING_PAGE,
+                    NULL,
+                    ordinal++);                    
+//
+    AddSettingItemL(ESettingListItemLoggingMode,
+                    R_LOGGINGMODE_SETTING_TITLE,
+                    R_LOGGINGMODE_SETTING_PAGE,
+                    R_LOGGINGMODE_SETTING_TEXTS,
+                    ordinal++);
+
+     AddSettingItemL(ESettingListItemLoggingFilePath,
+                    R_LOGGINGFILEPATH_SETTING_TITLE,
+                    R_LOGGINGFILEPATH_SETTING_PAGE,
+                    NULL,
+                    ordinal++);
+    
+    AddSettingItemL(ESettingListItemLoggingSources,
+                    R_SOURCES_SETTING_TITLE,
+                    R_SOURCES_SETTING_PAGE,
+                    NULL,
+                    ordinal++);                    
+                                                             
+    SetVisibilitiesOfSettingItemsL(); 
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CPerfMonSettingsViewDlg::AddSettingItemL(TInt aId,
+                                                 TInt aTitleResource,
+                                                 TInt aSettingPageResource,
+                                                 TInt aAssociatedResource,
+                                                 TInt aOrdinal)
+    {
+    // create a setting item
+    CAknSettingItem* settingItem = NULL;
+    
+    switch (aId)
+        {
+        case ESettingListItemHeartBeat:
+            settingItem = new(ELeave) CAknIntegerEdwinSettingItem(aId, iSettings.iHeartBeat);
+            break;
+
+        case ESettingListItemMaxSamples:
+            settingItem = new(ELeave) CAknIntegerEdwinSettingItem(aId, iSettings.iMaxSamples);
+            break;
+
+        case ESettingListItemPriority:
+            settingItem = new(ELeave) CAknEnumeratedTextPopupSettingItem(aId, iSettings.iPriority);
+            break;
+
+        case ESettingListItemCPUMode:
+            settingItem = new(ELeave) CAknEnumeratedTextPopupSettingItem(aId, iSettings.iCPUMode);
+            break;
+
+        case ESettingListItemKeepBackLightOn:
+            settingItem = new(ELeave) CAknBinaryPopupSettingItem(aId, iSettings.iKeepBacklightOn);
+            break;
+
+        case ESettingListItemDataPopupVisbility:
+            settingItem = new(ELeave) CAknEnumeratedTextPopupSettingItem(aId, iSettings.iDataPopupVisibility);
+            break;
+
+        case ESettingListItemDataPopupLocation:
+            settingItem = new(ELeave) CAknEnumeratedTextPopupSettingItem(aId, iSettings.iDataPopupLocation);
+            break;
+
+        case ESettingListItemDataPopupSources:
+            settingItem = new(ELeave) CSourceSelectionCheckBoxSettingItem(aId, iSettings.iDataPopupSources);
+            break;
+
+        case ESettingListItemGraphsVerticalBarPeriod:
+            settingItem = new(ELeave) CAknIntegerEdwinSettingItem(aId, iSettings.iGraphsVerticalBarPeriod);
+            break;
+
+        case ESettingListItemGraphsSources:
+            settingItem = new(ELeave) CSourceSelectionCheckBoxSettingItem(aId, iSettings.iGraphsSources);
+            break;
+
+        case ESettingListItemLoggingMode:
+            settingItem = new(ELeave) CAknEnumeratedTextPopupSettingItem(aId, iSettings.iLoggingMode);
+            break;
+
+        case ESettingListItemLoggingFilePath:
+            settingItem = new(ELeave) CAknTextSettingItem(aId, iSettings.iLoggingFilePath);
+            break;
+
+        case ESettingListItemLoggingSources:
+            settingItem = new(ELeave) CSourceSelectionCheckBoxSettingItem(aId, iSettings.iLoggingSources);
+            break;
+
+        default:
+            User::Panic(_L("NotSetItem"), 50);
+            break;
+        }
+        
+    CleanupStack::PushL(settingItem);
+
+    // get title text
+    HBufC* itemTitle = StringLoader::LoadLC(aTitleResource);
+
+    // construct the setting item
+    settingItem->ConstructL(EFalse, aOrdinal, *itemTitle, NULL, aSettingPageResource,
+                            EAknCtPopupSettingList, NULL, aAssociatedResource);
+
+    // append the setting item to settingitem array
+    iSettingItemArray->InsertL(aOrdinal, settingItem);
+
+    CleanupStack::PopAndDestroy(); //itemTitle
+    CleanupStack::Pop(); //settingItem
+    }
+
+
+// --------------------------------------------------------------------------------------------
+// --------------------------------------------------------------------------------------------
+	
+CSourceSelectionCheckBoxSettingItem::CSourceSelectionCheckBoxSettingItem( TInt aIdentifier, TPerfMonSources& aMemoryInUse ): 
+	CAknSettingItem(aIdentifier), iExternalSources( aMemoryInUse ) 
+	{
+	}	
+
+CSourceSelectionCheckBoxSettingItem::~CSourceSelectionCheckBoxSettingItem()
+	{
+	delete iSettingText;
+
+    if( iItemArray )
+        {
+        iItemArray->ResetAndDestroy();
+        delete iItemArray;
+        }
+	}
+
+void CSourceSelectionCheckBoxSettingItem::AddNewItemToArrayL(const TDesC& aLabel)
+	{
+	TBuf<64> buf;
+	buf.Copy(aLabel);
+	
+    CSelectableItem* item = new(ELeave) CSelectableItem(buf, EFalse);
+    CleanupStack::PushL(item);
+    item->ConstructL();
+    iItemArray->AppendL(item); // Ownership is transferred
+    CleanupStack::Pop(); // item	
+	}
+	
+void CSourceSelectionCheckBoxSettingItem::CompleteConstructionL()
+	{
+    SetEmptyItemTextL(_L("Nothing selected"));
+
+    iItemArray = new(ELeave) CSelectionItemList(16);
+    AddNewItemToArrayL(_L("CPU"));
+    AddNewItemToArrayL(_L("RAM"));
+    AddNewItemToArrayL(_L("C:"));
+    AddNewItemToArrayL(_L("D:"));
+    AddNewItemToArrayL(_L("E:"));
+    AddNewItemToArrayL(_L("F:"));
+    AddNewItemToArrayL(_L("G:"));
+    AddNewItemToArrayL(_L("H:"));
+    AddNewItemToArrayL(_L("I:"));
+
+	__ASSERT_ALWAYS(ESourcesLength==iItemArray->Count(), User::Panic(_L("Src.mismatch"),443));
+    }
+
+// transfer settings to the variables defined in the constructor    	
+void CSourceSelectionCheckBoxSettingItem::StoreL()
+	{
+	for (TInt i=0; i<ESourcesLength; i++)
+	    {
+        iExternalSources.iSrcEnabled[i] = iItemArray->At(i)->SelectionStatus();
+	    }
+	}
+
+// load settings from the variables defined in the constructor to our internal variables
+void CSourceSelectionCheckBoxSettingItem::LoadL()
+	{
+	for (TInt i=0; i<ESourcesLength; i++)
+	    {
+        iItemArray->At(i)->SetSelectionStatus( iExternalSources.iSrcEnabled[i] );
+	    }
+	}
+
+// returns the text shown in the setting item list
+const TDesC& CSourceSelectionCheckBoxSettingItem::SettingTextL()
+	{
+    TBuf<32> settingText;
+
+    if (iItemArray->At(ESourceCPU)->SelectionStatus())
+        settingText.Append(_L("CPU "));
+    if (iItemArray->At(ESourceRAM)->SelectionStatus())
+        settingText.Append(_L("RAM "));
+    if (iItemArray->At(ESourceC)->SelectionStatus())
+        settingText.Append(_L("C: "));
+    if (iItemArray->At(ESourceD)->SelectionStatus())
+        settingText.Append(_L("D: "));
+    if (iItemArray->At(ESourceE)->SelectionStatus())
+        settingText.Append(_L("E: "));
+    if (iItemArray->At(ESourceF)->SelectionStatus())
+        settingText.Append(_L("F: "));
+    if (iItemArray->At(ESourceG)->SelectionStatus())
+        settingText.Append(_L("G: "));
+    if (iItemArray->At(ESourceH)->SelectionStatus())
+        settingText.Append(_L("H: "));
+    if (iItemArray->At(ESourceI)->SelectionStatus())
+        settingText.Append(_L("I: "));
+    settingText.TrimAll();
+
+    if (iSettingText)
+        {
+        delete iSettingText;
+        iSettingText = NULL;
+        }
+
+    iSettingText = HBufC::NewL(settingText.Length());
+    iSettingText->Des().Copy(settingText);
+
+	if ( iSettingText->Length() > 0 )
+		return *iSettingText;
+	else
+		return EmptyItemText();
+	}
+
+
+// launches the setting page
+void CSourceSelectionCheckBoxSettingItem::EditItemL(TBool /*aCalledFromMenu*/)
+	{
+	CSourceSelectionCheckBoxSettingPage* dlg = new(ELeave) CSourceSelectionCheckBoxSettingPage(SettingPageResourceId(), iItemArray);
+
+	SetSettingPage( dlg );
+	SettingPage()->SetSettingPageObserver(this);
+
+	SettingPage()->ExecuteLD(CAknSettingPage::EUpdateWhenChanged);
+	SetSettingPage(0); // it is deleted now
+	}
+
+
+// handles setting page events
+void CSourceSelectionCheckBoxSettingItem::HandleSettingPageEventL( CAknSettingPage* aSettingPage, TAknSettingPageEvent aEventType )
+    {
+    switch( aEventType )
+        {
+        case EEventSettingCancelled:
+            {
+            // If setting is cancelled, load old values
+            LoadL();
+            break;
+            }
+        case EEventSettingChanged:
+            {
+            // If setting has changed, update CBA visibility
+            static_cast<CSourceSelectionCheckBoxSettingPage*>( aSettingPage )->UpdateCba();
+            break;
+            }
+        default:
+            {
+            break;
+            }
+        }
+    CAknSettingItem::HandleSettingPageEventL( aSettingPage, aEventType );
+    }
+
+// --------------------------------------------------------------------------------------------
+// --------------------------------------------------------------------------------------------
+
+CSourceSelectionCheckBoxSettingPage::CSourceSelectionCheckBoxSettingPage(TInt aResourceID, CSelectionItemList* aItemArray )
+    : CAknCheckBoxSettingPage( aResourceID, aItemArray )
+	{
+	}
+
+void CSourceSelectionCheckBoxSettingPage::UpdateCba()
+	{
+	// Cache the pointer to button group container
+	CEikButtonGroupContainer* cba = Cba();
+	// Left softkey should be visible if there are items selected,
+	// i.e. the selection index array has items.
+	TBool visible( ListBoxControl()->View()->SelectionIndexes()->Count() > 0 );
+	// Resolve left softkey command id
+	TInt leftId( cba->ButtonGroup()->CommandId( 0 ) );
+	// Check if left softkey visibility has changed
+	if( visible != cba->IsCommandVisible( leftId ) )
+		{
+		// Left softkey visibility has changed, update it
+		cba->MakeCommandVisible( leftId, visible );
+		}
+	}
+
+// --------------------------------------------------------------------------------------------
+// --------------------------------------------------------------------------------------------
+    
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/perfmon/ui/avkon/src/perfmon_valuescontainer.cpp	Mon May 03 12:32:02 2010 +0300
@@ -0,0 +1,143 @@
+/*
+* 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 FILES
+#include "perfmon_valuescontainer.h"
+#include "perfmon.hrh"
+#include "perfmon_document.h"
+#include "perfmon_appui.h"
+#include "perfmon_model.h"
+
+#include <AknUtils.h>
+
+_LIT(KPercentageFormat,"%S %d%%");
+_LIT(KFreeFormat,"%S free %S%S"); 
+_LIT(KSizeFormat,"%S size %S%S"); 
+
+const TInt KLeftMargin = 2;
+
+
+// ===================================== MEMBER FUNCTIONS =====================================
+
+void CPerfMonValuesContainer::ConstructL(const TRect& aRect)
+    {
+    iModel = static_cast<CPerfMonDocument*>(reinterpret_cast<CEikAppUi*>(iEikonEnv->AppUi())->Document())->Model();
+    iFont = AknLayoutUtils::FontFromId(EAknLogicalFontSecondaryFont);
+ 
+    CreateWindowL();
+    SetRect(aRect);
+    SetBlank();
+
+    ActivateL();
+    }
+
+// --------------------------------------------------------------------------------------------
+
+CPerfMonValuesContainer::~CPerfMonValuesContainer()
+    {
+    }
+    
+// --------------------------------------------------------------------------------------------
+
+void CPerfMonValuesContainer::Draw(const TRect& aRect) const
+    {
+    CWindowGc& gc = SystemGc();
+    gc.SetBrushColor(KRgbWhite);
+    gc.Clear(aRect);
+    
+    // check if sample array has been constructed
+    if (iModel->SampleEntryArray())
+        {
+        // init font
+        gc.SetPenColor(KRgbBlack);
+        gc.UseFont( iFont );
+        TUint separator = iFont->HeightInPixels()-2;
+
+        TInt c(1);
+
+        // draw all entries
+        for (TInt i=0; i<iModel->SampleEntryArray()->Count(); i++)
+            {
+            // check if data available
+            if (iModel->SampleEntryArray()->At(i).iSampleDataArray->Count() > 0)
+                {
+                TSampleData& currentSample = iModel->SampleEntryArray()->At(i).iSampleDataArray->At(0);
+                
+                if (i == ESourceCPU) // for CPU draw %
+                    {
+                    TBuf<16> buf;
+                    buf.Format(KPercentageFormat, &iModel->SampleEntryArray()->At(i).iDescription, currentSample.iSize > 0 ? TInt( (1 - ((TReal)(currentSample.iFree) / (TReal)currentSample.iSize)) * 100) : 0 );
+                    gc.DrawText(buf, TPoint(KLeftMargin,separator*c));
+                    c++;
+                    }
+                
+                else if (currentSample.iSize > 0) // ram+drives, ignore absent drives
+                    {
+                    TBuf<32> amountBuf;
+                    amountBuf.AppendNum(currentSample.iFree, TRealFormat(KDefaultRealWidth, 0));
+        
+                    TBuf<32> buf;
+                    buf.Format(KFreeFormat, &iModel->SampleEntryArray()->At(i).iDescription, &amountBuf, &iModel->SampleEntryArray()->At(i).iUnitTypeShort);
+                    gc.DrawText(buf, TPoint(KLeftMargin,separator*c));
+                    c++;
+                    
+                    amountBuf.Copy(KNullDesC);
+                    amountBuf.AppendNum(currentSample.iSize, TRealFormat(KDefaultRealWidth, 0));
+        
+                    buf.Format(KSizeFormat, &iModel->SampleEntryArray()->At(i).iDescription, &amountBuf, &iModel->SampleEntryArray()->At(i).iUnitTypeShort);
+                    gc.DrawText(buf, TPoint(KLeftMargin,separator*c));
+                    c++;            
+                    }                    
+                }
+            }
+           
+        gc.DiscardFont();        
+        }
+    }
+
+// --------------------------------------------------------------------------------------------
+
+TKeyResponse CPerfMonValuesContainer::OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType)
+    {
+    return CCoeControl::OfferKeyEventL(aKeyEvent, aType);
+    }
+        
+// --------------------------------------------------------------------------------------------
+
+void CPerfMonValuesContainer::HandleResourceChange(TInt aType)
+    {
+    if (aType == KEikDynamicLayoutVariantSwitch)
+        {
+        TRect mainPaneRect;
+        AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, mainPaneRect);
+        SetRect(mainPaneRect);
+        }
+    else
+        CCoeControl::HandleResourceChange(aType);    
+    }
+
+// --------------------------------------------------------------------------------------------
+
+void CPerfMonValuesContainer::DrawUpdate()
+    {
+    DrawDeferred(); 
+    }
+    
+// --------------------------------------------------------------------------------------------
+       
+// End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/perfmon/ui/avkon/src/perfmon_valuesview.cpp	Mon May 03 12:32:02 2010 +0300
@@ -0,0 +1,147 @@
+/*
+* 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 FILES
+#include "perfmon.hrh"
+#include "perfmon_valuesview.h"
+#include "perfmon_valuescontainer.h"
+#include "perfmon_document.h" 
+#include "perfmon_model.h"
+#include <perfmon.rsg>
+
+#include <eikenv.h>
+#include <aknViewAppUi.h> 
+
+
+// ================= MEMBER FUNCTIONS =======================
+
+// ---------------------------------------------------------
+// CPerfMonValuesView::ConstructL(const TRect& aRect)
+// EPOC two-phased constructor
+// ---------------------------------------------------------
+//
+void CPerfMonValuesView::ConstructL()
+    {
+    BaseConstructL( R_PERFMON_VIEW_VALUES );
+    iModel = static_cast<CPerfMonDocument*>(reinterpret_cast<CEikAppUi*>(iEikonEnv->AppUi())->Document())->Model();
+    }
+
+// ---------------------------------------------------------
+// CPerfMonValuesView::~CPerfMonValuesView()
+// ---------------------------------------------------------
+//
+CPerfMonValuesView::~CPerfMonValuesView()
+    {
+    if (iContainer)
+        {
+        AppUi()->RemoveFromViewStack( *this, iContainer );
+        delete iContainer;
+        iContainer = NULL;
+        }
+    }
+
+// ---------------------------------------------------------
+// TUid CPerfMonValuesView::Id()
+// ---------------------------------------------------------
+//
+TUid CPerfMonValuesView::Id() const
+    {
+    return KValuesViewUID;
+    }
+
+// ---------------------------------------------------------
+// TUid CPerfMonValuesView::DynInitMenuPaneL(TInt aResourceId, CEikMenuPane* aMenuPane)
+// ---------------------------------------------------------
+//
+void CPerfMonValuesView::DynInitMenuPaneL(TInt aResourceId, CEikMenuPane* aMenuPane)
+    {
+    AppUi()->DynInitMenuPaneL(aResourceId, aMenuPane);
+    }
+
+  
+// ---------------------------------------------------------
+// CPerfMonValuesView::HandleCommandL(TInt aCommand)
+// ---------------------------------------------------------
+//
+void CPerfMonValuesView::HandleCommandL(TInt aCommand)
+    {   
+/*
+    switch ( aCommand )
+        {
+        case EPerfMonCmdFileBack:
+            {
+            iModel->FileUtils()->MoveUpOneLevelL();
+            break;
+            }
+
+        default:
+            {
+*/
+            AppUi()->HandleCommandL( aCommand );
+/*
+            break;
+            }
+        }
+*/
+    }
+
+// ---------------------------------------------------------
+// CPerfMonValuesView::HandleClientRectChange()
+// ---------------------------------------------------------
+//
+void CPerfMonValuesView::HandleClientRectChange()
+    {
+    if ( iContainer )
+        {
+        iContainer->SetRect( ClientRect() );
+        }
+    }
+
+// ---------------------------------------------------------
+// CPerfMonValuesView::DoActivateL(...)
+// ---------------------------------------------------------
+//
+void CPerfMonValuesView::DoActivateL(
+   const TVwsViewId& /*aPrevViewId*/,TUid /*aCustomMessageId*/,
+   const TDesC8& /*aCustomMessage*/)
+    {
+    if (!iContainer)
+        {
+        iContainer = new (ELeave) CPerfMonValuesContainer;
+        iModel->SetValuesContainer(iContainer);
+        iContainer->SetMopParent(this);
+        iContainer->ConstructL( ClientRect() );
+        AppUi()->AddToStackL( *this, iContainer );
+        } 
+   }
+
+// ---------------------------------------------------------
+// CPerfMonValuesView::DoDeactivate()
+// ---------------------------------------------------------
+//
+void CPerfMonValuesView::DoDeactivate()
+    {
+    if (iContainer)
+        {
+        AppUi()->RemoveFromViewStack( *this, iContainer );
+        delete iContainer;
+        iContainer = NULL;
+        }
+    }
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/perfmon/ui/hb/app/app.pro	Mon May 03 12:32:02 2010 +0300
@@ -0,0 +1,68 @@
+#
+# 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 = app
+TARGET = PerfMon
+DEPENDPATH += .
+INCLUDEPATH += inc
+
+CONFIG += hb
+
+HEADERS += inc/application.h \
+    inc/mainwindow.h \
+    inc/mainview.h \
+    inc/datacontainer.h \
+    inc/valuedatacontainer.h \
+    inc/graphdatacontainer.h \
+    inc/settingsview.h \
+    inc/datapopup.h \
+    inc/enginewrapper.h
+
+SOURCES += src/main.cpp \
+    src/application.cpp \
+    src/mainwindow.cpp \
+    src/mainview.cpp \
+    src/valuedatacontainer.cpp \
+    src/graphdatacontainer.cpp \
+    src/settingsview.cpp \
+    src/datapopup.cpp \
+    src/enginewrapper.cpp
+
+RESOURCES +=
+
+symbian: {
+    INCLUDEPATH += ../../../engine/inc
+    HEADERS += ../../../engine/inc/perfmon_engine.h
+
+    SOURCES += ../../../engine/src/perfmon_engine.cpp
+
+    LIBS += -lestor \
+        -lbafl
+
+    TARGET.CAPABILITY = WriteDeviceData
+
+    TARGET.UID2 = 0x100039CE
+    TARGET.UID3 = 0x20011385
+    TARGET.SID = 0x20011385
+    TARGET.VID = 0x101FB657 // Nokia
+
+    TARGET.EPOCHEAPSIZE = 0x10000 0x2000000  // Min 64Kb, Max 32Mb
+
+    ICON = ../../../icons/qgn_menu_perfmon.svg
+
+    RSS_RULES += "group_name = \"RnD Tools\"";
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/perfmon/ui/hb/app/inc/application.h	Mon May 03 12:32:02 2010 +0300
@@ -0,0 +1,42 @@
+/*
+* 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 APPLICATION_H
+#define APPLICATION_H
+
+#include <HbApplication>
+
+
+class QSymbianEvent;
+
+class Application : public HbApplication
+{
+    Q_OBJECT
+
+public:
+    Application(int &argc, char *argv[]);
+
+signals:
+    void foregroundEvent(bool foreground);
+
+protected:
+#ifdef Q_OS_SYMBIAN
+    bool symbianEventFilter(const QSymbianEvent * event);
+#endif
+};
+
+#endif // APPLICATION_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/perfmon/ui/hb/app/inc/datacontainer.h	Mon May 03 12:32:02 2010 +0300
@@ -0,0 +1,59 @@
+/*
+* 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 DATACONTAINER_H
+#define DATACONTAINER_H
+
+#include <hbwidget.h>
+#include <enginewrapper.h>
+
+class DataContainer : public HbWidget
+{
+    Q_OBJECT
+
+public:
+    DataContainer(const EngineWrapper& engine, QGraphicsItem *parent = 0) :
+            HbWidget(parent),
+            mEngine(engine)
+    {
+    }
+
+    void hideContainer()
+        {
+        disconnect(&mEngine, SIGNAL(samplesUpdated()), this, SLOT(samplesUpdated()));
+        hide();
+        }
+    
+    void showContainer()
+        {
+        connect(&mEngine, SIGNAL(samplesUpdated()),this, SLOT(samplesUpdated()));
+        show();
+        }
+    
+    inline const EngineWrapper& engine() const { return mEngine; }
+
+public slots:
+    virtual void samplesUpdated()
+    {
+    update();
+    }
+
+private:
+    const EngineWrapper& mEngine;
+};
+
+#endif // DATACONTAINER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/perfmon/ui/hb/app/inc/datapopup.h	Mon May 03 12:32:02 2010 +0300
@@ -0,0 +1,58 @@
+/*
+* 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 DATAPOPUP_H
+#define DATAPOPUP_H
+
+#include <HbDeviceDialog>
+#include <QFont>
+
+class EngineWrapper;
+
+class DataPopup : public HbDeviceDialog
+{
+    Q_OBJECT
+
+public:
+    DataPopup(EngineWrapper &engine);
+
+public slots:
+    void show();
+    void hide();
+    void updateSamples();
+    void updateSettings();
+    void updateVisibility(bool foreground);
+
+signals:
+    void clicked();
+
+private slots:
+    void triggerAction(QVariantMap data);
+
+private:
+    QVariantMap collectParams() const;
+    void updateData();
+
+private:
+    EngineWrapper &mEngine;
+
+    bool mPopupCreated;
+
+    bool mPopupVisible;
+};
+
+#endif // DATAPOPUP_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/perfmon/ui/hb/app/inc/enginewrapper.h	Mon May 03 12:32:02 2010 +0300
@@ -0,0 +1,194 @@
+/*
+* 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 ENGINEWRAPPER_H
+#define ENGINEWRAPPER_H
+
+#include "perfmon_engine.h"
+
+#include <QObject>
+#include <QColor>
+#include <QList>
+#include <QVariant>
+
+struct SampleData
+{
+    qint64 mFree;
+    qint64 mSize;
+    qint64 mTimeFromStart;
+};
+
+class SampleEntry
+{
+public:
+    SampleEntry(const TSampleEntry& sampleEntry) : mEntry(&sampleEntry) {}
+
+    QString description() const { return QString((QChar*)mEntry->iDescription.Ptr(), mEntry->iDescription.Length()); }
+    QString unitShort() const { return QString((QChar*)mEntry->iUnitTypeShort.Ptr(), mEntry->iUnitTypeShort.Length()); }
+    QString unitLong() const { return QString((QChar*)mEntry->iUnitTypeLong.Ptr(), mEntry->iUnitTypeLong.Length()); }
+    int driveNumber() const { return mEntry->iDriveNumber; }
+    QColor graphColor() const { return QColor(mEntry->iGraphColor.Red(), mEntry->iGraphColor.Green(), mEntry->iGraphColor.Blue()); }
+
+    int sampleCount() const { return mEntry->iSampleDataArray->Count(); }
+    inline const SampleData& sample(int index) const { return reinterpret_cast<SampleData&>(mEntry->iSampleDataArray->At(index)); }
+private:
+    const TSampleEntry *mEntry;
+
+friend class EngineWrapper;
+};
+
+class PerfMonSources
+{
+public:
+    int count() const { return ESourcesLength; }
+    int isEnabled (int index) const { return mSources.iSrcEnabled[index]; }
+    void setEnabled(int index, bool enabled) { mSources.iSrcEnabled[index] = enabled; }
+    QList<QVariant> enabledIndexes() const {
+        QList<QVariant> indexes;
+        for(int i=0; i<count(); i++) {
+            if (isEnabled(i))
+                indexes.append(i);
+        }
+        return indexes;
+    }
+    void setEnabledIndexes(const QList<QVariant> &indexes)
+    {
+        for (int i=0; i<count(); i++) {
+            setEnabled(i, false);
+        }
+        foreach (const QVariant& index, indexes) {
+        	setEnabled(index.toInt(), true);
+        }
+    }
+
+private:
+    PerfMonSources(TPerfMonSources &sources) : mSources(sources) {}
+    friend class PerfMonSettings;
+
+private:
+    TPerfMonSources &mSources;
+};
+
+class PerfMonSettings
+{
+public:
+    int heartBeat() const { return mSettings.iHeartBeat; }
+    int maxSamples() const { return mSettings.iMaxSamples; }
+    int priority() const { return mSettings.iPriority; }
+    int cpuMode() const { return mSettings.iCPUMode; }
+    bool keepBacklightOn() const { return mSettings.iKeepBacklightOn; }
+
+    int dataPopupVisibility() const { return mSettings.iDataPopupVisibility; }
+    int dataPopupLocation() const { return mSettings.iDataPopupLocation; }
+    PerfMonSources &dataPopupSources() { return mDataPopupSources; }
+    const PerfMonSources &dataPopupSources() const { return mDataPopupSources; }
+
+    int graphVerticalBarPeriod() const { return mSettings.iGraphsVerticalBarPeriod; }
+    PerfMonSources &graphSources() { return mGraphSources; }
+    const PerfMonSources &graphSources() const { return mGraphSources; }
+
+    int loggingMode() const { return mSettings.iLoggingMode; }
+    QString loggingFilePath() const {
+        return QString((QChar*)mSettings.iLoggingFilePath.Ptr(),
+                       mSettings.iLoggingFilePath.Length());
+    }
+    PerfMonSources &loggingSources() { return mLogSources; }
+    const PerfMonSources &loggingSources() const { return mLogSources; }
+
+    bool loggingEnabled() { return mSettings.iLoggingEnabled; }
+
+
+    void setHeartBeat(int heartBeat) { mSettings.iHeartBeat = heartBeat; }
+    void setMaxSamples(int maxSamples) { mSettings.iMaxSamples = maxSamples; }
+    void setPriority(int priority) { mSettings.iPriority = priority; }
+    void setCpuMode(int cpuMode) { mSettings.iCPUMode = cpuMode; }
+    void setKeepBacklightOn(bool backlightOn) const { mSettings.iKeepBacklightOn = backlightOn; }
+
+    void setDataPopupVisibility(int visibility) { mSettings.iDataPopupVisibility = visibility; }
+    void setDataPopupLocation(int location) { mSettings.iDataPopupLocation = location; }
+
+    void setGraphVerticalBarPeriod(int period) { mSettings.iGraphsVerticalBarPeriod = period; }
+
+    void setLoggingMode(int mode) { mSettings.iLoggingMode = mode; }
+    void setLoggingFilePath(const QString& filePath) { mSettings.iLoggingFilePath = filePath.utf16(); }
+
+private:
+    // only EngineWrapper can create Settings instance
+    PerfMonSettings(TPerfMonSettings &settings) :
+            mSettings(settings),
+            mDataPopupSources(settings.iDataPopupSources),
+            mGraphSources(settings.iGraphsSources),
+            mLogSources(settings.iLoggingSources)
+    {}
+    friend class EngineWrapper;
+
+private:
+    TPerfMonSettings &mSettings;
+    PerfMonSources mDataPopupSources;
+    PerfMonSources mGraphSources;
+    PerfMonSources mLogSources;
+};
+
+/**
+ * class that is used for communicating between Symbian and Qt code.
+ */
+class EngineWrapper : public QObject, public CPerfMonEngine
+ {
+    Q_OBJECT
+
+public:
+
+    /**
+     * Constructor
+     */
+    EngineWrapper();
+
+    /**
+     * Destructor
+     */
+    ~EngineWrapper();
+
+public:
+    const QList<SampleEntry>& sampleEntries() const { return mEntries; }
+
+    PerfMonSettings &settings() { return mSettings; }
+    const PerfMonSettings &settings() const { return mSettings; }
+
+public slots:
+
+    bool updateSettings();
+    bool initialize();
+    void finalize();
+    void setLoggingEnabled(bool enabled);
+
+signals:
+
+    void samplesUpdated();
+    void settingsUpdated();
+
+protected:
+    void SendDrawEventToContainersL();
+
+private:
+    QList<SampleEntry> mEntries;
+
+    void createSampleEntriesArray();
+
+    PerfMonSettings mSettings;
+};
+
+#endif //ENGINEWRAPPER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/perfmon/ui/hb/app/inc/graphdatacontainer.h	Mon May 03 12:32:02 2010 +0300
@@ -0,0 +1,40 @@
+/*
+* 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 GRAPHDATACONTAINER_H
+#define GRAPHDATACONTAINER_H
+
+#include "datacontainer.h"
+
+#include <QFont>
+
+class GraphDataContainer : public DataContainer
+{
+    Q_OBJECT
+public:
+    GraphDataContainer(const EngineWrapper& engine, QGraphicsItem *parent = 0);
+
+protected:
+    void paint (QPainter *painter,
+                const QStyleOptionGraphicsItem *option,
+                QWidget *widget = 0);
+
+private:
+    QFont mFont;
+};
+
+#endif // GRAPHDATACONTAINER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/perfmon/ui/hb/app/inc/mainview.h	Mon May 03 12:32:02 2010 +0300
@@ -0,0 +1,64 @@
+/*
+* 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 MAINVIEW_H
+#define MAINVIEW_H
+
+#include <hbview.h>
+
+#include "valuedatacontainer.h"
+#include "graphdatacontainer.h"
+
+class HbAction;
+class EngineWrapper;
+
+class MainView : public HbView
+{
+    Q_OBJECT
+
+public:
+    MainView(EngineWrapper &engine);
+    ~MainView();
+
+private:
+    void createMenu();
+
+public slots:
+    void showValues();
+    void showGraphs();
+    void toggleLogging();
+    void showAbout();
+
+signals:
+    void settingsCommandInvoked();
+
+private:
+    void updateLoggingAction();
+
+private:
+    EngineWrapper &mEngine;
+
+    ValueDataContainer *mValueDataContainer;
+    GraphDataContainer *mGraphDataContainer;
+
+    HbAction *mValuesAction;
+    HbAction *mGraphAction;
+    HbAction *mSwitchViewAction;
+    HbAction *mLoggingAction;
+};
+
+#endif // MAINVIEW_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/perfmon/ui/hb/app/inc/mainwindow.h	Mon May 03 12:32:02 2010 +0300
@@ -0,0 +1,46 @@
+/*
+* 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 MAINWINDOW_H
+#define MAINWINDOW_H
+
+#include <HbMainWindow>
+
+class EngineWrapper;
+class MainView;
+class SettingsView;
+
+class MainWindow : public HbMainWindow
+{
+    Q_OBJECT
+public:
+    MainWindow(EngineWrapper &engine, QWidget *parent = 0);
+
+public slots:
+    void showMainView();
+    void showSettings();
+
+private:
+    void clearViews();
+
+private:
+    EngineWrapper &mEngine;
+    MainView* mMainView;
+    SettingsView* mSettingsView;
+};
+
+#endif // MAINWINDOW_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/perfmon/ui/hb/app/inc/popupdatacontainer.h	Mon May 03 12:32:02 2010 +0300
@@ -0,0 +1,43 @@
+/*
+* 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 POPUPDATACONTAINER_H
+#define POPUPDATACONTAINER_H
+
+#include "datacontainer.h"
+
+#include <QFont>
+
+class PopupDataContainer : public DataContainer
+{
+    Q_OBJECT
+public:
+    PopupDataContainer(const EngineWrapper& engine, QGraphicsItem *parent = 0);
+
+public slots:
+    virtual void samplesUpdated();
+
+protected:
+    void paint (QPainter *painter,
+                const QStyleOptionGraphicsItem *option,
+                QWidget *widget = 0);
+
+private:
+    QFont mFont;
+};
+
+#endif // POPUPDATACONTAINER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/perfmon/ui/hb/app/inc/settingsview.h	Mon May 03 12:32:02 2010 +0300
@@ -0,0 +1,78 @@
+/*
+* 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 SETTINGSVIEW_H
+#define SETTINGSVIEW_H
+
+#include <hbview.h>
+
+class HbDataForm;
+class HbDataFormModel;
+class HbDataFormModelItem;
+
+class EngineWrapper;
+class PerfMonSettings;
+class PerfMonSources;
+
+class SettingsView : public HbView
+{
+    Q_OBJECT
+
+signals:
+    void finished(bool ok);
+
+public:
+    SettingsView(EngineWrapper &engine);
+
+private slots:
+    void dataItemDisplayed(const QModelIndex &index);
+    void logModeChanged(int index);
+    void accept();
+    void reject();
+
+private:
+    void createModel(HbDataFormModel &model);
+    void load(const PerfMonSettings& settings);
+    void save(PerfMonSettings& settings);
+    void createLogFilePathItem();
+    void removeLogFilePathItem();
+    
+private:
+    EngineWrapper &mEngine;
+    HbDataForm *mSettingsForm;
+    HbDataFormModel *mModel;
+
+    HbDataFormModelItem* mHeartBeatItem;
+    HbDataFormModelItem* mMaxSamplesItem;
+    HbDataFormModelItem* mPriorityItem;
+    HbDataFormModelItem* mCpuSamplingItem;
+    HbDataFormModelItem* mKeepBacklightItem;
+    HbDataFormModelItem* mPopupVisibilityItem;
+    HbDataFormModelItem* mPopupLocationItem;
+    HbDataFormModelItem* mPopupSourcesItem;
+    HbDataFormModelItem* mVerticalBarPeriodItem;
+    HbDataFormModelItem* mGraphSourcesItem;
+
+    HbDataFormModelItem* mLogPage;
+    HbDataFormModelItem* mLogModeItem;
+    HbDataFormModelItem* mLogFilePathItem;
+    HbDataFormModelItem* mLogSourcesItem;
+    
+    QString mLogFilePath;
+};
+
+#endif // SETTINGSVIEW_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/perfmon/ui/hb/app/inc/valuedatacontainer.h	Mon May 03 12:32:02 2010 +0300
@@ -0,0 +1,40 @@
+/*
+* 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 VALUEDATACONTAINER_H
+#define VALUEDATACONTAINER_H
+
+#include "datacontainer.h"
+
+#include <QFont>
+
+class ValueDataContainer : public DataContainer
+{
+    Q_OBJECT
+public:
+    ValueDataContainer(const EngineWrapper& engine, QGraphicsItem *parent = 0);
+
+protected:
+    void paint (QPainter *painter,
+                const QStyleOptionGraphicsItem *option,
+                QWidget *widget = 0);
+
+private:
+    QFont mFont;
+};
+
+#endif // VALUEDATACONTAINER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/perfmon/ui/hb/app/src/application.cpp	Mon May 03 12:32:02 2010 +0300
@@ -0,0 +1,49 @@
+/*
+* 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 <QSymbianEvent>
+
+#include "application.h"
+
+#ifdef Q_OS_SYMBIAN
+#include <w32std.h>
+
+#endif
+
+Application::Application(int &argc, char *argv[]) :
+        HbApplication(argc, argv)
+{
+}
+
+#ifdef Q_OS_SYMBIAN
+bool Application::symbianEventFilter(const QSymbianEvent * event)
+{
+    if (event->type() == QSymbianEvent::WindowServerEvent)
+    {
+        const TWsEvent *aEvent = event->windowServerEvent();
+
+        if (aEvent->Type() == EEventFocusLost) {
+            emit foregroundEvent(false);
+        }
+
+        if (aEvent->Type() == EEventFocusGained) {
+            emit foregroundEvent(true);
+        }
+    }
+    return HbApplication::symbianEventFilter(event);
+}
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/perfmon/ui/hb/app/src/datapopup.cpp	Mon May 03 12:32:02 2010 +0300
@@ -0,0 +1,151 @@
+/*
+* 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 <HbView>
+#include <HbEvent>
+#include <QFontMetrics>
+
+#include "datapopup.h"
+#include "enginewrapper.h"
+#include "popupdatacontainer.h"
+
+DataPopup::DataPopup(EngineWrapper &engine) :
+        mEngine(engine),
+        mPopupCreated(false),
+        mPopupVisible(false)
+{
+    connect(&mEngine, SIGNAL(samplesUpdated()), this, SLOT(updateSamples()));
+    connect(&mEngine, SIGNAL(settingsUpdated()), this, SLOT(updateSettings()));
+    connect(this, SIGNAL(dataReceived(QVariantMap)), this, SLOT(triggerAction(QVariantMap)));
+}
+
+void DataPopup::show()
+{
+    mPopupVisible = true;
+    if (!mPopupCreated &&
+        mEngine.sampleEntries().length() &&
+        mEngine.settings().dataPopupSources().enabledIndexes().length())
+    {
+        bool anyData = false;
+        foreach (QVariant index, mEngine.settings().dataPopupSources().enabledIndexes())
+            anyData = anyData || mEngine.sampleEntries().at(index.toInt()).sampleCount();
+
+        if (anyData) {
+            mPopupCreated = HbDeviceDialog::show("com.nokia.rnd.perfmondatapopup/1.0",
+                                                 collectParams());
+        }
+    }
+}
+
+void DataPopup::hide()
+{
+    mPopupVisible = false;
+    if (mPopupCreated) {
+        mPopupCreated = !cancel();
+    }
+}
+
+void DataPopup::updateSamples()
+{
+    updateData();
+}
+
+void DataPopup::updateSettings()
+{
+    // mEngine.settings().dataPopupVisibility can only be changed from
+    // main window, so we may assume the window is in foreground
+    updateVisibility(true);
+    updateData();
+}
+
+void DataPopup::updateVisibility(bool foreground)
+{
+    if (mEngine.settings().dataPopupVisibility() == EDataPopupVisbilityAlwaysOn ||
+        (mEngine.settings().dataPopupVisibility() == EDataPopupVisbilityBackgroundOnly && !foreground)) {
+
+        show();
+    } else {
+        hide();
+    }
+}
+
+void DataPopup::triggerAction(QVariantMap data)
+{
+    if (data.contains("mouseEvent") && data["mouseEvent"].toString() == "press") {
+        emit clicked();
+
+        // data popup was clicked, move it to other position
+        mEngine.settings().setDataPopupLocation(
+                EDataPopupLocationBottomMiddle - mEngine.settings().dataPopupLocation());
+        mEngine.updateSettings();
+    }
+}
+
+QVariantMap DataPopup::collectParams() const
+{
+    QVariantMap result;
+
+    // add location param
+    result["location"] = mEngine.settings().dataPopupLocation();
+
+    // add lines param
+    QStringList lines;
+    QList<SampleEntry> entries = mEngine.sampleEntries();
+    for (int i=0; i<entries.length(); i++)
+    {
+        if (mEngine.settings().dataPopupSources().isEnabled(i) &&
+            entries.at(i).sampleCount() > 0)
+        {
+            const SampleEntry &entry = entries.at(i);
+            const SampleData &sample = entry.sample(0);
+
+            if (i == ESourceCPU)
+            {
+                // CPU
+                double perc = sample.mSize > 0 ?
+                              100. - 100. * sample.mFree / sample.mSize : 0;
+
+
+                QString text = tr("%1 %2%").arg(entry.description()).
+                               arg(perc, 0, 'f', 0);
+                lines.append(text);
+            }
+            else
+            {
+                // RAM and Drives
+                QString text = tr("%1 free %L2%3").arg(entry.description()).
+                               arg(sample.mFree).arg(entry.unitShort());
+                lines.append(text);
+            }
+        }
+    }
+    result["lines"] = lines;
+
+    return result;
+}
+
+void DataPopup::updateData()
+{
+    if (!mPopupVisible)
+        return;
+
+    if (!mPopupCreated) {
+        show();
+    } else {
+        HbDeviceDialog::update(collectParams());
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/perfmon/ui/hb/app/src/enginewrapper.cpp	Mon May 03 12:32:02 2010 +0300
@@ -0,0 +1,105 @@
+/*
+* 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 <e32def.h>
+#include <e32cmn.h>
+
+#include "enginewrapper.h"
+
+
+// ---------------------------------------------------------------------------
+
+EngineWrapper::EngineWrapper() : mSettings(iSettings)
+{
+}
+
+// ---------------------------------------------------------------------------
+
+EngineWrapper::~EngineWrapper()
+{
+    finalize();
+}
+
+// ---------------------------------------------------------------------------
+
+bool EngineWrapper::initialize()
+{
+    TInt err = KErrNone;
+
+    TRAP(err, ConstructL());
+    if (err != KErrNone)
+        return false;
+
+    TRAP(err, ActivateEngineL());
+    if (err != KErrNone)
+        return false;
+
+    createSampleEntriesArray();
+
+    return true;
+}
+
+// ---------------------------------------------------------------------------
+
+void EngineWrapper::createSampleEntriesArray()
+{
+    for (TInt i=0; i < iSampleEntryArray->Count(); i++)
+    {
+        mEntries.append(iSampleEntryArray->At(i));
+    }
+}
+
+// ---------------------------------------------------------------------------
+
+void EngineWrapper::finalize()
+{
+    TRAP_IGNORE(DeActivateEngineL());
+}
+
+// ---------------------------------------------------------------------------
+
+bool EngineWrapper::updateSettings()
+{
+    TInt err = KErrNone;
+
+    TRAP(err, SaveSettingsL());
+    if (err != KErrNone)
+        return false;
+
+    TRAP(err, HandleSettingsChangeL());
+    if (err != KErrNone)
+        return false;
+
+    emit settingsUpdated();
+    return true;
+}
+
+// ---------------------------------------------------------------------------
+
+void EngineWrapper::setLoggingEnabled(bool enabled)
+{
+    EnableLogging(enabled);    
+}
+
+// ---------------------------------------------------------------------------
+
+void EngineWrapper::SendDrawEventToContainersL()
+{
+    emit samplesUpdated();
+}
+
+// ---------------------------------------------------------------------------
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/perfmon/ui/hb/app/src/graphdatacontainer.cpp	Mon May 03 12:32:02 2010 +0300
@@ -0,0 +1,188 @@
+/*
+* 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 "graphdatacontainer.h"
+#include "enginewrapper.h"
+
+#include <QPainter>
+#include <QFontMetrics>
+
+const int amountOfMicroSecondsFitsScreen = 20 * 1000000;
+const int microToSecondMultiplier = 1000000;
+
+GraphDataContainer::GraphDataContainer(const EngineWrapper& engine, QGraphicsItem *parent) :
+    DataContainer(engine, parent)
+{
+    HbFontSpec spec(HbFontSpec::Secondary);
+    mFont = spec.font();
+    mFont.setPixelSize(12);
+}
+
+void GraphDataContainer::paint (QPainter *painter,
+    const QStyleOptionGraphicsItem *option,
+    QWidget *widget)
+{
+    Q_UNUSED(option);
+    Q_UNUSED(widget);
+
+    // set proper font and prepare font metrics for text width / height calculation
+    painter->setFont(mFont);
+    QFontMetricsF metrics(mFont);
+
+    // fill background with black color
+    painter->fillRect(rect(), Qt::black);
+
+    // calculate time factor
+    qreal scaleFactor = rect().width() / (qreal) amountOfMicroSecondsFitsScreen;
+
+    // calculate area height which is used to draw the grpahs
+    qreal drawAreaHeight = rect().height() - 2 * metrics.height();
+
+
+    const QList<SampleEntry> sampleEntries = engine().sampleEntries();
+
+    // check if sample array has been constructed
+    if (sampleEntries.length())
+    {
+        // draw vertical time lines first
+        int verticalBarPeriodInSecs = engine().settings().graphVerticalBarPeriod();
+
+        if (verticalBarPeriodInSecs >= 1 && sampleEntries.first().sampleCount() > 0)
+        {
+            // get time from the first sample
+            const SampleData& firstSample = sampleEntries.first().sample(0);
+            qint64 currentMicroSeconds = firstSample.mTimeFromStart;
+
+            // calculate amount of microseconds exceeding value by using the modulo operator
+            int remainderInMicroSeconds = currentMicroSeconds % (verticalBarPeriodInSecs * 1000000);
+
+            // calculate first x pos
+            qreal vbarXpos = rect().width() - (remainderInMicroSeconds * scaleFactor);
+
+            // calculate the amount in seconds
+            int barSeconds = (currentMicroSeconds - remainderInMicroSeconds) / microToSecondMultiplier;
+
+            // continue drawing periodically the vertical lines
+            while (vbarXpos >= 0 && barSeconds >= 0)
+            {
+                // draw vertical line
+                painter->setPen(Qt::darkRed);
+                painter->drawLine(QPointF(vbarXpos, metrics.height() + 1),
+                                  QPointF(vbarXpos, rect().height() - metrics.height()));
+
+                // draw seconds value
+                painter->setPen(Qt::darkGray);
+                QString secsText = QString("%1s").arg(barSeconds);
+                QPointF secsPos(vbarXpos - metrics.width(secsText) / 2,
+                                rect().height());
+                painter->drawText(secsPos, secsText);
+
+                // calculate new position
+                vbarXpos -= verticalBarPeriodInSecs * 1000000 * scaleFactor;
+                barSeconds -= verticalBarPeriodInSecs;
+            }
+        }
+
+        // draw the basic grid
+        painter->setPen(Qt::darkGray);
+
+        qreal axisY = metrics.height();
+        painter->drawLine(QPointF(0, axisY), QPointF(rect().width(), axisY)); // upper line
+        painter->drawText(QPointF(0, axisY), tr("100%"));
+
+        axisY = rect().height() / 2;
+        painter->drawLine(QPointF(0, axisY), QPointF(rect().width(), axisY)); // mid line
+        painter->drawText(QPointF(0, axisY), tr("50%"));
+
+        axisY = rect().height() - metrics.height();
+        painter->drawLine(QPointF(0, axisY), QPointF(rect().width(), axisY)); // bottom line
+        painter->drawText(QPointF(0, axisY), tr("0%"));
+
+        int c = 0;
+        // draw graphs for each sampled type
+        for (int i=0; i<sampleEntries.length(); i++)
+        {
+            // check if this setting has been enabled and it has some data
+            if (engine().settings().graphSources().isEnabled(i) &&
+                sampleEntries.at(i).sampleCount() > 0)
+            {
+                // set pen color for the graph
+                painter->setPen(sampleEntries.at(i).graphColor());
+
+                // remember the position where drawing started
+                qreal currentXPos(rect().width()); // start drawing from right
+                qreal currentYPos(0.);
+
+                // draw samples
+                for (int j=0; j<sampleEntries.at(i).sampleCount()-1; j++)
+                {
+                    const SampleData& currentSample = sampleEntries.at(i).sample(j);
+                    const SampleData& previousSample = sampleEntries.at(i).sample(j+1);
+
+                    // calculate X position for previous (j+1)
+                    qreal previousXPos = currentXPos -
+                        qAbs(previousSample.mTimeFromStart - currentSample.mTimeFromStart) * scaleFactor;
+
+
+                    // calculate initial Y position
+                    if (j==0)
+                    {
+                        currentYPos = currentSample.mSize > 0 ?
+                            drawAreaHeight * currentSample.mFree / currentSample.mSize + metrics.height() :
+                            rect().height() - metrics.height();
+                    }
+
+                    // calculate Y position for previous (j+1)
+                    qreal previousYPos = previousSample.mSize > 0 ?
+                        drawAreaHeight * previousSample.mFree / previousSample.mSize + metrics.height() :
+                        rect().height() - metrics.height();
+
+
+                    // draw a line between the previous and current
+                    painter->drawLine(QPointF(previousXPos, previousYPos),
+                                      QPointF(currentXPos, currentYPos));
+
+                    // draw current value in %
+                    if (j==0) // draw the value of first sample
+                    {
+                        qreal perc = currentSample.mSize > 0 ?
+                                     100. - 100. * currentSample.mFree / currentSample.mSize : 0;
+                        QString percText = QString ("%1 %2%").
+                                           arg(sampleEntries.at(i).description()).
+                                           arg(perc, 0, 'f', 0);
+
+                        painter->drawText(QPointF(0, metrics.height() * (c + 2)),
+                                          percText);
+                        c++;
+                    }
+
+
+                    // stop drawing if we have run out of space
+                    if (previousXPos < 0)
+                        break;
+
+                    // remeber previous values
+                    currentXPos = previousXPos;
+                    currentYPos = previousYPos;
+                }
+
+
+            }
+        }
+
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/perfmon/ui/hb/app/src/main.cpp	Mon May 03 12:32:02 2010 +0300
@@ -0,0 +1,48 @@
+/*
+* 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 <QMessageBox>
+
+#include "application.h"
+#include "enginewrapper.h"
+#include "mainwindow.h"
+#include "datapopup.h"
+
+int main(int argc, char *argv[])
+{
+    Application app(argc, argv);
+	
+    EngineWrapper engine;
+    if (!engine.initialize())
+    {
+        QMessageBox::critical(0, QObject::tr("Error"), QObject::tr("Unable to initialize engine. Application will now quit."));
+        return 1;
+    }
+
+    MainWindow window(engine);
+	window.show();
+
+//    DataPopup dataPopup(engine);
+
+//    QObject::connect(&app, SIGNAL(foregroundEvent(bool)),
+//                     &dataPopup, SLOT(updateVisibility(bool)));
+
+    // TODO: pass false if run in background
+//    dataPopup.updateVisibility(true);
+
+    return app.exec();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/perfmon/ui/hb/app/src/mainview.cpp	Mon May 03 12:32:02 2010 +0300
@@ -0,0 +1,136 @@
+/*
+* 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 <QActionGroup>
+#include <HbApplication>
+#include <HbMenu>
+#include <HbToolBar>
+#include <HbAction>
+#include <HbMessagebox>
+#include <HbLabel>
+
+#include "mainview.h"
+#include "enginewrapper.h"
+
+
+// ---------------------------------------------------------------------------
+
+MainView::MainView(EngineWrapper &engine) :
+    mEngine(engine),
+    mValueDataContainer(0),
+    mGraphDataContainer(0)
+{
+    setTitle(tr("Perf. Monitor"));
+    mValueDataContainer = new ValueDataContainer(mEngine, this); 
+    mGraphDataContainer = new GraphDataContainer(mEngine, this);
+    createMenu();
+    showValues();
+}
+
+// ---------------------------------------------------------------------------
+
+MainView::~MainView()
+{
+}
+
+// ---------------------------------------------------------------------------
+
+void MainView::createMenu()
+{
+    HbMenu *menu = this->menu();
+    HbToolBar *toolbar = this->toolBar();
+
+    if (menu && toolbar) {
+        mSwitchViewAction = new HbAction(toolbar);
+        toolbar->addAction(mSwitchViewAction);
+
+        QActionGroup *viewGroup = new QActionGroup(this);
+        HbMenu *viewSubmenu = menu->addMenu(tr("View"));
+        mValuesAction = viewSubmenu->addAction(tr("Values"), this, SLOT(showValues()));
+        mValuesAction->setCheckable(true);
+        mValuesAction->setChecked(true);
+        viewGroup->addAction(mValuesAction);
+
+        mGraphAction = viewSubmenu->addAction(tr("Graphs"), this, SLOT(showGraphs()));
+        mGraphAction->setCheckable(true);
+        viewGroup->addAction(mGraphAction);
+
+        mLoggingAction = menu->addAction(QString(), this, SLOT(toggleLogging()));
+        toolbar->addAction(mLoggingAction);
+        updateLoggingAction();
+
+        menu->addAction(tr("Settings..."), this, SIGNAL(settingsCommandInvoked()));
+        menu->addAction(tr("About..."), this, SLOT(showAbout()));
+        menu->addAction(tr("Exit"), qApp, SLOT(quit()));
+
+    }
+}
+
+void MainView::showValues()
+{
+    // remove old widget & take ownership
+    takeWidget();
+    mGraphDataContainer->hideContainer();
+    mValueDataContainer->showContainer(); 
+    // set new widget
+    this->setWidget(mValueDataContainer);
+    
+    mValuesAction->setChecked(true);
+
+    mSwitchViewAction->setText(tr("View Graphs"));
+    disconnect(mSwitchViewAction, SIGNAL(triggered(bool)), this, SLOT(showValues()));
+    connect(mSwitchViewAction, SIGNAL(triggered(bool)), this, SLOT(showGraphs()));
+}
+
+void MainView::showGraphs()
+{
+    // remove old widget & take ownership
+    takeWidget();
+    mValueDataContainer->hideContainer();    
+    mGraphDataContainer->showContainer();
+    // set new widget
+    this->setWidget(mGraphDataContainer);
+
+    mGraphAction->setChecked(true);
+
+    mSwitchViewAction->setText(tr("View Values"));
+    disconnect(mSwitchViewAction, SIGNAL(triggered(bool)), this, SLOT(showGraphs()));
+    connect(mSwitchViewAction, SIGNAL(triggered(bool)), this, SLOT(showValues()));
+}
+
+void MainView::updateLoggingAction()
+{
+    mLoggingAction->setText(mEngine.settings().loggingEnabled() ?
+                            tr("Stop Logging") :
+                            tr("Start Logging"));
+}
+
+void MainView::toggleLogging()
+{
+    mEngine.setLoggingEnabled(!mEngine.settings().loggingEnabled());
+    updateLoggingAction();
+}
+
+void MainView::showAbout()
+{
+    HbMessageBox dlg;
+    dlg.setText("Version 1.1.0 - 15th March 2010. Copyright © 2010 Nokia Corporation and/or its subsidiary(-ies). All rights reserved. Licensed under Eclipse Public License v1.0.");
+    HbLabel header("About PerfMon");
+    dlg.setHeadingWidget(&header);
+    dlg.setTimeout(HbPopup::NoTimeout);
+    dlg.exec();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/perfmon/ui/hb/app/src/mainwindow.cpp	Mon May 03 12:32:02 2010 +0300
@@ -0,0 +1,55 @@
+/*
+* 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 <HbAction>
+
+#include "mainwindow.h"
+
+#include "enginewrapper.h"
+#include "mainview.h"
+#include "settingsview.h"
+
+MainWindow::MainWindow(EngineWrapper &engine, QWidget *parent)
+    : HbMainWindow(parent)
+    , mEngine(engine)
+{
+    mMainView = new MainView(mEngine);
+    connect(mMainView, SIGNAL(settingsCommandInvoked()), this, SLOT(showSettings()));
+
+    addView(mMainView);
+    
+    mSettingsView = new SettingsView(mEngine);
+    connect(mSettingsView, SIGNAL(finished(bool)), this, SLOT(showMainView()));
+    
+    HbAction *action = new HbAction(Hb::BackNaviAction, mSettingsView);        
+    connect(action, SIGNAL(triggered()), mSettingsView, SLOT(reject()));
+    mSettingsView->setNavigationAction(action);
+
+    addView(mSettingsView);
+    
+    showMainView();
+}
+
+void MainWindow::showMainView()
+{
+    setCurrentView( mMainView );
+}
+
+void MainWindow::showSettings()
+{
+    setCurrentView( mSettingsView );
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/perfmon/ui/hb/app/src/popupdatacontainer.cpp	Mon May 03 12:32:02 2010 +0300
@@ -0,0 +1,87 @@
+/*
+* 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 "popupdatacontainer.h"
+#include "enginewrapper.h"
+
+#include <QGraphicsLinearLayout>
+#include <HbLabel>
+#include <QPainter>
+
+const int leftMargin = 2;
+
+PopupDataContainer::PopupDataContainer(const EngineWrapper& engine, QGraphicsItem *parent) :
+    DataContainer(engine, parent)
+{
+    connect(&engine, SIGNAL(samplesUpdated()), this, SLOT(samplesUpdated()));
+
+    HbFontSpec spec(HbFontSpec::Secondary);
+    mFont = spec.font();
+    mFont.setPixelSize(12);
+    
+}
+
+void PopupDataContainer::samplesUpdated()
+{
+    update();
+}
+
+void PopupDataContainer::paint (QPainter *painter,
+    const QStyleOptionGraphicsItem *option,
+    QWidget *widget)
+{
+    Q_UNUSED(option);
+    Q_UNUSED(widget);
+
+    // set proper font and prepare font metrics for text height calculation
+    painter->setFont(mFont);
+    QFontMetricsF metrics(mFont);
+
+    QList<SampleEntry> entries = engine().sampleEntries();
+    qreal verticalPos = metrics.height();
+
+    for (int i=0; i<entries.length(); i++)
+    {
+        if (engine().settings().dataPopupSources().isEnabled(i) &&
+            entries.at(i).sampleCount() > 0)
+        {
+            const SampleEntry &entry = entries.at(i);
+            const SampleData &sample = entry.sample(0);
+
+            if (i == ESourceCPU)
+            {
+                // CPU
+                double perc = sample.mSize > 0 ?
+                              100. - 100. * sample.mFree / sample.mSize : 0;
+
+
+                QString text = tr("%1 %2%").arg(entry.description()).
+                               arg(perc, 0, 'f', 2);
+                painter->drawText(QPointF(leftMargin, verticalPos), text);
+            }
+            else
+            {
+                // RAM and Drives
+                QString text = tr("%1 free %L2%3").arg(entry.description()).
+                               arg(sample.mFree).arg(entry.unitShort());
+                painter->drawText(QPointF(leftMargin, verticalPos), text);
+            }
+
+            verticalPos += metrics.height();
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/perfmon/ui/hb/app/src/settingsview.cpp	Mon May 03 12:32:02 2010 +0300
@@ -0,0 +1,272 @@
+/*
+* 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 "settingsview.h"
+
+#include <HbAction>
+#include <HbToolBar>
+#include <HbDataForm>
+#include <HbDataFormModel>
+#include <HbDataFormModelItem>
+#include <HbDataFormViewItem>
+#include <HbValidator>
+#include <HbLineEdit>
+#include <HbPushButton>
+#include <HbListDialog>
+
+#include "enginewrapper.h"
+
+const QStringList PRIORITY_ITEMS = QStringList() << SettingsView::tr("Much less") <<
+    SettingsView::tr("Less") << SettingsView::tr("Normal") <<
+    SettingsView::tr("More") << SettingsView::tr("Much more") <<
+    SettingsView::tr("Real time") << SettingsView::tr("Abs. very low") <<
+    SettingsView::tr("Abs. low") << SettingsView::tr("Abs background") <<
+    SettingsView::tr("Abs. foreground") << SettingsView::tr("Abs high");
+
+const QStringList CPU_SAMPLING = QStringList() << SettingsView::tr("CPU Time") <<
+    SettingsView::tr("NOPs");
+
+const QStringList POPUP_LOCATION = QStringList() << SettingsView::tr("Top right") <<
+    SettingsView::tr("Bottom middle");
+
+const QStringList POPUP_VISIBILITY = QStringList() << SettingsView::tr("On") <<
+    SettingsView::tr("Backgr. only") << SettingsView::tr("Off");
+
+const QStringList SOURCES = QStringList() << SettingsView::tr("CPU") <<
+    SettingsView::tr("Ram") << SettingsView::tr("C:") << SettingsView::tr("D:") <<
+    SettingsView::tr("E:") << SettingsView::tr("F:") << SettingsView::tr("G:") <<
+    SettingsView::tr("H:") << SettingsView::tr("I:");
+
+const QStringList LOG_MODES = QStringList() << SettingsView::tr("RDebug") <<
+    SettingsView::tr("Log file") << SettingsView::tr("RDebug & log file");
+
+
+SettingsView::SettingsView(EngineWrapper &engine)
+    : mEngine(engine), mLogFilePathItem(0)
+{
+    setTitle(tr("Settings"));
+
+    //create toolbar showing launch popup
+    HbToolBar *toolBar = this->toolBar();
+    HbAction *actionOk = new HbAction(tr("Ok"), toolBar);
+    HbAction *actionCancel = new HbAction(tr("Cancel"), toolBar);
+    
+    toolBar->addAction(actionOk);
+    toolBar->addAction(actionCancel);
+
+    //create setting form
+    mSettingsForm = new HbDataForm();
+
+    //create a model class
+    mModel = new HbDataFormModel(this);
+    createModel(*mModel);
+    load(engine.settings());
+
+    connect(mSettingsForm, SIGNAL(itemShown(const QModelIndex)),
+            this, SLOT(dataItemDisplayed(const QModelIndex)));
+
+    // Set created model to form
+    mSettingsForm->setModel(mModel);
+    setWidget(mSettingsForm);
+
+
+    connect(actionOk, SIGNAL(triggered()), this, SLOT(accept()));
+    connect(actionCancel, SIGNAL(triggered()), this, SLOT(reject()));
+    connect(this, SIGNAL(aboutToClose()), this, SLOT(accept()));
+
+}
+
+void SettingsView::createModel(HbDataFormModel &model)
+{
+    // General page
+    HbDataFormModelItem *generalPage = model.appendDataFormPage(tr("General"));
+
+    mHeartBeatItem = model.appendDataFormItem(
+            HbDataFormModelItem::TextItem, tr("Heart beat (ms)"), generalPage);
+    mHeartBeatItem->setContentWidgetData("maximum", 99999);
+    mHeartBeatItem->setContentWidgetData("minimum", 0);
+    mHeartBeatItem->setContentWidgetData("inputMethodHints", Qt::ImhDigitsOnly);
+
+    mMaxSamplesItem = model.appendDataFormItem(
+            HbDataFormModelItem::TextItem, tr("Max samples"), generalPage);
+    mMaxSamplesItem->setContentWidgetData("maximum", 9999);
+    mMaxSamplesItem->setContentWidgetData("minimum", 0);
+    mMaxSamplesItem->setContentWidgetData("inputMethodHints", Qt::ImhDigitsOnly);
+
+    mPriorityItem = model.appendDataFormItem(
+            HbDataFormModelItem::RadioButtonListItem, tr("Priority"), generalPage);
+    mPriorityItem->setContentWidgetData("items", PRIORITY_ITEMS);
+
+    mCpuSamplingItem = model.appendDataFormItem(
+            HbDataFormModelItem::RadioButtonListItem, tr("CPU sampling mode"), generalPage);
+    mCpuSamplingItem->setContentWidgetData("items", CPU_SAMPLING);
+    
+    // TODO: remove next line when NOPs will be working
+    mCpuSamplingItem->setContentWidgetData("enabled", false);
+            
+    mKeepBacklightItem = model.appendDataFormItem(
+            HbDataFormModelItem::CheckBoxItem, tr("Backlight"), generalPage);
+    mKeepBacklightItem->setContentWidgetData("text", tr("Keep backlight on"));
+
+    // Data popup page
+    HbDataFormModelItem *dataPopupPage = model.appendDataFormPage(tr("Data popup"));
+
+    mPopupVisibilityItem = model.appendDataFormItem(
+            HbDataFormModelItem::RadioButtonListItem, tr("Visibility"),
+            dataPopupPage);
+    mPopupVisibilityItem->setContentWidgetData("items", POPUP_VISIBILITY);
+
+    mPopupLocationItem = model.appendDataFormItem(
+            HbDataFormModelItem::RadioButtonListItem, tr("Location"), dataPopupPage);
+    mPopupLocationItem->setContentWidgetData("items", POPUP_LOCATION);
+
+    mPopupSourcesItem = model.appendDataFormItem(
+            HbDataFormModelItem::MultiselectionItem, tr("Sources"), dataPopupPage);
+    mPopupSourcesItem->setContentWidgetData("items", SOURCES);
+
+    // Graphs page
+    HbDataFormModelItem *graphsPage = model.appendDataFormPage(tr("Graphs"));
+
+    mVerticalBarPeriodItem = model.appendDataFormItem(
+            HbDataFormModelItem::TextItem, tr("Vertical bar period (s)"), graphsPage);
+    mVerticalBarPeriodItem->setContentWidgetData("maximum", 999);
+    mVerticalBarPeriodItem->setContentWidgetData("minimum", 0);
+    mVerticalBarPeriodItem->setContentWidgetData("inputMethodHints", Qt::ImhDigitsOnly);
+
+    mGraphSourcesItem = model.appendDataFormItem(
+            HbDataFormModelItem::MultiselectionItem, tr("Sources"), graphsPage);
+    mGraphSourcesItem->setContentWidgetData("items", SOURCES);
+
+    // Logging page
+    mLogPage = model.appendDataFormPage(tr("Logging"));
+
+    mLogModeItem = model.appendDataFormItem(
+            HbDataFormModelItem::RadioButtonListItem, tr("Mode"), mLogPage);
+    mLogModeItem->setContentWidgetData("items", LOG_MODES);
+    mSettingsForm->addConnection(mLogModeItem, SIGNAL(itemSelected(int)),
+                                 this, SLOT(logModeChanged(int)));
+
+    mLogSourcesItem = model.appendDataFormItem(
+            HbDataFormModelItem::MultiselectionItem, tr("Sources"), mLogPage);
+    mLogSourcesItem->setContentWidgetData("items", SOURCES);
+}
+
+void SettingsView::load(const PerfMonSettings& settings)
+{
+    mHeartBeatItem->setContentWidgetData("text", settings.heartBeat());
+    mMaxSamplesItem->setContentWidgetData("text", settings.maxSamples());
+    mPriorityItem->setContentWidgetData("selected", settings.priority());
+    mCpuSamplingItem->setContentWidgetData("selected", settings.cpuMode());
+    mKeepBacklightItem->setContentWidgetData("checkState", settings.keepBacklightOn() ? Qt::Checked : Qt::Unchecked);
+
+    mPopupVisibilityItem->setContentWidgetData("selected", settings.dataPopupVisibility());
+    mPopupLocationItem->setContentWidgetData("selected", settings.dataPopupLocation());
+    mPopupSourcesItem->setContentWidgetData("selectedItems",
+            qVariantFromValue(settings.dataPopupSources().enabledIndexes()));
+
+    mVerticalBarPeriodItem->setContentWidgetData("text", settings.graphVerticalBarPeriod());
+    mGraphSourcesItem->setContentWidgetData("selectedItems",
+            qVariantFromValue(settings.graphSources().enabledIndexes()));
+
+    mLogModeItem->setContentWidgetData("selected", settings.loggingMode());
+    mLogFilePath = settings.loggingFilePath();
+    if (settings.loggingMode() > ELoggingModeRDebug)
+    	createLogFilePathItem();
+    mLogSourcesItem->setContentWidgetData("selectedItems",
+            qVariantFromValue(settings.loggingSources().enabledIndexes()));
+}
+
+void SettingsView::save(PerfMonSettings& settings)
+{
+    settings.setHeartBeat(mHeartBeatItem->contentWidgetData("text").toInt());
+    settings.setMaxSamples(mMaxSamplesItem->contentWidgetData("text").toInt());
+    settings.setPriority(mPriorityItem->contentWidgetData("selected").toInt());
+    settings.setCpuMode(mCpuSamplingItem->contentWidgetData("selected").toInt());
+    settings.setKeepBacklightOn(mKeepBacklightItem->contentWidgetData("checkState").toInt() == Qt::Checked);
+
+    settings.setDataPopupVisibility(mPopupVisibilityItem->contentWidgetData("selected").toInt());
+    settings.setDataPopupLocation(mPopupLocationItem->contentWidgetData("selected").toInt());
+    settings.dataPopupSources().setEnabledIndexes(
+            qVariantValue<QList<QVariant> >(mPopupSourcesItem->contentWidgetData("selectedItems")));
+
+    settings.setGraphVerticalBarPeriod(mVerticalBarPeriodItem->contentWidgetData("text").toInt());
+    settings.graphSources().setEnabledIndexes(
+            qVariantValue<QList<QVariant> >(mGraphSourcesItem->contentWidgetData("selectedItems")));
+
+    settings.setLoggingMode(mLogModeItem->contentWidgetData("selected").toInt());
+    
+    if (mLogFilePathItem)
+    	settings.setLoggingFilePath(mLogFilePathItem->contentWidgetData("text").toString());
+    settings.loggingSources().setEnabledIndexes(
+            qVariantValue<QList<QVariant> >(mLogSourcesItem->contentWidgetData("selectedItems")));
+}
+
+void SettingsView::dataItemDisplayed(const QModelIndex &index)
+{
+    HbDataFormModelItem* modelItem = mModel->itemFromIndex(index);
+    HbDataFormViewItem *viewItem = mSettingsForm->dataFormViewItem(index);
+    HbWidget *dataContentWidget = viewItem->dataItemContentWidget();
+    HbWidget *contentWidget = viewItem->contentWidget();
+
+    // set input method hint for edits
+    // TODO: remove once setContentWidgetData works with inputMethodHints
+    if (modelItem == mHeartBeatItem ||
+        modelItem == mMaxSamplesItem ||
+        modelItem == mVerticalBarPeriodItem)
+    {
+        HbLineEdit *edit = static_cast<HbLineEdit*>(dataContentWidget);
+        edit->setInputMethodHints(Qt::ImhDigitsOnly);
+    }
+}
+
+void SettingsView::logModeChanged(int index)
+{
+    if (index == ELoggingModeRDebug && mLogFilePathItem) {
+        removeLogFilePathItem();
+    }
+    else if (index != ELoggingModeRDebug && !mLogFilePathItem) {
+		createLogFilePathItem();
+    }
+}
+
+void SettingsView::createLogFilePathItem()
+{
+	mLogFilePathItem = mModel->insertDataFormItem(mLogPage->indexOf(mLogModeItem) + 1,
+			HbDataFormModelItem::TextItem, tr("Log file path"), mLogPage);
+	mLogFilePathItem->setContentWidgetData("text", mLogFilePath);
+}
+
+void SettingsView::removeLogFilePathItem()
+{
+	// we need to store current text so that it is not lost when 
+	// user hides and then displays "Log file path" item again.
+	mLogFilePath = mLogFilePathItem->contentWidgetData("text").toString();
+	mModel->removeItem(mLogFilePathItem);
+	mLogFilePathItem = 0;
+}
+
+void SettingsView::accept()
+{
+    save(mEngine.settings());
+    mEngine.updateSettings();
+    emit finished(true);
+}
+
+void SettingsView::reject()
+{
+    emit finished(false);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/perfmon/ui/hb/app/src/valuedatacontainer.cpp	Mon May 03 12:32:02 2010 +0300
@@ -0,0 +1,86 @@
+/*
+* 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 "valuedatacontainer.h"
+#include "enginewrapper.h"
+
+#include <QGraphicsLinearLayout>
+#include <QPalette>
+#include <QPainter>
+#include <HbColorScheme>
+
+const int leftMargin = 2;
+
+ValueDataContainer::ValueDataContainer(const EngineWrapper& engine, QGraphicsItem *parent) :
+    DataContainer(engine, parent)
+{
+    HbFontSpec spec(HbFontSpec::Secondary);
+    mFont = spec.font();
+}
+
+void ValueDataContainer::paint (QPainter *painter,
+    const QStyleOptionGraphicsItem *option,
+    QWidget *widget)
+{
+    Q_UNUSED(option);
+    Q_UNUSED(widget);
+
+    // set proper font and prepare font metrics for text height calculation
+    painter->setFont(mFont);
+
+    painter->setPen(HbColorScheme::color("foreground"));
+    QFontMetricsF metrics(mFont);
+
+    QList<SampleEntry> entries = engine().sampleEntries();
+    int c = 1;
+
+    for (int i=0; i<entries.length(); i++)
+    {
+        const SampleEntry &entry = entries.at(i);
+
+        if (entry.sampleCount() == 0)
+            continue;
+
+        const SampleData &sample = entry.sample(0);
+
+        if (i == 0)
+        {
+            // CPU
+            double perc = sample.mSize > 0 ?
+                          100. - 100. * sample.mFree / sample.mSize : 0;
+
+
+            QString text = tr("%1 %2%").arg(entry.description()).
+                           arg(perc, 0, 'f', 0);
+            painter->drawText(QPointF(leftMargin, c * metrics.height()), text);
+            c++;
+        }
+        else if (sample.mSize > 0)
+        {
+            // RAM and Drives
+            QString text = tr("%1 free %L2%3").arg(entry.description()).
+                           arg(sample.mFree).arg(entry.unitShort());
+            painter->drawText(QPointF(leftMargin, c * metrics.height()), text);
+            c++;
+
+            text = tr("%1 size %L2%3").arg(entry.description()).
+                   arg(sample.mSize).arg(entry.unitShort());
+            painter->drawText(QPointF(leftMargin, c * metrics.height()), text);
+            c++;
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/perfmon/ui/hb/datapopup/datapopup.pro	Mon May 03 12:32:02 2010 +0300
@@ -0,0 +1,46 @@
+#
+# 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 = PerfMonDataPopupPlugin
+CONFIG += plugin hb
+
+# directories
+INCLUDEPATH += inc
+DEPENDPATH += inc
+
+HEADERS += inc/perfmondatapopupplugin_p.h
+HEADERS += inc/perfmondatapopupdialog_p.h
+HEADERS += inc/perfmondatapopupwidget_p.h
+
+SOURCES += src/perfmondatapopupplugin.cpp
+SOURCES += src/perfmondatapopupdialog.cpp
+SOURCES += src/perfmondatapopupwidget.cpp
+
+symbian {
+    TARGET.EPOCALLOWDLLDATA = 1
+    TARGET.CAPABILITY = CAP_GENERAL_DLL
+    TARGET.UID3 = 0x2002E6B0
+
+    hblib.sources = Hb.dll
+    hblib.path = \sys\bin
+    hblib.depends = "(0xEEF9EA38), 1, 0, 0, {\"Hb\"}"
+
+    pluginstub.sources = PerfMonDataPopupPlugin.dll
+    pluginstub.path = /private/20011385
+    DEPLOYMENT += pluginstub
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/perfmon/ui/hb/datapopup/inc/perfmondatapopupdialog_p.h	Mon May 03 12:32:02 2010 +0300
@@ -0,0 +1,88 @@
+/*
+* 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 PERFMONDATAPOPUPDIALOG_P_H
+#define PERFMONDATAPOPUPDIALOG_P_H
+
+#include <QObject>
+#include <QVariantMap>
+
+#include <hbdevicedialoginterface.h>
+#include <hbdevicedialog.h>
+#include <hbnotificationdialog.h>
+
+class PerfMonDataPopupWidget;
+
+class PerfMonDataPopupDialog : public HbDialog, public HbDeviceDialogInterface
+{
+    Q_OBJECT
+    Q_PROPERTY(Location location READ location WRITE setLocation)
+    Q_PROPERTY(QStringList lines READ lines WRITE setLines)
+
+    Q_ENUMS(Location)
+
+public:
+    enum Location
+    {
+        LocationTopRight = 0,
+        LocationBottomMiddle
+    };
+
+public:
+    PerfMonDataPopupDialog(const QVariantMap &parameters);
+    virtual ~PerfMonDataPopupDialog();
+
+    bool setDeviceDialogParameters(const QVariantMap &parameters);
+    int deviceDialogError() const;
+    void closeDeviceDialog(bool byClient);
+    HbPopup *deviceDialogWidget() const;
+
+protected:
+//    void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
+//               QWidget *widget=0);
+
+protected:
+    void hideEvent(QHideEvent *event);
+    void showEvent(QShowEvent *event);
+    void mousePressEvent(QGraphicsSceneMouseEvent *event);
+
+signals:
+    void deviceDialogClosed();
+    void deviceDialogData(QVariantMap data);
+
+private slots:
+    void reposition();
+
+private:
+    Location location() const;
+    void setLocation(Location location);
+
+    QStringList lines() const;
+    void setLines(const QStringList &lines);
+
+private:
+    Q_DISABLE_COPY(PerfMonDataPopupDialog)
+
+    int mLastError;
+    bool mShowEventReceived;
+
+    Location mLocation;
+
+    PerfMonDataPopupWidget *mWidget;
+};
+
+#endif // PERFMONDATAPOPUPDIALOG_P_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/perfmon/ui/hb/datapopup/inc/perfmondatapopupplugin_p.h	Mon May 03 12:32:02 2010 +0300
@@ -0,0 +1,53 @@
+/*
+* 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 PERFMONDATAPOPUPPLUGIN_P_H
+#define PERFMONDATAPOPUPPLUGIN_P_H
+
+#include <QObject>
+#include <QVariantMap>
+
+#include <hbdevicedialogplugin.h>
+
+class PerfMonDataPopupPluginPrivate;
+
+class PerfMonDataPopupPlugin : public HbDeviceDialogPlugin
+{
+    Q_OBJECT
+
+public:
+    friend class PerfMonDataPopupPluginPrivate;
+
+    PerfMonDataPopupPlugin();
+    ~PerfMonDataPopupPlugin();
+
+    bool accessAllowed(const QString &deviceDialogType,
+        const QVariantMap &parameters, const QVariantMap &securityInfo) const;
+    HbDeviceDialogInterface *createDeviceDialog(const QString &deviceDialogType,
+        const QVariantMap &parameters);
+    bool deviceDialogInfo(const QString &deviceDialogType,
+        const QVariantMap &parameters, DeviceDialogInfo *info) const;
+    QStringList deviceDialogTypes() const;
+    PluginFlags pluginFlags() const;
+    int error() const;
+
+private:
+    Q_DISABLE_COPY(PerfMonDataPopupPlugin)
+    PerfMonDataPopupPluginPrivate *d;
+};
+
+#endif // PERFMONDATAPOPUPPLUGIN_P_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/perfmon/ui/hb/datapopup/inc/perfmondatapopuppluginerrors_p.h	Mon May 03 12:32:02 2010 +0300
@@ -0,0 +1,28 @@
+/*
+* 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 PERFMONDATAPOPUPPLUGINERRORS_P_H
+#define PERFMONDATAPOPUPPLUGINERRORS_P_H
+
+#include <hbdevicedialog.h>
+
+// No error
+const int NoError = 0;
+// Illegal parameter error
+const int ParameterError = HbDeviceDialog::PluginErrors + 1;
+
+#endif // PERFMONDATAPOPUPPLUGINERRORS_P_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/perfmon/ui/hb/datapopup/inc/perfmondatapopupwidget_p.h	Mon May 03 12:32:02 2010 +0300
@@ -0,0 +1,46 @@
+/*
+* 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 PERFMONDATAPOPUPWIDGET_P_H
+#define PERFMONDATAPOPUPWIDGET_P_H
+
+#include <HbWidget>
+
+class PerfMonDataPopupWidget : public HbWidget
+{
+    Q_OBJECT
+    Q_PROPERTY(QStringList lines READ lines WRITE setLines)
+
+public:
+    explicit PerfMonDataPopupWidget(QGraphicsItem *parent = 0);
+
+public:
+    QStringList lines() const;
+    void setLines(const QStringList &lines);
+
+protected:
+    QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint = QSizeF()) const;
+    void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget=0);
+
+private:
+    QStringList mLines;
+
+    QFont mFont;
+
+};
+
+#endif // PERFMONDATAPOPUPWIDGET_P_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/perfmon/ui/hb/datapopup/src/perfmondatapopupdialog.cpp	Mon May 03 12:32:02 2010 +0300
@@ -0,0 +1,179 @@
+/*
+* 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 <QtDebug>
+#include <QIcon>
+#include <QVariant>
+#include <QList>
+#include <HbMainWindow>
+
+#include "perfmondatapopupdialog_p.h"
+#include "perfmondatapopuppluginerrors_p.h"
+#include "perfmondatapopupwidget_p.h"
+
+// Constructor
+PerfMonDataPopupDialog::PerfMonDataPopupDialog(const QVariantMap &parameters) :
+        mLastError(NoError),
+        mShowEventReceived(false),
+        mLocation(LocationTopRight),
+        mWidget(new PerfMonDataPopupWidget(this))
+{
+    setTimeout(0);
+    setModal(false);
+    setDismissPolicy(HbPopup::NoDismiss);
+    setBackgroundItem(HbStyle::P_None);
+    setContentWidget(mWidget);
+
+    setDeviceDialogParameters(parameters);
+}
+
+PerfMonDataPopupDialog::~PerfMonDataPopupDialog()
+{
+}
+
+// Set parameters
+bool PerfMonDataPopupDialog::setDeviceDialogParameters(const QVariantMap &parameters)
+{
+    if (parameters.contains("lines"))
+    {
+        QVariant lines = parameters.value("lines");
+        if (!lines.canConvert(QVariant::StringList)) {
+            mLastError = ParameterError;
+            return false;
+        }
+
+        setLines(lines.toStringList());
+    }
+
+    if (parameters.contains("location"))
+    {
+        QVariant location = parameters.value("location");
+        if (!location.canConvert<int>()) {
+            mLastError = ParameterError;
+            return false;
+        }
+
+        if (location.toInt() != LocationTopRight &&
+            location.toInt() != LocationBottomMiddle)
+        {
+            mLastError = ParameterError;
+            return false;
+        }
+
+        setLocation(static_cast<Location>(location.toInt()));
+    }
+    return true;
+}
+
+// Get error
+int PerfMonDataPopupDialog::deviceDialogError() const
+{
+    return mLastError;
+}
+
+// Close device dialog
+void PerfMonDataPopupDialog::closeDeviceDialog(bool byClient)
+{
+    Q_UNUSED(byClient);
+    close();
+    // If show event has been received, close is signalled from hide event. If not,
+    // hide event does not come and close is signalled from here.
+    if (!mShowEventReceived) {
+        emit deviceDialogClosed();
+    }
+}
+
+// Return display widget
+HbPopup *PerfMonDataPopupDialog::deviceDialogWidget() const
+{
+    return const_cast<PerfMonDataPopupDialog*>(this);
+}
+
+// Widget is about to hide. Closing effect has ended.
+void PerfMonDataPopupDialog::hideEvent(QHideEvent *event)
+{
+    if (mainWindow()) {
+        disconnect(mainWindow(), SIGNAL(orientationChanged(Qt::Orientation)),
+                   this, SLOT(reposition()));
+    }
+    HbPopup::hideEvent(event);
+    emit deviceDialogClosed();
+}
+
+// Widget is about to show
+void PerfMonDataPopupDialog::showEvent(QShowEvent *event)
+{
+    if (mainWindow()) {
+        connect(mainWindow(), SIGNAL(orientationChanged(Qt::Orientation)),
+                this, SLOT(reposition()));
+    }
+    reposition();
+    HbPopup::showEvent(event);
+    mShowEventReceived = true;
+}
+
+
+void PerfMonDataPopupDialog::mousePressEvent(QGraphicsSceneMouseEvent *event)
+{
+    Q_UNUSED(event);
+
+    QVariantMap data;
+    data["mouseEvent"] = "press";
+    emit deviceDialogData(data);
+}
+
+
+PerfMonDataPopupDialog::Location PerfMonDataPopupDialog::location() const
+{
+    return mLocation;
+}
+
+void PerfMonDataPopupDialog::setLocation(Location location)
+{
+    if (location != mLocation) {
+        mLocation = location;
+        reposition();
+    }
+}
+
+QStringList PerfMonDataPopupDialog::lines() const
+{
+    return mWidget->lines();
+}
+
+void PerfMonDataPopupDialog::setLines(const QStringList &lines)
+{
+    mWidget->setLines(lines);
+}
+
+void PerfMonDataPopupDialog::reposition()
+{
+    if (mainWindow()) {
+        QSize screenSize = HbDeviceProfile::profile(mainWindow()).logicalSize();
+        switch (mLocation) {
+            case LocationTopRight:
+                setPreferredPos(QPointF(screenSize.width(), 0),
+                                HbPopup::TopRightCorner);
+                break;
+
+            case LocationBottomMiddle:
+                setPreferredPos(QPointF(screenSize.width() / 2, screenSize.height()),
+                                HbPopup::BottomEdgeCenter);
+                break;
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/perfmon/ui/hb/datapopup/src/perfmondatapopupplugin.cpp	Mon May 03 12:32:02 2010 +0300
@@ -0,0 +1,124 @@
+/*
+* 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 <QtPlugin>
+
+#include <hbdevicedialog.h>
+#include "perfmondatapopupplugin_p.h"
+#include "perfmondatapopupdialog_p.h"
+#include "perfmondatapopuppluginerrors_p.h"
+
+Q_EXPORT_PLUGIN2(perfmondatapopupplugin, PerfMonDataPopupPlugin)
+
+// This plugin implements one device dialog type
+static const struct {
+    const char *mTypeString;
+} dialogInfos[] = {
+    {"com.nokia.rnd.perfmondatapopup/1.0"}
+};
+
+class PerfMonDataPopupPluginPrivate
+{
+public:
+    PerfMonDataPopupPluginPrivate() {mError = NoError;}
+
+    int mError;
+};
+
+// Constructor
+PerfMonDataPopupPlugin::PerfMonDataPopupPlugin()
+    : d(new PerfMonDataPopupPluginPrivate)
+{
+}
+
+// Destructor
+PerfMonDataPopupPlugin::~PerfMonDataPopupPlugin()
+{
+    delete d;
+}
+
+// Check if client is allowed to use device dialog widget
+bool PerfMonDataPopupPlugin::accessAllowed(const QString &deviceDialogType,
+    const QVariantMap &parameters, const QVariantMap &securityInfo) const
+{
+    Q_UNUSED(deviceDialogType)
+    Q_UNUSED(parameters)
+    Q_UNUSED(securityInfo)
+
+    // This plugin doesn't perform operations that may compromise security. All clients
+    // are allowed to use.
+    return true;
+}
+
+// Create device dialog widget
+HbDeviceDialogInterface *PerfMonDataPopupPlugin::createDeviceDialog(
+    const QString &deviceDialogType, const QVariantMap &parameters)
+{
+    Q_UNUSED(deviceDialogType)
+    d->mError = NoError;
+
+    HbDeviceDialogInterface *ret(0);
+    QVariantMap params = parameters;
+
+    PerfMonDataPopupDialog *deviceDialog =
+        new PerfMonDataPopupDialog(params);
+    d->mError = deviceDialog->deviceDialogError();
+    if (d->mError != NoError) {
+        delete deviceDialog;
+        deviceDialog = 0;
+    }
+    ret = deviceDialog;
+
+    return ret;
+}
+
+// Return device dialog flags
+bool PerfMonDataPopupPlugin::deviceDialogInfo(const QString &deviceDialogType,
+        const QVariantMap &parameters, DeviceDialogInfo *info) const
+{
+    Q_UNUSED(deviceDialogType);
+    Q_UNUSED(parameters);
+
+    info->group = DeviceNotificationDialogGroup;
+    info->flags = NoDeviceDialogFlags;
+    info->priority = DefaultPriority;
+
+    return true;
+}
+
+// Return device dialog types this plugin implements
+QStringList PerfMonDataPopupPlugin::deviceDialogTypes() const
+{
+    QStringList types;
+    const int numTypes = sizeof(dialogInfos) / sizeof(dialogInfos[0]);
+    for(int i = 0; i < numTypes; i++) {
+        types.append(dialogInfos[i].mTypeString);
+    }
+    return types;
+}
+
+// Return plugin flags
+HbDeviceDialogPlugin::PluginFlags PerfMonDataPopupPlugin::pluginFlags() const
+{
+    return NoPluginFlags;
+}
+
+// Return last error
+int PerfMonDataPopupPlugin::error() const
+{
+    return d->mError;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/perfmon/ui/hb/datapopup/src/perfmondatapopupwidget.cpp	Mon May 03 12:32:02 2010 +0300
@@ -0,0 +1,82 @@
+/*
+* 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 <QPainter>
+
+#include "perfmondatapopupwidget_p.h"
+
+const qreal popupMargin = 5.;
+
+PerfMonDataPopupWidget::PerfMonDataPopupWidget(QGraphicsItem *parent) :
+    HbWidget(parent)
+{
+    HbFontSpec fontSpec(HbFontSpec::Secondary);
+    mFont = fontSpec.font();
+    mFont.setPixelSize(12);
+}
+
+QStringList PerfMonDataPopupWidget::lines() const
+{
+    return mLines;
+}
+
+void PerfMonDataPopupWidget::setLines(const QStringList &lines)
+{
+    mLines = lines;
+    updateGeometry();
+}
+
+QSizeF PerfMonDataPopupWidget::sizeHint(Qt::SizeHint which, const QSizeF &constraint) const
+{
+    if (which == Qt::PreferredSize)
+    {
+        QFontMetricsF metrics(mFont);
+
+        qreal width = 0;
+        foreach (const QString &line, mLines) {
+            width = qMax(width, metrics.width(line));
+        }
+        qreal height = metrics.height() * mLines.length();
+
+        return QSizeF(width + 2 * popupMargin, height + 2 * popupMargin);
+    }
+
+    return HbWidget::sizeHint(which, constraint);
+}
+
+void PerfMonDataPopupWidget::paint(QPainter *painter,
+    const QStyleOptionGraphicsItem *option, QWidget *widget)
+{
+    Q_UNUSED(widget);
+    Q_UNUSED(option);
+
+    QFontMetricsF metrics(mFont);
+    qreal lineHeight = metrics.height();
+    qreal verticalPos = lineHeight + popupMargin;
+
+    // draw background
+    painter->setBrush(Qt::white);
+    painter->drawRect(option->rect);
+
+    painter->setFont(mFont);
+
+    foreach (const QString &line, mLines) {
+        painter->drawText(QPointF(popupMargin, verticalPos), line);
+        verticalPos += lineHeight;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/perfmon/ui/hb/win/enginewrapper.cpp	Mon May 03 12:32:02 2010 +0300
@@ -0,0 +1,114 @@
+/*
+* 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 "enginewrapper.h"
+
+
+// ---------------------------------------------------------------------------
+
+EngineWrapper::EngineWrapper()
+{
+}
+
+// ---------------------------------------------------------------------------
+
+EngineWrapper::~EngineWrapper()
+{
+    finalize();
+}
+
+// ---------------------------------------------------------------------------
+
+bool EngineWrapper::initialize()
+{
+
+    SampleEntry cpu;
+    cpu.mDescription = "CPU";
+    cpu.mDriveNumber = -1;
+    cpu.mGraphColor.setNamedColor("yellow");
+
+    SampleEntry ram;
+    ram.mDescription = "RAM";
+    ram.mUnitShort = "b";
+    ram.mUnitLong = "bytes";
+    ram.mDriveNumber = -1;
+    ram.mGraphColor.setNamedColor("green");
+
+    SampleEntry cdrive;
+    cdrive.mDescription = "C:";
+    cdrive.mUnitShort = "b";
+    cdrive.mUnitLong = "bytes";
+    cdrive.mDriveNumber = 0;
+    cdrive.mGraphColor.setNamedColor("cyan");
+
+    SampleEntry ddrive;
+    ddrive.mDescription = "D:";
+    ddrive.mUnitShort = "b";
+    ddrive.mUnitLong = "bytes";
+    ddrive.mDriveNumber = 0;
+    ddrive.mGraphColor.setNamedColor("blue");
+
+    mEntries << cpu << ram << cdrive << ddrive;
+
+    connect(&mTimer, SIGNAL(timeout()), this, SLOT(update()));
+    mStartTime = QTime::currentTime();
+    mTimer.start(600);
+
+    return true;
+}
+
+// ---------------------------------------------------------------------------
+
+void EngineWrapper::finalize()
+{
+}
+
+// ---------------------------------------------------------------------------
+
+bool EngineWrapper::updateSettings()
+{
+    emit settingsUpdated();
+    return true;
+}
+
+void EngineWrapper::update()
+{
+    // do some updates :)
+    for (int i=0; i<mEntries.length(); i++)
+    {
+        SampleEntry & entry = mEntries[i];
+        if (entry.mSampleData.length() > 0)
+        {
+            SampleData data = entry.mSampleData.at(0);
+            data.mFree += 10000 * (qrand() % 1000 - 500);
+            data.mTimeFromStart = mStartTime.msecsTo(QTime::currentTime()) * 1000;
+            entry.mSampleData.prepend(data);
+        }
+        else
+        {
+            SampleData data = {100000000L, 200000000L, mStartTime.msecsTo(QTime::currentTime()) * 1000};
+            entry.mSampleData.prepend(data);
+        }
+
+        if (entry.mSampleData.length() > 64)
+        {
+            entry.mSampleData.removeLast();
+        }
+    }
+
+    emit samplesUpdated();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/perfmon/ui/hb/win/enginewrapper.h	Mon May 03 12:32:02 2010 +0300
@@ -0,0 +1,270 @@
+/*
+* 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 ENGINEWRAPPER_H
+#define ENGINEWRAPPER_H
+
+#include <QObject>
+#include <QColor>
+#include <QList>
+#include <QTime>
+#include <QTimer>
+
+enum SettingThreadPriorityTypes
+{
+    EThreadPriorityTypeMuchLess = 0,
+    EThreadPriorityTypeLess,
+    EThreadPriorityTypeNormal,
+    EThreadPriorityTypeMore,
+    EThreadPriorityTypeMuchMore,
+    EThreadPriorityTypeRealTime,
+    EThreadPriorityTypeAbsoluteVeryLow,
+    EThreadPriorityTypeAbsoluteLow,
+    EThreadPriorityTypeAbsoluteBackground,
+    EThreadPriorityTypeAbsoluteForeground,
+    EThreadPriorityTypeAbsoluteHigh
+};
+
+enum SettingCPUModes
+{
+    ECPUModeNotSet = -1,
+    ECPUModeCPUTime,
+    ECPUModeNOPs
+};
+
+enum SettingDataPopupVisbilities
+{
+    EDataPopupVisbilityAlwaysOn = 0,
+    EDataPopupVisbilityBackgroundOnly,
+    EDataPopupVisbilityAlwaysAlwaysOff
+};
+
+enum SettingDataPopupLocations
+{
+    EDataPopupLocationTopRight = 0,
+    EDataPopupLocationBottomMiddle
+};
+
+enum SettingSources
+{
+    ESourceCPU = 0,
+    ESourceRAM,
+    ESourceC,
+    ESourceD,
+    ESourceE,
+    ESourceF,
+    ESourceG,
+    ESourceH,
+    ESourceI,
+    ESourcesLength // this should be always the last!
+};
+
+enum SettingLoggingMode
+{
+    ELoggingModeRDebug = 0,
+    ELoggingModeLogFile,
+    ELoggingModeRDebugLogFile
+};
+
+
+struct SampleData
+{
+    qint64 mFree;
+    qint64 mSize;
+    qint64 mTimeFromStart;
+};
+
+class SampleEntry
+{
+public:
+    QString description() const { return mDescription; }
+    QString unitShort() const { return mUnitShort; }
+    QString unitLong() const { return mUnitLong; }
+    int driveNumber() const { return mDriveNumber; }
+    QColor graphColor() const { return mGraphColor; }
+
+    int sampleCount() const { return mSampleData.length(); }
+    const SampleData &sample(int index) const { return mSampleData[index]; }
+private:
+    QString mDescription;
+    QString mUnitShort;
+    QString mUnitLong;
+    int mDriveNumber;
+    QColor mGraphColor;
+
+    QList<SampleData> mSampleData;
+
+friend class EngineWrapper;
+};
+
+class PerfMonSources
+{
+public:
+    int count() const { return 9; }
+    int isEnabled (int index) const { return mSources[index]; }
+    void setEnabled(int index, bool enabled) { mSources[index] = enabled; }
+    QList<int> enabledIndexes() const
+    {
+        QList<int> indexes;
+        for(int i=0; i<count(); i++) {
+            if (isEnabled(i))
+                indexes.append(i);
+        }
+        return indexes;
+    }
+    void setEnabledIndexes(const QList<int> &indexes)
+    {
+        for(int i=0; i<count(); i++) {
+            setEnabled(i, indexes.contains(i));
+        }
+    }
+
+PerfMonSources() {
+    memset(mSources, 0, sizeof mSources);
+    mSources[0] = mSources[1] = mSources[2] = true;
+}
+
+private:
+    bool mSources[9];
+};
+
+class PerfMonSettings
+{
+public:
+    int heartBeat() const { return mHeartBeat; }
+    int maxSamples() const { return mMaxSamples; }
+    int priority() const { return mPriority; }
+    int cpuMode() const { return mCPUMode; }
+    bool keepBacklightOn() const { return mKeepBacklightOn; }
+
+    int dataPopupVisibility() const { return mDataPopupVisibility; }
+    int dataPopupLocation() const { return mDataPopupLocation; }
+    PerfMonSources &dataPopupSources() { return mDataPopupSources; }
+    const PerfMonSources &dataPopupSources() const { return mDataPopupSources; }
+
+    int graphVerticalBarPeriod() const { return mGraphsVerticalBarPeriod; }
+    PerfMonSources &graphSources() { return mGraphSources; }
+    const PerfMonSources &graphSources() const { return mGraphSources; }
+
+    int loggingMode() const { return mLoggingMode; }
+    QString loggingFilePath() const { return mLoggingFilePath; }
+    PerfMonSources &loggingSources() { return mLogSources; }
+    const PerfMonSources &loggingSources() const { return mLogSources; }
+
+    bool loggingEnabled() { return mLoggingEnabled; }
+
+
+    void setHeartBeat(int heartBeat) { mHeartBeat = heartBeat; }
+    void setMaxSamples(int maxSamples) { mMaxSamples = maxSamples; }
+    void setPriority(int priority) { mPriority = priority; }
+    void setCpuMode(int cpuMode) { mCPUMode = cpuMode; }
+    void setKeepBacklightOn(bool backlightOn) { mKeepBacklightOn = backlightOn; }
+
+    void setDataPopupVisibility(int visibility) { mDataPopupVisibility = visibility; }
+    void setDataPopupLocation(int location) { mDataPopupLocation = location; }
+
+    void setGraphVerticalBarPeriod(int period) { mGraphsVerticalBarPeriod = period; }
+
+    void setLoggingMode(int mode) { mLoggingMode = mode; }
+    void setLoggingFilePath(const QString& filePath) { mLoggingFilePath = filePath; }
+
+    void setLoggingEnabled(bool enabled) { mLoggingEnabled = enabled; }
+
+private:
+    friend class EngineWrapper;
+
+    PerfMonSettings() : mHeartBeat(600), mMaxSamples(64), mPriority(2), mCPUMode(1),
+        mKeepBacklightOn(true), mDataPopupVisibility(0), mDataPopupLocation(0),
+        mGraphsVerticalBarPeriod(5), mLoggingMode(1), mLoggingFilePath("C:\\data\\perfmon.log"),
+        mLoggingEnabled(true) {}
+
+
+private:
+    int mHeartBeat;
+    int mMaxSamples;
+    int mPriority;
+    int mCPUMode;
+    bool mKeepBacklightOn;
+
+    int mDataPopupVisibility;
+    int mDataPopupLocation;
+    PerfMonSources mDataPopupSources;
+
+    int mGraphsVerticalBarPeriod;
+    PerfMonSources mGraphSources;
+
+    int mLoggingMode;
+    QString mLoggingFilePath;
+    PerfMonSources mLogSources;
+
+    bool mLoggingEnabled;
+};
+
+/**
+ * Mock engine to simulate perfmon engine for non-symbian development.
+ */
+class EngineWrapper : public QObject
+ {
+    Q_OBJECT
+
+public:
+
+    /**
+     * Constructor
+     */
+    EngineWrapper();
+
+    /**
+     * Destructor
+     */
+    ~EngineWrapper();
+
+public:
+    const QList<SampleEntry>& sampleEntries() const { return mEntries; }
+
+    PerfMonSettings &settings() { return mSettings; }
+    const PerfMonSettings &settings() const { return mSettings; }
+
+    void setLoggingEnabled(bool enabled) { mSettings.setLoggingEnabled(enabled); }
+
+public slots:
+
+    bool updateSettings();
+    bool initialize();
+    void finalize();
+
+signals:
+
+    void samplesUpdated();
+    void settingsUpdated();
+
+private slots:
+
+    void update();
+
+private:
+
+    QList<SampleEntry> mEntries;
+
+    QTimer mTimer;
+
+    QTime mStartTime;
+
+    PerfMonSettings mSettings;
+};
+
+#endif //ENGINEWRAPPER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/perfmon/ui/hb/win/win.pro	Mon May 03 12:32:02 2010 +0300
@@ -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:
+#
+#
+
+win32 {
+    TEMPLATE = subdirs
+
+    SUBDIRS = ../app ../datapopup
+
+    system($$QMAKE_COPY enginewrapper.cpp ..\app\src\enginewrapper.cpp)
+    system($$QMAKE_COPY enginewrapper.h ..\app\inc\enginewrapper.h)
+} else {
+    error("Only Windows supported")
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/screengrabber/ReleaseNotes_ScreenGrabber.txt	Mon May 03 12:32:02 2010 +0300
@@ -0,0 +1,144 @@
+===============================================================================
+
+RELEASE NOTES - SCREENGRABBER v5.0.0
+RELEASED 10th March 2010 
+
+SUPPORTS S60 3.0+
+
+===============================================================================
+
+Product Description:
+====================
+ScreenGrabber tool is used to capture images and video of the visible screen
+area in S60 platform. Captures can be handled with the Media Gallery
+application or with PC when the device is connected via PC suite.
+
+Main Features:
+==============
+- Image capture in single or in sequential mode supporting PNG, JPEG and BMP
+  formats
+- Video capture in animated GIF format
+- Configurable saving format, hotkey, time delta in sequential mode, target
+  memory and default filename
+- Ability to change the screen mode to one of the supported more by the device
+
+===============================================================================
+
+What's New in v5.0.0
+====================
+- Orbit UI
+
+===============================================================================
+
+Installation Notes:
+===================
+ScreenGrabber is typically preinstalled on ROM. If not, it can be added to the
+ROM with the .iby file. Alternatively, the .sis file can be found under the sis-
+directory, but the user need to sign it with their own developer certificate.
+In Nokia R&D environment, you can use directly the R&D-signed .sis file under the
+internal\sis directory.
+
+When signing with own developer certificate, the following capabilities are
+needed:
+  WriteDeviceData
+  SwEvent
+
+When builing ScreenGrabber against S60 3.0 or 3.1, you may need to patch your
+SDK environment first with some fixes. For more information, please refer to
+the instructions under the "envpatcher" directory.
+
+===============================================================================
+
+System Requirements:
+====================
+Basic Requirements:
+- Any S60 3.x device or emulator environment
+
+===============================================================================
+
+Compatibility Issues:
+=====================
+N/A
+
+===============================================================================
+
+Known Issues:
+=============
+
+Sluggish UI when capturing video
+--------------------------------
+- Video capturing requires huge amount of processing power and thus may cause
+  the UI to become sluggish. If supported by the device, try to decrease the
+  screen resolution.
+
+===============================================================================
+
+Version History:
+================
+Version 4.2.0 - 14th May 2009
+------------------------------
+- Feature: Added a new SIS file for S60 3.2 devices and newer to support the
+  features in newer platforms
+- Feature: Added multidrive support in the settings dialog
+
+Version 4.1.3 - 8th March 2009
+------------------------------
+- Fix: ScreenGrabber does not work in devices which do not have Media Gallery
+  (Media Gallery File Manager API dependency changed from static to dynamic)
+    
+Version 4.1.2 - 8th February 2008
+---------------------------------
+- Fix: Transparency errors in GIF animations (hopefully) finally fixed
+  
+Version 4.1.1 - 28th January 2008
+---------------------------------
+- Feature: Added hash+* and alternative camera key into selection of capture
+  keys
+- Change: Reimplemented settings handling so that AllFiles and WriteUserData
+  capabilities are no longer needed
+    
+Version 4.1.0 - 14th January 2008
+---------------------------------
+- Feature: Added support for GIF and MBM formats although it is always
+  recommended to capture screens in PNG format
+- Feature: JPEG format can now be selected as high quality (97%) or low quality
+  (60%) 
+- Feature: Added POC key under capturing key options
+- Change: Dimensions of a video will be grown if the screen resolution of the
+  device will grow during capturing
+- Change: Capturing is now done always from current focus screen which allows to
+  support secondary displays
+- Change: Send key is now the default key
+- Fix: Black color didn't always work correctly in GIF animation optimization
+  with transparency  
+- Fix: Capturing to JPEG format leaked memory
+
+Version 4.0.3 - 16th November 2007
+----------------------------------
+- Fix: Scroll bar in the main view can be scrolled on a touch UI
+- Fix: Application closes automatically when closed via open applications menu
+
+Version 4.0.2 - 9th October 2007
+--------------------------------
+- Fix: Main screen layout in mirrored mode
+  
+Version 4.0.1 - 14th February 2007
+----------------------------------
+- Fix: Help screen on larger displays
+  
+Version 4.0.0 - 25th October 2006
+---------------------------------
+- Feature: Support for sequential capture mode
+- Feature: Support for capturing video in animated GIF format
+- Feature: Ability to change screen mode to one of the supported more by the
+  device
+
+===============================================================================
+
+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".
--- a/screengrabber/data/screengrabber.rss	Fri Apr 16 14:59:17 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,550 +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:  
-*
-*/
-
-
-
-NAME MATT
-
-#include <eikon.rh>
-#include <eikon.rsg>
-#include <avkon.rh>
-#include <avkon.rsg>
-#include <avkon.mbg>
-#include <CommonDialogs.hrh>
-#include <CommonDialogs.rh>
-#include <pathconfiguration.hrh>
-
-#include "SG.hrh"
-#include "SGStd.h"
-#include <data_caging_paths_strings.hrh>
-#include <appinfo.rh>
-
-
-// ---------------------------------------------------------
-//   
-//    Define the resource file signature 
-//    This resource should be empty.
-//
-// ---------------------------------------------------------
-//
-RESOURCE RSS_SIGNATURE { }
-
-// ---------------------------------------------------------
-//   
-//    Default Document Name
-//
-// ---------------------------------------------------------
-//
-RESOURCE TBUF r_default_document_name { buf=""; }
-
-// ---------------------------------------------------------
-//   
-//    Define default menu and CBA key.
-//
-// ---------------------------------------------------------
-//
-RESOURCE EIK_APP_INFO
-    {
-	//status_pane = r_screengrabber_status_pane;
-    //menubar = r_screengrabber_menubar;
-    //cba = R_AVKON_SOFTKEYS_OPTIONS_EXIT;
-    }
-
-
-//----------------------------------------------------
-//   
-//    r_screengrabber_hotkeys
-//
-//----------------------------------------------------
-//
-RESOURCE HOTKEYS r_screengrabber_hotkeys
-    {
-    control=
-        {
-        HOTKEY { command=EAknCmdExit; key='e'; }
-        };
-    }
-
-
-//----------------------------------------------------
-//   
-//    r_screengrabber_view1
-//
-//----------------------------------------------------
-//
-RESOURCE AVKON_VIEW r_screengrabber_view1
-    {
-    hotkeys=r_screengrabber_hotkeys;
-    menubar=r_screengrabber_menubar_view1;  
-    cba=R_AVKON_SOFTKEYS_OPTIONS_EXIT;    
-    }
-
-//----------------------------------------------------
-//   
-//    r_screengrabber_menubar_view1
-//
-//----------------------------------------------------
-//
-RESOURCE MENU_BAR r_screengrabber_menubar_view1
-    {
-    titles=
-        {
-        MENU_TITLE { menu_pane=r_screengrabber_app_menu; txt="App"; },
-        MENU_TITLE { menu_pane=r_screengrabber_view1_menu; txt="View"; }
-        };
-    }
-
-//----------------------------------------------------
-//   
-//    r_screengrabber_view1_menu
-//
-//----------------------------------------------------
-//
-
-RESOURCE MENU_PANE r_screengrabber_view1_menu
-    {
-    items=
-        {
-        MENU_ITEM { command=EScreenGrabberCmdSendToBackground; txt="Send to background"; },
-        MENU_ITEM { command=EScreenGrabberCmdScreenResolution; cascade = r_screengrabber_resolution_submenu; txt="Screen resolution"; },
-        MENU_ITEM { command=EScreenGrabberCmdSettings; txt="Settings"; },
-        MENU_ITEM { command=EScreenGrabberCmdAbout; txt="About"; },
-        MENU_ITEM { command=EAknCmdExit; txt="Exit"; }
-        };
-    }
-
-RESOURCE MENU_PANE r_screengrabber_resolution_submenu
-    {
-    items=
-        {
-        };
-    }
-    
-//----------------------------------------------------
-//   
-//    r_screengrabber_view2
-//
-//----------------------------------------------------
-//
-RESOURCE CBA r_screengrabber_softkeys_view2
-	{
-	buttons =
-		{
-		CBA_BUTTON {id=EAknSoftkeyOptions; txt = "Options" ;},
-		CBA_BUTTON {id=EScreenGrabberCmdSettingsBack; txt = "Back" ; }
-		};
-	}
-
-RESOURCE AVKON_VIEW r_screengrabber_view2
-    {
-    hotkeys=r_screengrabber_hotkeys;
-    menubar=r_screengrabber_menubar_view2;  
-    cba=r_screengrabber_softkeys_view2; 
-    }
-
-//----------------------------------------------------
-//   
-//    r_screengrabber_menubar_view2
-//
-//----------------------------------------------------
-//
-RESOURCE MENU_BAR r_screengrabber_menubar_view2
-    {
-    titles=
-        {
-        MENU_TITLE { menu_pane=r_screengrabber_app_menu; txt="App"; },
-        MENU_TITLE { menu_pane=r_screengrabber_view2_menu; txt="View"; }
-        };
-    }
-
-//----------------------------------------------------
-//   
-//    r_screengrabber_view2_menu
-//    ?description
-//
-//----------------------------------------------------
-//
-RESOURCE MENU_PANE r_screengrabber_view2_menu
-    {
-    items=
-        {
-        MENU_ITEM { command=EScreenGrabberCmdSettingsChange; txt="Change"; },
-        MENU_ITEM { command=EScreenGrabberCmdSettingsExit; txt="Exit"; }
-        };
-    }
-
-//----------------------------------------------------
-//   
-//    r_screengrabber_app_menu
-//
-//----------------------------------------------------
-//
-RESOURCE MENU_PANE r_screengrabber_app_menu
-    {
-    items=
-        {
-        };
-    }
-
-
-//----------------------------------------------------
-//   
-//    r_screengrabber_settinglist
-//
-//----------------------------------------------------
-//
-RESOURCE AVKON_SETTING_ITEM_LIST r_screengrabber_settinglist
-	{
-	title = "Settings";
-	initial_number = 1;
-	items = 
-		{
-		AVKON_SETTING_ITEM
-			{
-			identifier = ESettingListCaptureModeSelection;
-			name = "Capture mode";
-			setting_page_resource = r_capturemodeselection_setting_page;
-			associated_resource = r_capturemodeselection_setting_texts;
-			},
-					
-		AVKON_SETTING_ITEM
-			{
-			identifier = ESettingListSingleCaptureHotkeySelection;
-			name = "Capture hotkey";
-			setting_page_resource = r_hotkeyselection_setting_page;
-			associated_resource = r_hotkeyselection_setting_texts;
-			},
-		AVKON_SETTING_ITEM
-			{
-			identifier = ESettingListSingleCaptureImageFormatSelection;
-			name = "Image format";
-			setting_page_resource = r_imageformatselection_setting_page;
-			associated_resource = r_imageformatselection_setting_texts;
-			},
-		AVKON_SETTING_ITEM
-			{
-			identifier = ESettingListSingleCaptureMemorySelection;
-			name = "Memory in use";
-			setting_page_resource = r_memoryselection_dialog;
-			},
-		AVKON_SETTING_ITEM
-			{
-			identifier = ESettingListSingleCaptureFileNameSelection;
-			name = "File name";
-			setting_page_resource = r_filenameselection_setting_page;
-			},
-			
-		AVKON_SETTING_ITEM
-			{
-			identifier = ESettingListSequantialCaptureHotkeySelection;
-			name = "Start/stop hotkey";
-			setting_page_resource = r_hotkeyselection_setting_page;
-			associated_resource = r_hotkeyselection_setting_texts;
-			},
-		AVKON_SETTING_ITEM
-			{
-			identifier = ESettingListSequantialCaptureImageFormatSelection;
-			name = "Image format";
-			setting_page_resource = r_imageformatselection_setting_page;
-			associated_resource = r_imageformatselection_setting_texts;
-			},
-		AVKON_SETTING_ITEM
-			{
-			identifier = ESettingListSequantialCaptureDelaySelection;
-			name = "Delay (ms)";
-			setting_page_resource = r_delayselection_setting_page;
-			},
-		AVKON_SETTING_ITEM
-			{
-			identifier = ESettingListSequantialCaptureMemorySelection;
-			name = "Memory in use";
-			setting_page_resource = r_memoryselection_dialog;
-			},
-		AVKON_SETTING_ITEM
-			{
-			identifier = ESettingListSequantialCaptureFileNameSelection;
-			name = "File name";
-			setting_page_resource = r_filenameselection_setting_page;
-			},
-
-		AVKON_SETTING_ITEM
-			{
-			identifier = ESettingListVideoCaptureHotkeySelection;
-			name = "Start/stop hotkey";
-			setting_page_resource = r_hotkeyselection_setting_page;
-			associated_resource = r_hotkeyselection_setting_texts;
-			},
-		AVKON_SETTING_ITEM
-			{
-			identifier = ESettingListVideoCaptureVideoFormatSelection;
-			name = "Video format";
-			setting_page_resource = r_videoformatselection_setting_page;
-			associated_resource = r_videoformatselection_setting_texts;
-			},
-		AVKON_SETTING_ITEM
-			{
-			identifier = ESettingListVideoCaptureMemorySelection;
-			name = "Memory in use";
-			setting_page_resource = r_memoryselection_dialog;
-			},
-		AVKON_SETTING_ITEM
-			{
-			identifier = ESettingListVideoCaptureFileNameSelection;
-			name = "File name";
-			setting_page_resource = r_filenameselection_setting_page;
-			}
-		};
-	}
-
-RESOURCE POPUP_SETTING_LIST r_popup_setting_list_editor
-	{
-	}
-
-//
-// resources for capture mode selection
-//
-RESOURCE AVKON_SETTING_PAGE r_capturemodeselection_setting_page
-	{
-    number = EAknSettingPageNoOrdinalDisplayed; 
-	type = EAknCtPopupSettingList;
-	editor_resource_id = r_popup_setting_list_editor;
-	}
-RESOURCE AVKON_POPUP_SETTING_TEXTS r_capturemodeselection_setting_texts
-	{
-	setting_texts_resource = r_capturemodeselection_text_array;
-	}
-RESOURCE ARRAY r_capturemodeselection_text_array
-	{
-	items =
-		{
-		AVKON_ENUMERATED_TEXT { value=ECaptureModeSingleCapture; text = "Single capture"; },
-		AVKON_ENUMERATED_TEXT { value=ECaptureModeSequantialCapture; text = "Sequantial capture"; },
-		AVKON_ENUMERATED_TEXT { value=ECaptureModeVideoCapture; text = "Video capture"; }
-		};
-	}
-	
-//
-// generic resources for hotkey selection
-//
-RESOURCE AVKON_SETTING_PAGE r_hotkeyselection_setting_page
-	{
-    number = EAknSettingPageNoOrdinalDisplayed; 
-	type = EAknCtPopupSettingList;
-	editor_resource_id = r_popup_setting_list_editor;
-	}
-RESOURCE AVKON_POPUP_SETTING_TEXTS r_hotkeyselection_setting_texts
-	{
-	setting_texts_resource = r_hotkeyselection_text_array;
-	}
-RESOURCE ARRAY r_hotkeyselection_text_array
-	{
-	items =
-		{
-		AVKON_ENUMERATED_TEXT { value=EHotkeySendKey; text = "Send key"; },
-		AVKON_ENUMERATED_TEXT { value=EHotkeyShiftStar; text = "SHIFT+*"; },
-		AVKON_ENUMERATED_TEXT { value=EHotkeyHashStar; text = "HASH+*"; },
-		AVKON_ENUMERATED_TEXT { value=EHotkeyShiftMenu; text = "SHIFT+Menu"; },
-		AVKON_ENUMERATED_TEXT { value=EHotkeyPowerKey; text = "Power key"; },
-		AVKON_ENUMERATED_TEXT { value=EHotkeySideKey; text = "Side key"; },
-		AVKON_ENUMERATED_TEXT { value=EHotkeyCameraKey1; text = "Camera key #1"; },
-		AVKON_ENUMERATED_TEXT { value=EHotkeyCameraKey2; text = "Camera key #2"; },
-		AVKON_ENUMERATED_TEXT { value=EHotkeyPOC; text = "POC"; }
-		};
-	}
-
-//
-// generic resources for image format selection
-//
-RESOURCE AVKON_SETTING_PAGE r_imageformatselection_setting_page
-	{
-    number = EAknSettingPageNoOrdinalDisplayed; 
-	type = EAknCtPopupSettingList;
-	editor_resource_id = r_popup_setting_list_editor;
-	}
-RESOURCE AVKON_POPUP_SETTING_TEXTS r_imageformatselection_setting_texts
-	{
-	setting_texts_resource = r_imageformatselection_text_array;
-	}
-RESOURCE ARRAY r_imageformatselection_text_array
-	{
-	items =
-		{
-		AVKON_ENUMERATED_TEXT { value=EImageFormatPNG; text = "PNG"; },
-		AVKON_ENUMERATED_TEXT { value=EImageFormatJPGHQ; text = "JPEG high qual."; },
-		AVKON_ENUMERATED_TEXT { value=EImageFormatJPGLQ; text = "JPEG low qual."; },
-		AVKON_ENUMERATED_TEXT { value=EImageFormatBMP; text = "BMP"; },
-		AVKON_ENUMERATED_TEXT { value=EImageFormatGIF; text = "GIF"; },
-		AVKON_ENUMERATED_TEXT { value=EImageFormatMBM; text = "MBM"; }
-		};
-	}
-
-//
-// generic resources for video format selection
-//
-RESOURCE AVKON_SETTING_PAGE r_videoformatselection_setting_page
-	{
-    number = EAknSettingPageNoOrdinalDisplayed; 
-	type = EAknCtPopupSettingList;
-	editor_resource_id = r_popup_setting_list_editor;
-	}
-RESOURCE AVKON_POPUP_SETTING_TEXTS r_videoformatselection_setting_texts
-	{
-	setting_texts_resource = r_videoformatselection_text_array;
-	}
-RESOURCE ARRAY r_videoformatselection_text_array
-	{
-	items =
-		{
-		AVKON_ENUMERATED_TEXT { value=EVideoFormatAnimatedGIF; text = "Animated GIF"; }
-		};
-	}
-
-//
-// generic resources for memory selection
-//
-RESOURCE MEMORYSELECTIONDIALOG r_memoryselection_dialog
-    {
-    title = "Memory in use";
-    locations =
-        {
-        LOCATION
-            { 
-            root_path = text_phone_memory_root_path;
-			default_folder = text_images_path; 
-            },
-        LOCATION 
-            { 
-            root_path = text_memory_card_root_path;
-			default_folder = text_images_path;
-            }
-        };
-    }
-
-//
-// generic resources for filename selection
-//
-RESOURCE AVKON_SETTING_PAGE r_filenameselection_setting_page
-	{
-	type = EEikCtEdwin;
-	editor_resource_id = r_filename_text_editor;
-	}
-
-RESOURCE EDWIN r_filename_text_editor
-	{
-	lines = 0;  // expanding to multiple rows
-	maxlength = 63;
-	flags = EEikEdwinNoLineOrParaBreaks;
-	}
-
-//
-// generic resources for delay selection
-//
-RESOURCE AVKON_SETTING_PAGE r_delayselection_setting_page
-	{
-	type = EAknCtIntegerEdwin;
-	editor_resource_id = r_delay_integer_editor;
-	}
-
-RESOURCE AVKON_INTEGER_EDWIN r_delay_integer_editor
-	{
-	maxlength = 6;
-	min = 0;
-	max = 999999;
-	}
-
-//
-// ---------------------------------------------------------
-//
-
-RESOURCE DIALOG r_my_general_confirmation_query
-	{
-	flags = EGeneralQueryFlags;
-	buttons = R_AVKON_SOFTKEYS_YES_NO;
-	items =
-		{
-		DLG_LINE
-			{
-			type = EAknCtQuery;
-			id = EGeneralQuery;
-			control = AVKON_CONFIRMATION_QUERY
-				{
-				layout = EConfirmationQueryLayout;
-				};
-			}
-		};
-	}
-
-   
-// ---------------------------------------------------------
-//   
-//   r_screengrabber_about_dialog
-//   About dialog - show version and copyright info etc.
-//
-// ---------------------------------------------------------
-//
-
-RESOURCE DIALOG r_screengrabber_about_dialog
-{
-    flags = EGeneralQueryFlags | EEikDialogFlagNoBorder | EEikDialogFlagNoShadow;
-    buttons = R_AVKON_SOFTKEYS_OK_EMPTY;
-    items=
-    {
-        DLG_LINE
-        {
-            type = EAknCtPopupHeadingPane;
-            id = EAknMessageQueryHeaderId;
-            control = AVKON_HEADING
-            {
-                label = "About Scr.Grabber";
-                headinglayout = R_AVKON_WML_SIGN_QUERY_HEADING_PANE;
-            };
-        },
-        DLG_LINE
-        {
-            type = EAknCtMessageQuery;
-            id = EAknMessageQueryContentId;
-            control = AVKON_MESSAGE_QUERY
-            {
-                message = "Version 4.2.0 - 14th May 2009. Copyright © 2009 Nokia Corporation and/or its subsidiary(-ies). All rights reserved. Licensed under Eclipse Public License v1.0.";
-            };
-        }
-    };
-}
-
-// ---------------------------------------------------------
-//   
-//    New framework:
-//    Secure platform and scalable UI changes 
-//
-// ---------------------------------------------------------
-//
-RESOURCE LOCALISABLE_APP_INFO r_screengrabber_localisable_app_info
-    {
-    short_caption = "Scr.Grabber";
-    caption_and_icon = 
-    CAPTION_AND_ICON_INFO
-        {
-        caption = "ScreenGrabber";
-
-        number_of_icons = 1;
-
-        // Note for ROM-based apps it is recommended to add the drive letter
-        // icon_file = "z:"APP_BITMAP_DIR"\\myapp_aif.mif";
-        icon_file = APP_BITMAP_DIR"\\screengrabber_aif.mif";
-        };
-    }
-
--- a/screengrabber/data/screengrabber_reg.rss	Fri Apr 16 14:59:17 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,36 +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 <screengrabber.rsg>
-#include <appinfo.rh>
-#include <data_caging_paths_strings.hrh>
-
-
-UID2 KUidAppRegistrationResourceFile
-UID3 0x101FB751
-
-
-
-RESOURCE APP_REGISTRATION_INFO
-    {
-    app_file = "ScreenGrabber";
-    localisable_resource_file = APP_RESOURCE_DIR"\\ScreenGrabber";
-    localisable_resource_id = R_SCREENGRABBER_LOCALISABLE_APP_INFO;
-    group_name = "RnD Tools";    
-    }
--- a/screengrabber/envpatcher/EnvPatcher.pl	Fri Apr 16 14:59:17 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,544 +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:
-# Environment Patcher - Patches older S60 SDKs for supporting
-# tricks in newer platforms
-#
-
-
-require v5.6.1;	
-
-use File::Copy;
-use strict;
-
-# check amount of commandline options is valid
-if (@ARGV != 1)
-{
-    print "Usage: EnvPatcher <EPOCROOT>\n";
-    exit 1;
-}
-
-
-# get epocroot and convert, convert \ -> /
-(my $epocroot = $ARGV[0]) =~ s{\\}{/}g;
-
-# remove any trailing forward slashes
-$epocroot =~ s/\/$//;
-
-
-# create variables for paths
-my $e32toolsdir = $epocroot."/epoc32/tools";
-my $e32includedir = $epocroot."/epoc32/include";
-my $e32includeoemdir = $e32includedir."/oem";
-my $platformpathspath = $e32includedir."/platform_paths.hrh";
-my $domainplatformpathspath = $e32includedir."/domain/osextensions/platform_paths.hrh";
-my $mmppmpath = $e32toolsdir."/mmp.pm";
-my $pathutlpmpath = $e32toolsdir."/pathutl.pm";
-my $prepfilepmpath = $e32toolsdir."/prepfile.pm";
-
-# variables for hacked content
-my $dependshack = "\t\t\tif (/^DEPENDS\$/o) {\r\n\t\t\t\tnext LINE;  # Ignore DEPENDS keyword, not needed by ABLD\r\n\t\t\t}\r\n";
-my $smpsafehack = "\t\tif (/^SMPSAFE\$/o) {\r\n\t\t\tnext LINE;  # Ignore SMPSAFE keyword, not needed by older environments\r\n\t\t}\r\n";
-my $forwardslashhack = "\t\t# EnvPatcher forwardslash hack begins\r\n\t\t\$_=~s{/}{\\\\}g;   # convert all forward slashes to backslashes\r\n\t\t# EnvPatcher forwardslash hack ends\r\n\r\n";
-my $coreibyexportsupport = "\r\n// Following definition is used for exporting tools and stubs IBY files to\r\n// Core image.\r\n#define CORE_IBY_EXPORT_PATH(path,exported)  /epoc32/rom/include/##exported\r\n";
-
-
-# check epoc32\tools exists
-unless (-d $e32toolsdir)
-{
-    print "$e32toolsdir not found, please check valid epocroot has been given!\n";
-    exit 1;
-}
-
-# check epoc32\include exists
-unless (-d $e32includedir)
-{
-    print "$e32includedir not found, please check valid epocroot has been given!\n";
-    exit 1;
-}
-
-
-# create epoc32\include\oem if it does not exist
-unless (-d $e32includeoemdir)
-{
-    mkdir $e32includeoemdir or die;
-    print "Missing directory $e32includeoemdir created succesfully.\n";
-}
-
-
-# check if epoc32\include\domain\osextensions\platform_paths.hrh exists
-if (-e $domainplatformpathspath)
-{
-    # show an error if the file does not have any platform macros
-    unless (string_exists_in_file($domainplatformpathspath, "OS_LAYER_SYSTEMINCLUDE"))
-    {
-        print "ERROR: $domainplatformpathspath does not have SF macros.\n";
-        print "Please check your environment, if you have S60 3.2 OEM or newer, please get the latest version!\n";
-        exit 2;
-    }
-}
-
-
-# check if epoc32\include\platform_paths.hrh exists
-if (-e $platformpathspath)
-{
-    print "$platformpathspath already exists, not checking it.\n";    
-}
-else
-{
-    # create the file missing file
-    create_default_platform_paths_hrh();
-    print "Missing file $platformpathspath created succesfully.\n";    
-}
-
-
-# check if CORE_IBY_EXPORT_PATH macro exist in the platform_paths.hrh
-unless (string_exists_in_file($platformpathspath, "CORE_IBY_EXPORT_PATH"))
-{
-    # read content of the platform_paths.hrh
-    my @filecontent = read_file_to_array($platformpathspath);  
-
-    my $match_found = 0;
-    my $i = 0;
-    my $match_found_pos = 0;
-    
-    # find the position where the include guards start (this should be a safe position)
-    foreach (@filecontent)
-    {
-        if ($_ =~ /#define PLATFORM_PATHS_HRH/)
-        {
-            $match_found = 1;
-            $match_found_pos = $i;
-            last;
-        } 
-
-        $i++;
-    }
-    
-    if ($match_found)
-    {
-        # insert the patched content to the file
-        splice(@filecontent, $match_found_pos+1, 0, $coreibyexportsupport);
-        
-        # write the modified array to the file
-        write_file_from_array($platformpathspath, @filecontent);
-    
-        print "Platform_paths.hrh updated to support CORE_IBY_EXPORT_PATH macro.\n";
-    }
-    else
-    {
-        print "WARNING: $platformpathspath is corrupted or not supported!\n";    
-    }
-}
- 
-    
-# check if epoc32\tools\mmp.pm exists
-if (-e $mmppmpath)
-{
-    # check if DEPENDS keyword already exists in the file
-    if (string_exists_in_file($mmppmpath, "DEPENDS"))
-    {
-        print "The SDK can already handle DEPENDS keyword in a MMP file.\n";        
-    }
-    else
-    {
-        # read content of the mmp.pm file
-        my @filecontent = read_file_to_array($mmppmpath);
-        
-        my $match_found = 0;
-        my $i = 0;
-        my $match_found_pos = 0;
-        
-        # loop through the array to find the correct place
-        foreach (@filecontent)
-        {
-            if ($_ =~ /Unrecognised Resource Keyword/)
-            {
-                $match_found = 1;
-                $match_found_pos = $i;
-                last;
-            } 
-
-            $i++;
-        }
-        
-        if ($match_found)
-        {
-            # insert the patched content to the file
-            splice(@filecontent, $match_found_pos-1, 0, $dependshack);
-            
-            # write the modified array to the file
-            write_file_from_array($mmppmpath, @filecontent);
-        
-            print "Mmp.pm patched with DEPENDS keyword hack.\n";
-        }
-        else
-        {
-            print "ERROR: Unable to find correct place from $mmppmpath for patching!\n";
-            print "Your SDK environment probably is not supported by this script!\n";
-            exit(2);    
-        }
-    }
-
-    # check if SMPSAFE keyword already exists in the file
-    if (string_exists_in_file($mmppmpath, "SMPSAFE"))
-    {
-        print "The SDK can already handle SMPSAFE keyword in a MMP file.\n";        
-    }
-    else
-    {
-        # read content of the mmp.pm file
-        my @filecontent = read_file_to_array($mmppmpath);
-        
-        my $match_found = 0;
-        my $i = 0;
-        my $match_found_pos = 0;
-        
-        # loop through the array to find the correct place
-        foreach (@filecontent)
-        {
-            if ($_ =~ /Unrecognised Keyword/)
-            {
-                $match_found = 1;
-                $match_found_pos = $i;
-                last;
-            } 
-
-            $i++;
-        }
-        
-        if ($match_found)
-        {
-            # insert the patched content to the file
-            splice(@filecontent, $match_found_pos, 0, $smpsafehack);
-            
-            # write the modified array to the file
-            write_file_from_array($mmppmpath, @filecontent);
-        
-            print "Mmp.pm patched with SMPSAFE keyword hack.\n";
-        }
-        else
-        {
-            print "ERROR: Unable to find correct place from $mmppmpath for patching!\n";
-            print "Your SDK environment probably is not supported by this script!\n";
-            exit(2);    
-        }
-    }
-}
-else
-{
-    print "WARNING: $mmppmpath not found, this environment is not supported!\n";
-}
-
-
-# check if epoc32\tools\pathutl.pm exists
-if (-e $pathutlpmpath)
-{
-    # check if "sub Path_Norm" already exists in the pathutil.pm file
-    # if it does not exists, then we need to patch prepfile.pm
-    if (string_exists_in_file($pathutlpmpath, "sub Path_Norm"))
-    {
-        print "The SDK is non Symbian OS 9.1, no need to add forward slash hack.\n";        
-    }
-    else
-    {
-        # check if prepfile.pm has already been patched
-        if (string_exists_in_file($prepfilepmpath, "EnvPatcher forwardslash hack"))
-        {        
-            print "The SDK has already been patched with forwardslash hack.\n";         
-        }
-        else
-        {    
-            # read content of the prepfile.pm file
-            my @filecontent = read_file_to_array($prepfilepmpath);  
-    
-            my $match_found = 0;
-            my $i = 0;
-            my $match_found_pos = 0;
-            
-            # loop through the array to find the correct place
-            foreach (@filecontent)
-            {
-                if ($_ =~ /# skip blank lines/)
-                {
-                    $match_found = 1;
-                    $match_found_pos = $i;
-                    last;
-                } 
-    
-                $i++;
-            }
-            
-            if ($match_found)
-            {
-                # insert the patched content to the file
-                splice(@filecontent, $match_found_pos+6, 0, $forwardslashhack);
-                
-                # write the modified array to the file
-                write_file_from_array($prepfilepmpath, @filecontent);
-            
-                print "Prepfile.pm patched with forward slash hack.\n";
-            }
-            else
-            {
-                print "ERROR: Unable to find correct place from $prepfilepmpath for patching!\n";
-                print "Your SDK environment probably is not supported by this script!\n";
-                exit(2);    
-            }
-        }
-    }    
-}
-else
-{
-    print "WARNING: $pathutlpmpath not found, this environment is not supported!\n";
-}
- 
- 
- 
-# checks if string exists in the file    
-sub string_exists_in_file
-{
-    my $filepath = $_[0];
-    my $findstring = $_[1];
-    my $match_found = 0;     
-
-    open(FILE, "<", $filepath) or die "Failed to open $filepath for reading!";
-
-    # loop through the file for occurances
-    while (<FILE>)
-    {
-        if ($_ =~ /$findstring/)
-        {
-            $match_found = 1;
-            last;
-        } 
-    }
-
-    close FILE;
-    
-    return $match_found;
-}
-
-
-# reads lines from a file to an array    
-sub read_file_to_array
-{
-    my $filepath = $_[0];
-
-    open(FILE, "<", $filepath) or die "Failed to open $filepath for reading!";
-    my @data = <FILE>;
-    close FILE;
-    
-    return(@data);
-}
-
-
-# writes lines from an array to a file
-sub write_file_from_array
-{
-    my ($filepath, @data) = @_;
-    
-    # take a backup of the file
-    copy ($filepath, $filepath."EnvPatcher") or die "Cannot take backup of $filepath to $filepath.EnvPatcher";
-        
-    open(FILE, ">", $filepath) or die "Failed to open $filepath for writing!";
-
-    # write the array to file
-    foreach my $line (@data)
-    {
-        print FILE "$line";
-    }
-
-    close FILE;
-}
-
-sub create_default_platform_paths_hrh
-{
-    # the file does not exist, so create the missing file
-    open(FILE, ">", $platformpathspath) or die "Failed to open $platformpathspath for writing!\n";
-    
-    print FILE <<ENDOFTHEFILE;
-#ifndef PLATFORM_PATHS_HRH
-#define PLATFORM_PATHS_HRH
-
-/**
-* ---------------------------------------
-* Location, where the applications layer specific public headers should be exported
-* See usage on top of this hrh-file.
-* ---------------------------------------
-*/
-#define APP_LAYER_SDK_EXPORT_PATH(exported) /epoc32/include/##exported
-#define APP_LAYER_PUBLIC_EXPORT_PATH(exported) /epoc32/include/##exported
-
-/**
-* ---------------------------------------
-* Location, where the applications layer specific platform headers should be exported
-* See usage on top of this hrh-file.
-* ---------------------------------------
-*/
-#define APP_LAYER_DOMAIN_EXPORT_PATH(exported) /epoc32/include/##exported
-#define APP_LAYER_PLATFORM_EXPORT_PATH(exported) /epoc32/include/##exported
-
-/**
-* ---------------------------------------
-* Location, where the middleware layer specific public headers should be exported
-* See usage on top of this hrh-file.
-* ---------------------------------------
-*/
-#define MW_LAYER_SDK_EXPORT_PATH(exported) /epoc32/include/##exported
-#define MW_LAYER_PUBLIC_EXPORT_PATH(exported) /epoc32/include/##exported
-
-/**
-* ---------------------------------------
-* Location, where the middleware layer specific platform headers should be exported
-* ---------------------------------------
-*/
-#define MW_LAYER_DOMAIN_EXPORT_PATH(exported) /epoc32/include/##exported
-#define MW_LAYER_PLATFORM_EXPORT_PATH(exported) /epoc32/include/##exported
-
-/**
-* ---------------------------------------
-* Location, where the os layer specific public headers should be exported
-* ---------------------------------------
-*/
-#define  OSEXT_LAYER_SDK_EXPORT_PATH(exported) /epoc32/include/##exported
-#define  OS_LAYER_PUBLIC_EXPORT_PATH(exported) /epoc32/include/##exported
-
-/**
-* ---------------------------------------
-* Location, where the os specific platform headers should be exported
-* ---------------------------------------
-*/
-#define OSEXT_LAYER_DOMAIN_EXPORT_PATH(exported) /epoc32/include/##exported
-#define OS_LAYER_PLATFORM_EXPORT_PATH(exported) /epoc32/include/##exported
-
-/**
-* ---------------------------------------
-* Location, where the  cenrep excel sheets should be exported
-* Deprecated: should no longer be used. Kept for compability.
-* ---------------------------------------
-*/
-#define CENREP_XLS_EXPORT_PATH(exported) /epoc32/tools/cenrep/data/src/##exported
-
-/**
-* This define statements defines the SYSTEMINCLUDE-line, which is intended to be 
-* used in the mmp-files that are part of the applications-layer. It includes all 
-* the needed directories from the /epoc32/include, that are valid ones for the 
-* application-layer components. 
-*
-* Applications layer is the last one in the list, since most likely the most of 
-* the headers come from middleware or os-layer  => thus they are first.
-*/
-#define APP_LAYER_SYSTEMINCLUDE SYSTEMINCLUDE /epoc32/include /epoc32/include/oem
- 
-/**
-* This define statements defines the SYSTEMINCLUDE-line, which is intended to be
-* used in the mmp-files that are part of the middleware-layer. It includes all 
-* the needed directories from the /epoc32/include, that are valid ones for the 
-* middleware-layer components. 
-*/
-#define MW_LAYER_SYSTEMINCLUDE SYSTEMINCLUDE /epoc32/include /epoc32/include/oem
-
-/**
-* This define statements defines the SYSTEMINCLUDE-line, which is intended to be
-* used in the mmp-files that are part of the  osextensions-layer. It includes all
-* the needed directories from the /epoc32/include, that are valid ones for the
-* os-layer components. 
-*/
-#define OS_LAYER_SYSTEMINCLUDE SYSTEMINCLUDE /epoc32/include /epoc32/include/oem
-
-
-// Below statement is Deprecated and the OS_LAYER_SYSTEMINCLUDE-macro has to be
-// used.
-#define OSEXT_LAYER_SYSTEMINCLUDE OS_LAYER_SYSTEMINCLUDE
-
-/**
-* This define statements defines the SYSTEMINCLUDE-line, which is intended to be
-* used in the mmp-files that are part of the os-layer. This is intended 
-* to be only used by those components which need to use in their mmp-file either
-* kern_ext.mmh or nkern_ext.mmh. Reason is that those
-* 2 files already contain the /epoc32/include  as system include path.
-* 
-*/
-#define OS_LAYER_KERNEL_SYSTEMINCLUDE SYSTEMINCLUDE /epoc32/include/oem
-
-
-// Below statement is Deprecated and the OS_LAYER_KERNEL_SYSTEMINCLUDE-macro 
-// has to be used.
-#define OSEXT_LAYER_KERNEL_SYSTEMINCLUDE OS_LAYER_KERNEL_SYSTEMINCLUDE
-
-/**
-****************************************************************************
-* Definitions that also define the paths to the layer specific source directories.
-****************************************************************************
-*/
-/**
-* The below 3 macros define the paths to the layer-specific source dirs.
-* See usage on top of this hrh-file, these are used the same way as 
-* for instance the OS_LAYER_DOMAIN_EXPORT_PATH
-* Deprecated: is not allowed to be using in Symbian Foundation
-*/
-#define APP_LAYER_SOURCE_PATH(rest)    /s60/app/##rest
-#define MW_LAYER_SOURCE_PATH(rest)     /s60/mw/##rest
-#define OSEXT_LAYER_SOURCE_PATH(rest)  /s60/osext/##rest
-
-/**
-****************************************************************************
-* Definitions to export IBY files to different folders where they will be taken 
-* to ROM image
-****************************************************************************
-*/
-// Following definition is used for exporting tools and stubs IBY files to 
-// Core image.
-#define CORE_IBY_EXPORT_PATH(path,exported)  /epoc32/rom/include/##exported
-
-/**
-* ---------------------------------------
-* Macros for Configuration tool migration. 
-* The below macros define the location under epoc32, where the confml 
-* (Configuration Markup Language) and crml (Central Repository Markup Language) 
-* files should be exported.
-* ---------------------------------------
-*/
-#define CONFML_EXPORT_PATH(file,category)           /epoc32/rom/config/confml_data/##category##/##file
-#define CRML_EXPORT_PATH(file,category)             /epoc32/rom/config/confml_data/##category##/##file
-#define GCFML_EXPORT_PATH(file,category)            /epoc32/rom/config/confml_data/##category##/##file
-#define CONFML_CONFIG_EXPORT_PATH(file,category)    /epoc32/rom/config/confml_data/##category##/config/##file
-
-#define APP_LAYER_CONFML(exported) 	                CONFML_EXPORT_PATH(exported,s60)
-#define APP_LAYER_CRML(exported)                    CRML_EXPORT_PATH(exported,s60)
-#define APP_LAYER_GCFML(exported)                   GCFML_EXPORT_PATH(exported,s60)
-#define APP_LAYER_CONFML_CONFIG(exported)           CONFML_CONFIG_EXPORT_PATH(exported,s60)
-                                                    
-#define MW_LAYER_CONFML(exported)                   CONFML_EXPORT_PATH(exported,s60)
-#define MW_LAYER_CRML(exported)                     CRML_EXPORT_PATH(exported,s60)
-#define MW_LAYER_GCFML(exported)                    GCFML_EXPORT_PATH(exported,s60)
-#define MW_LAYER_CONFML_CONFIG(exported)            CONFML_CONFIG_EXPORT_PATH(exported,s60)
-       
-// Deprecate: Use the OS_LAYER_* macros instead of OSEXT_LAYER_*                                             
-#define OSEXT_LAYER_CONFML(exported)                CONFML_EXPORT_PATH(exported,s60)
-#define OSEXT_LAYER_CRML(exported)                  CRML_EXPORT_PATH(exported,s60)
-#define OSEXT_LAYER_GCFML(exported)                 GCFML_EXPORT_PATH(exported,s60)
-#define OSEXT_LAYER_CONFML_CONFIG(exported)         CONFML_CONFIG_EXPORT_PATH(exported,s60)
-#define OS_LAYER_CONFML(exported)                   CONFML_EXPORT_PATH(exported,s60)
-#define OS_LAYER_CRML(exported)                     CRML_EXPORT_PATH(exported,s60)
-#define OS_LAYER_GCFML(exported)                    GCFML_EXPORT_PATH(exported,s60)
-#define OS_LAYER_CONFML_CONFIG(exported)            CONFML_CONFIG_EXPORT_PATH(exported,s60)
-
-#endif  // end of PLATFORM_PATHS_HRH
-
-ENDOFTHEFILE
-
-    close FILE;    
-}
--- a/screengrabber/envpatcher/ReadMe.txt	Fri Apr 16 14:59:17 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,46 +0,0 @@
-Environment Patcher v1.0.1
-==========================
-
-Updated: 12th November 2009
-
-
-Introduction:
--------------
-This tool can be used to patch your S60 SDK environment so that the tricks and
-macros introduced in the latest SDKs can be used in a public SDK and older
-OEM releases.
-
-This tool can perform the following tasks:
-- Adds support for forward slashes in paths in bld.inf/.mmp files in S60 3.0 
-- Removes an unncessary warning about DEPENDS and SMPSAFE resource keywords in
-  an .mmp file
-- Creates a missing epoc32\include\platform_paths.hrh file for supporting
-  platform macros introduced since S60 3.2 OEM and Symbian Foundation releases
-- Modifies epoc32\include\platform_paths.hrh for missing macros   
-- Creates a missing epoc32\include\oem directory to suppress a possible warning
-
-
-Usage:
-------
-EnvPatcher.pl <EPOCROOT>
-
-Where EPOCROOT is the path to the root of the SDK, for example:
-  EnvPatcher.pl c:\Symbian\9.1\S60_3rd_MR
-  EnvPatcher.pl z:\
-
-
-Requirements:
--------------
-- S60 SDK (public or OEM), version 3.0 or newer
-- Perl 5.6.1 or newer
-
-
-
-
-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".
--- a/screengrabber/group/ReleaseNotes_ScreenGrabber.txt	Fri Apr 16 14:59:17 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,141 +0,0 @@
-===============================================================================
-
-RELEASE NOTES - SCREENGRABBER v4.2.0
-RELEASED 14th May 2009 
-
-SUPPORTS S60 3.0+
-
-===============================================================================
-
-Product Description:
-====================
-ScreenGrabber tool is used to capture images and video of the visible screen
-area in S60 platform. Captures can be handled with the Media Gallery
-application or with PC when the device is connected via PC suite.
-
-Main Features:
-==============
-- Image capture in single or in sequential mode supporting PNG, JPEG and BMP
-  formats
-- Video capture in animated GIF format
-- Configurable saving format, hotkey, time delta in sequential mode, target
-  memory and default filename
-- Ability to change the screen mode to one of the supported more by the device
-
-===============================================================================
-
-What's New in v4.2.0
-====================
-- Feature: Added a new SIS file for S60 3.2 devices and newer to support the
-  features in newer platforms
-- Feature: Added multidrive support in the settings dialog
-
-===============================================================================
-
-Installation Notes:
-===================
-ScreenGrabber is typically preinstalled on ROM. If not, it can be added to the
-ROM with the .iby file. Alternatively, the .sis file can be found under the sis-
-directory, but the user need to sign it with their own developer certificate.
-In Nokia R&D environment, you can use directly the R&D-signed .sis file under the
-internal\sis directory.
-
-When signing with own developer certificate, the following capabilities are
-needed:
-  WriteDeviceData
-  SwEvent
-
-When builing ScreenGrabber against S60 3.0 or 3.1, you may need to patch your
-SDK environment first with some fixes. For more information, please refer to
-the instructions under the "envpatcher" directory.
-
-===============================================================================
-
-System Requirements:
-====================
-Basic Requirements:
-- Any S60 3.x device or emulator environment
-
-===============================================================================
-
-Compatibility Issues:
-=====================
-N/A
-
-===============================================================================
-
-Known Issues:
-=============
-
-Sluggish UI when capturing video
---------------------------------
-- Video capturing requires huge amount of processing power and thus may cause
-  the UI to become sluggish. If supported by the device, try to decrease the
-  screen resolution.
-
-===============================================================================
-
-Version History:
-================
-
-Version 4.1.3 - 8th March 2009
-------------------------------
-- Fix: ScreenGrabber does not work in devices which do not have Media Gallery
-  (Media Gallery File Manager API dependency changed from static to dynamic)
-    
-Version 4.1.2 - 8th February 2008
----------------------------------
-- Fix: Transparency errors in GIF animations (hopefully) finally fixed
-  
-Version 4.1.1 - 28th January 2008
----------------------------------
-- Feature: Added hash+* and alternative camera key into selection of capture
-  keys
-- Change: Reimplemented settings handling so that AllFiles and WriteUserData
-  capabilities are no longer needed
-    
-Version 4.1.0 - 14th January 2008
----------------------------------
-- Feature: Added support for GIF and MBM formats although it is always
-  recommended to capture screens in PNG format
-- Feature: JPEG format can now be selected as high quality (97%) or low quality
-  (60%) 
-- Feature: Added POC key under capturing key options
-- Change: Dimensions of a video will be grown if the screen resolution of the
-  device will grow during capturing
-- Change: Capturing is now done always from current focus screen which allows to
-  support secondary displays
-- Change: Send key is now the default key
-- Fix: Black color didn't always work correctly in GIF animation optimization
-  with transparency  
-- Fix: Capturing to JPEG format leaked memory
-
-Version 4.0.3 - 16th November 2007
-----------------------------------
-- Fix: Scroll bar in the main view can be scrolled on a touch UI
-- Fix: Application closes automatically when closed via open applications menu
-
-Version 4.0.2 - 9th October 2007
---------------------------------
-- Fix: Main screen layout in mirrored mode
-  
-Version 4.0.1 - 14th February 2007
-----------------------------------
-- Fix: Help screen on larger displays
-  
-Version 4.0.0 - 25th October 2006
----------------------------------
-- Feature: Support for sequential capture mode
-- Feature: Support for capturing video in animated GIF format
-- Feature: Ability to change screen mode to one of the supported more by the
-  device
-
-===============================================================================
-
-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".
--- a/screengrabber/group/backup_registration.xml	Fri Apr 16 14:59:17 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,8 +0,0 @@
-<?xml version="1.0" standalone="yes"?>
-<backup_registration>
-  <passive_backup>
-    <include_directory name="\"/>
-  </passive_backup>
-  <system_backup/>
-  <restore requires_reboot = "no"/>
-</backup_registration>
--- a/screengrabber/group/bld.inf	Fri Apr 16 14:59:17 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,53 +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 <platform_paths.hrh>
-
-
-PRJ_EXPORTS
-../group/backup_registration.xml    Z:/private/101fb751/backup_registration.xml
-../rom/screengrabber.iby CORE_IBY_EXPORT_PATH(tools,screengrabber.iby)
-
-
-PRJ_MMPFILES
-#if defined(__SERIES60_30__) || defined(__SERIES60_31__) || defined(__S60_32__)
-  gnumakefile screengrabber_icons_aif.mk
-
-  #ifdef MARM
-  gnumakefile screengrabber_stub_sis.mk
-  #endif
-#endif
-
-screengrabber.mmp
-
-
-#if(!defined __SERIES60_30__ && !defined __SERIES60_31__ && !defined __S60_32__)
-  PRJ_EXTENSIONS
-  START EXTENSION s60/mifconv
-  OPTION TARGETFILE screengrabber_aif.mif
-  OPTION SOURCEDIR ../icons
-  OPTION SOURCES -c8,8 qgn_menu_screengrabber
-  END
-
-  #ifdef MARM
-  START EXTENSION app-services/buildstubsis
-  OPTION SRCDIR ../sis
-  OPTION SISNAME ScreenGrabber_stub
-  END
-  #endif  
-#endif
--- a/screengrabber/group/screengrabber.mmp	Fri Apr 16 14:59:17 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,95 +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 <data_caging_paths.hrh>
-#include <platform_paths.hrh>
-
-
-TARGET            ScreenGrabber.exe
-TARGETTYPE        exe
-EPOCSTACKSIZE     0x5000
-EPOCHEAPSIZE      0x20000 0x1000000  // Min 128Kb, Max 16Mb
-
-UID               0x100039CE 0x101FB751
-
-VENDORID          VID_DEFAULT
-CAPABILITY        WriteDeviceData SwEvent
-
-SMPSAFE
-
-LANG              SC
-
-
-START RESOURCE    ../data/screengrabber.rss
-HEADER
-TARGETPATH        APP_RESOURCE_DIR
-END
-
-START RESOURCE    ../data/screengrabber_reg.rss
-DEPENDS           screengrabber.rsg
-TARGETPATH        /private/10003a3f/apps
-END
-
-APP_LAYER_SYSTEMINCLUDE
-USERINCLUDE       ../inc
-SOURCEPATH        ../src
-
-
-SOURCE            SGApp.cpp
-SOURCE            SGDocument.cpp 
-SOURCE            SGAppUi.cpp
-SOURCE            SGMainView.cpp 
-SOURCE            SGMainContainer.cpp 
-SOURCE            SGSettingListView.cpp
-SOURCE            SGSettingListContainer.cpp
-SOURCE            SGModel.cpp
-SOURCE            SGGifAnimator.cpp
-
-LIBRARY           euser.lib
-LIBRARY           apparc.lib
-LIBRARY           cone.lib 
-LIBRARY           eikcore.lib  
-LIBRARY           avkon.lib 
-LIBRARY           aknnotify.lib
-LIBRARY           ws32.lib
-LIBRARY           fbscli.lib
-LIBRARY           ImageConversion.lib
-LIBRARY           PlatformEnv.lib
-LIBRARY           CommonDialogs.lib
-LIBRARY           eikcoctl.lib
-LIBRARY           aknskins.lib
-LIBRARY           apgrfx.lib
-LIBRARY           efsrv.lib
-LIBRARY           CommonEngine.lib
-LIBRARY           bafl.lib
-LIBRARY           mediaclientaudio.lib
-LIBRARY           estor.lib
-LIBRARY           gdi.lib
-LIBRARY           eikctl.lib
-LIBRARY           eikcdlg.lib
-
-
-// Multidrive support
-#if(!defined __SERIES60_30__ && !defined __SERIES60_31__)
-MACRO SCREENGRABBER_MULTIDRIVE_SUPPORT
-#endif
-
-// Screen resolution change support
-MACRO SCREENGRABBER_SCREEN_RESOLUTION_CHANGE_SUPPORT
-
-// End of File
--- a/screengrabber/group/screengrabber_icons_aif.mk	Fri Apr 16 14:59:17 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,54 +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
-
-TARGETDIR=$(ZDIR)\resource\apps
-ICONTARGETFILENAME=$(TARGETDIR)\screengrabber_aif.mif
-
-
-do_nothing :
-	@rem do_nothing
-
-MAKMAKE : do_nothing
-
-BLD : do_nothing
-
-CLEAN :
-	@if exist $(ICONTARGETFILENAME) erase $(ICONTARGETFILENAME)
-
-LIB : do_nothing
-
-CLEANLIB : do_nothing
-
-RESOURCE : $(ICONTARGETFILENAME)
-
-$(ICONTARGETFILENAME) : ..\icons\qgn_menu_screengrabber.svg
-	mifconv $(ICONTARGETFILENAME) \
-		/c8,8 ..\icons\qgn_menu_screengrabber.svg
-
-FREEZE : do_nothing
-
-SAVESPACE : do_nothing
-
-RELEASABLES :
-	@echo $(ICONTARGETFILENAME)
-
-FINAL : do_nothing
--- a/screengrabber/group/screengrabber_stub_sis.mk	Fri Apr 16 14:59:17 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,56 +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:  
-#
-
-
-TARGETDIR=$(EPOCROOT)EPOC32\Data\Z\System\Install
-
-SISNAME=ScreenGrabber_stub
-PKGNAME=ScreenGrabber_stub
-
-$(TARGETDIR) :
-	@perl -S emkdir.pl "$(TARGETDIR)"
-
-do_nothing :
-	rem do_nothing
-
-SISFILE=$(TARGETDIR)\$(SISNAME).sis
-
-$(SISFILE) : ..\sis\$(PKGNAME).pkg
-	makesis -s $? $@ 
-
-
-
-MAKMAKE : do_nothing
-
-RESOURCE : do_nothing
-
-SAVESPACE : do_nothing
-
-BLD : do_nothing
-
-FREEZE : do_nothing
-
-LIB : do_nothing
-
-CLEANLIB : do_nothing
-
-FINAL : $(TARGETDIR) $(SISFILE)
-
-CLEAN : 
-	@if exist $(SISFILE) erase $(SISFILE)
-
-RELEASABLES : 
-	@echo $(SISFILE)
--- a/screengrabber/inc/SG.hrh	Fri Apr 16 14:59:17 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,103 +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:  
-*
-*/
-
-
-
-#ifndef SCREENGRABBER_HRH
-#define SCREENGRABBER_HRH
-
-enum TScreenGrabberCommandIds
-    {
-	EScreenGrabberCmdSendToBackground = 1,
-    EScreenGrabberCmdSettings,
-	EScreenGrabberCmdAbout,
-	EScreenGrabberCmdScreenResolution,
-    EScreenGrabberCmdScreenResolutionItem1,
-    EScreenGrabberCmdScreenResolutionItem2,
-    EScreenGrabberCmdScreenResolutionItem3,
-    EScreenGrabberCmdScreenResolutionItem4,
-    EScreenGrabberCmdScreenResolutionItem5,
-    EScreenGrabberCmdScreenResolutionItem6,
-    EScreenGrabberCmdScreenResolutionItem7,
-    EScreenGrabberCmdScreenResolutionItem8,
-    EScreenGrabberCmdScreenResolutionItem9,
-    EScreenGrabberCmdScreenResolutionItem10,
-    EScreenGrabberCmdScreenResolutionItem11,
-    EScreenGrabberCmdScreenResolutionItem12,
-	EScreenGrabberCmdSettingsChange,
-	EScreenGrabberCmdSettingsExit,
-	EScreenGrabberCmdSettingsBack,
-    EProgressNote
-    };
-
-enum TScreenGrabberSettingListIds
-    {
-	ESettingListCaptureModeSelection = 0,
-
-	ESettingListSingleCaptureHotkeySelection,
-    ESettingListSingleCaptureImageFormatSelection,
-	ESettingListSingleCaptureMemorySelection,
-	ESettingListSingleCaptureFileNameSelection,
-
-	ESettingListSequantialCaptureHotkeySelection,
-    ESettingListSequantialCaptureImageFormatSelection,
-    ESettingListSequantialCaptureDelaySelection,
-	ESettingListSequantialCaptureMemorySelection,
-	ESettingListSequantialCaptureFileNameSelection,
-
-	ESettingListVideoCaptureHotkeySelection,
-    ESettingListVideoCaptureVideoFormatSelection,
-	ESettingListVideoCaptureMemorySelection,
-	ESettingListVideoCaptureFileNameSelection
-    };
-
-enum TScreenGrabberSettingCaptureModes
-    {
-	ECaptureModeSingleCapture = 0,
-    ECaptureModeSequantialCapture,
-	ECaptureModeVideoCapture
-    };
-    
-enum TScreenGrabberSettingHotkeys
-    {
-	EHotkeySendKey = 0,
-	EHotkeyShiftStar,
-	EHotkeyHashStar,
-    EHotkeyShiftMenu,
-	EHotkeyPowerKey,
-	EHotkeySideKey,
-	EHotkeyCameraKey1,
-	EHotkeyCameraKey2,
-	EHotkeyPOC
-    };
-
-enum TScreenGrabberSettingImageFormats
-    {
-	EImageFormatPNG = 0,
-    EImageFormatJPGHQ,
-    EImageFormatJPGLQ,
-	EImageFormatBMP,
-	EImageFormatGIF,
-	EImageFormatMBM
-    };
-
-enum TScreenGrabberSettingVideoFormats
-    {
-	EVideoFormatAnimatedGIF = 0
-    };
-
-#endif      // SCREENGRABBER_HRH
--- a/screengrabber/inc/SGApp.h	Fri Apr 16 14:59:17 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,65 +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:  
-*
-*/
-
-
-
-#ifndef SCREENGRABBERAPP_H
-#define SCREENGRABBERAPP_H
-
-
-// INCLUDES
-#include <aknapp.h>
-
-// CONSTANTS
-// UID of the application
-const TUid KUidScreenGrabber = { 0x101FB751 };
-
-// CLASS DECLARATION
-
-/**
-* CScreenGrabberApp application class.
-* Provides factory to create concrete document object.
-* 
-*/
-class CScreenGrabberApp : public CAknApplication
-    {
-    
-    public: // Functions from base classes
-        /**
-        * From CApaApplication, overridden to enable INI file support.
-        * @return A pointer to the dictionary store
-        */
-    CDictionaryStore* OpenIniFileLC(RFs& aFs) const;
-    private:
-
-        /**
-        * From CApaApplication, creates CScreenGrabberDocument document object.
-        * @return A pointer to the created document object.
-        */
-        CApaDocument* CreateDocumentL();
-        
-        /**
-        * From CApaApplication, returns application's UID (KUidScreenGrabber).
-        * @return The value of KUidScreenGrabber.
-        */
-        TUid AppDllUid() const;
-    };
-
-#endif
-
-// End of File
-
--- a/screengrabber/inc/SGAppUi.h	Fri Apr 16 14:59:17 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,90 +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:  
-*
-*/
-
-
-
-#ifndef SCREENGRABBERAPPUI_H
-#define SCREENGRABBERAPPUI_H
-
-// INCLUDES
-#include <eikapp.h>
-#include <eikdoc.h>
-#include <e32std.h>
-#include <coeccntx.h>
-#include <aknViewAppUi.h>
-#include <akntabgrp.h>
-#include <aknnavide.h>
-#include "SGStd.h"
-
-// FORWARD DECLARATIONS
-class CScreenGrabberMainContainer;
-class CScreenGrabberModel;
-
-// CONSTANTS
-//const ?type ?constant_var = ?constant;
-
-
-// CLASS DECLARATION
-
-
-class CScreenGrabberAppUi : public CAknViewAppUi
-    {
-    public: // // Constructors and destructor
-
-        /**
-        * EPOC default constructor.
-        */      
-        void ConstructL();
-
-        /**
-        * Destructor.
-        */      
-        ~CScreenGrabberAppUi();
-        
-    public: // New functions
-
-    public: // Functions from base classes
-        void HandleWsEventL(const TWsEvent& aEvent, CCoeControl* aDestination);
-
-    private:
-        // From MEikMenuObserver
-        void DynInitMenuPaneL(TInt aResourceId,CEikMenuPane* aMenuPane);
-
-    private:
-        /**
-        * From CEikAppUi, takes care of command handling.
-        * @param aCommand command to be handled
-        */
-        void HandleCommandL(TInt aCommand);
-
-        /**
-        * From CEikAppUi, handles key events.
-        * @param aKeyEvent Event to handled.
-        * @param aType Type of the key event. 
-        * @return Response code (EKeyWasConsumed, EKeyWasNotConsumed). 
-        */
-        virtual TKeyResponse HandleKeyEventL(
-            const TKeyEvent& aKeyEvent,TEventCode aType);
-
-    private: //Data
-        CScreenGrabberModel*    iModel;
-
-    };
-
-#endif
-
-// End of File
--- a/screengrabber/inc/SGDocument.h	Fri Apr 16 14:59:17 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,85 +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:  
-*
-*/
-
-
-
-#ifndef SCREENGRABBERDOCUMENT_H
-#define SCREENGRABBERDOCUMENT_H
-
-// INCLUDES
-#include <AknDoc.h>
-   
-// CONSTANTS
-
-// FORWARD DECLARATIONS
-class CEikAppUi;
-class CScreenGrabberModel;
-
-
-// CLASS DECLARATION
-
-/**
-*  CScreenGrabberDocument application class.
-*/
-class CScreenGrabberDocument : public CAknDocument
-    {
-    public: // Constructors and destructor
-        /**
-        * Two-phased constructor.
-        */
-        static CScreenGrabberDocument* NewL(CEikApplication& aApp);
-
-        /**
-        * Destructor.
-        */
-        virtual ~CScreenGrabberDocument();
-
-    public: // New functions
-
-    public:	// from CEikDocument
-	CFileStore* OpenFileL(TBool aDoOpen,const TDesC& aFilename,RFs& aFs);
-    protected:  // New functions
-
-    protected:  // Functions from base classes
-
-    private:
-
-        /**
-        * EPOC default constructor.
-        */
-        CScreenGrabberDocument(CEikApplication& aApp);
-        void ConstructL();
-
-    private:
-
-        /**
-        * From CEikDocument, create CScreenGrabberAppUi "App UI" object.
-        */
-        CEikAppUi* CreateAppUiL();
-
-    public:
-        CScreenGrabberModel* Model();
-
-    private:
-        CScreenGrabberModel* iModel;
-
-    };
-
-#endif
-
-// End of File
-
--- a/screengrabber/inc/SGGifAnimator.h	Fri Apr 16 14:59:17 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,98 +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:  
-*
-*/
-
-
-
-#ifndef __GIFANIMATOR_H__
-#define __GIFANIMATOR_H__
-
-#include <e32std.h>
-#include <e32base.h>
-#include "SGModel.h"
-#include "SGStd.h"
-
-
-class CImageEncoder;
-class CSavingProgressDialog;
-class CAknGlobalProgressDialog;
-
-class MDialogCallback
-    {
-public:
-    virtual void DialogDismissedL( TInt aButtonId ) = 0;
-    };
-
-
-class CGifAnimator : public CActive, public MDialogCallback
-	{
-public:
-	static int CreateGifAnimation(const TDesC& aFileName, TSize aDimensions, CVideoFrameArray* aVideoFrameArray);
-	~CGifAnimator();
-
-private:
-    CGifAnimator();
-    void StartL(const TDesC& aFileName, const TSize& aDimensions, CVideoFrameArray* aVideoFrameArray);
-    void WriteHeaderL(const TSize& aDimensions);
-    void WriteGraphicControlL(const TVideoFrame& aFrame);
-    void WriteImageDescriptorL(const TVideoFrame& aFrame);
-    CFbsBitmap* GetBitmapLC(TVideoFrame& aFrame, const TSize& aDimensions);
-    void WriteRasterDataL(CFbsBitmap* aBitmap);
-    void WriteFooterL();
-    void FinishL();
-    void WriteInt8L(TInt aValue);
-    void WriteInt16L(TInt aValue);
-    void RunL();
-	void DoCancel();
-	void DialogDismissedL(TInt aButtonId); // from MDialogCallback
-    
-private:
-    RFs                         iFs;
-    RFile                       iOutFile;
-	CImageEncoder*              iImageEncoder;
-	HBufC8*                     iGIFImageData;
-	CActiveSchedulerWait        iWait;
-    CSavingProgressDialog*      iSavingProgressDialog;
-    };
-
-
-class CSavingProgressDialog : public CActive
-    {
-public:
-    static CSavingProgressDialog* NewL(MDialogCallback* aDialogCallback);
-    ~CSavingProgressDialog();
-    void StartDisplayingL(const TDesC &aText, TInt aFinalValue);
-    void IncreaseProgressValueWithOne();
-    void ProcessFinished();
-
-private:
-    void DoCancel();
-    void RunL();
-
-private: 
-    CSavingProgressDialog();
-    void ConstructL(MDialogCallback* aDialogCallback);
-
-private:
-    MDialogCallback*            iDialogCallback;
-    CAknGlobalProgressDialog*   iGlobalProgressDialog;
-    TBool                       iVisible;
-    TInt                        iCurrentValue;
-    TInt                        iFinalValue;
-    };
-		
-	
-#endif // __GIFANIMATOR_H__
\ No newline at end of file
--- a/screengrabber/inc/SGMainContainer.h	Fri Apr 16 14:59:17 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,97 +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:  
-*
-*/
-
-
-
-#ifndef SCREENGRABBERMAINCONTAINER_H
-#define SCREENGRABBERMAINCONTAINER_H
-
-// INCLUDES
-#include <coecntrl.h>
-#include <eiksbobs.h>
-
-// FORWARD DECLARATIONS
-class CEikScrollBarFrame;
-class CAknsBasicBackgroundControlContext;
-
-
-// CLASS DECLARATION
-
-/**
-*  CScreenGrabberMainContainer  container control class.
-*  
-*/
-class CScreenGrabberMainContainer : public CCoeControl, MCoeControlObserver, MEikScrollBarObserver
-    {
-    public: // Constructors and destructor
-        
-        /**
-        * EPOC default constructor.
-        * @param aRect Frame rectangle for container.
-        */
-        void ConstructL(const TRect& aRect);
-
-        /**
-        * Destructor.
-        */
-        ~CScreenGrabberMainContainer();
-
-    public: // New functions
-
-        void PrintText(const TDesC& aDes);
-        void ClearOutputWindow();
-
-
-    public: // Functions from base classes
-
-    private: // Functions from base classes
-
-        void Draw(const TRect& aRect) const;
-        void HandleControlEventL(CCoeControl* aControl,TCoeEvent aEventType);
-        TTypeUid::Ptr MopSupplyObject(TTypeUid aId);
-
-    public:
-        void HandleResourceChange(TInt aType);
-        void HandleScrollEventL(CEikScrollBar* aScrollBar,TEikScrollEvent aEventType); // From MEikScrollBarObserver
-        
-	private:
-		TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode /*aType*/);
-    
-    private:
-        void UpdateVisualContentL(TBool aScrollToBottom);
-
-    private: //data
-        CEikScrollBarFrame*     iScrollBarFrame;
-        HBufC*                  iText;
-        const CFont*            iFont;
-        HBufC*                  iWrapperString;
-        CArrayFix<TPtrC>*       iWrappedArray;
-        TInt                    iCurrentLine;
-        TInt                    iLineCount;
-        TInt                    iNumberOfLinesFitsScreen;
-        TInt                    iLeftDrawingPosition;
-        TReal                   iX_factor;
-        TReal                   iY_factor;
-
-        CAknsBasicBackgroundControlContext* iSkinContext;
-
-
-    };
-
-#endif
-
-// End of File
\ No newline at end of file
--- a/screengrabber/inc/SGMainView.h	Fri Apr 16 14:59:17 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,99 +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:  
-*
-*/
-
-
-
-#ifndef SCREENGRABBERMAINVIEW_H
-#define SCREENGRABBERMAINVIEW_H
-
-// INCLUDES
-#include <aknview.h>
-#include "SGStd.h"
-
-
-
-// CONSTANTS
-// UID of view
-const TUid KMainViewUID = {1};
-
-// FORWARD DECLARATIONS
-class CScreenGrabberMainContainer;
-
-// CLASS DECLARATION
-
-/**
-*  CScreenGrabberMainView view class.
-* 
-*/
-class CScreenGrabberMainView : public CAknView
-    {
-    public: // Constructors and destructor
-
-        /**
-        * EPOC default constructor.
-        */
-        void ConstructL();
-
-        /**
-        * Destructor.
-        */
-        ~CScreenGrabberMainView();
-
-    public: // Functions from base classes
-        
-        /**
-        * From ?base_class ?member_description
-        */
-        TUid Id() const;
-
-        /**
-        * From ?base_class ?member_description
-        */
-        void HandleCommandL(TInt aCommand);
-
-        /**
-        * From ?base_class ?member_description
-        */
-        void HandleClientRectChange();
-
-#ifdef SCREENGRABBER_SCREEN_RESOLUTION_CHANGE_SUPPORT
-    private:
-        // From MEikMenuObserver
-        void DynInitMenuPaneL(TInt aResourceId, CEikMenuPane* aMenuPane);
-#endif
-        
-    private:
-
-        /**
-        * From AknView, ?member_description
-        */
-        void DoActivateL(const TVwsViewId& aPrevViewId,TUid aCustomMessageId,
-            const TDesC8& aCustomMessage);
-
-        /**
-        * From AknView, ?member_description
-        */
-        void DoDeactivate();
-
-    private: // Data
-        CScreenGrabberMainContainer* iContainer;
-        
-    };
-
-#endif
-
-// End of File
--- a/screengrabber/inc/SGModel.h	Fri Apr 16 14:59:17 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,242 +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:  
-*
-*/
-
-
-
-#ifndef __SCREENGRABBER_MODEL_H__
-#define __SCREENGRABBER_MODEL_H__
-
-#include <e32std.h>
-#include <e32base.h>
-
-#include <CAknMemorySelectionSettingPage.h>
-#include <eikenv.h>
-#include <mdaaudiotoneplayer.h>
-#include <bamdesca.h>
-#include "SGStd.h"
-
-
-#define TRANSPARENCY_INDEX 30
-#define TRANSPARENCY_ALTERNATIVE_INDEX 24
-
-
-// setting keys (do not change uids of existing keys to maintain compatibility to older versions!)
-const TUid KSGSettingCaptureMode                            = { 0x00 };
-
-const TUid KSGSettingSingleCaptureHotkey                    = { 0x01 };
-const TUid KSGSettingSingleCaptureImageFormat               = { 0x02 };
-const TUid KSGSettingSingleCaptureMemoryInUse               = { 0x03 };
-const TUid KSGSettingSingleCaptureMemoryInUseMultiDrive     = { 0x04 };
-const TUid KSGSettingSingleCaptureFileName                  = { 0x05 };
-
-const TUid KSGSettingSequantialCaptureHotkey                = { 0x06 };
-const TUid KSGSettingSequantialCaptureImageFormat           = { 0x07 };
-const TUid KSGSettingSequantialCaptureDelay                 = { 0x08 };
-const TUid KSGSettingSequantialCaptureMemoryInUse           = { 0x09 };
-const TUid KSGSettingSequantialCaptureMemoryInUseMultiDrive = { 0x0A };
-const TUid KSGSettingSequantialCaptureFileName              = { 0x0B };
-
-const TUid KSGSettingVideoCaptureHotkey                     = { 0x0C };
-const TUid KSGSettingVideoCaptureVideoFormat                = { 0x0D };
-const TUid KSGSettingVideoCaptureMemoryInUse                = { 0x0E };
-const TUid KSGSettingVideoCaptureMemoryInUseMultiDrive      = { 0x0F };
-const TUid KSGSettingVideoCaptureFileName                   = { 0x10 };
-
-
-class CImageEncoder;
-class CFbsBitmap;
-class CFrameImageData;
-class CAknGlobalConfirmationQuery;
-class CSavedQuery;
-class CDictionaryFileStore;
-class CMGXFileManager;
-class CMGXFileNotificationHandler;
-
-class TGrabSettings
-    {
-public:
-    TInt                                        iCaptureMode;
-    
-    TInt                                        iSingleCaptureHotkey;
-    TInt                                        iSingleCaptureImageFormat;
-    CAknMemorySelectionSettingPage::TMemory     iSingleCaptureMemoryInUse; 
-    TDriveNumber                                iSingleCaptureMemoryInUseMultiDrive;
-    TFileName                                   iSingleCaptureFileName;
-
-    TInt                                        iSequantialCaptureHotkey;
-    TInt                                        iSequantialCaptureImageFormat;
-    TInt                                        iSequantialCaptureDelay;
-    CAknMemorySelectionSettingPage::TMemory     iSequantialCaptureMemoryInUse; 
-    TDriveNumber                                iSequantialCaptureMemoryInUseMultiDrive;
-    TFileName                                   iSequantialCaptureFileName;
-
-    TInt                                        iVideoCaptureHotkey;
-    TInt                                        iVideoCaptureVideoFormat;
-    CAknMemorySelectionSettingPage::TMemory     iVideoCaptureMemoryInUse; 
-    TDriveNumber                                iVideoCaptureMemoryInUseMultiDrive;
-    TFileName                                   iVideoCaptureFileName;
-    };
-
-
-class TVideoFrame
-    {
-public:
-    TUint       iWidth;
-    TUint       iHeight;
-    TUint       iXPos;
-    TUint       iYPos;
-    TUint       iDelay; // 100 = 1 sec
-    TBool       iEnableTransparency;
-    TBool       iFillsWholeScreen;
-    TFileName   iFileStorePath;
-    };
-
-
-typedef CArrayFixSeg<TVideoFrame> CVideoFrameArray;
-
-
-class CScreenGrabberModel : public CActive, public MMdaAudioToneObserver
-	{
-	// active object states
-	enum TState 
-		{
-		EIdle = 0,              // do nothing
-		EEncodingImage,         // ICL encoding of an image
-		ESequenceDelay,         // waiting till next capture
-		ECancelCapturing,       // asking to cancel capturing
-		ENextVideoFrame,        // get next frame for video
-		ECancelVideoCapturing,  // asking to cancel video capturing  
-		EQueryDelay             // waiting till to remove query
-		};
-
-public:
-	static CScreenGrabberModel* NewL();
-	~CScreenGrabberModel();
-	void ActivateModelL();
-	void DeActivateModelL();
-
-private:
-	CScreenGrabberModel();
-	void ConstructL();
-
-	void RunL();
-	void DoCancel();
-
-    void LoadSettingsL();
-    void TakeScreenShotAndSaveL();
-    void CaptureFrameForVideoL();
-    void SaveVideoL(TInt aErr);
-    void CapturingFinishedL(TInt aErr);
-    void CleanTemporaryFilesL();
-    TBool MemoryCardOK();
-    TBool DriveOK(TDriveNumber aNumber);
-    void PlayBeepSound();
-    void LoadDFSValueL(CDictionaryFileStore* aDicFS, const TUid& aUid, TInt& aValue);
-    void LoadDFSValueL(CDictionaryFileStore* aDicFS, const TUid& aUid, TDes& aValue);
-    void SaveDFSValueL(CDictionaryFileStore* aDicFS, const TUid& aUid, const TInt& aValue);
-    void SaveDFSValueL(CDictionaryFileStore* aDicFS, const TUid& aUid, const TDes& aValue);
-    TInt UpdateFileToGallery(const TDesC& aFullPath);
-
-public:
-    inline TGrabSettings GrabSettings() { return iGrabSettings; }
-    void SaveSettingsL(TGrabSettings aGrabSettings);
-    void ActivateCaptureKeysL(TBool aChangeKey=EFalse);
-    void CancelCapturing();
-    TBool HandleCaptureCommandsL(const TWsEvent& aEvent);
-    void MatoPrepareComplete(TInt aError);
-    void MatoPlayComplete(TInt aError);
-
-private:
-    CMdaAudioToneUtility*   iMdaAudioToneUtility;       // a tone player
-    TGrabSettings           iGrabSettings;              // a simple class to store the settings used in the screen capture
-    CEikonEnv*              iEnv;                       // pointer to our eikon environment
-	RWindowGroup            iRootWin;                   // application's window group
-	TInt                    iCapturedKey;               // a handle to the key which is captured
-	TInt                    iCapturedKeyUnD;            // a handle to the key which is captured, up and down
-	TInt                    iCapturedKeyHash;           // a handle to the hash key which is captured
-	TInt                    iCapturedKeyHashUnD;        // a handle to the hash key which is captured, up and down
-	CImageEncoder*          iImageEncoder;              // engine from ICL to do the image conversion
-    CFbsBitmap*             iPreviouslyCapturedBitmap;  // a previously captured bitmap
-	TState                  iState;                     // state of this active object
-    TFileName               iSaveFileName;              // target filename of the taken screen shot
-    CFrameImageData*        iFrameImageData;            // frame and image block data needed by ICL
-    CSavedQuery*            iSavedQuery;                // a class to display global queries
-	RTimer                  iTimer;                     // a timer for async delays
-    TBool 				    iCapturingInProgress;   	// boolean to check if capturing is in progress
-    TBool                   iStopCapturing;             // boolean to specify if to ask capturing
-    TUint                   iNumberOfTakenShots;        // a number of the taken screen shots in the sequantial mode
-    TUint                   iCurrentFrameNumber;        // a number of taken frames in video mode
-    TTime                   iPreviousFrameTaken;        // time when the last frame was taken
-    TSize                   iVideoDimensions;           // dimension of the video
-    TSize                   iPreviousFrameScreenDimension; // dimension of the screen in previous frame
-    CVideoFrameArray*       iVideoFrameArray;           // the frames of the video
-    TBool                   iHashKeyCapturingActivated; // captures hash key is activated
-    TBool                   iHashKeyDown;               // stores state if hash key is currently down
-    TBool                   iGalleryUpdaterSupported;   // specifies if it is possible to update the file to gallery
-    TBool                   iGalleryUpdaterInitialized; // specifies if gallery updater has been initialized or not
-    RLibrary                iGalleryUpdaterDLL;         // specifies pointer to Media Gallery File API DLL
-    CMGXFileManager*        iMGXFileManager;            // Media Gallery FileManager instance
-    };
-
-
-class CSavedQuery : public CActive
-    {
-public:
-    static CSavedQuery* NewL();
-    ~CSavedQuery();
-    void DisplayL(const TDesC &aText, TBool aDisplayErrorNote=EFalse);
-
-private:
-    void DoCancel();
-    void RunL();
-
-private: 
-    CSavedQuery();
-    void ConstructL();
-    void DisplayWithGraphicsL(const TDesC &aText, TBool aDisplayErrorNote);
-    void DisplayWithoutGraphicsL(const TDesC &aText);
-
-private:
-    CAknGlobalConfirmationQuery*    iGlobalConfirmationQuery;
-    TBool                           iVisible;
-    };
-
-
-// these classes have been copied Media Gallery File API
-
-class MGXFileManagerFactory
-    {
-    public:
-        static CMGXFileManager* NewFileManagerL( RFs& aFs );
-        static 
-            CMGXFileNotificationHandler* NewFileNotificationHandlerL();
-    };
-
-class CMGXFileManager : public CBase
-    {
-    public:
-        virtual TBool SuccessFileNameL( const TDesC& aFileName,
-                                        TDriveNumber aDrive ) = 0;
-        virtual void UpdateL() = 0;
-        virtual void UpdateL( const TDesC& aFullPath ) = 0;
-        virtual void UpdateL( const TDesC& aOldName,
-                              const TDesC& aNewName ) = 0;
-        virtual void UpdateL( const MDesCArray& aFileNameArray ) = 0;
-    };
-
-
-#endif // __SCREENGRABBER_MODEL_H__
\ No newline at end of file
--- a/screengrabber/inc/SGSettingListContainer.h	Fri Apr 16 14:59:17 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,76 +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:  
-*
-*/
-
-
-
-#ifndef SCREENGRABBERSETTINGLISTCONTAINER_H
-#define SCREENGRABBERSETTINGLISTCONTAINER_H
-
-
-// INCLUDES
-#include <aknsettingitemlist.h>
-#include "SGModel.h"
- 
-// FORWARD DECLARATIONS
-class CScreenGrabberModel;
-
-// CLASS DECLARATION
-
-/**
-*  CScreenGrabberSettingListContainer  container control class.
-*  
-*/
-class CScreenGrabberSettingListContainer : public CAknSettingItemList
-    {
-    public: // Constructors and destructor
-        
-        /**
-        * EPOC default constructor.
-        * @param aRect Frame rectangle for container.
-        */
-        void ConstructL(const TRect& aRect);
-
-        /**
-        * Destructor.
-        */
-        ~CScreenGrabberSettingListContainer();
-
-    public: // New functions
-        void ShowSettingPageL(TInt aCalledFromMenu);
-
-    public: // Functions from base classes
-        void HandleResourceChange(TInt aType);
-
-    private: // Functions from base classes
-
-        CAknSettingItem* CreateSettingItemL( TInt aIdentifier );
-        void HandleListBoxEventL(CEikListBox *aListBox, TListBoxEvent aEventType);
-
-    private:
-        void UpdateSettingsL();
-        void SetVisibilitiesOfSettingItems(); 
-
-    private: //data
-        CScreenGrabberModel*    iModel;
-        TGrabSettings           iGrabSettings;
-
-
-    };
-
-#endif
-
-// End of File
--- a/screengrabber/inc/SGSettingListView.h	Fri Apr 16 14:59:17 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,91 +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:  
-*
-*/
-
-
-
-#ifndef SCREENGRABBERSETTINGLISTVIEW_H
-#define SCREENGRABBERSETTINGLISTVIEW_H
-
-// INCLUDES
-#include <aknview.h>
-#include "SGStd.h"
-
-
-// CONSTANTS
-// UID of view
-const TUid KSettingListViewUID = {2};
-
-// FORWARD DECLARATIONS
-class CScreenGrabberSettingListContainer;
-
-// CLASS DECLARATION
-
-/**
-*  CScreenGrabberSettingListView view class.
-* 
-*/
-class CScreenGrabberSettingListView : public CAknView
-    {
-    public: // Constructors and destructor
-
-        /**
-        * EPOC default constructor.
-        */
-        void ConstructL();
-
-        /**
-        * Destructor.
-        */
-        ~CScreenGrabberSettingListView();
-
-    public: // Functions from base classes
-        
-        /**
-        * From ?base_class ?member_description
-        */
-        TUid Id() const;
-
-        /**
-        * From ?base_class ?member_description
-        */
-        void HandleCommandL(TInt aCommand);
-
-        /**
-        * From ?base_class ?member_description
-        */
-        void HandleClientRectChange();
-
-    private:
-
-        /**
-        * From AknView, ?member_description
-        */
-        void DoActivateL(const TVwsViewId& aPrevViewId,TUid aCustomMessageId,
-            const TDesC8& aCustomMessage);
-
-        /**
-        * From AknView, ?member_description
-        */
-        void DoDeactivate();
-
-    private: // Data
-        CScreenGrabberSettingListContainer* iContainer;
-    };
-
-#endif
-
-// End of File
--- a/screengrabber/inc/SGStd.h	Fri Apr 16 14:59:17 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,27 +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:  
-*
-*/
-
-
-
-#ifndef SCREENGRABBER_STD_H
-#define SCREENGRABBER_STD_H
-
-
-#endif
-
-// End of File
-
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/screengrabber/inc/application.h	Mon May 03 12:32:02 2010 +0300
@@ -0,0 +1,49 @@
+/*
+* 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 SGAPPLICATION_H
+#define SGAPPLICATION_H
+
+#include <e32keys.h>
+#include <w32std.h>
+
+#include <hbapplication.h>
+class EngineWrapper;
+
+class SGApplication : public HbApplication
+{
+public:
+    SGApplication(int argc, char *argv[]);//, EngineWrapper &engine);
+    ~SGApplication();
+#if defined(Q_WS_S60)
+
+#if defined(HB_QT_S60_EVENT_FILTER)
+    virtual bool s60EventFilter(TWsEvent *aEvent);
+#else
+    virtual bool symbianEventFilter(const QSymbianEvent *event);
+#endif // (HB_QT_S60_EVENT_FILTER)
+#endif//(Q_WS_S60)    
+    inline void SetEngineWrapper(EngineWrapper *aEngine){iEngine = aEngine;}
+private:
+	RWsSession    		iWsSession_a; 
+    RWindowGroup        iRootWin_a;  
+
+
+    EngineWrapper *iEngine;
+};
+
+#endif // SGAPPLICATION_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/screengrabber/inc/enginewrapper.h	Mon May 03 12:32:02 2010 +0300
@@ -0,0 +1,141 @@
+/*
+* 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 ENGINEWRAPPER_H
+#define ENGINEWRAPPER_H
+
+#include <S32FILE.H>
+#include <hbapplication.h>
+
+
+class SGEngine;
+class GrabSettings;
+class MainView;
+class TWsEvent;
+class HbDeviceProgressDialog;
+
+/**
+ * class that is used for communicating between Symbian and Qt code.
+ */
+class EngineWrapper{
+public:
+    
+    /**
+     * Constructor
+     */
+    EngineWrapper();
+    
+    /**
+     * Destructor
+     */
+    ~EngineWrapper();
+    
+    /**
+     * Initializes Engine Wrapper
+     * @return true if engine was started successfully
+     */
+    bool init();
+
+public: 
+    
+    /* Functions that are called from UI */
+
+    /**
+     * Fetches settings from engine and converts Symbian data types to Qt's types.
+     */
+    GrabSettings getGrabSettings();
+    
+    /**
+     * Converts given parameters into Symbian data types and saves them into ScreenGrabber engine
+     * @param settings new settings
+     */
+    bool saveSettings(const GrabSettings& settings); 
+    
+       
+    /*
+     * Sends received s60 event to engine
+     */
+#if defined(HB_QT_S60_EVENT_FILTER)
+	bool handleCaptureCommands(const TWsEvent* aEvent);
+#else
+	bool handleCaptureCommands(const QSymbianEvent *aEvent);
+#endif
+    
+    
+    /**
+     * Sends UI to background
+     */
+    void sendUIToBackground();
+	void EnableRcpOfFoc(TBool aState);
+    void LoadSettings(void);
+public:
+
+    /* Functions that are called from engine: */
+
+    /**
+     * uses Notifications class to show image captured note 
+     */
+    void ShowImageCapturedNote();
+    
+    /**
+     * uses Notifications class to show video captured note 
+     */
+    void ShowVideoCapturedNote();
+    
+    /** 
+     * uses Notifications class to show seguantial images captured note
+     */
+    void ShowSequantialImagesCapturedNote(TInt amount);
+    
+    /** 
+     * uses Notifications class to show error message 
+     */
+    void ShowErrorMessage(const TDesC16& aErrorMessage);
+
+    /**
+     * uses Notifications class to show progressbar
+     */
+    void ShowProgressBar(int max);
+    
+    /**
+     * increments shown progressbar's value
+     */
+    void IncrementProgressbarValue();
+    
+    /**
+     * closes progressbar
+     */
+    void CloseProgressbar();
+
+    
+private:
+    
+    bool convertTBoolToBool(TBool value);
+    
+private:
+    
+    
+    /* Screen grabber engine */
+    SGEngine *iSGEngine;
+    
+    /* progressnote that is shown */
+	HbDeviceProgressDialog *iProgressNote;
+    
+};
+
+#endif; 
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/screengrabber/inc/gifanimator.h	Mon May 03 12:32:02 2010 +0300
@@ -0,0 +1,69 @@
+/*
+* 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 __GIFANIMATOR_H__
+#define __GIFANIMATOR_H__
+
+#include <e32std.h>
+#include <e32base.h>
+#include "sgengine.h"
+
+
+
+class CImageEncoder;
+
+class MDialogCallback
+    {
+public:
+    virtual void DialogDismissedL( TInt aButtonId ) = 0;
+    };
+
+
+class CGifAnimator : public CBase 
+	{
+public:
+	static int CreateGifAnimation(const TDesC& aFileName, TSize aDimensions, CVideoFrameArray* aVideoFrameArray, EngineWrapper& aEngineWrapper);
+	~CGifAnimator();
+
+private:
+    CGifAnimator();
+    void StartL(const TDesC& aFileName, const TSize& aDimensions, CVideoFrameArray* aVideoFrameArray, EngineWrapper& aEngineWrapper);
+    void WriteHeaderL(const TSize& aDimensions);
+    void WriteGraphicControlL(const TVideoFrame& aFrame);
+    void WriteImageDescriptorL(const TVideoFrame& aFrame);
+    CFbsBitmap* GetBitmapLC(TVideoFrame& aFrame, const TSize& aDimensions);
+    void WriteRasterDataL(CFbsBitmap* aBitmap);
+    void WriteFooterL();
+    void FinishL();
+    void WriteInt8L(TInt aValue);
+    void WriteInt16L(TInt aValue);
+    
+    
+    
+private:
+    RFs                         iFs;
+    RFile                       iOutFile;
+	CImageEncoder*              iImageEncoder;
+	HBufC8*                     iGIFImageData;
+    
+    };
+
+		
+	
+#endif // __GIFANIMATOR_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/screengrabber/inc/mainview.h	Mon May 03 12:32:02 2010 +0300
@@ -0,0 +1,117 @@
+/*
+* 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 MAINVIEW_H
+#define MAINVIEW_H
+
+#include <hbview.h>
+#include <hbmainwindow.h>
+
+class EngineWrapper;
+class HbMainWindow;
+class HbApplication;
+class SettingsView;
+class HbAction;
+
+
+
+/**
+ * Class that implements the main view of Screen Grabber
+ */
+class MainView : public HbView
+{
+    Q_OBJECT
+    
+public:
+    
+    /**
+     * Constructor
+     */
+    MainView(HbMainWindow &mainWindow, EngineWrapper &engineWrapper);
+    
+    /**
+     * Destructor
+     */
+	~MainView();
+
+	/**
+     * Initializes Engine Wrapper
+     * @param app application class of Screen Grabber
+     */
+    void init(HbApplication &app);
+    
+    inline void setSettingsView(SettingsView *aSettingsView){ mSettingsView = aSettingsView; }
+
+    
+private:
+    
+    /**
+     * Creates menu
+     */
+    void createMenu(HbApplication &app);
+    
+    /**
+     * Created info text ui components
+     */
+    void createInfoText();
+    
+    /**
+     * Creates toolbar components
+     */
+    void createToolbar();
+
+public slots:
+
+    
+    /**
+     * Shows about pop-up
+     */
+    void showAboutPopup();
+    
+    /**
+     * Sends UI to background
+     */
+    void sendToBackground();
+    
+    /**
+     * opens settings view
+     */
+    void showSettings();
+
+    void my_quit();
+    
+
+public:
+    
+    /* Main windo of Screen Grabber */
+    HbMainWindow &mMainWindow;
+    
+    /* Settings view */
+    SettingsView *mSettingsView;
+    
+    /* Engine Wrapper */
+    EngineWrapper &mEngineWrapper;
+    
+    /* Actions that are used in toolbars and menus */
+    HbAction* actionSendToBg;
+    HbAction* actionSettings;
+    HbAction* actionAbout;
+    HbAction* actionExit;
+
+};
+
+#endif // MAINVIEW_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/screengrabber/inc/notifications.h	Mon May 03 12:32:02 2010 +0300
@@ -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 NOTIFICATIONS_H_
+#define NOTIFICATIONS_H_
+
+#include <hbmessagebox.h> 
+#include <hbdeviceprogressdialog.h>
+
+
+
+class Notifications
+    {
+public:
+    
+    /**
+     * shows about box
+     */
+    static void about();
+    
+    /**
+     * shows image captured note 
+     */
+    static void imageCaptured();
+    
+    /**
+     * shows video captured note 
+     */
+    static void videoCaptured();
+    
+    /** 
+     * shows seguantial images captured note
+     */
+    static void sequantialImagesCaptured(int amount);
+    
+    /** 
+     * shows error message 
+     */
+    static void error(const QString& errorMessage);
+    
+    /**
+     * to shows progressbar
+     */
+    static HbDeviceProgressDialog* showProgressBar(int max);
+ 
+private:
+    
+    /**
+     * shows global HbGlobalCommonNote type note
+     */
+    static void showGlobalNote(const QString& text, HbMessageBox::MessageBoxType type);
+    
+    };
+
+
+
+#endif // NOTIFICATIONS_H_
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/screengrabber/inc/settingsview.h	Mon May 03 12:32:02 2010 +0300
@@ -0,0 +1,189 @@
+/*
+* 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 SETTINGS_H
+#define SETTINGS_H
+
+#include <f32file.h>
+#include <hbmainwindow.h>
+#include <hbview.h>
+
+class EngineWrapper;
+class HbDataFormModelItem;
+class HbDataFormModel;
+class HbDataForm;
+class HbDataFormViewItem;
+    
+const QStringList CAPTUREMODES = (QStringList() << "Single capture" << "Sequential capture" << "Video capture");
+const QStringList KEYS = (QStringList() << "Send key" << "Power key" << "Side key" << "Camera key");
+const QStringList VIDEOFORMATS = (QStringList() << "Animated GIF");
+const QStringList IMAGEFORMATS = (QStringList() << "PNG" << "JPEG high qual." << "JPEG low qual." << "BMP" << "GIF");
+const QStringList MEMORYMODES = (QStringList() << "Phone memory" << "Memory card");
+
+
+/**
+ * Settings class that is used for 
+ */
+class GrabSettings
+    {
+public:
+    int             mCaptureMode;
+    
+    int             mSingleCaptureHotkey;
+    int             mSingleCaptureImageFormat;
+    int             mSingleCaptureMemoryInUseMultiDrive;
+    QString         mSingleCaptureFileName;
+
+    int             mSequantialCaptureHotkey;
+    int             mSequantialCaptureImageFormat;
+    int             mSequantialCaptureDelay;
+    int             mSequantialCaptureMemoryInUseMultiDrive;
+    QString         mSequantialCaptureFileName;
+
+    int             mVideoCaptureHotkey;
+    int             mVideoCaptureVideoFormat;
+    int             mVideoCaptureMemoryInUseMultiDrive;
+    QString         mVideoCaptureFileName;
+    };
+
+/**
+ * Class that creates settings view of Screen Grabber
+ */
+class SettingsView : public HbView
+{
+    Q_OBJECT
+
+    enum CaptureMode{ SINGLE, SEQUENTIAL, VIDEO };
+
+public:
+     /**
+     * Constuctor
+     * @param mainView pointer to main view
+     * @param mainWindow pointer to main window
+     */
+    SettingsView(HbView &mainView, HbMainWindow &mainWindow, EngineWrapper &engineWrapper);
+
+    /**
+    * destructor
+    */
+    ~SettingsView();
+
+
+    /**
+     * Loads settings from engine and formats those settings into form items
+     */
+    void loadSettings();
+    
+    
+private slots:
+  
+    /**
+     * saves settings and closes view.
+     */
+    void saveAndClose();
+    
+    /**
+     * closes setting view
+     */
+    void close();
+
+    /**
+     * Slot that is called each time capture mode is changed
+     */
+//    void updateShownItems();
+private:
+    
+    /**
+     * Creates single capture related components
+     */
+    void createSingleCaptureComponents(HbDataFormModel *model, HbDataFormModelItem *parent);
+    
+    /*
+     * Creates sequential capture related components.
+     */
+    void createSequentialCaptureComponents(HbDataFormModel *model, HbDataFormModelItem *parent);
+    
+    /**
+     * creates video capture related components
+     */
+    void createVideoCaptureComponents(HbDataFormModel *model, HbDataFormModelItem *parent);
+    
+    
+    
+    /**
+     * Reads form items and saves them into member variable mSettings
+     */
+    void readFormItems();
+
+private:
+    
+    /* Settings */
+    GrabSettings mSettings;
+    
+    /* EngineWrapper */
+    EngineWrapper &mEngineWrapper;
+    
+    /* Main Window of Screen Grabber */
+    HbMainWindow &mMainWindow;
+    
+    /* Main View of Screen Grabber */
+    HbView &mMainView;
+    
+    /* settingform */
+    HbDataForm *mSettingForm;
+    
+    /* model for settingform */
+    HbDataFormModel *mModel;
+    
+    /* model's components: */   
+    
+    /* mode selection item */
+    HbDataFormModelItem *mModeItem;
+    
+    /* groups that contain mode specific settings */
+    HbDataFormModelItem *mGroupImageCapture;
+    HbDataFormModelItem *mGroupSeguantialCapture;
+    HbDataFormModelItem *mGroupVideoCapture;
+    
+    /* Still image components */
+    HbDataFormModelItem *mImageHotKeyItem;
+    HbDataFormModelItem *mImageFormatItem;
+    HbDataFormModelItem *mImageMemoryInUseItem;
+    HbDataFormModelItem *mImageFileNameItem;
+       
+    /* Sequential image components */
+    HbDataFormModelItem *mSequantialHotKeyItem;
+    HbDataFormModelItem *mSequantialFormatItem;
+    HbDataFormModelItem *mSequantialDelayItem;
+    HbDataFormModelItem *mSequantialMemoryInUseItem;
+    HbDataFormModelItem *mSequantialFileNameItem;
+    
+    /* Video capture components */
+    HbDataFormModelItem *mVideoHotKeyItem;
+    HbDataFormModelItem *mVideoFormatItem;
+    HbDataFormModelItem *mVideoMemoryInUseItem;
+    HbDataFormModelItem *mVideoFileNameItem;
+    
+
+    
+    
+};
+
+
+
+#endif; 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/screengrabber/inc/sgengine.h	Mon May 03 12:32:02 2010 +0300
@@ -0,0 +1,271 @@
+/*
+* 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 SGENGINE_H
+#define SGENGINE_H
+
+
+// INCLUDES
+#include <e32std.h>
+#include <e32base.h>
+#include <f32file.h>
+#include <W32STD.H>
+#include <MdaAudioTonePlayer.h> 
+#include <qsymbianevent.h>
+
+
+class CFrameImageData;
+class CDictionaryFileStore;
+class CImageEncoder;
+class EngineWrapper;
+
+
+// setting keys (do not change uids of existing keys to maintain compatibility to older versions!)
+const TUid KSGSettingCaptureMode                            = { 0x00 };
+
+const TUid KSGSettingSingleCaptureHotkey                    = { 0x01 };
+const TUid KSGSettingSingleCaptureImageFormat               = { 0x02 };
+const TUid KSGSettingSingleCaptureMemoryInUseMultiDrive     = { 0x04 };
+const TUid KSGSettingSingleCaptureFileName                  = { 0x05 };
+
+const TUid KSGSettingSequantialCaptureHotkey                = { 0x06 };
+const TUid KSGSettingSequantialCaptureImageFormat           = { 0x07 };
+const TUid KSGSettingSequantialCaptureDelay                 = { 0x08 };
+const TUid KSGSettingSequantialCaptureMemoryInUseMultiDrive = { 0x0A };
+const TUid KSGSettingSequantialCaptureFileName              = { 0x0B };
+
+const TUid KSGSettingVideoCaptureHotkey                     = { 0x0C };
+const TUid KSGSettingVideoCaptureVideoFormat                = { 0x0D };
+const TUid KSGSettingVideoCaptureMemoryInUseMultiDrive      = { 0x0F };
+const TUid KSGSettingVideoCaptureFileName                   = { 0x10 };
+
+const TUid KUidScreenGrabber = { 0x101FB751 };
+
+
+#define TRANSPARENCY_INDEX 30
+#define TRANSPARENCY_ALTERNATIVE_INDEX 24
+
+enum TScreenGrabberSettingCaptureModes
+    {
+    ECaptureModeSingleCapture = 0,
+    ECaptureModeSequantialCapture,
+    ECaptureModeVideoCapture
+    };
+    
+enum TScreenGrabberSettingHotkeys
+    {
+    EHotkeySendKey = 0,
+    EHotkeyPowerKey,
+    EHotkeySideKey,
+    EHotkeyCameraKey1
+    };
+
+enum TScreenGrabberSettingImageFormats
+    {
+    EImageFormatPNG = 0,
+    EImageFormatJPGHQ,
+    EImageFormatJPGLQ,
+    EImageFormatBMP,
+    EImageFormatGIF,
+    EImageFormatMBM
+    };
+
+enum TScreenGrabberSettingVideoFormats
+    {
+    EVideoFormatAnimatedGIF = 0
+    };
+
+enum TScreenGrabberSettingMultiDrive
+	{
+	EPhoneMemory = 0,
+	EMemoryCard
+	};
+	
+
+class TGrabSettings
+    {
+public:
+    TInt            iCaptureMode;
+    
+    TInt            iSingleCaptureHotkey;
+    TInt            iSingleCaptureImageFormat;
+    TInt            iSingleCaptureMemoryInUseMultiDrive;
+    TFileName       iSingleCaptureFileName;
+
+    TInt            iSequantialCaptureHotkey;
+    TInt            iSequantialCaptureImageFormat;
+    TInt            iSequantialCaptureDelay;
+    TInt            iSequantialCaptureMemoryInUseMultiDrive;
+    TFileName       iSequantialCaptureFileName;
+
+    TInt            iVideoCaptureHotkey;
+    TInt            iVideoCaptureVideoFormat;
+    TInt		    iVideoCaptureMemoryInUseMultiDrive;
+    TFileName       iVideoCaptureFileName;
+    };
+
+class TVideoFrame
+    {
+public:
+    TUint       iWidth;
+    TUint       iHeight;
+    TUint       iXPos;
+    TUint       iYPos;
+    TUint       iDelay; // 1000 = 1 sec
+    TBool       iEnableTransparency;
+    TBool       iFillsWholeScreen;
+    TFileName   iFileStorePath;
+    };
+
+
+typedef CArrayFixSeg<TVideoFrame> CVideoFrameArray;
+
+/**
+ *  CEngine
+ * 
+ */
+class SGEngine : public CActive //, public MMdaAudioToneObserver
+    {
+    
+    // active object states
+
+    enum TState 
+        {
+        EIdle = 0,              // do nothing
+        EEncodingImage,         // ICL encoding of an image
+        ESequenceDelay,         // waiting till next capture
+        ECancelCapturing,       // asking to cancel capturing
+        ENextVideoFrame,        // get next frame for video
+        ECancelVideoCapturing,  // asking to cancel video capturing  
+        EQueryDelay             // waiting till to remove query
+        };
+    
+public:
+    // Constructors and destructor
+
+    /**
+     * Destructor.
+     */
+    ~SGEngine();
+
+    /**
+     * Two-phased constructor.
+     */
+    static SGEngine* NewL(EngineWrapper *aEngineWrapper);
+
+    /**
+     * Two-phased constructor.
+     */
+    static SGEngine* NewLC(EngineWrapper *aEngineWrapper);
+    
+    /**
+     * returns current settings
+     */
+    inline TGrabSettings GrabSettings(){ return iGrabSettings; };
+    
+    /**
+     * saves settings to engine
+     */
+    void SaveSettingsL(TGrabSettings aGrabSettings);
+    
+    /**
+     * takes one screen shot
+     */
+    bool TakeScreenShotAndSaveL();
+
+    TBool DriveOK(TDriveNumber aNumber);
+    
+    TBool IsDriveMMC(TDriveNumber aDrive);
+    
+#if defined(HB_QT_S60_EVENT_FILTER)
+    TBool HandleCaptureCommandsL(const TWsEvent* aEvent);
+#else
+    TBool HandleCaptureCommandsL(const QSymbianEvent *event);
+#endif
+	
+    
+    void ActivateModelL();
+    void DeActivateModelL();
+    void ActivateCaptureKeysL(TBool aChangeKey=EFalse);
+	void EnableRcpOfFoc(TBool aState);
+    void LoadSettingsL();
+	
+private:
+
+    void CapturingFinishedL(TInt aErr);
+
+    void RunL();
+    void DoCancel();
+    void SaveVideoL(TInt aErr);
+    void CleanTemporaryFilesL();
+    void LoadDFSValueL(CDictionaryFileStore* aDicFS, const TUid& aUid, TInt& aValue);
+    void LoadDFSValueL(CDictionaryFileStore* aDicFS, const TUid& aUid, TDes& aValue); 
+
+    void SaveDFSValueL(CDictionaryFileStore* aDicFS, const TUid& aUid, const TInt& aValue);
+    void SaveDFSValueL(CDictionaryFileStore* aDicFS, const TUid& aUid, const TDes& aValue);
+
+    void CancelCapturing();
+    void CaptureFrameForVideoL();
+	
+    
+    /**
+     * Constructor for performing 1st stage construction
+     */
+    SGEngine();
+
+    /**
+     * EPOC default constructor for performing 2nd stage construction
+     */
+    void ConstructL(EngineWrapper *aEngineWrapper);
+    
+    
+private:
+	RFs 		  iFileSession;
+
+    CActiveScheduler* iActiveScheduler;
+	CActiveSchedulerWait* iWait;
+ 
+    TGrabSettings           iGrabSettings;              // a simple class to store the settings used in the screen capture
+    RWindowGroup            iRootWin;                   // application's window group
+    TInt                    iCapturedKey;               // a handle to the key which is captured
+    TInt                    iCapturedKeyUnD;            // a handle to the key which is captured, up and down
+    TInt                    iCapturedKeyHash;           // a handle to the hash key which is captured
+    TInt                    iCapturedKeyHashUnD;        // a handle to the hash key which is captured, up and down
+    TBool                   iHashKeyCapturingActivated; // captures hash key is activated    
+    CFbsBitmap*             iPreviouslyCapturedBitmap;  // a previously captured bitmap
+    TFileName               iSaveFileName;   
+    CImageEncoder*          iImageEncoder;              // engine from ICL to do the image conversion// target filename of the taken screen shot
+    CFrameImageData*        iFrameImageData;            // frame and image block data needed by ICL
+    TState                  iState;                     // state of this active object
+    TBool                   iHashKeyDown;               // stores state if hash key is currently down
+    TBool                   iCapturingInProgress;       // boolean to check if capturing is in progress
+    TBool                   iStopCapturing;             // boolean to specify if to ask capturing
+    TUint                   iNumberOfTakenShots;        // a number of the taken screen shots in the sequantial mode
+    RTimer                  iTimer;                     // a timer for async delays
+    TUint                   iCurrentFrameNumber;        // a number of taken frames in video mode
+    TTime                   iPreviousFrameTaken;        // time when the last frame was taken
+    TSize                   iVideoDimensions;           // dimension of the video
+    TSize                   iPreviousFrameScreenDimension; // dimension of the screen in previous frame
+    CVideoFrameArray*       iVideoFrameArray;           // the frames of the video
+    EngineWrapper*          iEngineWrapper;             // Eninewrapper that is used for communicating between QT and Symbian
+    };
+
+
+
+
+
+#endif // SGENGINE_H
--- a/screengrabber/rom/screengrabber.iby	Fri Apr 16 14:59:17 2010 +0300
+++ b/screengrabber/rom/screengrabber.iby	Mon May 03 12:32:02 2010 +0300
@@ -22,12 +22,15 @@
 S60_APP_EXE(ScreenGrabber)
 S60_APP_AIF_ICONS(ScreenGrabber)
 S60_APP_RESOURCE(ScreenGrabber)
-#ifdef S60_UPGRADABLE_APP_REG_RSC
-  S60_UPGRADABLE_APP_REG_RSC(ScreenGrabber)
-#else
-  S60_APP_AIF_RSC(ScreenGrabber)
-#endif
+SCALABLE_IMAGE(APP_BITMAP_DIR,APP_BITMAP_DIR,ScreenGrabber_ExtraIcons)
+SCALABLE_IMAGE(APP_BITMAP_DIR,APP_BITMAP_DIR,ScreenGrabber)
+//#ifdef S60_UPGRADABLE_APP_REG_RSC
+//  S60_UPGRADABLE_APP_REG_RSC(ScreenGrabber)
+//#else
+//  S60_APP_AIF_RSC(ScreenGrabber)
+//#endif
 
+data=ZPRIVATE\10003a3f\import\APPS\ScreenGrabber_reg.RSC Private\10003a3f\import\Apps\ScreenGrabber_reg.rsc 
 data=ZPRIVATE\101FB751\backup_registration.xml        	private\101FB751\backup_registration.xml
 data=ZSYSTEM\Install\ScreenGrabber_stub.sis             \system\install\ScreenGrabber_stub.sis
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/screengrabber/screengrabber.pro	Mon May 03 12:32:02 2010 +0300
@@ -0,0 +1,69 @@
+#
+# 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 = app
+TARGET = ScreenGrabber
+DEPENDPATH += src
+INCLUDEPATH += inc
+INCLUDEPATH += $$APP_LAYER_SYSTEMINCLUDE
+CONFIG += hb
+
+HEADERS += inc/mainview.h \
+					 inc/settingsview.h \
+					 inc/application.h \
+					 inc/notifications.h
+
+SOURCES += main.cpp \
+					 mainview.cpp \
+					 application.cpp \
+					 settingsview.cpp \
+					 notifications.cpp 
+
+symbian: {
+
+		LIBS += -lestor -lws32 -lPlatformEnv -limageconversion  -lapgrfx -lcommonengine  -lfbscli -lgdi -leikcore -lbafl
+
+		HEADERS += inc/sgengine.h \
+   				   inc/enginewrapper.h \
+				   inc/gifanimator.h
+
+		SOURCES += sgengine.cpp \
+				   enginewrapper.cpp \
+				   gifanimator.cpp
+
+		RSS_RULES += "group_name = \"RnD Tools\"";
+
+    TARGET.CAPABILITY = WriteDeviceData SwEvent
+
+    TARGET.UID2 = 0x100039CE
+    TARGET.UID3 = 0x101FB751
+    TARGET.SID = 0x101FB751
+    TARGET.VID = 0x101FB657 // Nokia
+	
+	
+    TARGET.EPOCHEAPSIZE = 0x20000 0x1000000  // Min 128Kb, Max 16Mb
+
+    ICON = ./icons/qgn_menu_screengrabber.svg 
+	
+		BLD_INF_RULES.prj_exports += \
+    "./rom/screengrabber.iby CORE_IBY_EXPORT_PATH(tools,screengrabber.iby)
+
+
+} else {
+    error("Only Symbian supported!")
+}
--- a/screengrabber/src/SGApp.cpp	Fri Apr 16 14:59:17 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,74 +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 FILES
-#include    "SGApp.h"
-#include    "SGDocument.h"
-
-#include <eikstart.h>
-
-
-// ================= MEMBER FUNCTIONS =======================
-
-// ---------------------------------------------------------
-// CScreenGrabberApp::AppDllUid()
-// Returns application UID
-// ---------------------------------------------------------
-//
-TUid CScreenGrabberApp::AppDllUid() const
-    {
-    return KUidScreenGrabber;
-    }
-
-// ---------------------------------------------------------
-// CDictionaryStore* CScreenGrabberApp::OpenIniFileLC(RFs& aFs) const
-// overrides CAknApplication::OpenIniFileLC to enable INI file support
-// ---------------------------------------------------------
-//
-CDictionaryStore* CScreenGrabberApp::OpenIniFileLC(RFs& aFs) const
-{
-    return CEikApplication::OpenIniFileLC(aFs);
-}
-   
-// ---------------------------------------------------------
-// CScreenGrabberApp::CreateDocumentL()
-// Creates CScreenGrabberDocument object
-// ---------------------------------------------------------
-//
-CApaDocument* CScreenGrabberApp::CreateDocumentL()
-    {
-    return CScreenGrabberDocument::NewL( *this );
-    }
-
-// ================= OTHER EXPORTED FUNCTIONS ==============
-
-LOCAL_C CApaApplication* NewApplication()
-    {
-    return new CScreenGrabberApp;
-    }
-
-
-GLDEF_C TInt E32Main()
-    {
-    return EikStart::RunApplication(NewApplication);
-    }
-   
-
-// End of File  
-
--- a/screengrabber/src/SGAppUi.cpp	Fri Apr 16 14:59:17 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,148 +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 FILES
-#include "SGAppUi.h"
-#include "SGMainView.h"
-#include "SGSettingListView.h"
-#include <screengrabber.rsg>
-#include "SG.hrh"
-#include "SGModel.h"
-#include "SGDocument.h"
-
-#include <avkon.hrh>
-#include <AknQueryDialog.h>
-
-// ================= MEMBER FUNCTIONS =======================
-//
-// ----------------------------------------------------------
-// CScreenGrabberAppUi::ConstructL()
-// ?implementation_description
-// ----------------------------------------------------------
-//
-void CScreenGrabberAppUi::ConstructL()
-    {
-    // disable window server priority control for this application
-    iEikonEnv->WsSession().ComputeMode( RWsSession::EPriorityControlDisabled );
-
-    BaseConstructL(EAknEnableSkin);
-
-    iModel = static_cast<CScreenGrabberDocument*>(reinterpret_cast<CEikAppUi*>(iEikonEnv->AppUi())->Document())->Model();
-
-    CScreenGrabberMainView* view1 = new (ELeave) CScreenGrabberMainView;
-
-    CleanupStack::PushL( view1 );
-    view1->ConstructL();
-    AddViewL( view1 );      // transfer ownership to CAknViewAppUi
-    CleanupStack::Pop();    // view1
-
-    CScreenGrabberSettingListView* view2 = new (ELeave) CScreenGrabberSettingListView;
-
-    CleanupStack::PushL( view2 );
-    view2->ConstructL();
-    AddViewL( view2 );      // transfer ownership to CAknViewAppUi
-    CleanupStack::Pop();    // view2
-
-    SetDefaultViewL(*view1);
-
-    // notify the model that everything has been constructed
-    iModel->ActivateModelL();
-    }
-
-// ----------------------------------------------------
-// CScreenGrabberAppUi::~CScreenGrabberAppUi()
-// Destructor
-// Frees reserved resources
-// ----------------------------------------------------
-//
-CScreenGrabberAppUi::~CScreenGrabberAppUi()
-    {
-    // notify the model that app ui will be deconstructed
-    if (iModel)
-        TRAP_IGNORE(iModel->DeActivateModelL());
-    }
-
-// ------------------------------------------------------------------------------
-// CScreenGrabberAppUi::::DynInitMenuPaneL(TInt aResourceId,CEikMenuPane* aMenuPane)
-//  This function is called by the EIKON framework just before it displays
-//  a menu pane. Its default implementation is empty, and by overriding it,
-//  the application can set the state of menu items dynamically according
-//  to the state of application data.
-// ------------------------------------------------------------------------------
-//
-void CScreenGrabberAppUi::DynInitMenuPaneL(
-    TInt /*aResourceId*/,CEikMenuPane* /*aMenuPane*/)
-    {
-    }
-
-// ----------------------------------------------------
-// CScreenGrabberAppUi::HandleKeyEventL(
-//     const TKeyEvent& aKeyEvent,TEventCode /*aType*/)
-// ?implementation_description
-// ----------------------------------------------------
-//
-TKeyResponse CScreenGrabberAppUi::HandleKeyEventL(
-    const TKeyEvent& /*aKeyEvent*/,TEventCode /*aType*/)
-    {
-    return EKeyWasNotConsumed;
-    }
-
-// ----------------------------------------------------
-// CScreenGrabberAppUi::HandleCommandL(TInt aCommand)
-// ?implementation_description
-// ----------------------------------------------------
-//
-void CScreenGrabberAppUi::HandleCommandL(TInt aCommand)
-    {
-    switch ( aCommand )
-        {
-        // a normal way to close an application
-        case EAknCmdExit:
-        case EEikCmdExit: 
-			{
-            CAknQueryDialog* exitQuery = CAknQueryDialog::NewL();
-            exitQuery->SetPromptL(_L("Stop taking screen shots and exit?"));
-            if (exitQuery->ExecuteLD(R_MY_GENERAL_CONFIRMATION_QUERY))
-                {
-                // pressed yes, exit
-		        Exit();
-                }
-            else
-                {
-                // pressed no, do nothing
-                }
-			}
-            break;
-
-        default:
-            break;      
-        }
-    }
-
-// ----------------------------------------------------
-// CScreenGrabberAppUi::HandleWsEventL(const TWsEvent& aEvent, CCoeControl* aDestination)
-// ?implementation_description
-// ----------------------------------------------------
-//
-void CScreenGrabberAppUi::HandleWsEventL(const TWsEvent& aEvent, CCoeControl* aDestination)
-    {
-    if (iModel->HandleCaptureCommandsL(aEvent))
-      	CAknAppUi::HandleWsEventL(aEvent, aDestination);  //continue the event loop if needed
-    }
-
-// End of File  
--- a/screengrabber/src/SGDocument.cpp	Fri Apr 16 14:59:17 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,87 +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 FILES
-#include "SGDocument.h"
-#include "SGAppUi.h"
-#include "SGModel.h"
-
-// ================= MEMBER FUNCTIONS =======================
-
-// constructor
-CScreenGrabberDocument::CScreenGrabberDocument(CEikApplication& aApp)
-: CAknDocument(aApp)    
-    {
-    }
-
-// destructor
-CScreenGrabberDocument::~CScreenGrabberDocument()
-    {
-    delete iModel;
-    }
-
-// EPOC default constructor can leave.
-void CScreenGrabberDocument::ConstructL()
-    {
-    iModel = CScreenGrabberModel::NewL();
-    }
-
-// Two-phased constructor.
-CScreenGrabberDocument* CScreenGrabberDocument::NewL(
-        CEikApplication& aApp)     // CScreenGrabberApp reference
-    {
-    CScreenGrabberDocument* self = new (ELeave) CScreenGrabberDocument( aApp );
-    CleanupStack::PushL( self );
-    self->ConstructL();
-    CleanupStack::Pop();
-
-    return self;
-    }
-    
-// ----------------------------------------------------
-// CScreenGrabberDocument::CreateAppUiL()
-// constructs CScreenGrabberAppUi
-// ----------------------------------------------------
-//
-CEikAppUi* CScreenGrabberDocument::CreateAppUiL()
-    {
-    return new (ELeave) CScreenGrabberAppUi;
-    }
-
-// ----------------------------------------------------
-// CScreenGrabberDocument::OpenFileL
-// Overrides CAknDocument::OpenFileL to support document file
-// ----------------------------------------------------
-//
-CFileStore* CScreenGrabberDocument::OpenFileL(TBool aDoOpen,const TDesC& aFilename,RFs& aFs)
-    {
-    return CEikDocument::OpenFileL(aDoOpen, aFilename, aFs);
-    }
-
-
-// ----------------------------------------------------
-
-CScreenGrabberModel* CScreenGrabberDocument::Model()
-    {
-    return iModel;
-    }
-
-// ----------------------------------------------------
-
-// End of File  
--- a/screengrabber/src/SGGifAnimator.cpp	Fri Apr 16 14:59:17 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,413 +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 "SGGifAnimator.h"
-
-#include <s32file.h>
-#include <fbs.h>
-#include <gdi.h>
-#include <imageconversion.h>
-#include <aknenv.h>
-#include <AknGlobalProgressDialog.h>
-#include <AknQueryDialog.h> 
-#include <avkon.rsg>
-
-_LIT(KSavingText, "Saving");
-    
-// ---------------------------------------------------------------------------
-
-TInt CGifAnimator::CreateGifAnimation(const TDesC& aFileName, TSize aDimensions, CVideoFrameArray* aVideoFrameArray)
-    {
-	CGifAnimator* self = new(ELeave) CGifAnimator;
-	CleanupStack::PushL(self);
-	TRAPD(err, self->StartL(aFileName, aDimensions, aVideoFrameArray));
-	CleanupStack::PopAndDestroy();
-	return err;
-    }
-
-// ---------------------------------------------------------------------------
-
-CGifAnimator::CGifAnimator() : CActive(EPriorityStandard)
-    {
-    }
-
-// ---------------------------------------------------------------------------
-
-void CGifAnimator::StartL(const TDesC& aFileName, const TSize& aDimensions, CVideoFrameArray* aVideoFrameArray)
-    {
-    __ASSERT_ALWAYS(aFileName.Length() > 0, User::Panic(_L("GifAnim"), 100));
-    __ASSERT_ALWAYS(aDimensions.iHeight > 0, User::Panic(_L("GifAnim"), 101));
-    __ASSERT_ALWAYS(aDimensions.iWidth > 0, User::Panic(_L("GifAnim"), 102));
-    __ASSERT_ALWAYS(aVideoFrameArray != NULL, User::Panic(_L("GifAnim"), 103));
-    
-    CActiveScheduler::Add(this);
-    
-    // show a progress dialog
-    iSavingProgressDialog = CSavingProgressDialog::NewL(this);
-    iSavingProgressDialog->StartDisplayingL(KSavingText, aVideoFrameArray->Count()-1);
-
-    // open the file for writing
-    User::LeaveIfError(iFs.Connect());
-    User::LeaveIfError(iOutFile.Replace(iFs, aFileName, EFileWrite));
-    
-    // write header
-    WriteHeaderL(aDimensions);
-    
-    // process each frame of the animation
-    for (TInt i=0; i<aVideoFrameArray->Count(); i++)
-        {
-        // write headers and raster block
-        TVideoFrame frame = aVideoFrameArray->At(i);
-        WriteGraphicControlL(frame);
-        CFbsBitmap* bitmap = GetBitmapLC(frame, aDimensions);
-        WriteImageDescriptorL(frame);
-        WriteRasterDataL(bitmap);
-        CleanupStack::PopAndDestroy(); //bitmap
-
-        // update the progress bar
-        iSavingProgressDialog->IncreaseProgressValueWithOne();
-        }
-
-    // write footer and finish
-    WriteFooterL();
-    FinishL();
-    
-    // remove the progress dialog from the screen
-    iSavingProgressDialog->ProcessFinished();
-    }    
-
-// ---------------------------------------------------------------------------
-
-CGifAnimator::~CGifAnimator()
-    {
-    Cancel();
-    
-    if (iImageEncoder)
-        delete iImageEncoder;
-    
-    if (iGIFImageData)
-        delete iGIFImageData;
-    
-    delete iSavingProgressDialog;
-    }
-
-// ---------------------------------------------------------------------------
-
-void CGifAnimator::WriteHeaderL(const TSize& aDimensions)
-    {
-    WriteInt8L('G');
-    WriteInt8L('I');
-    WriteInt8L('F');
-    WriteInt8L('8');
-    WriteInt8L('9');
-    WriteInt8L('a');
-
-    WriteInt16L(aDimensions.iWidth);  // width of animation
-    WriteInt16L(aDimensions.iHeight); // height of animation
-    
-    // logical screen descriptor
-    TUint8 packedFlags = 0;
-	packedFlags |= 8 - 1; // size of colour table is number of bits in each color table minus one (bits 0-2)
-	packedFlags |= (8 - 1) << 4; // colour resolution ie maximum size of the original colour palette (bits 4-6)
-	packedFlags |= 0x80; // use global colour table (bit 7)
-    
-    WriteInt8L(packedFlags);
-    
-    WriteInt8L(TRANSPARENCY_INDEX); // background color index
-    
-    WriteInt8L(0); // pixel aspect ratio, 0=not used
-    
-    // write the Symbian default palette since that's what is used
-    CPalette* palette = CPalette::NewDefaultL(EColor256);
-    CleanupStack::PushL(palette);
-    
-    for (TInt i=0; i<palette->Entries(); i++)
-        {
-        TRgb entry = palette->GetEntry(i);
-
-        WriteInt8L(entry.Red());
-        WriteInt8L(entry.Green());
-        WriteInt8L(entry.Blue());
-        }
-    
-    CleanupStack::PopAndDestroy(); //palette
-    }
-
-// ---------------------------------------------------------------------------
-
-void CGifAnimator::WriteGraphicControlL(const TVideoFrame& aFrame)
-    {
-    TInt packedFlags(0);
-    
-    // enable transparency if needed
-    if (aFrame.iEnableTransparency)
-        packedFlags |= 0x01; 
-
-    // set disposal method:
-    // 0 = disposal method not specified, 1 = do not dispose of graphic,
-    // 2 = overwrite graphic with background color, 3 = overwrite graphic with previous graphic
-    TInt disposalMethod = 1;
-    packedFlags |= ((disposalMethod << 2) & 0x1c);
-    
-    WriteInt8L(0x21); // GIF extension
-    WriteInt8L(0xf9); // GIF graphic control block
-    WriteInt8L(0x04); // block size
-    WriteInt8L(packedFlags); // packed
-    WriteInt16L(aFrame.iDelay); // delay
-    WriteInt8L(TRANSPARENCY_INDEX); // transparent color index
-    WriteInt8L(0); // block terminator, always 0
-    }
-
-// ---------------------------------------------------------------------------
-
-void CGifAnimator::WriteImageDescriptorL(const TVideoFrame& aFrame)
-    {
-    WriteInt8L(0x2c); // GIF image descriptor
-    WriteInt16L(aFrame.iXPos);
-    WriteInt16L(aFrame.iYPos);
-    WriteInt16L(aFrame.iWidth);
-    WriteInt16L(aFrame.iHeight);
-    WriteInt8L(0); // packed flags, none specified in this case
-    }
-    
-// ---------------------------------------------------------------------------
-
-CFbsBitmap* CGifAnimator::GetBitmapLC(TVideoFrame& aFrame, const TSize& aDimensions)
-    {
-    CFbsBitmap* bitmap = new(ELeave) CFbsBitmap;
-    CleanupStack::PushL(bitmap);
-    
-    // read the bitmap from the temporary file
-    RFile bitmapFile;
-    User::LeaveIfError( bitmapFile.Open(iFs, aFrame.iFileStorePath, EFileRead) );
-    RFileReadStream readStream(bitmapFile);
-    bitmap->InternalizeL(readStream);
-    readStream.Close();
-    bitmapFile.Close();
-
-    // delete the temporary file since it's not needed anymore
-    iFs.Delete(aFrame.iFileStorePath);
-    
-    // resize the bitmap to match the video dimensions if it is a full screen one
-    if (aFrame.iFillsWholeScreen && (aFrame.iWidth != aDimensions.iWidth || aFrame.iHeight != aDimensions.iHeight))
-        {
-        if (bitmap->Resize(aDimensions) == KErrNone)
-            {
-            // also update dimensions of this frame to match the dimensions of the video            
-            aFrame.iWidth = aDimensions.iWidth;
-            aFrame.iHeight = aDimensions.iHeight;
-            }
-        }
-    
-    return bitmap;
-    }
-    
-// ---------------------------------------------------------------------------
-
-void CGifAnimator::WriteRasterDataL(CFbsBitmap* aBitmap)
-    {
-    // reset the encoder
-    if (iImageEncoder)
-        {
-	    delete iImageEncoder;
-        iImageEncoder = NULL;
-        }
-    
-    // make sure the buffer for conversion is empty    
-    if (iGIFImageData)
-        {
-	    delete iGIFImageData;
-        iGIFImageData = NULL;
-        }        
-        
-    // init & convert the bitmap to GIF format
-    iImageEncoder = CImageEncoder::DataNewL(iGIFImageData, CImageEncoder::EOptionNone, KImageTypeGIFUid);
-    iImageEncoder->Convert( &iStatus, *aBitmap );
-
-    // execute the async operation and wait till it's finished    
-    SetActive();
-    iWait.Start();
-    
-    // check any erros in active object
-    User::LeaveIfError( iStatus.Int() );
-    
-    // check if we have valid data
-    if (iGIFImageData == NULL || iGIFImageData->Des().Length()<793)
-        User::Leave(KErrNoMemory);
-    
-    // in GIF files generated by Symbian, the raster data always starts at offset 791,
-    // initial code size in GIF encoding should be 8 since we have a 8bpp image,
-    // also check that the second last byte is the terminator 0,
-    // if this check fails in newer releases of S60, proper parsing of GIF format is probably needed
-    TUint8* imagePtr = &iGIFImageData->Des()[0];
-    if (imagePtr[791] != 8 || imagePtr[iGIFImageData->Des().Length()-2] != 0)
-        User::Leave(KErrNotSupported);
-    
-    // write the raster data block to the file
-    TUint writeLength = iGIFImageData->Des().Length() - 1 - 791;
-    imagePtr+=791;
-    TPtr8 writePtr(imagePtr, writeLength, writeLength);
-    User::LeaveIfError( iOutFile.Write(writePtr) );
-    }
-
-// ---------------------------------------------------------------------------
-
-void CGifAnimator::WriteFooterL()
-    {
-    WriteInt8L(0x3b); // GIF trailer
-    }
-    
-// ---------------------------------------------------------------------------
-
-void CGifAnimator::FinishL()
-    {
-    iOutFile.Close();
-    iFs.Close();
-    }
-
-// ---------------------------------------------------------------------------
-
-void CGifAnimator::WriteInt8L(TInt aValue)
-    {
-    HBufC8* buf = HBufC8::NewMaxLC(1);
-
-    TUint8* ptr = &buf->Des()[0];
-    ptr[0] = TUint8(aValue);
-    
-    User::LeaveIfError( iOutFile.Write(buf->Des()) );
-    
-    CleanupStack::PopAndDestroy(); // buf
-    }
-
-// ---------------------------------------------------------------------------
-
-void CGifAnimator::WriteInt16L(TInt aValue)
-    {
-    HBufC8* buf = HBufC8::NewMaxLC(2);
-
-    TUint8* ptr = &buf->Des()[0];
-    ptr[0] = TUint8(aValue);
-    ptr[1] = TUint8(aValue>>8);
-        
-    User::LeaveIfError( iOutFile.Write(buf->Des()) );
-    
-    CleanupStack::PopAndDestroy(); // buf
-    }
-
-// ---------------------------------------------------------------------------
-
-void CGifAnimator::DoCancel()
-    {
-    CAknEnv::StopSchedulerWaitWithBusyMessage( iWait );
-    }
-
-// ---------------------------------------------------------------------------
-
-void CGifAnimator::RunL()
-    {
-    CAknEnv::StopSchedulerWaitWithBusyMessage( iWait );
-    }
-
-// ---------------------------------------------------------------------------
-
-void CGifAnimator::DialogDismissedL(TInt aButtonId)
-    {
-    // check if cancel button was pressed
-    if (aButtonId == EAknSoftkeyCancel)
-        {
-        }
-    }
-
-// ---------------------------------------------------------------------------
-
-/*************************************************************************************************/
-// a helper class to display the progress dialog on the screen
-
-CSavingProgressDialog::CSavingProgressDialog() : CActive(EPriorityLow)
-    {
-	CActiveScheduler::Add(this);
-    }
-
-void CSavingProgressDialog::ConstructL(MDialogCallback* aDialogCallback)
-    {
-    iGlobalProgressDialog = CAknGlobalProgressDialog::NewL();
-    iDialogCallback = aDialogCallback;
-    }
-
-CSavingProgressDialog* CSavingProgressDialog::NewL(MDialogCallback* aDialogCallback)
-    {
-    CSavingProgressDialog* self = new(ELeave) CSavingProgressDialog();
-    CleanupStack::PushL(self);
-    self->ConstructL(aDialogCallback);
-    CleanupStack::Pop(self);
-    return self;
-    }
-
-CSavingProgressDialog::~CSavingProgressDialog()
-    {
-    Cancel();
-    delete iGlobalProgressDialog;
-    }
-
-void CSavingProgressDialog::StartDisplayingL(const TDesC &aText, TInt aFinalValue)
-    {
-    if (!iVisible)
-        {
-        iFinalValue = aFinalValue;
-        iCurrentValue = 0;
-        
-        iGlobalProgressDialog->ShowProgressDialogL(iStatus, aText, R_AVKON_SOFTKEYS_EMPTY,
-            aFinalValue, CAknNoteDialog::ENoTone);
-            
-        iVisible = ETrue;
-        SetActive();
-        }
-    }
-
-void CSavingProgressDialog::DoCancel()
-    {
-    if (iGlobalProgressDialog)
-        {
-        iGlobalProgressDialog->CancelProgressDialog();
-        }
-    iVisible = EFalse;
-    }
-
-void CSavingProgressDialog::RunL()
-    {
-    if (iGlobalProgressDialog && iStatus.Int() == KErrNotFound)
-        {
-        // user dismissed the dialog
-        iDialogCallback->DialogDismissedL(EAknSoftkeyCancel);
-        }
-    }
-
-void CSavingProgressDialog::IncreaseProgressValueWithOne()
-    {
-    iCurrentValue++;
-    iGlobalProgressDialog->UpdateProgressDialog(iCurrentValue, iFinalValue);
-    }
-
-void CSavingProgressDialog::ProcessFinished()
-    {
-    iGlobalProgressDialog->ProcessFinished();
-    iVisible = EFalse;
-    }
-
-/*************************************************************************************************/
--- a/screengrabber/src/SGMainContainer.cpp	Fri Apr 16 14:59:17 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,399 +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 FILES
-#include "SGMainContainer.h"
-
-
-#include <AknBidiTextUtils.h>
-#include <AknUtils.h>
-#include <aknnotewrappers.h>
-#include <eiksbfrm.h>
-#include <AknsDrawUtils.h> 
-#include <AknsBasicBackgroundControlContext.h>
-#include <akntitle.h>
-#include <eikspane.h>  
-#include <AknDef.h>
-
-const TUint KLeftMargin = 2;
-const TUint KRightMargin = 2;
-
-
-// ================= MEMBER FUNCTIONS =======================
-
-
-void CScreenGrabberMainContainer::ConstructL(const TRect& aRect)
-    {
-    iSkinContext = NULL;
-
-    CreateWindowL();
-    Window().SetShadowDisabled(EFalse);
-    
-    SetBlank();
-    
-    // set title of the app
-    CEikStatusPane* statusPane = iEikonEnv->AppUiFactory()->StatusPane();
-    CAknTitlePane* title = static_cast<CAknTitlePane*>( statusPane->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) );
-    title->SetTextL( _L("Screen Grabber") );
-
-    iText = HBufC::NewL(200000);
-    iCurrentLine = 0;
-    iLineCount = 0;
-    iNumberOfLinesFitsScreen = 0;
-    iX_factor = 1;
-    iY_factor = 1;
-    iLeftDrawingPosition = KLeftMargin;
-
-    // get font
-    iFont = AknLayoutUtils::FontFromId(EAknLogicalFontSecondaryFont);
-
-    iWrappedArray = new(ELeave) CArrayFixFlat<TPtrC>(500);
-    
-    SetRect(aRect);
-    ActivateL(); 
-
-    PrintText(_L("Please use the settings screen to define the capture mode and any other related settings such capture hotkey and saving format. Using the PNG format for screen shots is recommended, since it is compressed but lossless. The captures can be managed with the Media Gallery application.\n\nYou may start taking screenshots or capturing video now. Please press the Applications key to go back to the Application menu or send this application to the background via the Options menu. To be able to take screenshots or capture video, this applications needs to stay running in the background.\n"));
-    }
-
-CScreenGrabberMainContainer::~CScreenGrabberMainContainer()
-    {
-    if (iSkinContext)
-    	delete iSkinContext;
-    
-	if (iWrappedArray)
-		{
-    	iWrappedArray->Reset();
-    	delete iWrappedArray;
-		}
-
-	if (iText)
-    	delete iText;
-
-    if (iScrollBarFrame)
-        delete iScrollBarFrame;
-
-    if (iWrapperString)
-        delete iWrapperString;
-    }
-
-
-// ---------------------------------------------------------
-// CScreenGrabberMainContainer::UpdateVisualContentL()
-// ---------------------------------------------------------
-//
-void CScreenGrabberMainContainer::UpdateVisualContentL(TBool aScrollToBottom)
-    {
-    TSize rectSize;
-    AknLayoutUtils::LayoutMetricsSize(AknLayoutUtils::EMainPane, rectSize);
-    TRect rect(rectSize);
-
-    // set the correct drawing area for the skin background
-    if(iSkinContext)
-        {
-        delete iSkinContext;
-        iSkinContext = NULL;
-        }  
-    iSkinContext = CAknsBasicBackgroundControlContext::NewL(KAknsIIDQsnBgAreaMain, rectSize, EFalse);
-
-    // init scroll bar if not yet done
-    if (!iScrollBarFrame)
-        {
-        iScrollBarFrame = new(ELeave) CEikScrollBarFrame(this, this, ETrue);
-
-        CAknAppUi* appUi = iAvkonAppUi;
-        
-	    if (AknLayoutUtils::DefaultScrollBarType(appUi) == CEikScrollBarFrame::EDoubleSpan)
-	        {
-		    iScrollBarFrame->CreateDoubleSpanScrollBarsL(ETrue, EFalse);            
-		    iScrollBarFrame->SetTypeOfVScrollBar(CEikScrollBarFrame::EDoubleSpan);
-	        }
-	    else
-	        {
-		    iScrollBarFrame->SetTypeOfVScrollBar(CEikScrollBarFrame::EArrowHead);
-	        }  
-	    iScrollBarFrame->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto);
-        }
-
-    // drawing positions, needed for scalable ui
-    iX_factor = TReal(rect.Width()) / 176;
-    iY_factor = TReal(rect.Height()) / 144;
-
-    iWrappedArray->Reset();
-
-    if (iWrapperString)
-        {
-        delete iWrapperString;
-        iWrapperString = NULL;
-        }
-
-    // define drawing width, some extra space needed if using double span scrolling bar
-    TUint drawingWidth(0);
-    if (iScrollBarFrame->TypeOfVScrollBar() == CEikScrollBarFrame::EDoubleSpan)
-        {
-        if (AknLayoutUtils::LayoutMirrored())  // scroll bar on 'left'
-            {
-            iLeftDrawingPosition = KLeftMargin + 12;
-            drawingWidth = TInt( rect.Width() - iLeftDrawingPosition*iX_factor - (KRightMargin*iX_factor)); 
-            }
-        else // scroll bar on 'right'
-            {
-            iLeftDrawingPosition = KLeftMargin;  
-            drawingWidth = TInt( rect.Width() - iLeftDrawingPosition*iX_factor - (KRightMargin*iX_factor + 7*iX_factor)); 
-            }        
-        }
-    else
-        drawingWidth = TInt( rect.Width() - KLeftMargin*iX_factor - KRightMargin*iX_factor);
-
-    // wrap the text
-    iWrapperString = AknBidiTextUtils::ConvertToVisualAndWrapToArrayL(
-        iText->Des(),
-        drawingWidth,
-        *iFont,
-        *iWrappedArray
-        );
-    
-    iLineCount = iWrappedArray->Count();
-
-    // count amount of lines fits to screen
-    iNumberOfLinesFitsScreen = TInt(rect.Height() / (iFont->HeightInPixels()));
-
-    // check if needed to scroll to the bottom
-    if (aScrollToBottom && iCurrentLine < iLineCount - iNumberOfLinesFitsScreen)
-        {
-        iCurrentLine = iLineCount-iNumberOfLinesFitsScreen;
-        }
-
-    // update the scroll bars
-	TEikScrollBarModel horizontalBar;
-    TEikScrollBarModel verticalBar;
-    verticalBar.iThumbPosition = iCurrentLine;
-    verticalBar.iScrollSpan = iLineCount - iNumberOfLinesFitsScreen + 1;
-    verticalBar.iThumbSpan = 1;
-
-    TEikScrollBarFrameLayout layout;
-	layout.iTilingMode = TEikScrollBarFrameLayout::EInclusiveRectConstant;
-
-    if (iScrollBarFrame->TypeOfVScrollBar() == CEikScrollBarFrame::EDoubleSpan)
-        {    
-        // do not let scrollbar values overflow
-        if (verticalBar.iThumbPosition + verticalBar.iThumbSpan > verticalBar.iScrollSpan)
-            verticalBar.iThumbPosition = verticalBar.iScrollSpan - verticalBar.iThumbSpan;
-		
-        TAknDoubleSpanScrollBarModel horizontalDSBar(horizontalBar);
-        TAknDoubleSpanScrollBarModel verticalDSBar(verticalBar);
-       
-        iScrollBarFrame->TileL(&horizontalDSBar, &verticalDSBar, rect, rect, layout);        
-        iScrollBarFrame->SetVFocusPosToThumbPos(verticalDSBar.FocusPosition());
-	    }  
-	else
-	    {
-		iScrollBarFrame->TileL( &horizontalBar, &verticalBar, rect, rect, layout );
-		iScrollBarFrame->SetVFocusPosToThumbPos( verticalBar.iThumbPosition );
-	    }
-
-
-    // update the screen
-    DrawNow();
-    }
-
-// ---------------------------------------------------------
-// CScreenGrabberMainContainer::Draw(const TRect& aRect) const
-// ---------------------------------------------------------
-//
-void CScreenGrabberMainContainer::Draw(const TRect& aRect) const
-    {
-    CWindowGc& gc = SystemGc();
-
-    MAknsSkinInstance* skin = AknsUtils::SkinInstance();
-    if (iSkinContext)
-	    {
-        // draws the skin background
-	    AknsDrawUtils::Background(skin, iSkinContext, this, gc, aRect);
-	    }
-    else
-        {
-        gc.Clear(aRect);
-        }
-
-
-    // get the text color from the skin   
-    TRgb skinPenColor;
-    if (AknsUtils::GetCachedColor( skin, skinPenColor, KAknsIIDQsnTextColors, EAknsCIQsnTextColorsCG6 ) == KErrNone)
-        {
-		gc.SetPenColor(skinPenColor);
-		}	
-    else
-        {
-        gc.SetPenColor(KRgbBlack);
-        }
-
-    gc.UseFont(iFont);
-
-    // draw the text
-    for (TInt i=0; i<iNumberOfLinesFitsScreen; i++)
-        {
-        // index out of bounds check and then draw text
-        if (i+iCurrentLine < iWrappedArray->Count())
-            gc.DrawText(iWrappedArray->At(i+iCurrentLine), TPoint(TInt(iLeftDrawingPosition*iX_factor), TInt(iFont->HeightInPixels()*(i+1))));
-        }
-
-    gc.DiscardFont();
-    }
-
-// ---------------------------------------------------------
-// CScreenGrabberMainContainer::HandleControlEventL(
-//     CCoeControl* aControl,TCoeEvent aEventType)
-// ---------------------------------------------------------
-//
-void CScreenGrabberMainContainer::HandleControlEventL(
-    CCoeControl* /*aControl*/,TCoeEvent /*aEventType*/)
-    {
-    }
-
-// ---------------------------------------------------------
-// CScreenGrabberMainContainer::PrintText(const TDesC& aDes)
-// Print text into output window.
-// ---------------------------------------------------------
-//
-void CScreenGrabberMainContainer::PrintText(const TDesC& aDes)
-    {
-    iText->Des().Append( aDes );
-    UpdateVisualContentL(EFalse);  // do not automatically scroll to the bottom
-    }
-
-// ---------------------------------------------------------
-// CScreenGrabberMainContainer::OfferKeyEventL(const TKeyEvent& aKeyEvent,
-//                                    TEventCode aType)
-// Handle key event. Only up and down key arrow events are
-// consumed in order to enable scrolling in output window.
-// ---------------------------------------------------------
-//
-TKeyResponse CScreenGrabberMainContainer::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType)
-    {
-    if(aType != EEventKey)
-        return EKeyWasNotConsumed;
-    
-    if(aKeyEvent.iCode == EKeyUpArrow)
-        {
-        if (iCurrentLine > 0)
-            {
-            iCurrentLine--;
-            UpdateVisualContentL(EFalse);
-            }
-
-        return EKeyWasConsumed;
-        }
-    
-    else if(aKeyEvent.iCode == EKeyDownArrow)
-        {
-        if (iCurrentLine < iLineCount - iNumberOfLinesFitsScreen)
-            {
-            iCurrentLine++;
-            UpdateVisualContentL(EFalse);
-            }
-
-        return EKeyWasConsumed;
-        }
-    
-    return EKeyWasNotConsumed;
-    }
-
-
-// ---------------------------------------------------------
-// CScreenGrabberMainContainer::ClearOutputWindow()
-// Clear the output window.
-// ---------------------------------------------------------
-//
-void CScreenGrabberMainContainer::ClearOutputWindow()
-    {
-    iText->Des() = _L("");
-    UpdateVisualContentL(ETrue);
-    }
-
-
-// ---------------------------------------------------------
-// CScreenGrabberMainContainer::HandleResourceChange(TInt aType)
-// Handle layout change of the screen
-// ---------------------------------------------------------
-//
-void CScreenGrabberMainContainer::HandleResourceChange(TInt aType)
-    {
-    if (aType == KEikDynamicLayoutVariantSwitch || aType == KAknsMessageSkinChange)
-        {
-        TRect mainPaneRect;
-        AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, mainPaneRect);
-        SetRect(mainPaneRect);
-
-        iCurrentLine = 0; // scroll to top
-
-        // update font
-        iFont = AknLayoutUtils::FontFromId(EAknLogicalFontSecondaryFont);
-
-        // delete the scroll and update screen
-        if (iScrollBarFrame)
-            {
-            delete iScrollBarFrame;
-            iScrollBarFrame = NULL;
-            }
-        UpdateVisualContentL(EFalse);
-        }
-    else
-        {
-        CCoeControl::HandleResourceChange(aType);
-        }
-    }
-
-// ---------------------------------------------------------
-// CScreenGrabberMainContainer::MopSupplyObject(TTypeUid aId)
-// Pass skin information if needed
-// ---------------------------------------------------------
-//
-TTypeUid::Ptr CScreenGrabberMainContainer::MopSupplyObject(TTypeUid aId)
-    {
-    if (aId.iUid == MAknsControlContext::ETypeId && iSkinContext)
-        {
-        return MAknsControlContext::SupplyMopObject(aId, iSkinContext);
-        }
-
-    return CCoeControl::MopSupplyObject(aId);
-    }
-
-
-// ---------------------------------------------------------
-// CScreenGrabberMainContainer::HandleScrollEventL()
-// Capture touch events on the scroll bar
-// ---------------------------------------------------------
-//
-void CScreenGrabberMainContainer::HandleScrollEventL(CEikScrollBar* aScrollBar, TEikScrollEvent aEventType)
-    {
-    // only on page up/down,scroll up/down and drag events
-    if ((aEventType == EEikScrollPageDown) || (aEventType == EEikScrollPageUp) || 
-       (aEventType == EEikScrollThumbDragVert) || (aEventType == EEikScrollUp) ||
-       (aEventType == EEikScrollDown))
-        {
-        // get the current position from the scroll bar
-        iCurrentLine = aScrollBar->ThumbPosition();
-        
-        // refresh now
-        UpdateVisualContentL(EFalse);
-        }
-    }
-
-    
-// End of File  
--- a/screengrabber/src/SGMainView.cpp	Fri Apr 16 14:59:17 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,252 +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 FILES
-#include  <aknViewAppUi.h>
-#include  <avkon.hrh>
-#include  <apgtask.h>
-#include  <aknmessagequerydialog.h> 
-
-#include  <screengrabber.rsg>
-#include  "SG.hrh"
-#include  "SGMainView.h"
-#include  "SGMainContainer.h"
-#include  "SGSettingListView.h"
-#include  "SGDocument.h" 
-#include  "SGModel.h"
-
-#ifdef SCREENGRABBER_SCREEN_RESOLUTION_CHANGE_SUPPORT
- #include <AknSgcc.h>
- #include <AknLayoutConfig.h>
- #include <e32property.h>
- #include <UikonInternalPSKeys.h>
-#endif
-
-// ================= MEMBER FUNCTIONS =======================
-
-// ---------------------------------------------------------
-// CScreenGrabberMainView::ConstructL(const TRect& aRect)
-// EPOC two-phased constructor
-// ---------------------------------------------------------
-//
-void CScreenGrabberMainView::ConstructL()
-    {
-    BaseConstructL( R_SCREENGRABBER_VIEW1 );
-    }
-
-// ---------------------------------------------------------
-// CScreenGrabberMainView::~CScreenGrabberMainView()
-// ---------------------------------------------------------
-//
-CScreenGrabberMainView::~CScreenGrabberMainView()
-    {
-    if ( iContainer )
-        {
-        AppUi()->RemoveFromViewStack( *this, iContainer );
-        }
-
-    delete iContainer;
-    }
-
-// ---------------------------------------------------------
-// TUid CScreenGrabberMainView::Id()
-// ---------------------------------------------------------
-//
-TUid CScreenGrabberMainView::Id() const
-    {
-    return KMainViewUID;
-    }
-
-
-
-#ifdef SCREENGRABBER_SCREEN_RESOLUTION_CHANGE_SUPPORT
-
-// ---------------------------------------------------------
-// TUid CScreenGrabberMainView::DynInitMenuPaneL(TInt aResourceId, CEikMenuPane* aMenuPane)
-// ---------------------------------------------------------
-//
-
-void CScreenGrabberMainView::DynInitMenuPaneL(TInt aResourceId, CEikMenuPane* aMenuPane)
-    {
-    if (aResourceId == R_SCREENGRABBER_RESOLUTION_SUBMENU)
-        {
-        // generate list of supported screen resolutions
-        TInt state = 0;
-        TInt width = 0;
-        TInt height = 0;
-        TInt screenMode = 0;
-        
-        const CAknLayoutConfig& config = CAknSgcClient::LayoutConfig();
-        const CAknLayoutConfig::THardwareStateArray& hwStates = config.HardwareStates();
-        const CAknLayoutConfig::TScreenModeArray& screenModes = config.ScreenModes();
-
-        CWsScreenDevice* screenDevice = CEikonEnv::Static()->ScreenDevice();
-        TInt currentHwState = screenDevice->CurrentScreenMode();
-            
-        for (TInt i=0; i<hwStates.Count(); i++)
-            {
-            // get an entry entry
-            const CAknLayoutConfig::THardwareState& hwState = hwStates.At(i);
-            screenMode = hwState.ScreenMode();
-            const CAknLayoutConfig::TScreenMode& mode = screenModes.Find(screenMode);
-            
-            // get more info
-            state = hwState.StateNumber();
-            width = mode.PixelsTwipsAndRotation().iPixelSize.iWidth;
-            height = mode.PixelsTwipsAndRotation().iPixelSize.iHeight;
-            
-            // generate new menu text
-            TBuf<64> menuText;
-            menuText.Format(_L("%dx%d  (%d)"), width, height, state);
-            
-            // create new menu item
-            CEikMenuPaneItem::SData menuItem;
-            menuItem.iFlags = 0;
-            menuItem.iText = menuText;
-            menuItem.iCommandId = EScreenGrabberCmdScreenResolutionItem1 + state;
-            menuItem.iCascadeId = 0;
-            aMenuPane->AddMenuItemL(menuItem);
-            }
-        }
-    }
-
-#endif
-    
-// ---------------------------------------------------------
-// CScreenGrabberMainView::HandleCommandL(TInt aCommand)
-// ---------------------------------------------------------
-//
-void CScreenGrabberMainView::HandleCommandL(TInt aCommand)
-    {   
-    switch ( aCommand )
-        {
-        case EScreenGrabberCmdSendToBackground:
-            {
-            TApaTask selfTask(iEikonEnv->WsSession());
-            selfTask.SetWgId(iEikonEnv->RootWin().Identifier());
-            selfTask.SendToBackground();
-            break;
-            }
-
-#ifdef SCREENGRABBER_SCREEN_RESOLUTION_CHANGE_SUPPORT
-        case EScreenGrabberCmdScreenResolutionItem1:
-        case EScreenGrabberCmdScreenResolutionItem2:
-        case EScreenGrabberCmdScreenResolutionItem3:
-        case EScreenGrabberCmdScreenResolutionItem4:
-        case EScreenGrabberCmdScreenResolutionItem5:
-        case EScreenGrabberCmdScreenResolutionItem6:
-        case EScreenGrabberCmdScreenResolutionItem7:
-        case EScreenGrabberCmdScreenResolutionItem8:
-        case EScreenGrabberCmdScreenResolutionItem9:
-        case EScreenGrabberCmdScreenResolutionItem10:
-        case EScreenGrabberCmdScreenResolutionItem11:
-        case EScreenGrabberCmdScreenResolutionItem12:
-            {
-            // change resolution
-            const CAknLayoutConfig& config = CAknSgcClient::LayoutConfig();
-            const CAknLayoutConfig::THardwareStateArray& hwStates = config.HardwareStates();
-            const CAknLayoutConfig::TScreenModeArray& screenModes = config.ScreenModes();
-        
-            const CAknLayoutConfig::THardwareState& hwState = hwStates.At(aCommand-EScreenGrabberCmdScreenResolutionItem1);
-            TInt screenMode = hwState.ScreenMode();
-            TInt state = hwState.StateNumber();
-            
-            CWsScreenDevice* screenDevice = CEikonEnv::Static()->ScreenDevice();
-            TInt err = RProperty::Define(KPSUidUikon, KUikLayoutState, RProperty::EInt);
-            err = RProperty::Set(KPSUidUikon, KUikLayoutState, state);
-
-            screenDevice->SetScreenMode(screenMode);
-
-            break;
-            }
-#endif
-            
-        case EScreenGrabberCmdSettings:
-            {
-            AppUi()->ActivateLocalViewL( KSettingListViewUID );
-            break;
-            }
-
-        case EScreenGrabberCmdAbout:
-            {
-	        CAknMessageQueryDialog* dialog = new (ELeave) CAknMessageQueryDialog;
-            dialog->ExecuteLD(R_SCREENGRABBER_ABOUT_DIALOG);
-            }
-            break;
-        
-        case EAknSoftkeyExit:
-            {
-            AppUi()->HandleCommandL( EEikCmdExit );
-            break;
-            }
-
-        default:
-            {
-            AppUi()->HandleCommandL( aCommand );
-            break;
-            }
-        }
-    }
-
-// ---------------------------------------------------------
-// CScreenGrabberMainView::HandleClientRectChange()
-// ---------------------------------------------------------
-//
-void CScreenGrabberMainView::HandleClientRectChange()
-    {
-    if ( iContainer )
-        {
-        iContainer->SetRect( ClientRect() );
-        }
-    }
-
-// ---------------------------------------------------------
-// CScreenGrabberMainView::DoActivateL(...)
-// ---------------------------------------------------------
-//
-void CScreenGrabberMainView::DoActivateL(
-   const TVwsViewId& /*aPrevViewId*/,TUid /*aCustomMessageId*/,
-   const TDesC8& /*aCustomMessage*/)
-    {
-    if (!iContainer)
-        {
-        iContainer = new (ELeave) CScreenGrabberMainContainer;
-        iContainer->SetMopParent(this);
-        iContainer->ConstructL( ClientRect() );
-        AppUi()->AddToStackL( *this, iContainer );
-        } 
-   }
-
-// ---------------------------------------------------------
-// CScreenGrabberMainView::HandleCommandL(TInt aCommand)
-// ---------------------------------------------------------
-//
-void CScreenGrabberMainView::DoDeactivate()
-    {
-    if ( iContainer )
-        {
-        AppUi()->RemoveFromViewStack( *this, iContainer );
-        }
-    
-    delete iContainer;
-    iContainer = NULL;
-    }
-
-// End of File
-
--- a/screengrabber/src/SGModel.cpp	Fri Apr 16 14:59:17 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1604 +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 "SGModel.h"
-#include "SGApp.h"
-#include "SG.hrh"
-#include "SGGifAnimator.h"
-
-#include <w32std.h>
-#include <e32keys.h>
-#include <imageconversion.h>
-#include <pathinfo.h>
-#include <AknGlobalConfirmationQuery.h>
-#include <aknnotewrappers.h>
-#include <textresolver.h>
-#include <bautils.h>
-#include <coeutils.h>
-#include <s32file.h>
-#include <AknGlobalNote.h>
-
-
-_LIT(KSingleShotSaved, "Screen shot saved to Media Gallery");
-_LIT(KMultipleShotsSaved, "%u screen shots saved to Media Gallery");
-_LIT(KVideoSaved, "Video saved to Media Gallery");
-_LIT(KErrorOccured, "Grabber error: ");
-_LIT(KDefaultImageFileName, "Shot");
-_LIT(KDefaultVideoFileName, "Video");
-_LIT(KScreenShotsSubDirectory, "Screen Shots\\");
-_LIT(KSGTemporaryDirectory, "\\system\\temp\\screengrabber\\");
-
-#define HIGH_QUALITY_JPEG 97
-#define LOW_QUALITY_JPEG 60
-#define DEFAULT_SEQ_CAPTURE_DELAY_MS 5000   // 5.000 secs
-#define VIDEO_CAPTURE_DELAY 250             // 0.25 secs
-#define VIDEO_CAPTURE_MINIMUM_DELAY 200     // 0.20 secs
-#define KEY_CAPTURE_PRIORITY 100            // do not change, this is for window server
-
-const TInt KSettingsDrive = EDriveC;
-_LIT(KSettingsFileName, "screengrabber_settings.ini");
-
-// ---------------------------------------------------------------------------
-
-CScreenGrabberModel* CScreenGrabberModel::NewL()
-	{
-	CScreenGrabberModel* self = new(ELeave) CScreenGrabberModel;
-	CleanupStack::PushL(self);
-	self->ConstructL();
-	CleanupStack::Pop();
-	return self;
-	}
-
-// ---------------------------------------------------------------------------
-
-CScreenGrabberModel::CScreenGrabberModel() : CActive(EPriorityStandard)
-	{
-	}
-
-// ---------------------------------------------------------------------------
-
-void CScreenGrabberModel::ConstructL()
-	{
-    User::LeaveIfError(iTimer.CreateLocal());
-
-    // init audio utility
-  	iMdaAudioToneUtility = CMdaAudioToneUtility::NewL(*this);
-
-    iSavedQuery = CSavedQuery::NewL();
-    iVideoFrameArray = new(ELeave) CVideoFrameArray(10000);
-
-	iPreviouslyCapturedBitmap = new(ELeave) CFbsBitmap;
-
-    iEnv = CEikonEnv::Static();
-  	iRootWin = iEnv->RootWin();
-  	iCapturingInProgress = EFalse;
-  	iStopCapturing = EFalse;
-  	iNumberOfTakenShots = 0;
-  	iCurrentFrameNumber = 0;
-  	iHashKeyCapturingActivated = EFalse;
-  	iHashKeyDown = EFalse;
-  	iGalleryUpdaterSupported = ETrue;
-  	iGalleryUpdaterInitialized = EFalse;
-
-	CActiveScheduler::Add(this);
-	}
-
-// ---------------------------------------------------------------------------
-
-void CScreenGrabberModel::ActivateModelL()
-	{
-    // clean temporary files
-    TRAP_IGNORE( CleanTemporaryFilesL() );
-            
-    // load settings
-    TRAP_IGNORE( LoadSettingsL() );
-
-    // start capturing
-    ActivateCaptureKeysL();
-	}
-
-// ---------------------------------------------------------------------------
-
-void CScreenGrabberModel::DeActivateModelL()
-	{
-    CancelCapturing();
-
-    // for a faster exit, send the application to background
-    TApaTask selfTask(iEnv->WsSession());
-    selfTask.SetWgId(iEnv->RootWin().Identifier());
-    selfTask.SendToBackground();
-	}
-	
-// ---------------------------------------------------------------------------
-
-CScreenGrabberModel::~CScreenGrabberModel()
-	{
-	Cancel();
-
-    // deactivate Media Gallery DLL
-    if (iGalleryUpdaterInitialized)
-        {
-        if (iMGXFileManager)
-            delete iMGXFileManager;
-            
-        iGalleryUpdaterDLL.Close();
-        }
-
-	TRAP_IGNORE( CleanTemporaryFilesL() );
-
-    iTimer.Close();
-
-    if (iFrameImageData)
-        delete iFrameImageData;
-
-    if (iPreviouslyCapturedBitmap)
-        delete iPreviouslyCapturedBitmap;
-
-    if (iImageEncoder)
-        delete iImageEncoder;
-        
-    delete iVideoFrameArray;
-
-    delete iSavedQuery;
-
-    delete iMdaAudioToneUtility;
-    }
-
-// ---------------------------------------------------------------------------
-
-void CScreenGrabberModel::LoadDFSValueL(CDictionaryFileStore* aDicFS, const TUid& aUid, TInt& aValue)
-    {
-    if (aDicFS->IsPresentL(aUid))
-        {
-        RDictionaryReadStream in;
-        in.OpenLC(*aDicFS, aUid);
-        aValue = in.ReadInt16L();
-        CleanupStack::PopAndDestroy(); // in        
-        }
-    }
-
-// ---------------------------------------------------------------------------
-
-void CScreenGrabberModel::LoadDFSValueL(CDictionaryFileStore* aDicFS, const TUid& aUid, TDes& aValue)
-    {
-    if (aDicFS->IsPresentL(aUid))
-        {
-        RDictionaryReadStream in;
-        in.OpenLC(*aDicFS, aUid);
-        TInt bufLength = in.ReadInt16L();   // get length of descriptor
-        in.ReadL(aValue, bufLength);        // get the descriptor itself
-        CleanupStack::PopAndDestroy(); // in
-        }
-    }
-
-// ---------------------------------------------------------------------------
-
-void CScreenGrabberModel::SaveDFSValueL(CDictionaryFileStore* aDicFS, const TUid& aUid, const TInt& aValue)
-    {
-    RDictionaryWriteStream out;
-    out.AssignLC(*aDicFS, aUid);
-    out.WriteInt16L(aValue);
-    out.CommitL(); 	
-    CleanupStack::PopAndDestroy(1);// out
-    }
-
-// ---------------------------------------------------------------------------
-
-void CScreenGrabberModel::SaveDFSValueL(CDictionaryFileStore* aDicFS, const TUid& aUid, const TDes& aValue)
-    {
-    RDictionaryWriteStream out;
-    out.AssignLC(*aDicFS, aUid);
-    out.WriteInt16L(aValue.Length());       // write length of the descriptor
-    out.WriteL(aValue, aValue.Length());    // write the descriptor itself
-    out.CommitL(); 	
-    CleanupStack::PopAndDestroy(1);// out
-    }
-    
-// ---------------------------------------------------------------------------
-
-void CScreenGrabberModel::LoadSettingsL()
-    {
-    // set defaults
-    iGrabSettings.iCaptureMode = ECaptureModeSingleCapture;
-    
-    iGrabSettings.iSingleCaptureHotkey = EHotkeySendKey;
-    iGrabSettings.iSingleCaptureImageFormat = EImageFormatPNG;
-    iGrabSettings.iSingleCaptureMemoryInUse = CAknMemorySelectionSettingPage::EPhoneMemory; 
-    iGrabSettings.iSingleCaptureMemoryInUseMultiDrive = EDriveC;
-    iGrabSettings.iSingleCaptureFileName.Copy( KDefaultImageFileName );
-
-    iGrabSettings.iSequantialCaptureHotkey = EHotkeySendKey;
-    iGrabSettings.iSequantialCaptureImageFormat = EImageFormatPNG;
-    iGrabSettings.iSequantialCaptureDelay = DEFAULT_SEQ_CAPTURE_DELAY_MS;
-    iGrabSettings.iSequantialCaptureMemoryInUse = CAknMemorySelectionSettingPage::EPhoneMemory; 
-    iGrabSettings.iSequantialCaptureMemoryInUseMultiDrive = EDriveC;
-    iGrabSettings.iSequantialCaptureFileName.Copy( KDefaultImageFileName );
-
-    iGrabSettings.iVideoCaptureHotkey = EHotkeySendKey;
-    iGrabSettings.iVideoCaptureVideoFormat = EVideoFormatAnimatedGIF;
-    iGrabSettings.iVideoCaptureMemoryInUse = CAknMemorySelectionSettingPage::EPhoneMemory; 
-    iGrabSettings.iVideoCaptureMemoryInUseMultiDrive = EDriveC;
-    iGrabSettings.iVideoCaptureFileName.Copy( KDefaultVideoFileName );
-       
-        
-    // make sure that the private path of this app in c-drive exists
-    iEnv->FsSession().CreatePrivatePath( KSettingsDrive ); // c:\\private\\101fb751\\
-    
-    // handle settings always in the private directory 
-    if (iEnv->FsSession().SetSessionToPrivate( KSettingsDrive ) == KErrNone)
-        {
-        // open or create a dictionary file store
-        CDictionaryFileStore* settingsStore = CDictionaryFileStore::OpenLC(iEnv->FsSession(), KSettingsFileName, KUidScreenGrabber);
-
-        LoadDFSValueL(settingsStore, KSGSettingCaptureMode,                             iGrabSettings.iCaptureMode);
-        
-        LoadDFSValueL(settingsStore, KSGSettingSingleCaptureHotkey,                     iGrabSettings.iSingleCaptureHotkey);
-        LoadDFSValueL(settingsStore, KSGSettingSingleCaptureImageFormat,                iGrabSettings.iSingleCaptureImageFormat);
-        LoadDFSValueL(settingsStore, KSGSettingSingleCaptureMemoryInUse,                (TInt&)iGrabSettings.iSingleCaptureMemoryInUse);
-        LoadDFSValueL(settingsStore, KSGSettingSingleCaptureMemoryInUseMultiDrive,      (TInt&)iGrabSettings.iSingleCaptureMemoryInUseMultiDrive);
-        LoadDFSValueL(settingsStore, KSGSettingSingleCaptureFileName,                   iGrabSettings.iSingleCaptureFileName);
-        
-        LoadDFSValueL(settingsStore, KSGSettingSequantialCaptureHotkey,                 iGrabSettings.iSequantialCaptureHotkey);
-        LoadDFSValueL(settingsStore, KSGSettingSequantialCaptureImageFormat,            iGrabSettings.iSequantialCaptureImageFormat);
-        LoadDFSValueL(settingsStore, KSGSettingSequantialCaptureDelay,                  iGrabSettings.iSequantialCaptureDelay);
-        LoadDFSValueL(settingsStore, KSGSettingSequantialCaptureMemoryInUse,            (TInt&)iGrabSettings.iSequantialCaptureMemoryInUse);
-        LoadDFSValueL(settingsStore, KSGSettingSequantialCaptureMemoryInUseMultiDrive,  (TInt&)iGrabSettings.iSequantialCaptureMemoryInUseMultiDrive);
-        LoadDFSValueL(settingsStore, KSGSettingSequantialCaptureFileName,               iGrabSettings.iSequantialCaptureFileName);
-
-        LoadDFSValueL(settingsStore, KSGSettingVideoCaptureHotkey,                      iGrabSettings.iVideoCaptureHotkey);
-        LoadDFSValueL(settingsStore, KSGSettingVideoCaptureVideoFormat,                 iGrabSettings.iVideoCaptureVideoFormat);
-        LoadDFSValueL(settingsStore, KSGSettingVideoCaptureMemoryInUse,                 (TInt&)iGrabSettings.iVideoCaptureMemoryInUse);
-        LoadDFSValueL(settingsStore, KSGSettingVideoCaptureMemoryInUseMultiDrive,       (TInt&)iGrabSettings.iVideoCaptureMemoryInUseMultiDrive);
-        LoadDFSValueL(settingsStore, KSGSettingVideoCaptureFileName,                    iGrabSettings.iVideoCaptureFileName);
-
-        CleanupStack::PopAndDestroy(); // settingsStore         
-        }
-    }
-
-// ---------------------------------------------------------------------------
-
-void CScreenGrabberModel::SaveSettingsL(TGrabSettings aGrabSettings)
-    {
-    // set the new settings
-    iGrabSettings = aGrabSettings;
-
-    // handle settings always in c:\\private\\101fb751\\
-    if (iEnv->FsSession().SetSessionToPrivate( KSettingsDrive ) == KErrNone)
-        {
-        // delete existing store to make sure that it is clean and not eg corrupted
-        if (BaflUtils::FileExists(iEnv->FsSession(), KSettingsFileName))
-            {
-            iEnv->FsSession().Delete(KSettingsFileName);
-            }
-        
-        // create a dictionary file store
-        CDictionaryFileStore* settingsStore = CDictionaryFileStore::OpenLC(iEnv->FsSession(), KSettingsFileName, KUidScreenGrabber);
-
-        SaveDFSValueL(settingsStore, KSGSettingCaptureMode,                             iGrabSettings.iCaptureMode);
-        
-        SaveDFSValueL(settingsStore, KSGSettingSingleCaptureHotkey,                     iGrabSettings.iSingleCaptureHotkey);
-        SaveDFSValueL(settingsStore, KSGSettingSingleCaptureImageFormat,                iGrabSettings.iSingleCaptureImageFormat);
-        SaveDFSValueL(settingsStore, KSGSettingSingleCaptureMemoryInUse,                (TInt&)iGrabSettings.iSingleCaptureMemoryInUse);
-        SaveDFSValueL(settingsStore, KSGSettingSingleCaptureMemoryInUseMultiDrive,      (TInt&)iGrabSettings.iSingleCaptureMemoryInUseMultiDrive);
-        SaveDFSValueL(settingsStore, KSGSettingSingleCaptureFileName,                   iGrabSettings.iSingleCaptureFileName);
-        
-        SaveDFSValueL(settingsStore, KSGSettingSequantialCaptureHotkey,                 iGrabSettings.iSequantialCaptureHotkey);
-        SaveDFSValueL(settingsStore, KSGSettingSequantialCaptureImageFormat,            iGrabSettings.iSequantialCaptureImageFormat);
-        SaveDFSValueL(settingsStore, KSGSettingSequantialCaptureDelay,                  iGrabSettings.iSequantialCaptureDelay);
-        SaveDFSValueL(settingsStore, KSGSettingSequantialCaptureMemoryInUse,            (TInt&)iGrabSettings.iSequantialCaptureMemoryInUse);
-        SaveDFSValueL(settingsStore, KSGSettingSequantialCaptureMemoryInUseMultiDrive,  (TInt&)iGrabSettings.iSequantialCaptureMemoryInUseMultiDrive);
-        SaveDFSValueL(settingsStore, KSGSettingSequantialCaptureFileName,               iGrabSettings.iSequantialCaptureFileName);
-
-        SaveDFSValueL(settingsStore, KSGSettingVideoCaptureHotkey,                      iGrabSettings.iVideoCaptureHotkey);
-        SaveDFSValueL(settingsStore, KSGSettingVideoCaptureVideoFormat,                 iGrabSettings.iVideoCaptureVideoFormat);
-        SaveDFSValueL(settingsStore, KSGSettingVideoCaptureMemoryInUse,                 (TInt&)iGrabSettings.iVideoCaptureMemoryInUse);
-        SaveDFSValueL(settingsStore, KSGSettingVideoCaptureMemoryInUseMultiDrive,       (TInt&)iGrabSettings.iVideoCaptureMemoryInUseMultiDrive);
-        SaveDFSValueL(settingsStore, KSGSettingVideoCaptureFileName,                    iGrabSettings.iVideoCaptureFileName);
-        
-        settingsStore->CommitL();
-        CleanupStack::PopAndDestroy(); // settingsStore             
-        }
-    }
-    	
-// ---------------------------------------------------------------------------
-
-void CScreenGrabberModel::DoCancel()
-	{
-    iTimer.Cancel();
-	}
-
-// ---------------------------------------------------------------------------
-
-void CScreenGrabberModel::ActivateCaptureKeysL(TBool aChangeKey)
-    {
-    // if changing the capture key, capturing needs to be cancelled first
-    if (aChangeKey)
-        {
-        CancelCapturing();
-        }
-
-    // get hotkey of the capture
-    TInt captureHotkey(0);
-    if (iGrabSettings.iCaptureMode == ECaptureModeSingleCapture)
-        captureHotkey = iGrabSettings.iSingleCaptureHotkey;
-    else if (iGrabSettings.iCaptureMode == ECaptureModeSequantialCapture)
-        captureHotkey = iGrabSettings.iSequantialCaptureHotkey;
-    else if (iGrabSettings.iCaptureMode == ECaptureModeVideoCapture)
-        captureHotkey = iGrabSettings.iVideoCaptureHotkey;
-    else
-        User::Panic(_L("Wrong mode"), 40);
-    
-    
-    // capture hash key if needed
-    if (captureHotkey == EHotkeyHashStar)
-        {
-        iCapturedKeyHash    = iRootWin.CaptureKey(EStdKeyHash, EModifierCtrl|EModifierShift|EModifierFunc, 0, KEY_CAPTURE_PRIORITY);
-        iCapturedKeyHashUnD = iRootWin.CaptureKeyUpAndDowns(EStdKeyHash, EModifierCtrl|EModifierShift|EModifierFunc, 0, KEY_CAPTURE_PRIORITY);
-        iHashKeyCapturingActivated = ETrue;
-        }
-    
-
-    // start capturing based on user selected key
-    switch (captureHotkey)
-        {
-        case EHotkeyShiftStar:
-            {
-            iCapturedKey    = iRootWin.CaptureKey('*', EModifierCtrl|EModifierShift|EModifierFunc, EModifierShift, KEY_CAPTURE_PRIORITY);
-            iCapturedKeyUnD = iRootWin.CaptureKeyUpAndDowns('*', EModifierCtrl|EModifierShift|EModifierFunc, EModifierShift, KEY_CAPTURE_PRIORITY);
-            break;
-            }
-        case EHotkeyHashStar:
-            {
-            iCapturedKey    = iRootWin.CaptureKey('*', EModifierCtrl|EModifierShift|EModifierFunc, 0, KEY_CAPTURE_PRIORITY);
-            iCapturedKeyUnD = iRootWin.CaptureKeyUpAndDowns('*', EModifierCtrl|EModifierShift|EModifierFunc, 0, KEY_CAPTURE_PRIORITY);
-            break;
-            }
-        case EHotkeyShiftMenu:
-            {
-            iCapturedKey    = iRootWin.CaptureKey(EStdKeyApplication0, EModifierCtrl|EModifierShift|EModifierFunc, EModifierShift, KEY_CAPTURE_PRIORITY);
-            iCapturedKeyUnD = iRootWin.CaptureKeyUpAndDowns(EStdKeyApplication0, EModifierCtrl|EModifierShift|EModifierFunc, EModifierShift, KEY_CAPTURE_PRIORITY);
-            break;
-            }
-        case EHotkeySendKey:
-            {
-            iCapturedKey    = iRootWin.CaptureKey(EStdKeyYes, EModifierCtrl|EModifierShift|EModifierFunc, 0, KEY_CAPTURE_PRIORITY);
-            iCapturedKeyUnD = iRootWin.CaptureKeyUpAndDowns(EStdKeyYes, EModifierCtrl|EModifierShift|EModifierFunc, 0, KEY_CAPTURE_PRIORITY);
-            break;
-            }
-        case EHotkeyPowerKey:
-            {
-            iCapturedKey    = iRootWin.CaptureKey(EStdKeyDevice2, EModifierCtrl|EModifierShift|EModifierFunc, 0, KEY_CAPTURE_PRIORITY);
-            iCapturedKeyUnD = iRootWin.CaptureKeyUpAndDowns(EStdKeyDevice2, EModifierCtrl|EModifierShift|EModifierFunc, 0, KEY_CAPTURE_PRIORITY);
-            break;
-            }
-        case EHotkeySideKey:
-            {
-            iCapturedKey    = iRootWin.CaptureKey(EStdKeyDevice6, EModifierCtrl|EModifierShift|EModifierFunc, 0, KEY_CAPTURE_PRIORITY);
-            iCapturedKeyUnD = iRootWin.CaptureKeyUpAndDowns(EStdKeyDevice6, EModifierCtrl|EModifierShift|EModifierFunc, 0, KEY_CAPTURE_PRIORITY);
-            break;            
-            }
-        case EHotkeyCameraKey1:
-            {
-            iCapturedKey    = iRootWin.CaptureKey(EStdKeyDevice7, EModifierCtrl|EModifierShift|EModifierFunc, 0, KEY_CAPTURE_PRIORITY);
-            iCapturedKeyUnD = iRootWin.CaptureKeyUpAndDowns(EStdKeyDevice7, EModifierCtrl|EModifierShift|EModifierFunc, 0, KEY_CAPTURE_PRIORITY);
-            break;            
-            }
-        case EHotkeyCameraKey2:
-            {
-            iCapturedKey    = iRootWin.CaptureKey(EStdKeyApplication1A, EModifierCtrl|EModifierShift|EModifierFunc, 0, KEY_CAPTURE_PRIORITY);
-            iCapturedKeyUnD = iRootWin.CaptureKeyUpAndDowns(EStdKeyApplication1A, EModifierCtrl|EModifierShift|EModifierFunc, 0, KEY_CAPTURE_PRIORITY);
-            break;            
-            }
-       	case EHotkeyPOC:
-        	{
-        	iCapturedKey    = iRootWin.CaptureKey(EStdKeyApplication1, EModifierCtrl|EModifierShift|EModifierFunc, 0, KEY_CAPTURE_PRIORITY);
-            iCapturedKeyUnD = iRootWin.CaptureKeyUpAndDowns(EStdKeyApplication1, EModifierCtrl|EModifierShift|EModifierFunc, 0, KEY_CAPTURE_PRIORITY);
-           	break;
-        	}  
-        default:
-            {
-            User::Panic(_L("Key not supported"), 100);
-            break;
-            }
-        }
-    }
-
-// ---------------------------------------------------------------------------
-
-void CScreenGrabberModel::CancelCapturing()
-    {
-	// cancel all captures
-    iRootWin.CancelCaptureKey(iCapturedKey);
-    iRootWin.CancelCaptureKeyUpAndDowns(iCapturedKeyUnD);
-    
-    if (iHashKeyCapturingActivated)
-        {
-        iRootWin.CancelCaptureKey(iCapturedKeyHash);
-        iRootWin.CancelCaptureKeyUpAndDowns(iCapturedKeyHashUnD);
-        
-        iHashKeyCapturingActivated = EFalse;
-        }
-    }
-
-// ---------------------------------------------------------------------------
-
-TBool CScreenGrabberModel::HandleCaptureCommandsL(const TWsEvent& aEvent)
-    {
-    TBool continueEventLoop(ETrue);
-    
-    // get hotkey of the capture
-    TInt captureHotkey(0);
-    if (iGrabSettings.iCaptureMode == ECaptureModeSingleCapture)
-        captureHotkey = iGrabSettings.iSingleCaptureHotkey;
-    else if (iGrabSettings.iCaptureMode == ECaptureModeSequantialCapture)
-        captureHotkey = iGrabSettings.iSequantialCaptureHotkey;
-    else if (iGrabSettings.iCaptureMode == ECaptureModeVideoCapture)
-        captureHotkey = iGrabSettings.iVideoCaptureHotkey;
-    else
-        User::Panic(_L("Wrong mode"), 41);
-
-
-    // ignore any errors
-    if (aEvent.Type()==EEventErrorMessage)
-	    {
-	    // error
-	    }
-	
-	// check if hash key has been pushed down
-	else if (iHashKeyCapturingActivated && aEvent.Type()==EEventKeyDown && aEvent.Key()->iScanCode==EStdKeyHash)
-	    {
-        iHashKeyDown = ETrue;	    
-	    }
-
-	// check if hash key has been released
-	else if (iHashKeyCapturingActivated && aEvent.Type()==EEventKeyUp && aEvent.Key()->iScanCode==EStdKeyHash)
-	    {
-        iHashKeyDown = EFalse;	    
-	    }
-	    	
-    // handle captured keys, we are interested here only of the keydown events
-    else if (
-              ( captureHotkey == EHotkeyShiftStar &&
-                aEvent.Type()==EEventKeyDown && aEvent.Key()->iScanCode=='*' &&
-                aEvent.Key()->iModifiers & EModifierShift)
-            ||
-              ( captureHotkey == EHotkeyHashStar &&
-                aEvent.Type()==EEventKeyDown && aEvent.Key()->iScanCode=='*' &&
-                iHashKeyDown)
-            ||
-              ( captureHotkey == EHotkeyShiftMenu &&
-                aEvent.Type()==EEventKeyDown && aEvent.Key()->iScanCode==EStdKeyApplication0 &&
-                aEvent.Key()->iModifiers & EModifierShift)
-            ||
-              ( captureHotkey == EHotkeySendKey &&
-                aEvent.Type()==EEventKeyDown && aEvent.Key()->iScanCode==EStdKeyYes )
-            ||
-              ( captureHotkey == EHotkeyPowerKey &&
-                aEvent.Type()==EEventKeyDown && aEvent.Key()->iScanCode==EStdKeyDevice2 )
-            ||
-              ( captureHotkey == EHotkeySideKey &&
-                aEvent.Type()==EEventKeyDown && aEvent.Key()->iScanCode==EStdKeyDevice6 )
-            ||
-              ( captureHotkey == EHotkeyCameraKey1 &&
-                aEvent.Type()==EEventKeyDown && aEvent.Key()->iScanCode==EStdKeyDevice7 )
-            ||
-              ( captureHotkey == EHotkeyCameraKey2 &&
-                aEvent.Type()==EEventKeyDown && aEvent.Key()->iScanCode==EStdKeyDevice7 )
-            ||
-              ( captureHotkey == EHotkeyPOC &&
-                aEvent.Type()==EEventKeyDown && aEvent.Key()->iScanCode==EStdKeyApplication1A )
-            )
-		{
-		
-		// check if already capturing images in sequence
-		if ( iCapturingInProgress && !iStopCapturing && iNumberOfTakenShots!=0 && iGrabSettings.iCaptureMode == ECaptureModeSequantialCapture )
-            {
-            // asking to stop capturing
-            iStopCapturing = ETrue;
-            
-            // cancel the active object, this will cancel any timer delays and ICL stuff
-            Cancel();
-            
-            // set status
-            iState = ECancelCapturing; 
-            
-            // jump smoothly to RunL()
-            iTimer.After(iStatus, 50);
-            SetActive(); 
-
-       		// do not continue the event loop in HandleWsEventL for these events
-           	continueEventLoop = EFalse;
-            }
-
-		// check if already capturing video
-		else if ( iCapturingInProgress && !iStopCapturing && iGrabSettings.iCaptureMode == ECaptureModeVideoCapture )
-            {
-            // asking to stop capturing
-            iStopCapturing = ETrue;
-            
-            // cancel the active object, this will cancel any timer delays and ICL stuff
-            Cancel();
-
-            // set status
-            iState = ECancelVideoCapturing;
-            
-            // jump smoothly to RunL()
-            iTimer.After(iStatus, 50);
-            SetActive(); 
-
-       		// do not continue the event loop in HandleWsEventL for these events
-           	continueEventLoop = EFalse;
-            }        
-        else if (!iCapturingInProgress && (iGrabSettings.iCaptureMode == ECaptureModeSingleCapture || iGrabSettings.iCaptureMode == ECaptureModeSequantialCapture ))
-            {
-            // not capturing anything, so start doing that
-            iCapturingInProgress = ETrue;    
-
-			// take a screen shot and save it
-    	    TakeScreenShotAndSaveL();                
-
-       		// do not continue the event loop in HandleWsEventL for these events
-           	continueEventLoop = EFalse;
-            }
-        
-        else if (!iCapturingInProgress && iGrabSettings.iCaptureMode == ECaptureModeVideoCapture )
-            {
-            // not capturing anything, so start doing that
-            iCapturingInProgress = ETrue;
-            
-            // clean temporary files
-            TRAP_IGNORE( CleanTemporaryFilesL() );
-            
-            // get initial dimensions for the video
-            CWsScreenDevice* screenDevice = new(ELeave) CWsScreenDevice ( CEikonEnv::Static()->WsSession() );
-            CleanupStack::PushL(screenDevice);
-            User::LeaveIfError( screenDevice->Construct( iEnv->WsSession().GetFocusScreen() ) );
-            iVideoDimensions = screenDevice->SizeInPixels();
-            iPreviousFrameScreenDimension = screenDevice->SizeInPixels();
-            CleanupStack::PopAndDestroy(); // screenDevice
-
-			// capture the first frame
-			CaptureFrameForVideoL();              
-
-       		// do not continue the event loop in HandleWsEventL for these events
-           	continueEventLoop = EFalse;
-            }
-
-		}
-
-    // catch other event types as well so that we can ignore them
-    else if (
-              ( captureHotkey == EHotkeyShiftStar &&
-                aEvent.Key()->iScanCode=='*' &&
-                aEvent.Key()->iModifiers & EModifierShift)
-            ||
-              ( captureHotkey == EHotkeyHashStar &&
-                aEvent.Key()->iScanCode=='*' &&
-                iHashKeyDown)
-            ||
-              ( captureHotkey == EHotkeyShiftMenu &&
-                aEvent.Key()->iScanCode==EStdKeyApplication0 &&
-                aEvent.Key()->iModifiers & EModifierShift)
-            ||
-              ( captureHotkey == EHotkeySendKey &&
-                aEvent.Key()->iScanCode==EStdKeyYes )
-            ||
-              ( captureHotkey == EHotkeyPowerKey &&
-                aEvent.Key()->iScanCode==EStdKeyDevice2 )
-            ||
-              ( captureHotkey == EHotkeySideKey &&
-                aEvent.Key()->iScanCode==EStdKeyDevice6 )
-            ||
-              ( captureHotkey == EHotkeyCameraKey1 &&
-                aEvent.Key()->iScanCode==EStdKeyDevice7 )
-            ||
-              ( captureHotkey == EHotkeyCameraKey2 &&
-                aEvent.Key()->iScanCode==EStdKeyApplication1A )
-            ||
-    		  ( captureHotkey == EHotkeyPOC &&
-                aEvent.Key()->iScanCode==EStdKeyApplication1 )
-            )
-		{
-		// do not continue the event loop in HandleWsEventL for these events
-        continueEventLoop = EFalse;
-		}
-
-    return continueEventLoop;
-    }
-
-// ---------------------------------------------------------------------------
-
-void CScreenGrabberModel::TakeScreenShotAndSaveL()
-    {
-	// take a screen shot
-	CWsScreenDevice* screenDevice = new( ELeave ) CWsScreenDevice( CEikonEnv::Static()->WsSession() );
-	CleanupStack::PushL( screenDevice );
-	User::LeaveIfError( screenDevice->Construct( iEnv->WsSession().GetFocusScreen() ) );
-	User::LeaveIfError( iPreviouslyCapturedBitmap->Create(screenDevice->SizeInPixels(), screenDevice->DisplayMode()) );
-	User::LeaveIfError( screenDevice->CopyScreenToBitmap(iPreviouslyCapturedBitmap) );
-	CleanupStack::PopAndDestroy(); // screenDevice
-
-    // play a beep sound for each shot when capturing in sequantial mode
-    if (iGrabSettings.iCaptureMode == ECaptureModeSequantialCapture)
-        PlayBeepSound();
-
-
-    // get memory in use & image format of the screen capture
-#ifdef SCREENGRABBER_MULTIDRIVE_SUPPORT            
-    TDriveNumber memoryInUse(EDriveC);
-#else
-    TInt memoryInUse(0);
-#endif
-    TInt imageFormat(0);
-    TFileName fileName;
-    
-    if (iGrabSettings.iCaptureMode == ECaptureModeSingleCapture)
-        {
-#ifdef SCREENGRABBER_MULTIDRIVE_SUPPORT            
-        memoryInUse = iGrabSettings.iSingleCaptureMemoryInUseMultiDrive;
-#else
-        memoryInUse = iGrabSettings.iSingleCaptureMemoryInUse;
-#endif
-        imageFormat = iGrabSettings.iSingleCaptureImageFormat;
-        fileName = iGrabSettings.iSingleCaptureFileName;
-        }
-    else if (iGrabSettings.iCaptureMode == ECaptureModeSequantialCapture)
-        {
-#ifdef SCREENGRABBER_MULTIDRIVE_SUPPORT            
-        memoryInUse = iGrabSettings.iSequantialCaptureMemoryInUseMultiDrive;
-#else
-        memoryInUse = iGrabSettings.iSequantialCaptureMemoryInUse;
-#endif
-
-        imageFormat = iGrabSettings.iSequantialCaptureImageFormat;
-        fileName = iGrabSettings.iSequantialCaptureFileName;
-        }
-    else
-        User::Panic(_L("Wrong mode"), 30);  
-
-
-    // init the path for saving the file
-#ifdef SCREENGRABBER_MULTIDRIVE_SUPPORT
-    if (PathInfo::GetRootPath(iSaveFileName, memoryInUse) != KErrNone || !DriveOK(memoryInUse))
-        iSaveFileName.Copy( PathInfo::PhoneMemoryRootPath() );
-#else
-    if (memoryInUse == CAknMemorySelectionSettingPage::EPhoneMemory || !MemoryCardOK())
-        iSaveFileName.Copy( PathInfo::PhoneMemoryRootPath() );
-    else
-        iSaveFileName.Copy( PathInfo::MemoryCardRootPath() );
-#endif
-
-    iSaveFileName.Append( PathInfo::ImagesPath() );
-    iSaveFileName.Append( KScreenShotsSubDirectory );
-    
-    
-    // a quick check that filename is valid
-    if (fileName.Length() > 0 && fileName.Length() <= 255) 
-        iSaveFileName.Append( fileName );
-    else
-        iSaveFileName.Append( KDefaultImageFileName );
-
-    iSaveFileName.Append( _L(".") );
-
-
-    // reset the encoder
-    if (iImageEncoder)
-        {
-	    delete iImageEncoder;
-        iImageEncoder = NULL;
-        }
-        
-    
-    switch (imageFormat)
-        {
-        case EImageFormatPNG:
-            {
-            // set filename
-            iSaveFileName.Append(_L("png"));
-            CApaApplication::GenerateFileName(iEnv->FsSession(), iSaveFileName );  // unique filename
-
-            // init & convert
-            iImageEncoder = CImageEncoder::FileNewL(iEnv->FsSession(), iSaveFileName, CImageEncoder::EOptionAlwaysThread, KImageTypePNGUid);
-            iImageEncoder->Convert( &iStatus, *iPreviouslyCapturedBitmap );
-            }
-            break;
-        
-        case EImageFormatJPGHQ:
-        case EImageFormatJPGLQ:
-            {
-            // reset frameimagedata
-            if (iFrameImageData)
-                {
-                delete iFrameImageData;
-                iFrameImageData = NULL;
-                }
-            
-            // set filename
-            iSaveFileName.Append(_L("jpg"));
-            CApaApplication::GenerateFileName(iEnv->FsSession(), iSaveFileName );  // unique filename
-
-            // init 
-            iImageEncoder = CImageEncoder::FileNewL(iEnv->FsSession(), iSaveFileName, CImageEncoder::EOptionAlwaysThread, KImageTypeJPGUid);
-
-            // JPEG properties
-            TJpegImageData* imageData = new(ELeave) TJpegImageData;
-            imageData->iSampleScheme = TJpegImageData::EColor444;
-            imageData->iQualityFactor = (imageFormat==EImageFormatJPGHQ) ? HIGH_QUALITY_JPEG : LOW_QUALITY_JPEG;
-            iFrameImageData = CFrameImageData::NewL();
-            User::LeaveIfError(iFrameImageData->AppendImageData(imageData));  //ownership of imageData is transferred
-
-            // convert
-            iImageEncoder->Convert( &iStatus, *iPreviouslyCapturedBitmap, iFrameImageData );
-            }
-            break;
-        
-        case EImageFormatBMP:
-            {
-            // set filename
-            iSaveFileName.Append(_L("bmp"));
-            CApaApplication::GenerateFileName(iEnv->FsSession(), iSaveFileName );  // unique filename
-
-            // init & convert
-            iImageEncoder = CImageEncoder::FileNewL(iEnv->FsSession(), iSaveFileName, CImageEncoder::EOptionAlwaysThread, KImageTypeBMPUid);
-            iImageEncoder->Convert( &iStatus, *iPreviouslyCapturedBitmap );
-            }
-            break;
-
-        case EImageFormatGIF:
-            {
-            // set filename
-            iSaveFileName.Append(_L("gif"));
-            CApaApplication::GenerateFileName(iEnv->FsSession(), iSaveFileName );  // unique filename
-
-            // init & convert
-            iImageEncoder = CImageEncoder::FileNewL(iEnv->FsSession(), iSaveFileName, CImageEncoder::EOptionAlwaysThread, KImageTypeGIFUid);
-            iImageEncoder->Convert( &iStatus, *iPreviouslyCapturedBitmap );
-            }
-            break;
-            
-        case EImageFormatMBM:
-            {
-            // set filename
-            iSaveFileName.Append(_L("mbm"));
-            CApaApplication::GenerateFileName(iEnv->FsSession(), iSaveFileName );  // unique filename
-
-            // init & convert
-            iImageEncoder = CImageEncoder::FileNewL(iEnv->FsSession(), iSaveFileName, CImageEncoder::EOptionAlwaysThread, KImageTypeMBMUid);
-            iImageEncoder->Convert( &iStatus, *iPreviouslyCapturedBitmap );
-            }
-            break;
-            
-        default:
-            {
-            User::Panic(_L("Invalid Img Type"), 20);
-            }
-        }
-
-    // set the state of the active object
-	iState = EEncodingImage;
-
-    // indicate an outstanding request
-    SetActive();
-    }
-    
-// ---------------------------------------------------------------------------
-
-void CScreenGrabberModel::CaptureFrameForVideoL()
-    {
-    // record time
-    TTime timeNow;
-    timeNow.HomeTime();
-    
-    // take a screen shot	
- 	CFbsBitmap* currentCapturedBitmap = new(ELeave) CFbsBitmap;
- 	CleanupStack::PushL(currentCapturedBitmap);
-
-	CWsScreenDevice* screenDevice = new(ELeave) CWsScreenDevice( CEikonEnv::Static()->WsSession() );
-	CleanupStack::PushL( screenDevice );
-	User::LeaveIfError( screenDevice->Construct( iEnv->WsSession().GetFocusScreen() ) );
-	
-    TSize currentScreenSize = screenDevice->SizeInPixels();
-
-	User::LeaveIfError( currentCapturedBitmap->Create(currentScreenSize, EColor256) );
-	User::LeaveIfError( screenDevice->CopyScreenToBitmap(currentCapturedBitmap) );
-	CleanupStack::PopAndDestroy(); // screenDevice
-
-	// grow video's dimensions if the size has changed
-	if (currentScreenSize.iWidth > iVideoDimensions.iWidth)
-	    {
-	    iVideoDimensions.iWidth = currentScreenSize.iWidth;
-	    }
-	if (currentScreenSize.iHeight > iVideoDimensions.iHeight)
-	    {
-	    iVideoDimensions.iHeight = currentScreenSize.iHeight;
-	    }
-
-    TInt64 currentDelay(0);
- 
-    // play a beep sound every 30th frame
-    if (iCurrentFrameNumber%30 == 0)
-        PlayBeepSound();
-
-    // create a new frame
-    TVideoFrame frame;
-    frame.iDelay = 500; // use default delay 5.00 secs
-    
-    // get info of the RAM drive
-    TDriveNumber ramDrive = EDriveD;
-    TVolumeInfo ramDriveInfo;
-    iEnv->FsSession().Volume(ramDriveInfo, ramDrive);
-    
-    // init the directory for saving the file, preferably use ram drive if there is enough disk space, otherwise use always C drive
-    TFileName tempDirectory;
-    TFileName sessionPath;
-    
-    if (ramDriveInfo.iFree > (iVideoDimensions.iWidth*iVideoDimensions.iHeight+50000))
-        sessionPath.Copy( _L("D:") );
-    else
-        sessionPath.Copy( _L("C:") );
-    
-    sessionPath.Append(KSGTemporaryDirectory);
-    tempDirectory.Copy(KSGTemporaryDirectory);
-    
-    iEnv->FsSession().MkDirAll(sessionPath);
-    iEnv->FsSession().SetSessionPath(sessionPath);
-
-    // create a temp file, path to the bitmap is saved automatically to frame.iFileStorePath
-    RFile file;
-    User::LeaveIfError( file.Temp(iEnv->FsSession(), tempDirectory, frame.iFileStorePath, EFileWrite) );
-    RFileWriteStream writeStream(file);
-    
-    TBool ignoreFrame(EFalse);
-    
-    // check if is this the first frame
-    if (iCurrentFrameNumber == 0)
-        {
-        // first frame is always the full one
-        frame.iWidth = currentScreenSize.iWidth;    
-        frame.iHeight = currentScreenSize.iHeight;  
-        frame.iXPos = 0;
-        frame.iYPos = 0;
-        frame.iEnableTransparency = EFalse;
-        frame.iFillsWholeScreen = ETrue;
-        
-        currentCapturedBitmap->ExternalizeL(writeStream);  
-
-        }
-    
-    else
-        {
-        // next frame is a difference between the previous one
-        currentDelay = timeNow.MicroSecondsFrom(iPreviousFrameTaken).Int64();
-        
-        // get reference to previos frame
-        TVideoFrame& prevFrame = iVideoFrameArray->At(iVideoFrameArray->Count()-1);
-        
-        
-        // check if video dimensions have changed
-        if (currentScreenSize.iWidth != iPreviousFrameScreenDimension.iWidth
-            || currentScreenSize.iHeight != iPreviousFrameScreenDimension.iHeight)
-            {
-            // dimensions have changed -> save a full bitmap
-            frame.iWidth = currentScreenSize.iWidth;    
-            frame.iHeight = currentScreenSize.iHeight;  
-            frame.iXPos = 0;
-            frame.iYPos = 0;
-            frame.iEnableTransparency = EFalse;
-            frame.iFillsWholeScreen = ETrue;
-            
-            currentCapturedBitmap->ExternalizeL(writeStream);            
-
-            // update the previous frame to contain the new delay value
-            prevFrame.iDelay = TUint( (double) currentDelay / 10000 );
-            }
-
-        else
-            {
-            // compare the bitmaps
-            HBufC8* curImgScanLineBuf = HBufC8::NewLC(currentScreenSize.iWidth*3);
-            TPtr8 curImgScanLinePtr = curImgScanLineBuf->Des();
-            HBufC8* prevImgScanLineBuf = HBufC8::NewLC(currentScreenSize.iWidth*3);
-            TPtr8 prevImgScanLinePtr = prevImgScanLineBuf->Des();
-            
-            TPoint pt(0,0);
-            TBool differenceFound(EFalse);
-            TPoint leftTopDifferencePoint(0,0);
-            TPoint rightBottomDifferencePoint(currentScreenSize.iWidth,currentScreenSize.iHeight);
-            
-            // scan the image from top to bottom
-            for (TInt i=0; i<currentScreenSize.iHeight; i++)
-                {
-                pt.iY = i;
-                
-                currentCapturedBitmap->GetScanLine(curImgScanLinePtr, pt, currentScreenSize.iWidth, EColor256);
-                iPreviouslyCapturedBitmap->GetScanLine(prevImgScanLinePtr, pt, currentScreenSize.iWidth, EColor256);
-                
-                if (curImgScanLinePtr != prevImgScanLinePtr)
-                    {
-                    differenceFound = ETrue;
-                    
-                    // get the y-coordinate
-                    leftTopDifferencePoint.iY = i;
-
-                    break;    
-                    }
-                }
-                
-            if (differenceFound)
-                {
-                // now we know that there is some difference between those two captured frames,
-                // get the bottom value by scaning from bottom to top
-                for (TInt i=currentScreenSize.iHeight-1; i>=0; i--)
-                    {
-                    pt.iY = i;
-                    
-                    currentCapturedBitmap->GetScanLine(curImgScanLinePtr, pt, currentScreenSize.iWidth, EColor256);
-                    iPreviouslyCapturedBitmap->GetScanLine(prevImgScanLinePtr, pt, currentScreenSize.iWidth, EColor256);
-                    
-                    if (curImgScanLinePtr != prevImgScanLinePtr)
-                        {
-                        // get the y-coordinate
-                        rightBottomDifferencePoint.iY = i+1;
-
-                        break;    
-                        }
-                    }
-                    
-                // check that the height of the cropped image will be at least 1
-                if (rightBottomDifferencePoint.iY <= leftTopDifferencePoint.iY)
-                    rightBottomDifferencePoint.iY = leftTopDifferencePoint.iY+1;  
-                
-                      
-                // get also the x-coordinates by scanning vertical scan lines
-                HBufC8* curImgVerticalScanLineBuf = HBufC8::NewLC(currentScreenSize.iHeight*3);
-                TPtr8 curImgVerticalScanLinePtr = curImgScanLineBuf->Des();
-                HBufC8* prevImgVerticalScanLineBuf = HBufC8::NewLC(currentScreenSize.iHeight*3);
-                TPtr8 prevImgVerticalScanLinePtr = prevImgScanLineBuf->Des();
-                        
-                // first scan by from left to right
-                for (TInt i=0; i<currentScreenSize.iWidth; i++)
-                    {
-                    currentCapturedBitmap->GetVerticalScanLine(curImgVerticalScanLinePtr, i, EColor256);
-                    iPreviouslyCapturedBitmap->GetVerticalScanLine(prevImgVerticalScanLinePtr, i, EColor256);
-                    
-                    if (curImgVerticalScanLinePtr != prevImgVerticalScanLinePtr)
-                        {
-                        leftTopDifferencePoint.iX = i;
-                        break;
-                        }
-                    }
-
-                // finally scan from right to left
-                for (TInt i=currentScreenSize.iWidth-1; i>=0; i--)
-                    {
-                    currentCapturedBitmap->GetVerticalScanLine(curImgVerticalScanLinePtr, i, EColor256);
-                    iPreviouslyCapturedBitmap->GetVerticalScanLine(prevImgVerticalScanLinePtr, i, EColor256);
-                    
-                    if (curImgVerticalScanLinePtr != prevImgVerticalScanLinePtr)
-                        {
-                        rightBottomDifferencePoint.iX = i+1;
-                        break;
-                        }
-                    }
-                    
-                CleanupStack::PopAndDestroy(2); //curImgVerticalScanLineBuf,prevImgVerticalScanLineBuf               
-
-                
-                // check that the width of the cropped image will be at least 1
-                if (rightBottomDifferencePoint.iX <= leftTopDifferencePoint.iX)
-                    rightBottomDifferencePoint.iX = leftTopDifferencePoint.iX+1;
-                   
-                
-                // record dimensions and position of the image           
-                frame.iWidth = rightBottomDifferencePoint.iX - leftTopDifferencePoint.iX;    
-                frame.iHeight = rightBottomDifferencePoint.iY - leftTopDifferencePoint.iY;  
-                frame.iXPos = leftTopDifferencePoint.iX;
-                frame.iYPos = leftTopDifferencePoint.iY;
-                frame.iEnableTransparency = ETrue;
-                frame.iFillsWholeScreen = EFalse;
-            
-            
-                // take a copy of the current frame
-             	CFbsBitmap* workingBitmap = new(ELeave) CFbsBitmap;
-             	CleanupStack::PushL(workingBitmap);
-                User::LeaveIfError( workingBitmap->Create(currentScreenSize, EColor256) );
-
-                HBufC8* tempScanLineBuf = HBufC8::NewLC(currentScreenSize.iWidth*3);
-                TPtr8 tempScanLinePtr = tempScanLineBuf->Des();
-                
-                for (TInt i=0; i<currentScreenSize.iHeight; i++)
-                    {
-                    pt.iY = i;
-                    currentCapturedBitmap->GetScanLine(tempScanLinePtr, pt, currentScreenSize.iWidth, EColor256);
-                    workingBitmap->SetScanLine(tempScanLinePtr, i);
-                    }
-                    
-                CleanupStack::PopAndDestroy(); //tempScanLineBuf
-                
-                
-                // mark the non-changed areas with transparency color
-                TUint8* curPtr = NULL;
-                TUint8* prevPtr = NULL;
-                for (TInt i=frame.iYPos; i<frame.iYPos+frame.iHeight; i++)
-                    {
-                    pt.iY = i;
-                    
-                    workingBitmap->GetScanLine(curImgScanLinePtr, pt, currentScreenSize.iWidth, EColor256);
-                    iPreviouslyCapturedBitmap->GetScanLine(prevImgScanLinePtr, pt, currentScreenSize.iWidth, EColor256);
-                    
-                    // check single pixels in the scanline
-                    for (TInt j=frame.iXPos; j<frame.iXPos+frame.iWidth; j++)
-                        {
-                        curPtr = &curImgScanLinePtr[j];
-                        prevPtr = &prevImgScanLinePtr[j];
-                        
-                        // check that our transparency index isn't already in use
-                        if (curPtr[0] == TRANSPARENCY_INDEX)
-                            curPtr[0] = TRANSPARENCY_ALTERNATIVE_INDEX;
-                        
-                        // replace with transparency index if there is no change compared to the previous frame
-                        if (curPtr[0] == prevPtr[0])
-                            curPtr[0] = TRANSPARENCY_INDEX;
-                        }
-                        
-                    // set new scanline    
-                    workingBitmap->SetScanLine(curImgScanLinePtr, i);
-                    }
-
-
-                // externalize the bitmap
-                TRect changedRect(leftTopDifferencePoint, rightBottomDifferencePoint);
-                workingBitmap->ExternalizeRectangleL(writeStream, changedRect);
-                
-                CleanupStack::PopAndDestroy(); //workingBitmap
- 
-                // update the previous frame to contain the new delay value
-                prevFrame.iDelay = TUint( (double) currentDelay / 10000 );
-                }
-
-            else
-                {
-                // frames are identical, we can just ignore this one
-                ignoreFrame = ETrue;     
-                }
-            
-            CleanupStack::PopAndDestroy(2); //curImgScanLineBuf,prevImgScanLineBuf
-
-            } // if (videoDimensionsHaveChanged)
-
-        } //if (iCurrentFrameNumber == 0)
-            
-    // close the stream
-    writeStream.CommitL();
-    writeStream.Close();
-    file.Close();
-    
-
-    if (ignoreFrame)
-        {
-        // delete the temp file since we don't need that
-        iEnv->FsSession().Delete(frame.iFileStorePath);
-        }
-    else
-        {
-        // remember for the next frame when this frame was taken
-        iPreviousFrameTaken = timeNow;
-
-        // take a copy of currentCapturedBitmap to iPreviouslyCapturedBitmap
-        User::LeaveIfError( iPreviouslyCapturedBitmap->Create(iVideoDimensions, EColor256) );
-
-        TPoint pt(0,0);
-        HBufC8* tempScanLineBuf = HBufC8::NewMaxLC(iVideoDimensions.iWidth);
-        TPtr8 tempScanLinePtr = tempScanLineBuf->Des();
-        
-        for (TInt i=0; i<iVideoDimensions.iHeight; i++)
-            {
-            pt.iY = i;
-            currentCapturedBitmap->GetScanLine(tempScanLinePtr, pt, iVideoDimensions.iWidth, EColor256);
-            iPreviouslyCapturedBitmap->SetScanLine(tempScanLinePtr, i);
-            }
-            
-        CleanupStack::PopAndDestroy(); //tempScanLineBuf
-        
-        // append frame information to the array
-        iVideoFrameArray->AppendL(frame);
-        
-        // remember screen size
-        iPreviousFrameScreenDimension = currentScreenSize;
-        }    
-
-    
-    CleanupStack::PopAndDestroy(); //currentCapturedBitmap
-    
-
-    // set the state of the active object
-	iState = ENextVideoFrame;
-	
-    // check time spent on the work above (probably this is not so important)
-	TTime timeNow2;
-    timeNow2.HomeTime();
-    TInt64 handlingDelay = timeNow2.MicroSecondsFrom(timeNow).Int64();
-    
-	// calculate delay till next frame
-	TUint idealDelay = VIDEO_CAPTURE_DELAY*1000;
-	TInt usedDelay; 
-	if (currentDelay > idealDelay)
-	    usedDelay = idealDelay - (currentDelay - idealDelay) - handlingDelay;
-	else
-	    usedDelay = idealDelay - handlingDelay;
-	
-	// check that the delay is atleast minimum delay anyway
-	if (usedDelay < VIDEO_CAPTURE_MINIMUM_DELAY*1000)
-	    usedDelay = VIDEO_CAPTURE_MINIMUM_DELAY*1000;
-	
-	iTimer.After(iStatus, usedDelay);
-
-    // indicate an outstanding request
-    SetActive();
-    }
-    
-// ---------------------------------------------------------------------------
-    
-void CScreenGrabberModel::RunL()
-    {
-	switch (iState) 
-		{
-        // encoding of the image is now finished
-		case EEncodingImage: 
-			{
-            if (iGrabSettings.iCaptureMode == ECaptureModeSingleCapture)
-                {
-                // single shot done
-                CapturingFinishedL( iStatus.Int() );
-                }
-
-            else if (iGrabSettings.iCaptureMode == ECaptureModeSequantialCapture)
-                {
-                // increase the counter    
-                iNumberOfTakenShots++;
-                
-                // check if we can take more shots or just finish
-                if (!iStopCapturing && iStatus.Int()==KErrNone)
-                    {
-                    // notify the new file to Media Gallery
-                    UpdateFileToGallery(iSaveFileName);
-        
-                    // some delay before the next shot can be taken    
-                    iState = ESequenceDelay;
-                    
-                    // some checking that the value of delay is valid
-                    TInt delay(iGrabSettings.iSequantialCaptureDelay); //ms
-                    if (delay<0 && delay > 999999)
-                        delay = DEFAULT_SEQ_CAPTURE_DELAY_MS;
-                      
-                    iTimer.After(iStatus, delay*1000);
-                    SetActive();  
-                    }
-                else
-                    {
-                    // finished
-                    CapturingFinishedL( iStatus.Int() );
-                    }                       
-               }
-            else
-                User::Panic(_L("Wrong mode"), 32);            
-
-            break;
-			}
-
-        // delay finished, ready to take the next shot
-		case ESequenceDelay: 
-			{
-			TakeScreenShotAndSaveL();
-
-            break;
-			}
-			
-		// asked to cancel capturing	
-		case ECancelCapturing:
-			{
-            // finished
-            CapturingFinishedL( iStatus.Int() );
-
-            break;
-			}
-			
-		case ENextVideoFrame:
-		    {
-		    // increase the counter
-		    iCurrentFrameNumber++;
-		    
-            // check if we can take more frames or just finish
-            if (!iStopCapturing && iStatus.Int()==KErrNone)
-                {
-                // take next frame
-                CaptureFrameForVideoL();
-                }
-            else
-                {
-                // finished, save video
-                SaveVideoL( iStatus.Int() );
-                } 		        
-		    }
-		    break;
-
-		case ECancelVideoCapturing:
-		    {
-            // finished, save video
-            SaveVideoL( iStatus.Int() ); 		        
-		    }
-		    break;
-		    			        
-        // delay of the query is now finished
-        case EQueryDelay:
-			{
-    		iState = EIdle;
-
-            // now remove the query
-            iSavedQuery->Cancel();
-
-            // capturing can now be restarted
-            iCapturingInProgress = EFalse;
-            iStopCapturing = EFalse;
-
-            break;
-			}
-
-		default:
-			{
-            break;
-			}
-        }
-    }
-
-// ---------------------------------------------------------------------------
-
-void CScreenGrabberModel::SaveVideoL(TInt aErr)
-    {
-    if (aErr)
-        CapturingFinishedL(aErr);   
-   
-    else if (iGrabSettings.iVideoCaptureVideoFormat == EVideoFormatAnimatedGIF)
-        {
-        TInt err(KErrNone);
-        
-        // init the path for saving the file
-
-#ifdef SCREENGRABBER_MULTIDRIVE_SUPPORT
-        if (PathInfo::GetRootPath(iSaveFileName, iGrabSettings.iVideoCaptureMemoryInUseMultiDrive) != KErrNone || !DriveOK(iGrabSettings.iVideoCaptureMemoryInUseMultiDrive))
-            iSaveFileName.Copy( PathInfo::PhoneMemoryRootPath() );
-#else
-        if (iGrabSettings.iVideoCaptureMemoryInUse == CAknMemorySelectionSettingPage::EPhoneMemory || !MemoryCardOK())
-            iSaveFileName.Copy( PathInfo::PhoneMemoryRootPath() );
-        else
-            iSaveFileName.Copy( PathInfo::MemoryCardRootPath() );
-#endif
-
-        iSaveFileName.Append( PathInfo::ImagesPath() );     // animated gif is actually an image, not a video
-        iSaveFileName.Append( KScreenShotsSubDirectory );
- 
-    
-        // a quick check that filename is valid
-        if (iGrabSettings.iVideoCaptureFileName.Length() > 0 && iGrabSettings.iVideoCaptureFileName.Length() <= 255) 
-            iSaveFileName.Append( iGrabSettings.iVideoCaptureFileName );
-        else
-            iSaveFileName.Append( KDefaultVideoFileName );
-
-        iSaveFileName.Append( _L(".gif") );
-
-        CApaApplication::GenerateFileName(iEnv->FsSession(), iSaveFileName );  // unique filename
-
-        // create and save the gif animation
-        err = CGifAnimator::CreateGifAnimation(iSaveFileName, iVideoDimensions, iVideoFrameArray);
-        
-        // remove the saved file in case of errors since it's likely corrupted
-        if (err != KErrNone)
-            iEnv->FsSession().Delete(iSaveFileName);
-        
-        CapturingFinishedL(err);   
-        }
-        
-    else
-        CapturingFinishedL(KErrNotSupported);
-    }
-
-// ---------------------------------------------------------------------------
-
-void CScreenGrabberModel::CleanTemporaryFilesL()
-    {
-    // delete temporary files from C and D drives    
-    CFileMan* fileMan = CFileMan::NewL(iEnv->FsSession());
-
-    TFileName delFilesPath;
-        
-    for (TInt i=0; i<1; i++)
-        {
-        delFilesPath.Copy(KNullDesC);
-        delFilesPath.Append('C'+i);
-        delFilesPath.Append(_L(":"));
-        delFilesPath.Append(KSGTemporaryDirectory);
-        delFilesPath.Append(_L("*.$$$"));
-        
-        fileMan->Delete(delFilesPath);
-        }
-
-    delete fileMan;    
-    }
-
-// ---------------------------------------------------------------------------
-    
-void CScreenGrabberModel::CapturingFinishedL(TInt aErr)
-    {
-    // display a global query to show the results
-
-    if (aErr == KErrNone)
-        {
-        switch (iGrabSettings.iCaptureMode)
-            {
-            case ECaptureModeSingleCapture:
-                {
-                iSavedQuery->DisplayL(KSingleShotSaved);
-                }
-                break;
-            
-            case ECaptureModeSequantialCapture:
-                {
-                if (iNumberOfTakenShots == 1)
-                    iSavedQuery->DisplayL(KSingleShotSaved);
-                else
-                    {
-                    TBuf<256> note;
-                    note.Format(KMultipleShotsSaved, iNumberOfTakenShots);
-                    iSavedQuery->DisplayL(note);
-                    }
-                }
-                break;            
-    
-            case ECaptureModeVideoCapture:
-                {
-                iSavedQuery->DisplayL(KVideoSaved);
-                }
-                break;             
-    
-            default:
-                User::Panic(_L("Inv.capt.mode"), 51);
-                break;
-            }            
-       
-        // notify the new file to Media Gallery
-        UpdateFileToGallery(iSaveFileName);
-        }
-    else
-        {
-        TBuf<256> errorNote;
-        errorNote.Copy( KErrorOccured );
-
-        CTextResolver* textResolver = CTextResolver::NewLC();
-        errorNote.Append( textResolver->ResolveErrorString(aErr) );
-        CleanupStack::PopAndDestroy();  //textResolver    
-          
-        iSavedQuery->DisplayL(errorNote, ETrue);
-        }
-
-    // reset values
-    iNumberOfTakenShots = 0;
-    iCurrentFrameNumber = 0;
-    iVideoFrameArray->Reset();
-
-
-    // remove the query after 2.0 secs
-    iState = EQueryDelay;
-    iTimer.After(iStatus, 2000000);
-    SetActive();
-
-    }
-    
-// ---------------------------------------------------------------------------
-
-TBool CScreenGrabberModel::MemoryCardOK()
-	{
-	return DriveOK(EDriveE); // hardcoding EDriveE here maybe is not so good idea..   
-	}
-
-// ---------------------------------------------------------------------------
-
-TBool CScreenGrabberModel::DriveOK(TDriveNumber aNumber)
-	{
-	TBool isOK(EFalse);
-
-    TVolumeInfo vInfo;
-
-	// check if we can access the drive
-	if (iEnv->FsSession().Volume(vInfo, aNumber) == KErrNone)
-		isOK = ETrue;
-
-	// returns ETrue if memory card working properly
-	return isOK;
-	}
-// ---------------------------------------------------------------------------
-
-void CScreenGrabberModel::PlayBeepSound()
-    {
-    TMdaAudioToneUtilityState toneState = iMdaAudioToneUtility->State();
-    
-    if (toneState == EMdaAudioToneUtilityPlaying)
-        iMdaAudioToneUtility->CancelPlay();
-    else if (toneState == EMdaAudioToneUtilityNotReady)
-        iMdaAudioToneUtility->CancelPrepare();
-
-    iMdaAudioToneUtility->PrepareToPlayTone(500, TTimeIntervalMicroSeconds(100000));
-    }
-
-// ---------------------------------------------------------------------------
-
-void CScreenGrabberModel::MatoPrepareComplete(TInt aError)
-    {
-    if (aError == KErrNone)
-        iMdaAudioToneUtility->Play();
-    }
-
-// ---------------------------------------------------------------------------
-
-void CScreenGrabberModel::MatoPlayComplete(TInt /*aError*/)
-    {
-    }
-
-// ---------------------------------------------------------------------------
-
-TInt CScreenGrabberModel::UpdateFileToGallery(const TDesC& aFullPath)
-    {
-    // first check if this feature is supported    
-    if (iGalleryUpdaterSupported)
-        {
-        // check if has been initialized
-        if (!iGalleryUpdaterInitialized)
-            {
-            // not initialized, first try to load the DLL    
-            if (iGalleryUpdaterDLL.Load(_L("MGXMediaFileAPI.dll")) == KErrNone)
-                {
-                // construct the object, equals:
-                // CMGXFileManager* mgxFileManager = (MGXFileManagerFactory::NewFileManagerL)(NewFileManagerLEntry)(iEnv->FsSession());
-            
-                typedef CMGXFileManager* (*TMyFunc)(RFs& aFs);
-                TMyFunc theFunc = (TMyFunc)iGalleryUpdaterDLL.Lookup(1);
-                if (theFunc)
-                    {
-                    TRAPD( err, iMGXFileManager = theFunc(iEnv->FsSession()) );
-                    if (iMGXFileManager && err == KErrNone)
-                        {
-                        // construction completed succesfully
-                        iGalleryUpdaterInitialized = ETrue;
-                        }
-                    else
-                        {
-                        // out of memory or other unknown error?    
-                        iGalleryUpdaterDLL.Close();
-                        }
-                    }
-                else
-                    {
-                    // ordinal not found from the DLL 
-                    iGalleryUpdaterDLL.Close();
-                    }    
-                }
-            else
-                {
-                // DLL does not exist in the device
-                }
-            }
-
-        // update the file if gallery updater has been initialized
-        if (iGalleryUpdaterInitialized)
-            {
-            TRAPD(err, iMGXFileManager->UpdateL(aFullPath));
-            return err;    
-            }
-        else
-            {
-            // gallery updater not supported if initialization failed    
-            iGalleryUpdaterSupported = EFalse;
-            return KErrNotSupported;    
-            }            
-        }
-    else
-        {
-        return KErrNotSupported;
-        }
-    }
-
-// ---------------------------------------------------------------------------
-
-/*************************************************************************************************/
-// a class to display an info message that the screen shot was saved to disk
-
-CSavedQuery::CSavedQuery() : CActive(EPriorityLow)
-    {
-	CActiveScheduler::Add(this);
-    }
-
-void CSavedQuery::ConstructL()
-    {
-    iGlobalConfirmationQuery = CAknGlobalConfirmationQuery::NewL();
-    }
-
-CSavedQuery* CSavedQuery::NewL()
-    {
-    CSavedQuery* self = new(ELeave) CSavedQuery();
-    CleanupStack::PushL(self);
-    self->ConstructL();
-    CleanupStack::Pop(self);
-    return self;
-    }
-
-CSavedQuery::~CSavedQuery()
-    {
-    delete iGlobalConfirmationQuery;
-    }
-
-void CSavedQuery::DisplayL(const TDesC &aText, TBool aDisplayErrorNote)
-    {
-    if (!iVisible)
-        {
-        TRAPD(err, DisplayWithGraphicsL(aText, aDisplayErrorNote));
-        if (err != KErrNone)
-            {
-            DisplayWithoutGraphicsL(aText);
-            }
-        iVisible = ETrue;
-        SetActive();
-        }
-    }
-
-void CSavedQuery::DoCancel()
-    {
-    if (iGlobalConfirmationQuery)
-        {
-        iGlobalConfirmationQuery->CancelConfirmationQuery();
-        }
-    iVisible = EFalse;
-    }
-
-void CSavedQuery::RunL()
-    {
-    iVisible = EFalse;
-    }
-
-void CSavedQuery::DisplayWithGraphicsL(const TDesC &aText, TBool aDisplayErrorNote)
-    {
-    if (aDisplayErrorNote)
-        {
-        iGlobalConfirmationQuery->ShowConfirmationQueryL
-            (iStatus, aText, R_AVKON_SOFTKEYS_EMPTY, R_QGN_NOTE_ERROR_ANIM,
-            KNullDesC, 0, 0, CAknQueryDialog::EErrorTone, ETrue);
-        }
-    else
-        {
-        iGlobalConfirmationQuery->ShowConfirmationQueryL
-            (iStatus, aText, R_AVKON_SOFTKEYS_EMPTY, R_QGN_NOTE_OK_ANIM,
-            KNullDesC, 0, 0, CAknQueryDialog::EConfirmationTone, ETrue);
-        }
-    }
-
-void CSavedQuery::DisplayWithoutGraphicsL(const TDesC &aText)
-    {
-	iGlobalConfirmationQuery->ShowConfirmationQueryL
-        (iStatus, aText, R_AVKON_SOFTKEYS_OK_EMPTY);
-    }
-
-/*************************************************************************************************/
--- a/screengrabber/src/SGSettingListContainer.cpp	Fri Apr 16 14:59:17 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,318 +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 FILES
-#include "SGSettingListContainer.h"
-#include <screengrabber.rsg>
-#include "SG.hrh"
-#include "SGDocument.h"
-
-
-#ifdef SCREENGRABBER_MULTIDRIVE_SUPPORT
-  #include <CAknMemorySelectionSettingItemMultiDrive.h>
-#else
-  #include <CAknMemorySelectionSettingItem.h>
-#endif
-
-#include <eikappui.h>
-#include <akntitle.h>
-#include <eikspane.h> 
-
-#include <AknDef.h>
-
-
-// ================= MEMBER FUNCTIONS =======================
-
-// ---------------------------------------------------------
-// CScreenGrabberSettingListContainer::ConstructL(const TRect& aRect)
-// EPOC two phased constructor
-// ---------------------------------------------------------
-//
-void CScreenGrabberSettingListContainer::ConstructL(const TRect& aRect)
-    {
-    CreateWindowL();
-    
-    // set title of the app
-    CEikStatusPane* statusPane = iEikonEnv->AppUiFactory()->StatusPane();
-    CAknTitlePane* title = static_cast<CAknTitlePane*>( statusPane->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) );
-    title->SetTextL( _L("Settings") );
-
-    // get an instance of the engine
-    iModel = static_cast<CScreenGrabberDocument*>(reinterpret_cast<CEikAppUi*>(iEikonEnv->AppUi())->Document())->Model();
-
-    // get the settings from the engine
-    iGrabSettings = iModel->GrabSettings();
-
-    // construct the settings list from resources
-    ConstructFromResourceL(R_SCREENGRABBER_SETTINGLIST);
-    
-    // set visibilities
-    SetVisibilitiesOfSettingItems();
-
-    // set correct drawing area for the listbox
-    SetRect(aRect);
-    HandleResourceChange(KEikDynamicLayoutVariantSwitch);
-
-    ActivateL();
-    }
-
-
-// Destructor
-CScreenGrabberSettingListContainer::~CScreenGrabberSettingListContainer()
-    {
-    }
-
-
-// ---------------------------------------------------------
-// CScreenGrabberSettingListView::CreateSettingItemL( TInt aIdentifier )
-// ---------------------------------------------------------
-//
-CAknSettingItem* CScreenGrabberSettingListContainer::CreateSettingItemL( TInt aIdentifier )
-    {
-    CAknSettingItem* settingItem = NULL;
-
-    switch (aIdentifier)
-        {
-        case ESettingListCaptureModeSelection:
-            settingItem = new(ELeave) CAknEnumeratedTextPopupSettingItem(aIdentifier, iGrabSettings.iCaptureMode);
-            break;
-      
-            
-        case ESettingListSingleCaptureHotkeySelection:
-            settingItem = new(ELeave) CAknEnumeratedTextPopupSettingItem(aIdentifier, iGrabSettings.iSingleCaptureHotkey);
-            break;
-        
-        case ESettingListSingleCaptureImageFormatSelection:
-            settingItem = new(ELeave) CAknEnumeratedTextPopupSettingItem(aIdentifier, iGrabSettings.iSingleCaptureImageFormat);
-            break;
-        
-        case ESettingListSingleCaptureMemorySelection:
-#ifdef SCREENGRABBER_MULTIDRIVE_SUPPORT
-            settingItem = new(ELeave) CAknMemorySelectionSettingItemMultiDrive(aIdentifier, iGrabSettings.iSingleCaptureMemoryInUseMultiDrive);
-#else
-            settingItem = new(ELeave) CAknMemorySelectionSettingItem(aIdentifier, iGrabSettings.iSingleCaptureMemoryInUse);
-#endif
-            break;
-
-        case ESettingListSingleCaptureFileNameSelection:
-            settingItem = new(ELeave) CAknTextSettingItem(aIdentifier, iGrabSettings.iSingleCaptureFileName);
-            break;
-
-
-        case ESettingListSequantialCaptureHotkeySelection:
-            settingItem = new(ELeave) CAknEnumeratedTextPopupSettingItem(aIdentifier, iGrabSettings.iSequantialCaptureHotkey);
-            break;
-        
-        case ESettingListSequantialCaptureImageFormatSelection:
-            settingItem = new(ELeave) CAknEnumeratedTextPopupSettingItem(aIdentifier, iGrabSettings.iSequantialCaptureImageFormat);
-            break;
-
-        case ESettingListSequantialCaptureDelaySelection:
-            settingItem = new(ELeave) CAknIntegerEdwinSettingItem(aIdentifier, iGrabSettings.iSequantialCaptureDelay);
-            break;
-                    
-        case ESettingListSequantialCaptureMemorySelection:
-#ifdef SCREENGRABBER_MULTIDRIVE_SUPPORT
-            settingItem = new(ELeave) CAknMemorySelectionSettingItemMultiDrive(aIdentifier, iGrabSettings.iSequantialCaptureMemoryInUseMultiDrive);
-#else
-            settingItem = new(ELeave) CAknMemorySelectionSettingItem(aIdentifier, iGrabSettings.iSequantialCaptureMemoryInUse);
-#endif
-            break;
-
-        case ESettingListSequantialCaptureFileNameSelection:
-            settingItem = new(ELeave) CAknTextSettingItem(aIdentifier, iGrabSettings.iSequantialCaptureFileName);
-            break;
-
-
-        case ESettingListVideoCaptureHotkeySelection:
-            settingItem = new(ELeave) CAknEnumeratedTextPopupSettingItem(aIdentifier, iGrabSettings.iVideoCaptureHotkey);
-            break;
-        
-        case ESettingListVideoCaptureVideoFormatSelection:
-            settingItem = new(ELeave) CAknEnumeratedTextPopupSettingItem(aIdentifier, iGrabSettings.iVideoCaptureVideoFormat);
-            break;
-        
-        case ESettingListVideoCaptureMemorySelection:
-#ifdef SCREENGRABBER_MULTIDRIVE_SUPPORT
-            settingItem = new(ELeave) CAknMemorySelectionSettingItemMultiDrive(aIdentifier, iGrabSettings.iVideoCaptureMemoryInUseMultiDrive);
-#else
-            settingItem = new(ELeave) CAknMemorySelectionSettingItem(aIdentifier, iGrabSettings.iVideoCaptureMemoryInUse);
-#endif
-            break;
-
-        case ESettingListVideoCaptureFileNameSelection:
-            settingItem = new(ELeave) CAknTextSettingItem(aIdentifier, iGrabSettings.iVideoCaptureFileName);
-            break;
-
-        }
-
-    return settingItem;
-    }
-
-
-// ---------------------------------------------------------
-// CScreenGrabberSettingListView::UpdateSettings()
-// ---------------------------------------------------------
-//
-void CScreenGrabberSettingListContainer::UpdateSettingsL()
-    {
-    // get the modified settings to our own variables
-    StoreSettingsL();  // from CAknSettingItemList
-
-    // store new settings in engine and save the settings in disk
-    TRAP_IGNORE(iModel->SaveSettingsL(iGrabSettings));
-    
-    // Change the keys used for capturing
-    iModel->ActivateCaptureKeysL(ETrue);
-    }
-
-
-// ---------------------------------------------------------
-// CScreenGrabberSettingListView::HandleListBoxEventL(CEikListBox* aListBox, TListBoxEvent aEventType)
-// ---------------------------------------------------------
-//
-void CScreenGrabberSettingListContainer::HandleListBoxEventL(CEikListBox* /*aListBox*/, TListBoxEvent aEventType)
-    {
-    switch (aEventType) 
-        {
-        case EEventEnterKeyPressed:
-        case EEventItemDoubleClicked:
-            ShowSettingPageL(EFalse);
-            break;
-        default:
-            break;
-        }
-    }
-
-// ---------------------------------------------------------
-// CScreenGrabberSettingListView::ShowSettingPageL(TInt aCalledFromMenu)
-// ---------------------------------------------------------
-//
-void CScreenGrabberSettingListContainer::ShowSettingPageL(TInt aCalledFromMenu) 
-    {
-    // open the setting page
-    TInt listIndex = ListBox()->CurrentItemIndex();
-    TInt realIndex = SettingItemArray()->ItemIndexFromVisibleIndex(listIndex);
-    EditItemL(realIndex, aCalledFromMenu);
-
-    // update and save the settings
-    UpdateSettingsL();
-    
-    // set visibilities
-    SetVisibilitiesOfSettingItems();
-
-    // refresh the screen 
-    DrawNow();
-    }
-
-// ---------------------------------------------------------
-// CScreenGrabberSettingListContainer::SetVisibilitiesOfSettingItems()
-// ---------------------------------------------------------
-//
-void CScreenGrabberSettingListContainer::SetVisibilitiesOfSettingItems() 
-    {
-
-    switch (iGrabSettings.iCaptureMode)
-        {
-        case ECaptureModeSingleCapture:
-            {
-            ((*SettingItemArray())[ESettingListSingleCaptureHotkeySelection])->SetHidden(EFalse);
-            ((*SettingItemArray())[ESettingListSingleCaptureImageFormatSelection])->SetHidden(EFalse);
-            ((*SettingItemArray())[ESettingListSingleCaptureMemorySelection])->SetHidden(EFalse);
-            ((*SettingItemArray())[ESettingListSingleCaptureFileNameSelection])->SetHidden(EFalse);
-            ((*SettingItemArray())[ESettingListSequantialCaptureHotkeySelection])->SetHidden(ETrue);
-            ((*SettingItemArray())[ESettingListSequantialCaptureImageFormatSelection])->SetHidden(ETrue);
-            ((*SettingItemArray())[ESettingListSequantialCaptureDelaySelection])->SetHidden(ETrue);
-            ((*SettingItemArray())[ESettingListSequantialCaptureMemorySelection])->SetHidden(ETrue);
-            ((*SettingItemArray())[ESettingListSequantialCaptureFileNameSelection])->SetHidden(ETrue);
-            ((*SettingItemArray())[ESettingListVideoCaptureHotkeySelection])->SetHidden(ETrue);
-            ((*SettingItemArray())[ESettingListVideoCaptureVideoFormatSelection])->SetHidden(ETrue);
-            ((*SettingItemArray())[ESettingListVideoCaptureMemorySelection])->SetHidden(ETrue);
-            ((*SettingItemArray())[ESettingListVideoCaptureFileNameSelection])->SetHidden(ETrue);
-            }
-            break;
-        
-        case ECaptureModeSequantialCapture:
-            {
-            ((*SettingItemArray())[ESettingListSingleCaptureHotkeySelection])->SetHidden(ETrue);
-            ((*SettingItemArray())[ESettingListSingleCaptureImageFormatSelection])->SetHidden(ETrue);
-            ((*SettingItemArray())[ESettingListSingleCaptureMemorySelection])->SetHidden(ETrue);
-            ((*SettingItemArray())[ESettingListSingleCaptureFileNameSelection])->SetHidden(ETrue);
-            ((*SettingItemArray())[ESettingListSequantialCaptureHotkeySelection])->SetHidden(EFalse);
-            ((*SettingItemArray())[ESettingListSequantialCaptureImageFormatSelection])->SetHidden(EFalse);
-            ((*SettingItemArray())[ESettingListSequantialCaptureDelaySelection])->SetHidden(EFalse);
-            ((*SettingItemArray())[ESettingListSequantialCaptureMemorySelection])->SetHidden(EFalse);
-            ((*SettingItemArray())[ESettingListSequantialCaptureFileNameSelection])->SetHidden(EFalse);
-            ((*SettingItemArray())[ESettingListVideoCaptureHotkeySelection])->SetHidden(ETrue);
-            ((*SettingItemArray())[ESettingListVideoCaptureVideoFormatSelection])->SetHidden(ETrue);
-            ((*SettingItemArray())[ESettingListVideoCaptureMemorySelection])->SetHidden(ETrue);
-            ((*SettingItemArray())[ESettingListVideoCaptureFileNameSelection])->SetHidden(ETrue);
-            }
-            break;            
-
-        case ECaptureModeVideoCapture:
-            {
-            ((*SettingItemArray())[ESettingListSingleCaptureHotkeySelection])->SetHidden(ETrue);
-            ((*SettingItemArray())[ESettingListSingleCaptureImageFormatSelection])->SetHidden(ETrue);
-            ((*SettingItemArray())[ESettingListSingleCaptureMemorySelection])->SetHidden(ETrue);
-            ((*SettingItemArray())[ESettingListSingleCaptureFileNameSelection])->SetHidden(ETrue);
-            ((*SettingItemArray())[ESettingListSequantialCaptureHotkeySelection])->SetHidden(ETrue);
-            ((*SettingItemArray())[ESettingListSequantialCaptureImageFormatSelection])->SetHidden(ETrue);
-            ((*SettingItemArray())[ESettingListSequantialCaptureDelaySelection])->SetHidden(ETrue);
-            ((*SettingItemArray())[ESettingListSequantialCaptureMemorySelection])->SetHidden(ETrue);
-            ((*SettingItemArray())[ESettingListSequantialCaptureFileNameSelection])->SetHidden(ETrue);
-            ((*SettingItemArray())[ESettingListVideoCaptureHotkeySelection])->SetHidden(EFalse);
-            ((*SettingItemArray())[ESettingListVideoCaptureVideoFormatSelection])->SetHidden(EFalse);
-            ((*SettingItemArray())[ESettingListVideoCaptureMemorySelection])->SetHidden(EFalse);
-            ((*SettingItemArray())[ESettingListVideoCaptureFileNameSelection])->SetHidden(EFalse);
-            }
-            break;             
-
-        default:
-            User::Panic(_L("Inv.capt.mode"), 50);
-            break;
-        }
-        
-    HandleChangeInItemArrayOrVisibilityL(); 
-    }
-
-// ---------------------------------------------------------
-// CScreenGrabberSettingListView::HandleResourceChange(TInt aType)
-// ---------------------------------------------------------
-//
-void CScreenGrabberSettingListContainer::HandleResourceChange(TInt aType)
-    {
-    if ( aType == KEikDynamicLayoutVariantSwitch )
-        {
-        TRect mainPaneRect;
-        AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, mainPaneRect);
-        SetRect(mainPaneRect);
-
-        TSize outputRectSize;
-        AknLayoutUtils::LayoutMetricsSize(AknLayoutUtils::EMainPane, outputRectSize);
-        TRect outputRect(outputRectSize);
-        ListBox()->SetRect(outputRect);
-        }
-    else
-        {
-        CCoeControl::HandleResourceChange(aType);
-        }
-    }
-
-// End of File  
--- a/screengrabber/src/SGSettingListView.cpp	Fri Apr 16 14:59:17 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,155 +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 FILES
-#include  <aknViewAppUi.h>
-#include  <avkon.hrh>
-#include  <screengrabber.rsg>
-#include  "SGSettingListView.h"
-#include  "SGSettingListContainer.h"
-#include  "SGMainView.h"
-#include  "SG.hrh"
- 
-
-// ================= MEMBER FUNCTIONS =======================
-
-// ---------------------------------------------------------
-// CScreenGrabberSettingListView::ConstructL(const TRect& aRect)
-// EPOC two-phased constructor
-// ---------------------------------------------------------
-//
-void CScreenGrabberSettingListView::ConstructL()
-    {
-    BaseConstructL( R_SCREENGRABBER_VIEW2 );
-    }
-
-// ---------------------------------------------------------
-// CScreenGrabberSettingListView::~CScreenGrabberSettingListView()
-// ?implementation_description
-// ---------------------------------------------------------
-//
-CScreenGrabberSettingListView::~CScreenGrabberSettingListView()
-    {
-    if ( iContainer )
-        {
-        AppUi()->RemoveFromViewStack( *this, iContainer );
-        }
-
-    delete iContainer;
-    }
-
-// ---------------------------------------------------------
-// TUid CScreenGrabberSettingListView::Id()
-// ?implementation_description
-// ---------------------------------------------------------
-//
-TUid CScreenGrabberSettingListView::Id() const
-    {
-    return KSettingListViewUID;
-    }
-
-// ---------------------------------------------------------
-// CScreenGrabberSettingListView::HandleCommandL(TInt aCommand)
-// ?implementation_description
-// ---------------------------------------------------------
-//
-void CScreenGrabberSettingListView::HandleCommandL(TInt aCommand)
-    {   
-    switch ( aCommand )
-        {
-        case EScreenGrabberCmdSettingsExit:
-            {
-            // exit the application
-            AppUi()->HandleCommandL( EAknCmdExit );
-
-            break;
-            }
-
-        case EScreenGrabberCmdSettingsBack:
-            {
-            // switch back to the main view
-            AppUi()->ActivateLocalViewL( KMainViewUID );
-
-            break;
-            }
-
-        case EScreenGrabberCmdSettingsChange:
-            {
-            // show the setting page
-            iContainer->ShowSettingPageL(ETrue);
-
-            break;
-            }
-
-        default:
-            {
-            AppUi()->HandleCommandL( aCommand );
-            break;
-            }
-        }
-    }
-
-// ---------------------------------------------------------
-// CScreenGrabberSettingListView::HandleClientRectChange()
-// ---------------------------------------------------------
-//
-void CScreenGrabberSettingListView::HandleClientRectChange()
-    {
-    if ( iContainer )
-        {
-        iContainer->SetRect( ClientRect() );
-        }
-    }
-
-// ---------------------------------------------------------
-// CScreenGrabberSettingListView::DoActivateL(...)
-// ?implementation_description
-// ---------------------------------------------------------
-//
-void CScreenGrabberSettingListView::DoActivateL(
-   const TVwsViewId& /*aPrevViewId*/,TUid /*aCustomMessageId*/,
-   const TDesC8& /*aCustomMessage*/)
-    {
-    if (!iContainer)
-        {
-        iContainer = new (ELeave) CScreenGrabberSettingListContainer;
-        iContainer->SetMopParent(this);
-        iContainer->ConstructL( ClientRect() );
-        AppUi()->AddToStackL( *this, iContainer );
-        }
-   }
-
-// ---------------------------------------------------------
-// CScreenGrabberSettingListView::HandleCommandL(TInt aCommand)
-// ?implementation_description
-// ---------------------------------------------------------
-//
-void CScreenGrabberSettingListView::DoDeactivate()
-    {
-    if ( iContainer )
-        {
-        AppUi()->RemoveFromViewStack( *this, iContainer );
-        }
-    
-    delete iContainer;
-    iContainer = NULL;
-    }
-
-// End of File
-
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/screengrabber/src/application.cpp	Mon May 03 12:32:02 2010 +0300
@@ -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: 
+*
+*/
+#include <eikenv.h>
+#include "application.h"
+#include "enginewrapper.h"
+
+#define KEY_CAPTURE_PRIORITY 100
+
+SGApplication::SGApplication(int argc, char *argv[])  
+    : HbApplication(argc, argv) 
+     {
+	 
+	
+     }
+
+	 
+SGApplication::~SGApplication()  
+{
+		
+}	
+	 
+// ---------------------------------------------------------------------------
+
+#if defined(Q_WS_S60)
+#if defined(HB_QT_S60_EVENT_FILTER)
+bool SGApplication::s60EventFilter(TWsEvent *aEvent)
+#else
+bool SGApplication::symbianEventFilter(const QSymbianEvent *aEvent)
+#endif // (HB_QT_S60_EVENT_FILTER)
+{
+    // pass event to engine, if engine returns true(event was not handled),
+    // forward it.
+    if(!iEngine->handleCaptureCommands(aEvent)) 
+        {
+        return false;
+        }
+    else
+        {
+#if defined(HB_QT_S60_EVENT_FILTER)
+        return HbApplication::s60EventFilter(aEvent);
+#else
+		return HbApplication::symbianEventFilter(aEvent);
+#endif		
+        }
+    
+    }
+#endif
+
+// ---------------------------------------------------------------------------
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/screengrabber/src/enginewrapper.cpp	Mon May 03 12:32:02 2010 +0300
@@ -0,0 +1,250 @@
+/*
+* 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 <eikenv.h>
+#include <APGTASK.H>
+#include <hbdeviceprogressdialog.h>
+#include "enginewrapper.h"
+
+#include "settingsview.h"
+#include "sgengine.h"
+#include "mainview.h"
+#include "notifications.h"
+
+
+// ---------------------------------------------------------------------------
+
+EngineWrapper::EngineWrapper()
+: iSGEngine(0), iProgressNote(0)
+{
+}
+
+// ---------------------------------------------------------------------------
+
+EngineWrapper::~EngineWrapper()
+{
+    if (iSGEngine) {
+        iSGEngine->DeActivateModelL();
+        delete iSGEngine;
+    }
+    if(iProgressNote){
+        delete iProgressNote;
+    }
+}
+
+// ---------------------------------------------------------------------------
+
+bool EngineWrapper::init()
+{
+    TRAPD(error, iSGEngine = SGEngine::NewL(this));
+	
+    
+    if (error == KErrNone) {
+        TRAP(error, iSGEngine->ActivateModelL());
+    }
+    
+    if (error != KErrNone) {
+        return false;
+    }
+    else {
+        return true;
+    }
+	
+}
+
+// ---------------------------------------------------------------------------
+
+GrabSettings EngineWrapper::getGrabSettings()
+{
+    TGrabSettings tSettings = iSGEngine->GrabSettings();
+    GrabSettings settings;
+    
+    // Convert TGrabSettings to GrabSettings
+    settings.mCaptureMode = tSettings.iCaptureMode;
+    
+    // Single image settings
+    settings.mSingleCaptureHotkey = tSettings.iSingleCaptureHotkey;
+    settings.mSingleCaptureImageFormat = tSettings.iSingleCaptureImageFormat;
+	settings.mSingleCaptureMemoryInUseMultiDrive = tSettings.iSingleCaptureMemoryInUseMultiDrive;
+    settings.mSingleCaptureFileName = QString((QChar*)tSettings.iSingleCaptureFileName.Ptr(),tSettings.iSingleCaptureFileName.Length());
+    
+    //Seguantial image settings
+    settings.mSequantialCaptureDelay = tSettings.iSequantialCaptureDelay;
+    settings.mSequantialCaptureHotkey = tSettings.iSequantialCaptureHotkey;
+    settings.mSequantialCaptureImageFormat = tSettings.iSequantialCaptureImageFormat;
+	settings.mSequantialCaptureMemoryInUseMultiDrive = tSettings.iSequantialCaptureMemoryInUseMultiDrive;
+    settings.mSequantialCaptureDelay = tSettings.iSequantialCaptureDelay;
+    //convert TFilename to QString
+    settings.mSequantialCaptureFileName = QString((QChar*)tSettings.iSequantialCaptureFileName.Ptr(),tSettings.iSequantialCaptureFileName.Length());
+    
+    
+    // Video settings
+    settings.mVideoCaptureHotkey = tSettings.iVideoCaptureHotkey;
+    settings.mVideoCaptureVideoFormat = tSettings.iVideoCaptureVideoFormat;
+	settings.mVideoCaptureMemoryInUseMultiDrive = tSettings.iVideoCaptureMemoryInUseMultiDrive;
+    //convert TFilename to QString
+    settings.mVideoCaptureFileName = QString((QChar*)tSettings.iVideoCaptureFileName.Ptr(),tSettings.iVideoCaptureFileName.Length());
+    
+    return settings;
+}
+
+// ---------------------------------------------------------------------------
+
+bool EngineWrapper::saveSettings(const GrabSettings& settings)
+{
+    TGrabSettings tSettings;
+    // Convert GrabSettings to TGrabSettings
+    tSettings.iCaptureMode = settings.mCaptureMode;
+    
+    tSettings.iSingleCaptureHotkey = settings.mSingleCaptureHotkey;
+    tSettings.iSingleCaptureImageFormat = settings.mSingleCaptureImageFormat;
+    tSettings.iSingleCaptureMemoryInUseMultiDrive = settings.mSingleCaptureMemoryInUseMultiDrive;
+    //convert TFilename to QString
+    tSettings.iSingleCaptureFileName = TFileName(settings.mSingleCaptureFileName.utf16());
+    tSettings.iSequantialCaptureDelay = settings.mSequantialCaptureDelay;
+    tSettings.iSequantialCaptureHotkey = settings.mSequantialCaptureHotkey;
+    tSettings.iSequantialCaptureImageFormat = settings.mSequantialCaptureImageFormat;
+    tSettings.iSequantialCaptureMemoryInUseMultiDrive = settings.mSequantialCaptureMemoryInUseMultiDrive; 
+    tSettings.iSequantialCaptureDelay = settings.mSequantialCaptureDelay;
+    //convert TFilename to QString
+    tSettings.iSequantialCaptureFileName = TFileName(settings.mSequantialCaptureFileName.utf16());
+    
+    tSettings.iVideoCaptureHotkey = settings.mVideoCaptureHotkey;
+    tSettings.iVideoCaptureVideoFormat = settings.mVideoCaptureVideoFormat;
+    tSettings.iVideoCaptureMemoryInUseMultiDrive = settings.mVideoCaptureMemoryInUseMultiDrive; 
+    //convert TFilename to QString
+    tSettings.iVideoCaptureFileName = TFileName(settings.mVideoCaptureFileName.utf16());
+    TRAPD(error, iSGEngine->SaveSettingsL(tSettings));
+    
+    if (error == KErrNone) {
+        TRAP(error, iSGEngine->ActivateCaptureKeysL(true));
+    }
+    
+    if (error == KErrNone) {
+        return true;
+    }
+    else {
+        return false;
+    }
+    
+    
+}
+
+// ---------------------------------------------------------------------------
+
+
+void EngineWrapper::ShowImageCapturedNote()
+{
+    Notifications::imageCaptured();
+}
+
+// ---------------------------------------------------------------------------
+
+void EngineWrapper::ShowErrorMessage(const TDesC16& aErrorMessage)
+{
+    QString errorMessage((QChar*)aErrorMessage.Ptr(),aErrorMessage.Length());
+    Notifications::error(errorMessage);
+ 
+}
+
+// ---------------------------------------------------------------------------
+
+void EngineWrapper::sendUIToBackground()
+{
+    CCoeEnv* coeEnv = CCoeEnv::Static();
+    TApaTask selfTask(coeEnv->WsSession());
+    selfTask.SetWgId(coeEnv->RootWin().Identifier());
+    selfTask.SendToBackground();
+}
+
+// ---------------------------------------------------------------------------
+
+
+#if defined(HB_QT_S60_EVENT_FILTER)
+bool EngineWrapper::handleCaptureCommands(const TWsEvent* aEvent)
+#else
+bool EngineWrapper::handleCaptureCommands(const QSymbianEvent *aEvent)
+#endif
+{
+    TBool retVal = ETrue;
+    TRAPD(errorCode, retVal = iSGEngine->HandleCaptureCommandsL(aEvent));
+    if (errorCode != KErrNone) {
+        Notifications::error("Error occured when capturing screen.");
+    }
+    
+    return convertTBoolToBool(retVal);
+    
+}
+
+// ---------------------------------------------------------------------------
+
+bool EngineWrapper::convertTBoolToBool(TBool value)
+{
+    if (value) {
+        return true;
+    }
+    else {
+        return false;
+    }
+}
+
+// ---------------------------------------------------------------------------
+
+void EngineWrapper::ShowSequantialImagesCapturedNote(TInt amount)
+{
+    Notifications::sequantialImagesCaptured(amount);
+}
+
+// ---------------------------------------------------------------------------
+
+void EngineWrapper::ShowVideoCapturedNote()
+{
+    Notifications::videoCaptured();
+}
+
+// ---------------------------------------------------------------------------
+
+void EngineWrapper::ShowProgressBar(int max)
+{
+    iProgressNote = Notifications::showProgressBar(max);
+}
+
+// ---------------------------------------------------------------------------
+
+void EngineWrapper::IncrementProgressbarValue()
+{
+    iProgressNote->setProgressValue(iProgressNote->progressValue() + 1);
+}
+
+// ---------------------------------------------------------------------------
+
+void EngineWrapper::CloseProgressbar()
+{
+    delete iProgressNote;
+    iProgressNote = 0;
+}
+
+void EngineWrapper::EnableRcpOfFoc(TBool aState)
+{
+    iSGEngine->EnableRcpOfFoc(aState);
+}
+
+void EngineWrapper::LoadSettings(void)
+{
+	iSGEngine->LoadSettingsL();
+}
+
+// ---------------------------------------------------------------------------
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/screengrabber/src/gifanimator.cpp	Mon May 03 12:32:02 2010 +0300
@@ -0,0 +1,308 @@
+/*
+* 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 "gifanimator.h"
+
+#include <S32FILE.H>
+#include <FBS.H>
+#include <GDI.H>
+#include <ImageConversion.h>
+#include "enginewrapper.h"
+
+    
+// ---------------------------------------------------------------------------
+
+TInt CGifAnimator::CreateGifAnimation(const TDesC& aFileName, TSize aDimensions, CVideoFrameArray* aVideoFrameArray, EngineWrapper& aEngineWrapper)
+    {
+	CGifAnimator* self = new(ELeave) CGifAnimator;
+	CleanupStack::PushL(self);
+	TRAPD(err, self->StartL(aFileName, aDimensions, aVideoFrameArray, aEngineWrapper));
+	CleanupStack::PopAndDestroy();
+	return err;
+    }
+
+// ---------------------------------------------------------------------------
+
+CGifAnimator::CGifAnimator()   
+    {
+    }
+
+// ---------------------------------------------------------------------------
+
+void CGifAnimator::StartL(const TDesC& aFileName, const TSize& aDimensions, CVideoFrameArray* aVideoFrameArray, EngineWrapper& aEngineWrapper)
+    {
+    
+    __ASSERT_ALWAYS(aFileName.Length() > 0, User::Panic(_L("GifAnim"), 100));
+    __ASSERT_ALWAYS(aDimensions.iHeight > 0, User::Panic(_L("GifAnim"), 101));
+    __ASSERT_ALWAYS(aDimensions.iWidth > 0, User::Panic(_L("GifAnim"), 102));
+    __ASSERT_ALWAYS(aVideoFrameArray != NULL, User::Panic(_L("GifAnim"), 103));
+    
+    
+    // show a progress dialog
+    aEngineWrapper.ShowProgressBar(aVideoFrameArray->Count()-1);
+    
+    // open the file for writing
+    User::LeaveIfError(iFs.Connect());
+    User::LeaveIfError(iOutFile.Replace(iFs, aFileName, EFileWrite));
+    
+    // write header
+    WriteHeaderL(aDimensions);
+    
+    // process each frame of the animation
+    for (TInt i=0; i<aVideoFrameArray->Count(); i++)
+        {
+        // write headers and raster block
+        TVideoFrame frame = aVideoFrameArray->At(i);
+        WriteGraphicControlL(frame);
+        CFbsBitmap* bitmap = GetBitmapLC(frame, aDimensions);
+        WriteImageDescriptorL(frame);
+        WriteRasterDataL(bitmap);
+        CleanupStack::PopAndDestroy(); //bitmap
+
+        // update the progress bar
+        aEngineWrapper.IncrementProgressbarValue();
+        }
+
+    // write footer and finish
+    WriteFooterL();
+    FinishL();
+    
+    // remove the progress dialog from the screen
+    aEngineWrapper.CloseProgressbar();
+    }    
+
+// ---------------------------------------------------------------------------
+
+CGifAnimator::~CGifAnimator()
+    {
+    
+    if (iImageEncoder)
+        delete iImageEncoder;
+    
+    if (iGIFImageData)
+        delete iGIFImageData;
+    
+    }
+
+// ---------------------------------------------------------------------------
+
+void CGifAnimator::WriteHeaderL(const TSize& aDimensions)
+    {
+    WriteInt8L('G');
+    WriteInt8L('I');
+    WriteInt8L('F');
+    WriteInt8L('8');
+    WriteInt8L('9');
+    WriteInt8L('a');
+
+    WriteInt16L(aDimensions.iWidth);  // width of animation
+    WriteInt16L(aDimensions.iHeight); // height of animation
+    
+    // logical screen descriptor
+    TUint8 packedFlags = 0;
+	packedFlags |= 8 - 1; // size of colour table is number of bits in each color table minus one (bits 0-2)
+	packedFlags |= (8 - 1) << 4; // colour resolution ie maximum size of the original colour palette (bits 4-6)
+	packedFlags |= 0x80; // use global colour table (bit 7)
+    
+    WriteInt8L(packedFlags);
+    
+    WriteInt8L(TRANSPARENCY_INDEX); // background color index
+    
+    WriteInt8L(0); // pixel aspect ratio, 0=not used
+    
+    // write the Symbian default palette since that's what is used
+    CPalette* palette = CPalette::NewDefaultL(EColor256);
+    CleanupStack::PushL(palette);
+    
+    for (TInt i=0; i<palette->Entries(); i++)
+        {
+        TRgb entry = palette->GetEntry(i);
+
+        WriteInt8L(entry.Red());
+        WriteInt8L(entry.Green());
+        WriteInt8L(entry.Blue());
+        }
+    
+    CleanupStack::PopAndDestroy(); //palette
+    }
+
+// ---------------------------------------------------------------------------
+
+void CGifAnimator::WriteGraphicControlL(const TVideoFrame& aFrame)
+    {
+    TInt packedFlags(0);
+    
+    // enable transparency if needed
+    if (aFrame.iEnableTransparency)
+        packedFlags |= 0x01; 
+
+    // set disposal method:
+    // 0 = disposal method not specified, 1 = do not dispose of graphic,
+    // 2 = overwrite graphic with background color, 3 = overwrite graphic with previous graphic
+    TInt disposalMethod = 1;
+    packedFlags |= ((disposalMethod << 2) & 0x1c);
+    
+    WriteInt8L(0x21); // GIF extension
+    WriteInt8L(0xf9); // GIF graphic control block
+    WriteInt8L(0x04); // block size
+    WriteInt8L(packedFlags); // packed
+    WriteInt16L(aFrame.iDelay); // delay
+    WriteInt8L(TRANSPARENCY_INDEX); // transparent color index
+    WriteInt8L(0); // block terminator, always 0
+    }
+
+// ---------------------------------------------------------------------------
+
+void CGifAnimator::WriteImageDescriptorL(const TVideoFrame& aFrame)
+    {
+    WriteInt8L(0x2c); // GIF image descriptor
+    WriteInt16L(aFrame.iXPos);
+    WriteInt16L(aFrame.iYPos);
+    WriteInt16L(aFrame.iWidth);
+    WriteInt16L(aFrame.iHeight);
+    WriteInt8L(0); // packed flags, none specified in this case
+    }
+    
+// ---------------------------------------------------------------------------
+
+CFbsBitmap* CGifAnimator::GetBitmapLC(TVideoFrame& aFrame, const TSize& aDimensions)
+    {
+    CFbsBitmap* bitmap = new(ELeave) CFbsBitmap;
+    CleanupStack::PushL(bitmap);
+    
+    // read the bitmap from the temporary file
+    RFile bitmapFile;
+    User::LeaveIfError( bitmapFile.Open(iFs, aFrame.iFileStorePath, EFileRead) );
+    RFileReadStream readStream(bitmapFile);
+    bitmap->InternalizeL(readStream);
+    readStream.Close();
+    bitmapFile.Close();
+
+    // delete the temporary file since it's not needed anymore
+    iFs.Delete(aFrame.iFileStorePath);
+    
+    // resize the bitmap to match the video dimensions if it is a full screen one
+    if (aFrame.iFillsWholeScreen && (aFrame.iWidth != aDimensions.iWidth || aFrame.iHeight != aDimensions.iHeight))
+        {
+        if (bitmap->Resize(aDimensions) == KErrNone)
+            {
+            // also update dimensions of this frame to match the dimensions of the video            
+            aFrame.iWidth = aDimensions.iWidth;
+            aFrame.iHeight = aDimensions.iHeight;
+            }
+        }
+    
+    return bitmap;
+    }
+    
+// ---------------------------------------------------------------------------
+
+void CGifAnimator::WriteRasterDataL(CFbsBitmap* aBitmap)
+    {
+    // reset the encoder
+    if (iImageEncoder)
+        {
+	    delete iImageEncoder;
+        iImageEncoder = NULL;
+        }
+    
+    // make sure the buffer for conversion is empty    
+    if (iGIFImageData)
+        {
+	    delete iGIFImageData;
+        iGIFImageData = NULL;
+        }        
+
+    
+    TRequestStatus Stat = KRequestPending;
+    
+    // init & convert the bitmap to GIF format
+    iImageEncoder = CImageEncoder::DataNewL(iGIFImageData, CImageEncoder::EOptionAlwaysThread, KImageTypeGIFUid);
+    iImageEncoder->Convert( &Stat, *aBitmap );
+    User::WaitForRequest(Stat);
+   
+   
+    // check any erros in converting 
+    User::LeaveIfError( Stat.Int() );
+    
+    // check if we have valid data
+    if (iGIFImageData == NULL || iGIFImageData->Des().Length()<793)
+        User::Leave(KErrNoMemory);
+    
+    // in GIF files generated by Symbian, the raster data always starts at offset 791,
+    // initial code size in GIF encoding should be 8 since we have a 8bpp image,
+    // also check that the second last byte is the terminator 0,
+    // if this check fails in newer releases of S60, proper parsing of GIF format is probably needed
+    TUint8* imagePtr = &iGIFImageData->Des()[0];
+    if (imagePtr[791] != 8 || imagePtr[iGIFImageData->Des().Length()-2] != 0)
+        User::Leave(KErrNotSupported);
+    
+    // write the raster data block to the file
+    TUint writeLength = iGIFImageData->Des().Length() - 1 - 791;
+    imagePtr+=791;
+    TPtr8 writePtr(imagePtr, writeLength, writeLength);
+    User::LeaveIfError( iOutFile.Write(writePtr) );
+    }
+
+// ---------------------------------------------------------------------------
+
+void CGifAnimator::WriteFooterL()
+    {
+    WriteInt8L(0x3b); // GIF trailer
+    }
+    
+// ---------------------------------------------------------------------------
+
+void CGifAnimator::FinishL()
+    {
+    iOutFile.Close();
+    iFs.Close();
+    }
+
+// ---------------------------------------------------------------------------
+
+void CGifAnimator::WriteInt8L(TInt aValue)
+    {
+    HBufC8* buf = HBufC8::NewMaxLC(1);
+
+    TUint8* ptr = &buf->Des()[0];
+    ptr[0] = TUint8(aValue);
+    
+    User::LeaveIfError( iOutFile.Write(buf->Des()) );
+    
+    CleanupStack::PopAndDestroy(); // buf
+    }
+
+// ---------------------------------------------------------------------------
+
+void CGifAnimator::WriteInt16L(TInt aValue)
+    {
+    HBufC8* buf = HBufC8::NewMaxLC(2);
+
+    TUint8* ptr = &buf->Des()[0];
+    ptr[0] = TUint8(aValue);
+    ptr[1] = TUint8(aValue>>8);
+        
+    User::LeaveIfError( iOutFile.Write(buf->Des()) );
+    
+    CleanupStack::PopAndDestroy(); // buf
+    }
+
+// ---------------------------------------------------------------------------
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/screengrabber/src/main.cpp	Mon May 03 12:32:02 2010 +0300
@@ -0,0 +1,68 @@
+/*
+* 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 <QtGui/QMessageBox>
+
+#include <hbmainwindow.h>
+#include <hbview.h>
+#include <hbmessagebox.h>
+#include <coecntrl.h>
+
+#include "mainview.h"
+#include "application.h"
+#include "enginewrapper.h"
+#include "settingsview.h"
+
+
+
+int main(int argc, char *argv[])
+{
+    
+    SGApplication app(argc, argv);
+	
+    EngineWrapper engineWrapper;
+	app.SetEngineWrapper(&engineWrapper);
+    if (!engineWrapper.init()) {
+      return EXIT_FAILURE;
+    }
+
+	
+	
+    HbMainWindow mainWindow;
+    
+    //Create main view
+    MainView* view = new MainView(mainWindow, engineWrapper);
+    //initialize main view
+    view->init(app);
+
+	
+    SettingsView* settingsView = new SettingsView(*view, mainWindow, engineWrapper);
+	
+	view->setSettingsView(settingsView);
+    
+	// Add Views to main window and reveal it.
+    mainWindow.addView(view);
+    mainWindow.addView(settingsView);
+
+    
+    mainWindow.show();
+     
+    int result = app.exec();
+   
+    return result;
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/screengrabber/src/mainview.cpp	Mon May 03 12:32:02 2010 +0300
@@ -0,0 +1,163 @@
+/*
+* 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 <hbview.h>
+#include <hbmainwindow.h>
+#include <hbapplication.h>
+#include <hblabel.h>
+#include <hbmenu.h>
+#include <hbaction.h>
+#include <hbtextedit.h>
+#include <hbmessagebox.h>
+#include <qgraphicslinearlayout.h>
+#include "enginewrapper.h"
+#include "settingsView.h"
+#include "mainview.h"
+#include "notifications.h"
+#include "hbtoolbar.h"
+
+// ---------------------------------------------------------------------------
+
+MainView::MainView(HbMainWindow &mainWindow, EngineWrapper &engineWrapper):
+    mMainWindow(mainWindow),
+    mSettingsView(0),
+    mEngineWrapper(engineWrapper)
+{
+}
+
+// ---------------------------------------------------------------------------
+
+MainView::~MainView()
+{
+}
+
+// ---------------------------------------------------------------------------
+
+void MainView::init(HbApplication &app)
+{
+    this->setTitle("Screen Grabber");
+    createMenu(app);
+    createInfoText();
+    createToolbar();
+
+}
+
+void MainView::createMenu(HbApplication& app)
+{
+    
+    HbMenu* menu = this->menu();
+   
+    if (menu != NULL) {
+    
+        actionSendToBg = menu->addAction("Send to background");
+        connect(actionSendToBg, SIGNAL( triggered() ), this, SLOT( sendToBackground() ) );
+        
+        actionSettings = menu->addAction("Settings");
+        connect(actionSettings, SIGNAL( triggered() ), this, SLOT( showSettings() ) );
+    
+        actionAbout = menu->addAction("About");
+        connect(actionAbout, SIGNAL( triggered() ), this, SLOT( showAboutPopup() ) );
+    
+        actionExit = menu->addAction("Exit");
+        connect(actionExit, SIGNAL(triggered()), this, SLOT( my_quit() ) );
+
+		HbAction *mDefaultNavigationAction = new HbAction(Hb::QuitNaviAction, this);
+		connect(mDefaultNavigationAction,SIGNAL(triggered()), this, SLOT(my_quit()));
+		setNavigationAction(mDefaultNavigationAction);
+        
+    	//setNavigationAction(actionExit);
+    }
+}
+
+
+
+void MainView::my_quit()
+    {
+	HbLabel label(" Exit Screen grabber confirm");
+	if (HbMessageBox::question("Do you really want to exit the Screen Grabber application?","yes","no",&label))
+		qApp->quit();   
+    }
+
+// ---------------------------------------------------------------------------
+
+void MainView::createInfoText()
+{
+    QGraphicsLinearLayout* layout = new QGraphicsLinearLayout(Qt::Vertical, this);
+    if (layout != NULL) {
+        HbTextEdit* edit = new HbTextEdit(this);
+        if(edit != NULL) {
+            edit->setPlainText("Please use the settings screen to define the "
+                               "capture mode and any other related settings "
+                               "such as capture hotkey and saving format. "
+                               "Using the PNG format for screen shots is "
+                               "recommended, since it is compressed but "
+                               "lossless. The captures can be managed with "
+                               "the Media Gallery application.\n\nYou may "
+                               "start taking screenshots or capturing video "
+                               "now. Please press the Applications key to go back "
+                               "to the Application menu or send this application "
+                               "to the background via the Options menu. To be "
+                               "able to take screenshots or capture video, this "
+                               "application needs to stay running in the "
+                               "background.");
+            edit->setReadOnly(true);
+            //TODO edit->setCursorHidden(true);
+            //TODO edit->setAttribute(Qt::WA_InputMethodEnabled, false);
+            layout->addItem(edit);
+            layout->setContentsMargins(5, 5, 5, 5);
+            this->setLayout(layout);
+        }
+        
+    }
+    
+}
+
+// ---------------------------------------------------------------------------
+
+void MainView::showSettings()
+{
+    mEngineWrapper.EnableRcpOfFoc(ETrue);
+	mEngineWrapper.LoadSettings();	
+	mSettingsView->loadSettings();
+	mMainWindow.setCurrentView(mSettingsView);
+}
+
+// ---------------------------------------------------------------------------
+
+void MainView::createToolbar()
+{
+    HbToolBar *toolbar = new HbToolBar(this); // main view takes the ownership
+    toolbar->addAction(actionSettings);
+    toolbar->addAction(actionSendToBg);
+    setToolBar(toolbar);
+}
+
+// ---------------------------------------------------------------------------
+
+void MainView::showAboutPopup()
+{
+    Notifications::about();
+}
+
+// ---------------------------------------------------------------------------
+
+void MainView::sendToBackground()
+    {
+    mEngineWrapper.sendUIToBackground();
+    }
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/screengrabber/src/notifications.cpp	Mon May 03 12:32:02 2010 +0300
@@ -0,0 +1,97 @@
+/*
+* 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 <hbdevicemessagebox.h>
+#include <hblabel.h>
+#include <hbdeviceprogressdialog.h>
+
+#include "notifications.h"
+
+
+
+// ---------------------------------------------------------------------------
+
+void Notifications::imageCaptured()
+{
+    showGlobalNote("Screen shot saved to Media Gallery", HbMessageBox::MessageTypeInformation);
+}
+
+// ---------------------------------------------------------------------------
+
+void Notifications::about()
+{
+
+  HbMessageBox dlg;
+    
+	dlg.setText("Version 5.0.0 - March 10th 2010. Copyright © 2010 Nokia Corporation and/or its subsidiary(-ies). All rights reserved. Licensed under Eclipse Public License v1.0.");
+    HbLabel header("About Screen Grabber");
+    dlg.setHeadingWidget(&header);
+	dlg.setTimeout(HbPopup::NoTimeout);
+    dlg.exec();
+}
+
+// ---------------------------------------------------------------------------
+
+void Notifications::error(const QString& errorMessage)
+{
+    showGlobalNote(errorMessage, HbMessageBox::MessageTypeWarning);
+
+}
+
+// ---------------------------------------------------------------------------
+
+void Notifications::sequantialImagesCaptured(int amount){
+    // Code below launches a global note
+    QString text;
+    text.setNum(amount, 10);
+    text.append(" screen shots saved to Media Gallery");
+    
+    showGlobalNote(text, HbMessageBox::MessageTypeInformation);
+ 
+}
+
+// ---------------------------------------------------------------------------
+
+void Notifications::videoCaptured()
+{
+    showGlobalNote("Video saved to Media Gallery", HbMessageBox::MessageTypeInformation);
+
+}
+
+// ---------------------------------------------------------------------------
+
+HbDeviceProgressDialog* Notifications::showProgressBar(int max)
+{
+    HbDeviceProgressDialog *note = new HbDeviceProgressDialog(HbProgressDialog::ProgressDialog);
+    note->setText("Saving...");
+    note->setMaximum(max);
+    note->show();
+    return note;
+}
+
+// ---------------------------------------------------------------------------
+
+void Notifications::showGlobalNote(const QString& text, HbMessageBox::MessageBoxType type)
+{
+    // Code below launches a global note
+
+	HbDeviceMessageBox note(text, type);
+	note.information(text);
+
+}
+
+// ---------------------------------------------------------------------------
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/screengrabber/src/settingsview.cpp	Mon May 03 12:32:02 2010 +0300
@@ -0,0 +1,351 @@
+/*
+* 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 <hbdataform.h>
+#include <hbdataformmodelitem.h>
+#include <hbdataformmodel.h>
+#include <hbdataformviewitem.h>
+#include <hbaction.h>
+#include <hbmenu.h>
+#include <hbtoolbar.h>
+#include <hbabstractviewitem.h>
+#include <hbaction.h>
+
+
+#include "settingsview.h"
+#include "enginewrapper.h"
+#include "sgengine.h"
+#include "hbslider.h"
+#include "notifications.h"
+
+
+
+// ---------------------------------------------------------------------------
+
+SettingsView::SettingsView(HbView &mainView, HbMainWindow &mainWindow, EngineWrapper &engineWrapper): 
+    mEngineWrapper(engineWrapper), 
+    mMainWindow(mainWindow), 
+    mMainView(mainView)
+{
+    // Set title and add this view to main window
+    setTitle("Settings");
+    
+    HbAction *actionSaveSettings = menu()->addAction(QString("Save & close"));
+    HbAction *actionCancel = menu()->addAction("Cancel & close");
+    
+    toolBar()->addAction(actionSaveSettings);
+    toolBar()->addAction(actionCancel);
+  
+    
+    //create setting form
+    mSettingForm = new HbDataForm();
+    
+    //create a model class
+    mModel = new HbDataFormModel(this);
+    
+    // DataFormItem for mode selection
+    mModeItem = mModel->appendDataFormItem(
+            HbDataFormModelItem::RadioButtonListItem, QString("Capture mode"), 0);
+    //setting the text property of check box.
+    mModeItem->setData(HbDataFormModelItem::KeyRole, QString("mode"));
+    mModeItem->setContentWidgetData(QString("items"), CAPTUREMODES);
+    
+    // Create setting model
+     createSingleCaptureComponents(mModel, 0);
+     createSequentialCaptureComponents(mModel, 0);
+     createVideoCaptureComponents(mModel, 0);
+ 
+    // Set created model model to form
+    mSettingForm->setModel(mModel);
+    setWidget(mSettingForm);//takes ownership
+    
+    // Get view item of mode selection item
+    HbDataFormViewItem *viewItemVideoPage = mSettingForm->dataFormViewItem(mModel->indexFromItem(mModeItem));
+
+    loadSettings();
+    
+    // Connect signals from item modifications and close with this form's slots
+   
+//    connect(viewItemVideoPage, SIGNAL(itemModified(QPersistentModelIndex, QVariant)), this, SLOT(updateShownItems()));
+    connect(actionSaveSettings, SIGNAL(triggered()), this, SLOT(saveAndClose()));
+    connect(actionCancel, SIGNAL(triggered()), this, SLOT(close()));
+	
+	HbAction *mDefaultNavigationAction = new HbAction(Hb::QuitNaviAction, this);
+	connect(mDefaultNavigationAction,SIGNAL(triggered()), this, SLOT(saveAndClose()));
+	setNavigationAction(mDefaultNavigationAction);
+	
+
+
+}
+
+
+// ---------------------------------------------------------------------------
+
+SettingsView::~SettingsView()
+{
+
+}
+
+// ---------------------------------------------------------------------------
+
+void SettingsView::loadSettings()
+{
+
+    // get settings from engine;
+    mSettings = mEngineWrapper.getGrabSettings();
+    
+    //Capture mode
+    mModeItem->setContentWidgetData("selected", mSettings.mCaptureMode);
+    
+    // Still image 
+    mImageHotKeyItem->setContentWidgetData("selected", mSettings.mSingleCaptureHotkey);
+    mImageFormatItem->setContentWidgetData("selected", mSettings.mSingleCaptureImageFormat);
+    mImageMemoryInUseItem->setContentWidgetData("selected", mSettings.mSingleCaptureMemoryInUseMultiDrive);
+    mImageFileNameItem->setContentWidgetData("text", mSettings.mSingleCaptureFileName);
+       
+    // Seguantial image components
+    mSequantialHotKeyItem->setContentWidgetData("selected", mSettings.mSequantialCaptureHotkey);
+    mSequantialFormatItem->setContentWidgetData("selected", mSettings.mSequantialCaptureImageFormat);
+    mSequantialDelayItem->setContentWidgetData("text", mSettings.mSequantialCaptureDelay);
+    mSequantialMemoryInUseItem->setContentWidgetData("selected", mSettings.mSequantialCaptureMemoryInUseMultiDrive);
+    mSequantialFileNameItem->setContentWidgetData("text", mSettings.mSequantialCaptureFileName);
+    
+    // Video capture components
+    mVideoHotKeyItem->setContentWidgetData("selected", mSettings.mVideoCaptureHotkey);
+    mVideoFormatItem->setContentWidgetData("selected", mSettings.mVideoCaptureVideoFormat);
+    mVideoMemoryInUseItem->setContentWidgetData("selected", mSettings.mVideoCaptureMemoryInUseMultiDrive);
+    mVideoFileNameItem->setContentWidgetData("text", mSettings.mVideoCaptureFileName);
+    
+	
+}
+
+// ---------------------------------------------------------------------------
+
+void SettingsView::createSingleCaptureComponents(HbDataFormModel *model, HbDataFormModelItem *parent)
+{
+    
+    // Create Group for single image components
+    mGroupImageCapture = model->appendDataFormGroup(QString("Single image settings"), parent);
+
+    // DataFormItem for hotkey selection
+    mImageHotKeyItem = model->appendDataFormItem(
+            HbDataFormModelItem::RadioButtonListItem, QString("Capture hotkey"), mGroupImageCapture);
+    //setting the text property of check box.
+    mImageHotKeyItem->setData(HbDataFormModelItem::KeyRole, QString("image_hotkey"));
+    mImageHotKeyItem->setContentWidgetData(QString("items"), KEYS);
+
+    // DataFormItem for image format selection
+    mImageFormatItem = model->appendDataFormItem(
+            HbDataFormModelItem::RadioButtonListItem, QString("Image format"), mGroupImageCapture);
+    //setting the text property of check box.
+    mImageFormatItem->setData(HbDataFormModelItem::KeyRole, QString("image_format"));
+    mImageFormatItem->setContentWidgetData(QString("items"), IMAGEFORMATS);
+    
+    // DataFormItem for memory in use selection
+    mImageMemoryInUseItem = model->appendDataFormItem(
+            HbDataFormModelItem::RadioButtonListItem, QString("Memory in use"), mGroupImageCapture);
+    //setting the text property of check box.
+    mImageMemoryInUseItem->setData(HbDataFormModelItem::KeyRole, QString("image_memory"));
+    mImageMemoryInUseItem->setContentWidgetData(QString("items"), MEMORYMODES);
+    
+    // DataFormItem for file name
+    mImageFileNameItem = model->appendDataFormItem(
+            HbDataFormModelItem::TextItem, QString("File name"), mGroupImageCapture);
+    //setting the text property of check box.
+    mImageFileNameItem->setData(HbDataFormModelItem::KeyRole, QString("image_name"));
+    mImageFileNameItem->setContentWidgetData(QString("text"), QString("Shot"));
+    
+}
+
+// ---------------------------------------------------------------------------
+
+void SettingsView::createSequentialCaptureComponents(HbDataFormModel *model, HbDataFormModelItem *parent)
+{
+    
+    
+    // Create Group for sequential image components
+    mGroupSeguantialCapture = model->appendDataFormGroup(QString("Sequential image settings"), parent);
+    
+    // DataFormItem for hotkey selection
+    mSequantialHotKeyItem = model->appendDataFormItem(
+            HbDataFormModelItem::RadioButtonListItem, QString("Capture hotkey"), mGroupSeguantialCapture);
+    //setting the text property of check box.
+    mSequantialHotKeyItem->setData(HbDataFormModelItem::KeyRole, QString("seguential_hotkey"));
+    mSequantialHotKeyItem->setContentWidgetData(QString("items"), KEYS);
+    
+    // DataFormItem for image format selection
+    mSequantialFormatItem = model->appendDataFormItem(
+            HbDataFormModelItem::RadioButtonListItem, QString("Image format"), mGroupSeguantialCapture);
+    //setting the text property of check box.
+    mSequantialFormatItem->setData(HbDataFormModelItem::KeyRole, QString("seguential_format"));
+    mSequantialFormatItem->setContentWidgetData(QString("items"), IMAGEFORMATS);
+    
+    // DataFormItem for delay between images selection
+    mSequantialDelayItem = model->appendDataFormItem(
+            HbDataFormModelItem::TextItem, QString("Delay between two images(ms)"), mGroupSeguantialCapture);
+    //setting the text property of check box.
+    mSequantialDelayItem->setData(HbDataFormModelItem::KeyRole, QString("seguential_name"));
+    mSequantialDelayItem->setContentWidgetData(QString("text"), QString("Shot"));
+    
+    // DataFormItem for memory selection
+    mSequantialMemoryInUseItem = model->appendDataFormItem(
+            HbDataFormModelItem::RadioButtonListItem, QString("Memory in use"), mGroupSeguantialCapture);
+    //setting the text property of check box.
+    mSequantialMemoryInUseItem->setData(HbDataFormModelItem::KeyRole, QString("seguential_memory"));
+    mSequantialMemoryInUseItem->setContentWidgetData(QString("items"), MEMORYMODES);
+    
+    // DataFormItem for file name
+    mSequantialFileNameItem = model->appendDataFormItem(
+            HbDataFormModelItem::TextItem, QString("File name"), mGroupSeguantialCapture);
+    //setting the text property of check box.
+    mSequantialFileNameItem->setData(HbDataFormModelItem::KeyRole, QString("seguential_name"));
+    mSequantialFileNameItem->setContentWidgetData(QString("text"), QString("Shot"));
+    
+}
+
+// ---------------------------------------------------------------------------
+
+void SettingsView::createVideoCaptureComponents(HbDataFormModel *model, HbDataFormModelItem *parent)
+{
+
+    // Create Group for video capturing components
+    mGroupVideoCapture = model->appendDataFormGroup(QString("Video settings"), parent);
+    
+    // DataFormItem for hotkey selection
+    mVideoHotKeyItem = model->appendDataFormItem(
+            HbDataFormModelItem::RadioButtonListItem, QString("Start/Stop hotkey"), mGroupVideoCapture);
+    //setting the text property of check box.
+    mVideoHotKeyItem->setData(HbDataFormModelItem::KeyRole, QString("video_hotkey"));
+    mVideoHotKeyItem->setContentWidgetData(QString("items"), KEYS);
+    
+    // DataFormItem for video format selection
+    mVideoFormatItem = model->appendDataFormItem(
+            HbDataFormModelItem::RadioButtonListItem, QString("Video format"), mGroupVideoCapture);
+    //setting the text property of check box.
+    mVideoFormatItem->setData(HbDataFormModelItem::KeyRole, QString("video_format"));
+    mVideoFormatItem->setContentWidgetData(QString("items"), VIDEOFORMATS);
+    
+    // DataFormItem for memory selection
+    mVideoMemoryInUseItem = model->appendDataFormItem(
+            HbDataFormModelItem::RadioButtonListItem, QString("Memory in use"), mGroupVideoCapture);
+    //setting the text property of check box.mGroupVideoCapture
+    mVideoMemoryInUseItem->setData(HbDataFormModelItem::KeyRole, QString("video_memory"));
+    mVideoMemoryInUseItem->setContentWidgetData(QString("items"), MEMORYMODES);
+    
+    // DataFormItem for file name
+    mVideoFileNameItem = model->appendDataFormItem(
+            HbDataFormModelItem::TextItem, QString("File name"), mGroupVideoCapture);
+    //setting the text property of check box.
+    mVideoFileNameItem->setData(HbDataFormModelItem::KeyRole, QString("video_name"));
+    mVideoFileNameItem->setContentWidgetData(QString("text"), QString("Video"));
+    
+}
+
+// ---------------------------------------------------------------------------
+
+void SettingsView::saveAndClose()
+{
+
+    readFormItems();
+    if (!mEngineWrapper.saveSettings(mSettings)) {
+        Notifications::error("Unable to save settings");
+    }    
+    
+    mEngineWrapper.EnableRcpOfFoc(EFalse);
+    mMainWindow.setCurrentView(&mMainView);
+	
+}
+
+
+
+// ---------------------------------------------------------------------------
+
+void SettingsView::readFormItems()
+{
+    
+    //TODO this does not work correctly with WK38 ( Text box items )
+
+    mSettings.mCaptureMode = mModeItem->contentWidgetData("selected").toInt();
+
+    mSettings.mSingleCaptureImageFormat = mImageFormatItem->contentWidgetData("selected").toInt();
+    mSettings.mSingleCaptureHotkey = mImageHotKeyItem->contentWidgetData("selected").toInt();
+    mSettings.mSingleCaptureMemoryInUseMultiDrive = mImageMemoryInUseItem->contentWidgetData("selected").toInt(); 
+    mSettings.mSingleCaptureFileName = mImageFileNameItem->contentWidgetData("text").toString();
+    
+    mSettings.mSequantialCaptureImageFormat = mSequantialFormatItem->contentWidgetData("selected").toInt();
+    mSettings.mSequantialCaptureHotkey = mSequantialHotKeyItem ->contentWidgetData("selected").toInt();
+    mSettings.mSequantialCaptureMemoryInUseMultiDrive = mSequantialMemoryInUseItem ->contentWidgetData("selected").toInt();
+    mSettings.mSequantialCaptureFileName = mSequantialFileNameItem->contentWidgetData("text").toString();
+    mSettings.mSequantialCaptureDelay = mSequantialDelayItem->contentWidgetData("text").toInt();
+    
+
+    mSettings.mVideoCaptureVideoFormat = mVideoFormatItem->contentWidgetData("selected").toInt();
+    mSettings.mVideoCaptureHotkey = mVideoHotKeyItem ->contentWidgetData("selected").toInt();
+    mSettings.mVideoCaptureMemoryInUseMultiDrive = mVideoMemoryInUseItem ->contentWidgetData("selected").toInt();
+    mSettings.mVideoCaptureFileName = mVideoFileNameItem ->contentWidgetData("text").toString();
+	
+   
+}
+
+
+// ---------------------------------------------------------------------------
+/*
+void SettingsView::updateShownItems()
+{ 
+
+    if (mMainWindow.currentView() == this) {
+        // Get view items of each group
+        HbDataFormViewItem *viewItemImageGroup = mSettingForm->dataFormViewItem(mModel->indexFromItem(mGroupImageCapture));
+        HbDataFormViewItem *viewItemSequantialGroup = mSettingForm->dataFormViewItem(mModel->indexFromItem(mGroupSeguantialCapture));
+        HbDataFormViewItem *viewItemVideoGroup = mSettingForm->dataFormViewItem(mModel->indexFromItem(mGroupVideoCapture));
+
+    
+        // Set certain group expanded according to selected mode. 
+        // TODO this does not work correctly with WK38(selectedItem is for some reason always 1)
+    
+        int selectedItem = mModeItem->contentWidgetData("selected").toInt();
+        
+        if (selectedItem == SINGLE){
+            viewItemImageGroup->setExpanded(true);
+            viewItemSequantialGroup->setExpanded(false);
+            viewItemVideoGroup->setExpanded(false);
+    
+        }
+        else if (selectedItem == SEQUENTIAL){
+            viewItemImageGroup->setExpanded(false);
+            viewItemSequantialGroup->setExpanded(true);
+            viewItemVideoGroup->setExpanded(false);    
+        }
+        
+        else if (selectedItem == VIDEO){
+            viewItemImageGroup->setExpanded(false);
+            viewItemSequantialGroup->setExpanded(false);
+            viewItemVideoGroup->setExpanded(true);
+        }
+        
+        
+    }
+    
+}
+*/
+// ---------------------------------------------------------------------------
+
+void SettingsView::close()
+{
+    mEngineWrapper.EnableRcpOfFoc(EFalse);
+    mMainWindow.setCurrentView(&mMainView);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/screengrabber/src/sgengine.cpp	Mon May 03 12:32:02 2010 +0300
@@ -0,0 +1,1483 @@
+/*
+* 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 <S32FILE.H> 
+#include <BAUTILS.H>
+#include <PATHINFO.H>
+#include <APPARC.H> 
+#include <IMAGECONVERSION.H>
+#include <TEXTRESOLVER.H>
+#include <APGTASK.H> 
+
+#include <hblabel.h>
+#include <hbmessagebox.h>
+
+#include "mainview.h"
+#include "sgengine.h"
+#include "enginewrapper.h"
+#include "gifanimator.h"
+
+
+#define SC_PRINTS
+
+    #ifdef SC_PRINTS
+     #define SC_DEBUG(a) RDebug::Print(a)
+     #define SC_DEBUG2(a,b) RDebug::Print(a,b)
+    #else
+     #define SC_DEBUG(a) 
+     #define SC_DEBUG2(a,b)
+    #endif
+
+
+
+
+_LIT(KDefaultImageFileName, "Shot");
+_LIT(KDefaultVideoFileName, "Video");
+
+#define HIGH_QUALITY_JPEG 97
+#define LOW_QUALITY_JPEG 60
+#define DEFAULT_SEQ_CAPTURE_DELAY_MS 5000   // 5.000 secs
+#define VIDEO_CAPTURE_DELAY 250             // 0.25 secs
+#define VIDEO_CAPTURE_MINIMUM_DELAY 200     // 0.20 secs
+const TInt KSettingsDrive = EDriveC;
+_LIT(KSettingsFileName, "screengrabber_settings.ini");
+_LIT(KScreenShotsSubDirectory, "Screen Shots\\");
+_LIT(KSGTemporaryDirectory, "\\system\\temp\\screengrabber\\");
+
+
+#define KEY_CAPTURE_PRIORITY 100            // do not change, this is for window server
+
+// ---------------------------------------------------------------------------
+
+SGEngine::SGEngine() : CActive(EPriorityStandard)
+    {
+    // No implementation required
+    }
+
+// ---------------------------------------------------------------------------
+
+SGEngine::~SGEngine()
+    {
+ 
+    TRAP_IGNORE( CleanTemporaryFilesL() );
+
+
+    if (iFrameImageData)
+        delete iFrameImageData;
+
+    if (iPreviouslyCapturedBitmap)
+        delete iPreviouslyCapturedBitmap;
+
+    if (iImageEncoder)
+        delete iImageEncoder;
+     
+    delete iVideoFrameArray;
+
+    Cancel();
+    iTimer.Close();
+
+    iFileSession.Close(); 
+    
+    }
+
+// ---------------------------------------------------------------------------
+
+SGEngine* SGEngine::NewLC(EngineWrapper *aEngineWrapper)
+    {
+    SGEngine* self = new (ELeave) SGEngine();
+    CleanupStack::PushL(self);
+    self->ConstructL(aEngineWrapper);
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+
+SGEngine* SGEngine::NewL(EngineWrapper *aEngineWrapper)
+    {
+    SGEngine* self = SGEngine::NewLC(aEngineWrapper);
+    CleanupStack::Pop(); // self;
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+
+void SGEngine::ConstructL(EngineWrapper *aEngineWrapper)
+    {
+
+    iEngineWrapper = aEngineWrapper;
+   
+    iHashKeyCapturingActivated = EFalse; // Check this
+   
+    User::LeaveIfError(iTimer.CreateLocal());
+
+    iVideoFrameArray = new(ELeave) CVideoFrameArray(10000);
+
+    iPreviouslyCapturedBitmap = new(ELeave) CFbsBitmap;
+
+    iCapturingInProgress = EFalse;
+    iStopCapturing = EFalse;
+    iNumberOfTakenShots = 0;
+    iCurrentFrameNumber = 0;
+    iHashKeyDown = EFalse;
+	
+
+	CActiveScheduler::Add(this);
+	User::LeaveIfError(iFileSession.Connect());  
+	
+	// create window group.
+    iRootWin = CEikonEnv::Static()->RootWin();
+	iRootWin.EnableReceiptOfFocus(EFalse);
+    
+    }
+
+// ---------------------------------------------------------------------------
+
+void SGEngine::RunL(){
+
+
+    SC_DEBUG(_L("SCREENGRABBER ------------------------------------------------------- RunL begin"));
+    
+    switch (iState) 
+        {
+        // encoding of the image is now finished
+        case EEncodingImage: 
+            {
+            if (iGrabSettings.iCaptureMode == ECaptureModeSingleCapture)
+                {
+                // single shot done
+                CapturingFinishedL( iStatus.Int() );
+                }
+
+            else if (iGrabSettings.iCaptureMode == ECaptureModeSequantialCapture)
+                {
+                // increase the counter    
+                iNumberOfTakenShots++;
+                
+                // check if we can take more shots or just finish
+                if (!iStopCapturing && iStatus.Int()==KErrNone)
+                    {
+        
+                    // some delay before the next shot can be taken    
+                    iState = ESequenceDelay;
+                    
+                    // some checking that the value of delay is valid
+                    TInt delay(iGrabSettings.iSequantialCaptureDelay); //ms
+                    if (delay<0 && delay > 999999)
+                        delay = DEFAULT_SEQ_CAPTURE_DELAY_MS;
+                      
+                    iTimer.After(iStatus, delay*1000);
+                    SetActive();  
+                    }
+                else
+                    {
+                    // finished
+                    CapturingFinishedL( iStatus.Int() );
+                    }                       
+               }
+            else
+                User::Panic(_L("Wrong mode"), 32);            
+
+            break;
+            }
+
+        // delay finished, ready to take the next shot
+        case ESequenceDelay: 
+            {
+            TakeScreenShotAndSaveL();
+
+            break;
+            }
+            
+        // asked to cancel capturing    
+        case ECancelCapturing:
+            {
+            // finished
+            CapturingFinishedL( iStatus.Int() );
+
+            break;
+            }
+            
+        case ENextVideoFrame:
+            {
+            // increase the counter
+            iCurrentFrameNumber++;
+            
+            // check if we can take more frames or just finish
+            if (!iStopCapturing && iStatus.Int()==KErrNone)
+                {
+                // take next frame
+                CaptureFrameForVideoL();
+                }
+            else
+                {
+                // finished, save video
+                SaveVideoL( iStatus.Int() );
+                }               
+            }
+            break;
+
+        case ECancelVideoCapturing:
+            {
+            // finished, save video
+            SaveVideoL( iStatus.Int() );                
+            }
+            break;
+                                
+
+        default:
+            {
+            break;
+            }
+        }
+    SC_DEBUG(_L("SCREENGRABBER ------------------------------------------------------- RunL end"));
+    
+
+}
+
+
+void SGEngine::EnableRcpOfFoc(TBool aState)
+	{
+	iRootWin.EnableReceiptOfFocus(aState);
+	}
+
+
+// ---------------------------------------------------------------------------
+
+void SGEngine::DoCancel(){
+    iTimer.Cancel();
+}
+
+// ---------------------------------------------------------------------------
+
+void SGEngine::LoadDFSValueL(CDictionaryFileStore* aDicFS, const TUid& aUid, TInt& aValue)
+    {
+    if (aDicFS->IsPresentL(aUid))
+        {
+        RDictionaryReadStream in;
+        in.OpenLC(*aDicFS, aUid);
+        aValue = in.ReadInt16L();
+        CleanupStack::PopAndDestroy(); // in        
+        }
+    }
+
+// ---------------------------------------------------------------------------
+
+void SGEngine::LoadDFSValueL(CDictionaryFileStore* aDicFS, const TUid& aUid, TDes& aValue)
+    {
+    if (aDicFS->IsPresentL(aUid))
+        {
+        RDictionaryReadStream in;
+        in.OpenLC(*aDicFS, aUid);
+        TInt bufLength = in.ReadInt16L();   // get length of descriptor
+        in.ReadL(aValue, bufLength);        // get the descriptor itself
+        CleanupStack::PopAndDestroy(); // in
+        }
+    }
+// ----------------------------------------------------------------------------
+
+void SGEngine::LoadSettingsL()
+    {
+	 
+    // set defaults
+    iGrabSettings.iCaptureMode = ECaptureModeSingleCapture;
+    
+    iGrabSettings.iSingleCaptureHotkey = EHotkeySendKey;
+    iGrabSettings.iSingleCaptureImageFormat = EImageFormatPNG;
+    iGrabSettings.iSingleCaptureMemoryInUseMultiDrive = EPhoneMemory;
+    iGrabSettings.iSingleCaptureFileName.Copy( KDefaultImageFileName );
+
+    iGrabSettings.iSequantialCaptureHotkey = EHotkeySendKey;
+    iGrabSettings.iSequantialCaptureImageFormat = EImageFormatPNG;
+    iGrabSettings.iSequantialCaptureDelay = DEFAULT_SEQ_CAPTURE_DELAY_MS;
+    iGrabSettings.iSequantialCaptureMemoryInUseMultiDrive = EPhoneMemory;
+    iGrabSettings.iSequantialCaptureFileName.Copy( KDefaultImageFileName );
+
+    iGrabSettings.iVideoCaptureHotkey = EHotkeySendKey;
+    iGrabSettings.iVideoCaptureVideoFormat = EVideoFormatAnimatedGIF;
+    iGrabSettings.iVideoCaptureMemoryInUseMultiDrive = EPhoneMemory;    
+    iGrabSettings.iVideoCaptureFileName.Copy( KDefaultVideoFileName );
+       
+        
+    // make sure that the private path of this app in c-drive exists
+    
+	iFileSession.CreatePrivatePath( KSettingsDrive ); // c:\\private\\101fb751\\
+    
+    // handle settings always in the private directory 
+    
+	if (iFileSession.SetSessionToPrivate( KSettingsDrive ) == KErrNone)
+        {
+        // open or create a dictionary file store
+        CDictionaryFileStore* settingsStore = CDictionaryFileStore::OpenLC(iFileSession, KSettingsFileName, KUidScreenGrabber);
+
+        LoadDFSValueL(settingsStore, KSGSettingCaptureMode,                             iGrabSettings.iCaptureMode);
+        
+        LoadDFSValueL(settingsStore, KSGSettingSingleCaptureHotkey,                     iGrabSettings.iSingleCaptureHotkey);
+        LoadDFSValueL(settingsStore, KSGSettingSingleCaptureImageFormat,                iGrabSettings.iSingleCaptureImageFormat);
+        LoadDFSValueL(settingsStore, KSGSettingSingleCaptureMemoryInUseMultiDrive,      iGrabSettings.iSingleCaptureMemoryInUseMultiDrive);
+        LoadDFSValueL(settingsStore, KSGSettingSingleCaptureFileName,                   iGrabSettings.iSingleCaptureFileName);
+        
+        LoadDFSValueL(settingsStore, KSGSettingSequantialCaptureHotkey,                 iGrabSettings.iSequantialCaptureHotkey);
+        LoadDFSValueL(settingsStore, KSGSettingSequantialCaptureImageFormat,            iGrabSettings.iSequantialCaptureImageFormat);
+        LoadDFSValueL(settingsStore, KSGSettingSequantialCaptureDelay,                  iGrabSettings.iSequantialCaptureDelay);
+        LoadDFSValueL(settingsStore, KSGSettingSequantialCaptureMemoryInUseMultiDrive,  iGrabSettings.iSequantialCaptureMemoryInUseMultiDrive);
+        LoadDFSValueL(settingsStore, KSGSettingSequantialCaptureFileName,               iGrabSettings.iSequantialCaptureFileName);
+
+        LoadDFSValueL(settingsStore, KSGSettingVideoCaptureHotkey,                      iGrabSettings.iVideoCaptureHotkey);
+        LoadDFSValueL(settingsStore, KSGSettingVideoCaptureVideoFormat,                 iGrabSettings.iVideoCaptureVideoFormat);
+        LoadDFSValueL(settingsStore, KSGSettingVideoCaptureMemoryInUseMultiDrive,       iGrabSettings.iVideoCaptureMemoryInUseMultiDrive);
+        LoadDFSValueL(settingsStore, KSGSettingVideoCaptureFileName,                    iGrabSettings.iVideoCaptureFileName);
+
+        CleanupStack::PopAndDestroy(); // settingsStore         
+        }
+//chesk if all settings are in range - for safety reason, not to set some controls out of range - it causes the crash
+	if (!(iGrabSettings.iCaptureMode >= ECaptureModeSingleCapture && iGrabSettings.iCaptureMode <= ECaptureModeVideoCapture))
+	    { //give it default value
+        iGrabSettings.iCaptureMode = ECaptureModeSingleCapture;
+	    }
+	if (!(iGrabSettings.iSingleCaptureHotkey >= EHotkeySendKey && iGrabSettings.iSingleCaptureHotkey <= EHotkeyCameraKey1))
+	    {
+        iGrabSettings.iSingleCaptureHotkey = EHotkeySendKey;
+	    }
+	if (!(iGrabSettings.iSingleCaptureImageFormat >= EImageFormatPNG && iGrabSettings.iSingleCaptureImageFormat <= EImageFormatGIF))
+	    {
+        iGrabSettings.iSingleCaptureImageFormat = EImageFormatPNG;
+	    }
+	if (!(iGrabSettings.iSingleCaptureMemoryInUseMultiDrive >= EPhoneMemory && iGrabSettings.iSingleCaptureMemoryInUseMultiDrive <= EMemoryCard))
+	    {
+        iGrabSettings.iSingleCaptureMemoryInUseMultiDrive = EPhoneMemory;
+	    }
+	
+    if (!(iGrabSettings.iSequantialCaptureHotkey >= EHotkeySendKey && iGrabSettings.iSequantialCaptureHotkey <= EHotkeyCameraKey1))
+        {
+        iGrabSettings.iSequantialCaptureHotkey = EHotkeySendKey;
+        }
+    if (!(iGrabSettings.iSequantialCaptureImageFormat >= EImageFormatPNG && iGrabSettings.iSequantialCaptureImageFormat <= EImageFormatGIF))
+        {
+        iGrabSettings.iSequantialCaptureImageFormat = EImageFormatPNG;
+        }
+    if (!(iGrabSettings.iSequantialCaptureMemoryInUseMultiDrive >= EPhoneMemory && iGrabSettings.iSequantialCaptureMemoryInUseMultiDrive <= EMemoryCard))
+        {
+        iGrabSettings.iSequantialCaptureMemoryInUseMultiDrive = EPhoneMemory;
+        }
+
+    if (!(iGrabSettings.iVideoCaptureHotkey >= EHotkeySendKey && iGrabSettings.iVideoCaptureHotkey <= EHotkeyCameraKey1))
+        {
+        iGrabSettings.iVideoCaptureHotkey = EHotkeySendKey;
+        }
+    if (iGrabSettings.iVideoCaptureVideoFormat != EVideoFormatAnimatedGIF)
+        {
+        iGrabSettings.iVideoCaptureVideoFormat = EVideoFormatAnimatedGIF;
+        }
+    if (!(iGrabSettings.iVideoCaptureMemoryInUseMultiDrive >= EPhoneMemory && iGrabSettings.iVideoCaptureMemoryInUseMultiDrive <= EMemoryCard))
+        {
+        iGrabSettings.iVideoCaptureMemoryInUseMultiDrive = EPhoneMemory;
+        }
+	
+    }
+
+// ---------------------------------------------------------------------------
+
+void SGEngine::SaveDFSValueL(CDictionaryFileStore* aDicFS, const TUid& aUid, const TInt& aValue)
+    {
+    RDictionaryWriteStream out;
+    out.AssignLC(*aDicFS, aUid);
+    out.WriteInt16L(aValue);
+    out.CommitL();  
+    CleanupStack::PopAndDestroy(1);// out
+    }
+
+// ---------------------------------------------------------------------------
+
+void SGEngine::SaveDFSValueL(CDictionaryFileStore* aDicFS, const TUid& aUid, const TDes& aValue)
+    {
+    RDictionaryWriteStream out;
+    out.AssignLC(*aDicFS, aUid);
+    out.WriteInt16L(aValue.Length());       // write length of the descriptor
+    out.WriteL(aValue, aValue.Length());    // write the descriptor itself
+    out.CommitL();  
+    CleanupStack::PopAndDestroy(1);// out
+    }
+    
+// ---------------------------------------------------------------------------
+void SGEngine::SaveSettingsL(TGrabSettings aGrabSettings)
+    {
+
+	
+    // set the new settings
+    iGrabSettings = aGrabSettings;
+
+    // handle settings always in c:\\private\\101fb751\\
+    if (iFileSession.SetSessionToPrivate( KSettingsDrive ) == KErrNone)
+        {
+        // delete existing store to make sure that it is clean and not eg corrupted
+        if (BaflUtils::FileExists(iFileSession, KSettingsFileName))
+            {
+            iFileSession.Delete(KSettingsFileName);
+            }
+        
+        // create a dictionary file store
+        CDictionaryFileStore* settingsStore = CDictionaryFileStore::OpenLC(iFileSession, KSettingsFileName, KUidScreenGrabber);
+
+        SaveDFSValueL(settingsStore, KSGSettingCaptureMode,                             iGrabSettings.iCaptureMode);
+        
+        SaveDFSValueL(settingsStore, KSGSettingSingleCaptureHotkey,                     iGrabSettings.iSingleCaptureHotkey);
+        SaveDFSValueL(settingsStore, KSGSettingSingleCaptureImageFormat,                iGrabSettings.iSingleCaptureImageFormat);
+        SaveDFSValueL(settingsStore, KSGSettingSingleCaptureMemoryInUseMultiDrive,      iGrabSettings.iSingleCaptureMemoryInUseMultiDrive);
+        SaveDFSValueL(settingsStore, KSGSettingSingleCaptureFileName,                   iGrabSettings.iSingleCaptureFileName);
+        
+        SaveDFSValueL(settingsStore, KSGSettingSequantialCaptureHotkey,                 iGrabSettings.iSequantialCaptureHotkey);
+        SaveDFSValueL(settingsStore, KSGSettingSequantialCaptureImageFormat,            iGrabSettings.iSequantialCaptureImageFormat);
+        SaveDFSValueL(settingsStore, KSGSettingSequantialCaptureDelay,                  iGrabSettings.iSequantialCaptureDelay);
+        SaveDFSValueL(settingsStore, KSGSettingSequantialCaptureMemoryInUseMultiDrive,  iGrabSettings.iSequantialCaptureMemoryInUseMultiDrive);
+        SaveDFSValueL(settingsStore, KSGSettingSequantialCaptureFileName,               iGrabSettings.iSequantialCaptureFileName);
+
+        SaveDFSValueL(settingsStore, KSGSettingVideoCaptureHotkey,                      iGrabSettings.iVideoCaptureHotkey);
+        SaveDFSValueL(settingsStore, KSGSettingVideoCaptureVideoFormat,                 iGrabSettings.iVideoCaptureVideoFormat);
+        SaveDFSValueL(settingsStore, KSGSettingVideoCaptureMemoryInUseMultiDrive,       iGrabSettings.iVideoCaptureMemoryInUseMultiDrive);
+        SaveDFSValueL(settingsStore, KSGSettingVideoCaptureFileName,                    iGrabSettings.iVideoCaptureFileName);
+        
+        settingsStore->CommitL();
+        CleanupStack::PopAndDestroy(); // settingsStore             
+        }
+		
+    }
+        
+// ---------------------------------------------------------------------------
+
+void SGEngine::ActivateCaptureKeysL(TBool aChangeKey)
+    {
+	
+    // if changing the capture key, capturing needs to be cancelled first
+    if (aChangeKey)
+        {
+        CancelCapturing();
+        }
+
+    // get hotkey of the capture
+    TInt captureHotkey(0);
+    if (iGrabSettings.iCaptureMode == ECaptureModeSingleCapture)
+        captureHotkey = iGrabSettings.iSingleCaptureHotkey;
+    else if (iGrabSettings.iCaptureMode == ECaptureModeSequantialCapture)
+        captureHotkey = iGrabSettings.iSequantialCaptureHotkey;
+    else if (iGrabSettings.iCaptureMode == ECaptureModeVideoCapture)
+        captureHotkey = iGrabSettings.iVideoCaptureHotkey;
+    else
+        User::Panic(_L("Wrong mode"), 40);
+    
+    
+
+    // start capturing based on user selected key
+    switch (captureHotkey)
+        {
+        case EHotkeySendKey:
+            {
+            iCapturedKey    = iRootWin.CaptureKey(EStdKeyYes, EModifierCtrl|EModifierShift|EModifierFunc, 0, KEY_CAPTURE_PRIORITY);
+            iCapturedKeyUnD = iRootWin.CaptureKeyUpAndDowns(EStdKeyYes, EModifierCtrl|EModifierShift|EModifierFunc, 0, KEY_CAPTURE_PRIORITY);
+            break;
+            }
+        case EHotkeyPowerKey:
+            {
+            iCapturedKey    = iRootWin.CaptureKey(EStdKeyDevice2, EModifierCtrl|EModifierShift|EModifierFunc, 0, KEY_CAPTURE_PRIORITY);
+            iCapturedKeyUnD = iRootWin.CaptureKeyUpAndDowns(EStdKeyDevice2, EModifierCtrl|EModifierShift|EModifierFunc, 0, KEY_CAPTURE_PRIORITY);
+            break;
+            }
+        case EHotkeySideKey:
+            {
+            iCapturedKey    = iRootWin.CaptureKey(EStdKeyDevice6, EModifierCtrl|EModifierShift|EModifierFunc, 0, KEY_CAPTURE_PRIORITY);
+            iCapturedKeyUnD = iRootWin.CaptureKeyUpAndDowns(EStdKeyDevice6, EModifierCtrl|EModifierShift|EModifierFunc, 0, KEY_CAPTURE_PRIORITY);
+            break;            
+            }
+        case EHotkeyCameraKey1:
+            {
+            iCapturedKey    = iRootWin.CaptureKey(EStdKeyDevice7, EModifierCtrl|EModifierShift|EModifierFunc, 0, KEY_CAPTURE_PRIORITY);
+            iCapturedKeyUnD = iRootWin.CaptureKeyUpAndDowns(EStdKeyDevice7, EModifierCtrl|EModifierShift|EModifierFunc, 0, KEY_CAPTURE_PRIORITY);
+            break;            
+            }
+        default:
+            {
+            User::Panic(_L("Key not supported"), 100);
+            break;
+            }
+        }
+		
+    }
+
+// ---------------------------------------------------------------------------
+
+
+void SGEngine::CancelCapturing()
+    {
+	
+    SC_DEBUG(_L("SCREENGRABBER ------------------------------------------------------- CancelCapturing start"));
+    // cancel all captures
+    iRootWin.CancelCaptureKey(iCapturedKey);
+    iRootWin.CancelCaptureKeyUpAndDowns(iCapturedKeyUnD);
+    
+    if (iHashKeyCapturingActivated)
+        {
+        iRootWin.CancelCaptureKey(iCapturedKeyHash);
+        iRootWin.CancelCaptureKeyUpAndDowns(iCapturedKeyHashUnD);
+        
+        iHashKeyCapturingActivated = EFalse;
+        }
+    
+    SC_DEBUG(_L("SCREENGRABBER ------------------------------------------------------- CancelCapturing end"));
+	
+    }
+
+// ---------------------------------------------------------------------------
+
+bool SGEngine::TakeScreenShotAndSaveL()
+    {
+	
+    SC_DEBUG(_L("SCREENGRABBER ------------------------------------------------------- TakeSsAndSave start"));
+    if ( IsActive() )
+        {
+        SC_DEBUG(_L("SCREENGRABBER ------------------------------------------------------- TakeSsAndSave already active, ignored"));
+        return false;
+        }
+    
+    // take a screen shot
+    CWsScreenDevice* screenDevice = new( ELeave ) CWsScreenDevice(CEikonEnv::Static()->WsSession() );
+    CleanupStack::PushL( screenDevice );
+	
+    User::LeaveIfError( screenDevice->Construct( CEikonEnv::Static()->WsSession().GetFocusScreen() ) );
+
+	
+    User::LeaveIfError( iPreviouslyCapturedBitmap->Create(screenDevice->SizeInPixels(), screenDevice->DisplayMode()) );
+    User::LeaveIfError( screenDevice->CopyScreenToBitmap(iPreviouslyCapturedBitmap) );
+    CleanupStack::PopAndDestroy(); // screenDevice
+
+
+    // get memory in use & image format of the screen capture
+    TDriveNumber memoryInUse(EDriveC);
+    TInt intMemInUse(0);
+    TInt imageFormat(0);
+    TFileName fileName;
+    
+    if (iGrabSettings.iCaptureMode == ECaptureModeSingleCapture)
+        {        
+//        memoryInUse = iGrabSettings.iSingleCaptureMemoryInUseMultiDrive;
+        intMemInUse = iGrabSettings.iSingleCaptureMemoryInUseMultiDrive;
+        
+        imageFormat = iGrabSettings.iSingleCaptureImageFormat;
+        fileName = iGrabSettings.iSingleCaptureFileName;
+        }
+    else if (iGrabSettings.iCaptureMode == ECaptureModeSequantialCapture)
+        {          
+//        memoryInUse = iGrabSettings.iSequantialCaptureMemoryInUseMultiDrive;
+        intMemInUse = iGrabSettings.iSequantialCaptureMemoryInUseMultiDrive;
+        
+        imageFormat = iGrabSettings.iSequantialCaptureImageFormat;
+        fileName = iGrabSettings.iSequantialCaptureFileName;
+        }
+    else
+        User::Panic(_L("Wrong mode"), 30);  
+
+
+    // init the path for saving the file
+	
+	iSaveFileName.Copy( PathInfo::PhoneMemoryRootPath() );
+	
+//    if (memoryInUse != EDriveC)//something different as PhoneMemory (memory card or mass memory)
+    if (intMemInUse != 0)//something different as PhoneMemory (memory card or mass memory)
+    	{
+		memoryInUse = EDriveY;	    
+		if (PathInfo::GetRootPath(iSaveFileName, memoryInUse) != KErrNone || !DriveOK(memoryInUse))
+			{
+			//we need to find first available memory card in EDriveE - EDriveY range
+			for (TInt i = EDriveY; i>=EDriveE; i--)
+				{
+				if ( DriveOK((TDriveNumber)(i)))
+					{
+					if (IsDriveMMC((TDriveNumber)(i)))
+						{
+						PathInfo::GetRootPath(iSaveFileName, (TDriveNumber)(i));
+						break;
+						}    
+					}
+				}
+			}
+    	}
+
+    iSaveFileName.Append( PathInfo::ImagesPath() );
+    iSaveFileName.Append( KScreenShotsSubDirectory );
+    
+    
+    // a quick check that filename is valid
+    if (fileName.Length() > 0 && fileName.Length() <= 255) 
+        iSaveFileName.Append( fileName );
+    else
+        iSaveFileName.Append( KDefaultImageFileName );
+
+    iSaveFileName.Append( _L(".") );
+
+
+    // reset the encoder
+    if (iImageEncoder)
+        {
+        delete iImageEncoder;
+        iImageEncoder = NULL;
+        }
+        
+    
+    switch (imageFormat)
+        {
+        case EImageFormatPNG:
+            {
+            // set filename
+            iSaveFileName.Append(_L("png"));
+            CApaApplication::GenerateFileName(iFileSession, iSaveFileName );  // unique filename
+
+            // init & convert
+            iImageEncoder = CImageEncoder::FileNewL(iFileSession, iSaveFileName, CImageEncoder::EOptionAlwaysThread, KImageTypePNGUid);
+			
+            iImageEncoder->Convert( &iStatus, *iPreviouslyCapturedBitmap );
+            }
+            break;
+        
+        case EImageFormatJPGHQ:
+        case EImageFormatJPGLQ:
+            {
+            // reset frameimagedata
+            if (iFrameImageData)
+                {
+                delete iFrameImageData;
+                iFrameImageData = NULL;
+                }
+            
+            // set filename
+            iSaveFileName.Append(_L("jpg"));
+            CApaApplication::GenerateFileName(iFileSession, iSaveFileName );  // unique filename
+
+            // init 
+            iImageEncoder = CImageEncoder::FileNewL(iFileSession, iSaveFileName, CImageEncoder::EOptionAlwaysThread, KImageTypeJPGUid);
+
+            // JPEG properties
+            TJpegImageData* imageData = new(ELeave) TJpegImageData;
+            imageData->iSampleScheme = TJpegImageData::EColor444;
+            imageData->iQualityFactor = (imageFormat==EImageFormatJPGHQ) ? HIGH_QUALITY_JPEG : LOW_QUALITY_JPEG;
+            iFrameImageData = CFrameImageData::NewL();
+            User::LeaveIfError(iFrameImageData->AppendImageData(imageData));  //ownership of imageData is transferred
+
+            // convert
+            iImageEncoder->Convert( &iStatus, *iPreviouslyCapturedBitmap, iFrameImageData );
+            }
+            break;
+        
+        case EImageFormatBMP:
+            {
+            // set filename
+            iSaveFileName.Append(_L("bmp"));
+            CApaApplication::GenerateFileName(iFileSession, iSaveFileName );  // unique filename
+
+            // init & convert
+            iImageEncoder = CImageEncoder::FileNewL(iFileSession, iSaveFileName, CImageEncoder::EOptionAlwaysThread, KImageTypeBMPUid);
+            iImageEncoder->Convert( &iStatus, *iPreviouslyCapturedBitmap );
+            }
+            break;
+
+        case EImageFormatGIF:
+            {
+            // set filename
+            iSaveFileName.Append(_L("gif"));
+            CApaApplication::GenerateFileName(iFileSession, iSaveFileName );  // unique filename
+
+            // init & convert
+            iImageEncoder = CImageEncoder::FileNewL(iFileSession, iSaveFileName, CImageEncoder::EOptionAlwaysThread, KImageTypeGIFUid);
+            iImageEncoder->Convert( &iStatus, *iPreviouslyCapturedBitmap );
+            }
+            break;
+            
+        case EImageFormatMBM:
+            {
+            // set filename
+            iSaveFileName.Append(_L("mbm"));
+            CApaApplication::GenerateFileName(iFileSession, iSaveFileName );  // unique filename
+
+            // init & convert
+            iImageEncoder = CImageEncoder::FileNewL(iFileSession, iSaveFileName, CImageEncoder::EOptionAlwaysThread, KImageTypeMBMUid);
+            iImageEncoder->Convert( &iStatus, *iPreviouslyCapturedBitmap );
+            }
+            break;
+            
+        default:
+            {
+            User::Panic(_L("Invalid Img Type"), 20);
+            }
+        }
+
+    // set the state of the active object
+    iState = EEncodingImage;
+
+    // indicate an outstanding request
+    SetActive();
+    SC_DEBUG(_L("SCREENGRABBER ------------------------------------------------------- TakeSsAndSave end"));
+	return true;
+    }
+    
+// ---------------------------------------------------------------------------
+
+
+TBool SGEngine::DriveOK(TDriveNumber aNumber)
+    {
+	
+    SC_DEBUG(_L("SCREENGRABBER ------------------------------------------------------- Driveok start"));
+    TBool isOK(EFalse);
+
+    TVolumeInfo vInfo;
+
+    // check if we can access the drive
+    if (iFileSession.Volume(vInfo, aNumber) == KErrNone)
+        isOK = ETrue;
+
+    // returns ETrue if memory card working properly
+    SC_DEBUG(_L("SCREENGRABBER ------------------------------------------------------- DriveOK end"));
+    return isOK;
+	
+    }
+// ---------------------------------------------------------------------------
+
+
+TBool SGEngine::IsDriveMMC(TDriveNumber aDrive)
+    {
+    SC_DEBUG(_L("SCREENGRABBER ------------------------------------------------------- IsDriveMMC start"));
+    TBool isOK(EFalse);
+
+    TDriveInfo ii;   
+    if (iFileSession.Drive(ii, aDrive)==KErrNone) 
+        {      
+            if (ii.iType!=EMediaNotPresent &&
+                ii.iType!=EMediaUnknown &&           
+                ii.iType!=EMediaCdRom &&         
+                ii.iType!=EMediaRom) 
+                {           // memory card          
+                    isOK=ETrue;      
+                }   
+        }    
+                
+    
+    SC_DEBUG(_L("SCREENGRABBER ------------------------------------------------------- IsDriveMMC end"));
+    return isOK;
+    }
+
+
+void SGEngine::CapturingFinishedL(TInt aErr)
+    {
+	
+    SC_DEBUG(_L("SCREENGRABBER ------------------------------------------------------- CapturingFinished start"));
+    // display a global query to show the results
+    
+    if (aErr == KErrNone)
+        {
+        switch (iGrabSettings.iCaptureMode)
+            {
+            case ECaptureModeSingleCapture:
+                {
+                iEngineWrapper->ShowImageCapturedNote();
+                }
+                break;
+            
+            case ECaptureModeSequantialCapture:
+                {
+                iEngineWrapper->ShowSequantialImagesCapturedNote(iNumberOfTakenShots);
+                }
+                break;            
+    
+            case ECaptureModeVideoCapture:
+                {
+                iEngineWrapper->ShowVideoCapturedNote();
+                }
+                break;             
+    
+            default:
+                User::Panic(_L("Inv.capt.mode"), 51);
+                break;
+            }            
+       
+        }
+    else
+        {
+        
+        // Get error message with CTextResolver
+        CTextResolver* textResolver = CTextResolver::NewLC();
+        iEngineWrapper->ShowErrorMessage(textResolver->ResolveErrorString(aErr));
+
+        CleanupStack::PopAndDestroy();  //textResolver    
+        
+        }
+
+    // capturing can now be restarted
+    iState = EIdle;
+    iCapturingInProgress = EFalse;
+    iStopCapturing = EFalse;
+    
+    // reset values
+    iNumberOfTakenShots = 0;
+    iCurrentFrameNumber = 0;
+    iVideoFrameArray->Reset();
+    
+    
+    iState = EQueryDelay;
+    iTimer.After(iStatus, 2000000);
+    SetActive(); 
+    
+    SC_DEBUG(_L("SCREENGRABBER ------------------------------------------------------- capturingfinished end"));
+	
+    }
+
+
+#if defined(HB_QT_S60_EVENT_FILTER)
+    TBool SGEngine::HandleCaptureCommandsL(const TWsEvent* aEvent)
+	{
+#else
+    TBool SGEngine::HandleCaptureCommandsL(const QSymbianEvent *event)
+	{
+    if (event->type() != QSymbianEvent::WindowServerEvent) {
+        return ETrue; //continueEventLoop
+    }
+    const TWsEvent *aEvent = event->windowServerEvent();
+#endif
+	
+    SC_DEBUG(_L("SCREENGRABBER ------------------------------------------------------- HandleCaptureCommand start"));
+	
+	
+    TBool continueEventLoop(ETrue);
+    
+    // get hotkey of the capture
+    TInt captureHotkey(0);
+    if (iGrabSettings.iCaptureMode == ECaptureModeSingleCapture)
+        captureHotkey = iGrabSettings.iSingleCaptureHotkey;
+    else if (iGrabSettings.iCaptureMode == ECaptureModeSequantialCapture)
+        captureHotkey = iGrabSettings.iSequantialCaptureHotkey;
+    else if (iGrabSettings.iCaptureMode == ECaptureModeVideoCapture)
+        captureHotkey = iGrabSettings.iVideoCaptureHotkey;
+    else
+        User::Panic(_L("Wrong mode"), 41);
+    
+    // ignore any errors
+    if (aEvent->Type()==EEventErrorMessage)
+        {
+        // error
+        }
+    
+            
+    // handle captured keys, we are interested here only of the keydown events
+    else
+        
+        if (
+              ( captureHotkey == EHotkeySendKey &&
+                aEvent->Type()==EEventKeyDown && aEvent->Key()->iScanCode==EStdKeyYes )
+            ||
+              ( captureHotkey == EHotkeyPowerKey &&
+                aEvent->Type()==EEventKeyDown && aEvent->Key()->iScanCode==EStdKeyDevice2 )
+            ||
+              ( captureHotkey == EHotkeySideKey &&
+                aEvent->Type()==EEventKeyDown && aEvent->Key()->iScanCode==EStdKeyDevice6 )
+            ||
+              ( captureHotkey == EHotkeyCameraKey1 &&
+                aEvent->Type()==EEventKeyDown && aEvent->Key()->iScanCode==EStdKeyDevice7 )
+            )
+        {
+        
+        // check if already capturing images in sequence
+        if ( iCapturingInProgress && !iStopCapturing && iNumberOfTakenShots!=0 && iGrabSettings.iCaptureMode == ECaptureModeSequantialCapture )
+            {
+            // asking to stop capturing
+            iStopCapturing = ETrue; 
+            
+            // cancel the active object, this will cancel any timer delays and ICL stuff
+            Cancel();
+            
+            // set status
+            iState = ECancelCapturing; 
+            
+            // jump smoothly to RunL()
+            iTimer.After(iStatus, 50);
+            SetActive(); 
+
+            // do not continue the event loop in HandleWsEventL for these events
+            continueEventLoop = EFalse;
+            }
+
+        // check if already capturing video
+        else if ( iCapturingInProgress && !iStopCapturing && iGrabSettings.iCaptureMode == ECaptureModeVideoCapture )
+            {
+            // asking to stop capturing
+            iStopCapturing = ETrue;
+            
+            // cancel the active object, this will cancel any timer delays and ICL stuff
+            Cancel();
+
+            // set status
+            iState = ECancelVideoCapturing;
+            
+            // jump smoothly to RunL()
+            iTimer.After(iStatus, 50);
+            SetActive(); 
+
+            // do not continue the event loop in HandleWsEventL for these events
+            continueEventLoop = EFalse;
+            }        
+        else if (!iCapturingInProgress && (iGrabSettings.iCaptureMode == ECaptureModeSingleCapture || iGrabSettings.iCaptureMode == ECaptureModeSequantialCapture ))
+            {
+            
+            // take a screen shot and save it
+           if( TakeScreenShotAndSaveL())
+               {
+               // not capturing anything, so start doing that
+               iCapturingInProgress = ETrue;    
+               // do not continue the event loop in HandleWsEventL for these events
+               continueEventLoop = EFalse;
+               }
+            }
+        
+        else if (!iCapturingInProgress && iGrabSettings.iCaptureMode == ECaptureModeVideoCapture )
+            {
+            // not capturing anything, so start doing that
+            iCapturingInProgress = ETrue;
+            
+            // clean temporary files
+            TRAP_IGNORE( CleanTemporaryFilesL() );
+            
+            // get initial dimensions for the video
+            CWsScreenDevice* screenDevice = new(ELeave) CWsScreenDevice ( CEikonEnv::Static()->WsSession() );
+            CleanupStack::PushL(screenDevice);
+			
+            User::LeaveIfError( screenDevice->Construct( CEikonEnv::Static()->WsSession().GetFocusScreen() ) );
+			
+            iVideoDimensions = screenDevice->SizeInPixels();
+            iPreviousFrameScreenDimension = screenDevice->SizeInPixels();
+            CleanupStack::PopAndDestroy(); // screenDevice
+
+            // capture the first frame
+            CaptureFrameForVideoL();              
+
+            // do not continue the event loop in HandleWsEventL for these events
+            continueEventLoop = EFalse;
+            }
+
+        }
+
+    // catch other event types as well so that we can ignore them
+    else if (
+              ( captureHotkey == EHotkeySendKey &&
+                aEvent->Key()->iScanCode==EStdKeyYes )
+            ||
+              ( captureHotkey == EHotkeyPowerKey &&
+                aEvent->Key()->iScanCode==EStdKeyDevice2 )
+            ||
+              ( captureHotkey == EHotkeySideKey &&
+                aEvent->Key()->iScanCode==EStdKeyDevice6 )
+            ||
+              ( captureHotkey == EHotkeyCameraKey1 &&
+                aEvent->Key()->iScanCode==EStdKeyDevice7 )
+           )
+        {
+        // do not continue the event loop in HandleWsEventL for these events
+        continueEventLoop = EFalse;
+        }
+
+    SC_DEBUG(_L("SCREENGRABBER ------------------------------------------------------- HandleCapturcommand end"));
+
+    
+    return continueEventLoop;
+    
+    }
+
+// ---------------------------------------------------------------------------
+
+void SGEngine::CleanTemporaryFilesL()
+    {
+	
+    SC_DEBUG(_L("SCREENGRABBER ------------------------------------------------------- CleanTempFiles start"));
+    
+    // delete temporary files from C and D drives    
+    CFileMan* fileMan = CFileMan::NewL(iFileSession);
+
+    TFileName delFilesPath;
+        
+    for (TInt i=0; i<1; i++)
+        {
+        delFilesPath.Copy(KNullDesC);
+        delFilesPath.Append('C'+i);
+        delFilesPath.Append(_L(":"));
+        delFilesPath.Append(KSGTemporaryDirectory);
+        delFilesPath.Append(_L("*.$$$"));
+        
+        fileMan->Delete(delFilesPath);
+        }
+
+    delete fileMan;    
+    SC_DEBUG(_L("SCREENGRABBER ------------------------------------------------------- CleanTempfile end"));
+	
+    }
+
+// ---------------------------------------------------------------------------
+
+void SGEngine::ActivateModelL()
+    {
+    // clean temporary files
+    TRAP_IGNORE( CleanTemporaryFilesL() );
+            
+    // load settings
+    TRAP_IGNORE( LoadSettingsL() );
+
+    // start capturing
+    ActivateCaptureKeysL();
+    }
+
+// ---------------------------------------------------------------------------
+
+void SGEngine::DeActivateModelL()
+    {
+	
+    CancelCapturing();
+
+    // for a faster exit, send the application to background
+    TApaTask selfTask(CEikonEnv::Static()->WsSession());
+    selfTask.SetWgId(iRootWin.Identifier());
+    selfTask.SendToBackground();
+	
+	
+    }
+    
+// ---------------------------------------------------------------------------
+
+
+void SGEngine::CaptureFrameForVideoL()
+    {
+    
+    SC_DEBUG(_L("SCREENGRABBER ------------------------------------------------------- CaptureFrameforvide start"));
+    // record time
+    TTime timeNow;
+    timeNow.HomeTime();
+    
+    // take a screen shot   
+    CFbsBitmap* currentCapturedBitmap = new(ELeave) CFbsBitmap;
+    CleanupStack::PushL(currentCapturedBitmap);
+
+    CWsScreenDevice* screenDevice = new(ELeave) CWsScreenDevice( CEikonEnv::Static()->WsSession() );
+    CleanupStack::PushL( screenDevice );
+    User::LeaveIfError( screenDevice->Construct( CEikonEnv::Static()->WsSession().GetFocusScreen() ) );
+    
+    TSize currentScreenSize = screenDevice->SizeInPixels();
+
+    User::LeaveIfError( currentCapturedBitmap->Create(currentScreenSize, EColor256) );
+    User::LeaveIfError( screenDevice->CopyScreenToBitmap(currentCapturedBitmap) );
+    CleanupStack::PopAndDestroy(); // screenDevice
+
+    // grow video's dimensions if the size has changed
+    if (currentScreenSize.iWidth > iVideoDimensions.iWidth)
+        {
+        iVideoDimensions.iWidth = currentScreenSize.iWidth;
+        }
+    if (currentScreenSize.iHeight > iVideoDimensions.iHeight)
+        {
+        iVideoDimensions.iHeight = currentScreenSize.iHeight;
+        }
+
+    TInt64 currentDelay(0);
+ 
+
+    // create a new frame
+    TVideoFrame frame;
+    frame.iDelay = 500; // use default delay 5.00 secs
+    
+    // get info of the RAM drive
+    TDriveNumber ramDrive = EDriveD;
+    TVolumeInfo ramDriveInfo;
+    iFileSession.Volume(ramDriveInfo, ramDrive);
+    
+    // init the directory for saving the file, preferably use ram drive if there is enough disk space, otherwise use always C drive
+    TFileName tempDirectory;
+    TFileName sessionPath;
+    
+    if (ramDriveInfo.iFree > (iVideoDimensions.iWidth*iVideoDimensions.iHeight+50000))
+        sessionPath.Copy( _L("D:") );
+    else
+        sessionPath.Copy( _L("C:") );
+    
+    sessionPath.Append(KSGTemporaryDirectory);
+    tempDirectory.Copy(KSGTemporaryDirectory);
+    
+    iFileSession.MkDirAll(sessionPath);
+    iFileSession.SetSessionPath(sessionPath);
+
+    // create a temp file, path to the bitmap is saved automatically to frame.iFileStorePath
+    RFile file;
+    User::LeaveIfError( file.Temp(iFileSession, tempDirectory, frame.iFileStorePath, EFileWrite) );
+    RFileWriteStream writeStream(file);
+    
+    TBool ignoreFrame(EFalse);
+    
+    // check if is this the first frame
+    if (iCurrentFrameNumber == 0)
+        {
+        // first frame is always the full one
+        frame.iWidth = currentScreenSize.iWidth;    
+        frame.iHeight = currentScreenSize.iHeight;  
+        frame.iXPos = 0;
+        frame.iYPos = 0;
+        frame.iEnableTransparency = EFalse;
+        frame.iFillsWholeScreen = ETrue;
+        
+        currentCapturedBitmap->ExternalizeL(writeStream);  
+
+        }
+    
+    else
+        {
+        // next frame is a difference between the previous one
+        currentDelay = timeNow.MicroSecondsFrom(iPreviousFrameTaken).Int64();
+        
+        // get reference to previos frame
+        TVideoFrame& prevFrame = iVideoFrameArray->At(iVideoFrameArray->Count()-1);
+        
+        
+        // check if video dimensions have changed
+        if (currentScreenSize.iWidth != iPreviousFrameScreenDimension.iWidth
+            || currentScreenSize.iHeight != iPreviousFrameScreenDimension.iHeight)
+            {
+            // dimensions have changed -> save a full bitmap
+            frame.iWidth = currentScreenSize.iWidth;    
+            frame.iHeight = currentScreenSize.iHeight;  
+            frame.iXPos = 0;
+            frame.iYPos = 0;
+            frame.iEnableTransparency = EFalse;
+            frame.iFillsWholeScreen = ETrue;
+            
+            currentCapturedBitmap->ExternalizeL(writeStream);            
+
+            // update the previous frame to contain the new delay value
+            prevFrame.iDelay = TUint( (double) currentDelay / 10000 );
+            }
+
+        else
+            {
+            // compare the bitmaps
+            HBufC8* curImgScanLineBuf = HBufC8::NewLC(currentScreenSize.iWidth*3);
+            TPtr8 curImgScanLinePtr = curImgScanLineBuf->Des();
+            HBufC8* prevImgScanLineBuf = HBufC8::NewLC(currentScreenSize.iWidth*3);
+            TPtr8 prevImgScanLinePtr = prevImgScanLineBuf->Des();
+            
+            TPoint pt(0,0);
+            TBool differenceFound(EFalse);
+            TPoint leftTopDifferencePoint(0,0);
+            TPoint rightBottomDifferencePoint(currentScreenSize.iWidth,currentScreenSize.iHeight);
+            
+            // scan the image from top to bottom
+            for (TInt i=0; i<currentScreenSize.iHeight; i++)
+                {
+                pt.iY = i;
+                
+                currentCapturedBitmap->GetScanLine(curImgScanLinePtr, pt, currentScreenSize.iWidth, EColor256);
+                iPreviouslyCapturedBitmap->GetScanLine(prevImgScanLinePtr, pt, currentScreenSize.iWidth, EColor256);
+                
+                if (curImgScanLinePtr != prevImgScanLinePtr)
+                    {
+                    differenceFound = ETrue;
+                    
+                    // get the y-coordinate
+                    leftTopDifferencePoint.iY = i;
+
+                    break;    
+                    }
+                }
+                
+            if (differenceFound)
+                {
+                // now we know that there is some difference between those two captured frames,
+                // get the bottom value by scaning from bottom to top
+                for (TInt i=currentScreenSize.iHeight-1; i>=0; i--)
+                    {
+                    pt.iY = i;
+                    
+                    currentCapturedBitmap->GetScanLine(curImgScanLinePtr, pt, currentScreenSize.iWidth, EColor256);
+                    iPreviouslyCapturedBitmap->GetScanLine(prevImgScanLinePtr, pt, currentScreenSize.iWidth, EColor256);
+                    
+                    if (curImgScanLinePtr != prevImgScanLinePtr)
+                        {
+                        // get the y-coordinate
+                        rightBottomDifferencePoint.iY = i+1;
+
+                        break;    
+                        }
+                    }
+                    
+                // check that the height of the cropped image will be at least 1
+                if (rightBottomDifferencePoint.iY <= leftTopDifferencePoint.iY)
+                    rightBottomDifferencePoint.iY = leftTopDifferencePoint.iY+1;  
+                
+                      
+                // get also the x-coordinates by scanning vertical scan lines
+                HBufC8* curImgVerticalScanLineBuf = HBufC8::NewLC(currentScreenSize.iHeight*3);
+                TPtr8 curImgVerticalScanLinePtr = curImgScanLineBuf->Des();
+                HBufC8* prevImgVerticalScanLineBuf = HBufC8::NewLC(currentScreenSize.iHeight*3);
+                TPtr8 prevImgVerticalScanLinePtr = prevImgScanLineBuf->Des();
+                        
+                // first scan by from left to right
+                for (TInt i=0; i<currentScreenSize.iWidth; i++)
+                    {
+                    currentCapturedBitmap->GetVerticalScanLine(curImgVerticalScanLinePtr, i, EColor256);
+                    iPreviouslyCapturedBitmap->GetVerticalScanLine(prevImgVerticalScanLinePtr, i, EColor256);
+                    
+                    if (curImgVerticalScanLinePtr != prevImgVerticalScanLinePtr)
+                        {
+                        leftTopDifferencePoint.iX = i;
+                        break;
+                        }
+                    }
+
+                // finally scan from right to left
+                for (TInt i=currentScreenSize.iWidth-1; i>=0; i--)
+                    {
+                    currentCapturedBitmap->GetVerticalScanLine(curImgVerticalScanLinePtr, i, EColor256);
+                    iPreviouslyCapturedBitmap->GetVerticalScanLine(prevImgVerticalScanLinePtr, i, EColor256);
+                    
+                    if (curImgVerticalScanLinePtr != prevImgVerticalScanLinePtr)
+                        {
+                        rightBottomDifferencePoint.iX = i+1;
+                        break;
+                        }
+                    }
+                    
+                CleanupStack::PopAndDestroy(2); //curImgVerticalScanLineBuf,prevImgVerticalScanLineBuf               
+
+                
+                // check that the width of the cropped image will be at least 1
+                if (rightBottomDifferencePoint.iX <= leftTopDifferencePoint.iX)
+                    rightBottomDifferencePoint.iX = leftTopDifferencePoint.iX+1;
+                   
+                
+                // record dimensions and position of the image           
+                frame.iWidth = rightBottomDifferencePoint.iX - leftTopDifferencePoint.iX;    
+                frame.iHeight = rightBottomDifferencePoint.iY - leftTopDifferencePoint.iY;  
+                frame.iXPos = leftTopDifferencePoint.iX;
+                frame.iYPos = leftTopDifferencePoint.iY;
+                frame.iEnableTransparency = ETrue;
+                frame.iFillsWholeScreen = EFalse;
+            
+            
+                // take a copy of the current frame
+                CFbsBitmap* workingBitmap = new(ELeave) CFbsBitmap;
+                CleanupStack::PushL(workingBitmap);
+                User::LeaveIfError( workingBitmap->Create(currentScreenSize, EColor256) );
+
+                HBufC8* tempScanLineBuf = HBufC8::NewLC(currentScreenSize.iWidth*3);
+                TPtr8 tempScanLinePtr = tempScanLineBuf->Des();
+                
+                for (TInt i=0; i<currentScreenSize.iHeight; i++)
+                    {
+                    pt.iY = i;
+                    currentCapturedBitmap->GetScanLine(tempScanLinePtr, pt, currentScreenSize.iWidth, EColor256);
+                    workingBitmap->SetScanLine(tempScanLinePtr, i);
+                    }
+                    
+                CleanupStack::PopAndDestroy(); //tempScanLineBuf
+                
+                
+                // mark the non-changed areas with transparency color
+                TUint8* curPtr = NULL;
+                TUint8* prevPtr = NULL;
+                for (TInt i=frame.iYPos; i<frame.iYPos+frame.iHeight; i++)
+                    {
+                    pt.iY = i;
+                    
+                    workingBitmap->GetScanLine(curImgScanLinePtr, pt, currentScreenSize.iWidth, EColor256);
+                    iPreviouslyCapturedBitmap->GetScanLine(prevImgScanLinePtr, pt, currentScreenSize.iWidth, EColor256);
+                    
+                    // check single pixels in the scanline
+                    for (TInt j=frame.iXPos; j<frame.iXPos+frame.iWidth; j++)
+                        {
+                        curPtr = &curImgScanLinePtr[j];
+                        prevPtr = &prevImgScanLinePtr[j];
+                        
+                        // check that our transparency index isn't already in use
+                        if (curPtr[0] == TRANSPARENCY_INDEX)
+                            curPtr[0] = TRANSPARENCY_ALTERNATIVE_INDEX;
+                        
+                        // replace with transparency index if there is no change compared to the previous frame
+                        if (curPtr[0] == prevPtr[0])
+                            curPtr[0] = TRANSPARENCY_INDEX;
+                        }
+                        
+                    // set new scanline    
+                    workingBitmap->SetScanLine(curImgScanLinePtr, i);
+                    }
+
+
+                // externalize the bitmap
+                TRect changedRect(leftTopDifferencePoint, rightBottomDifferencePoint);
+                workingBitmap->ExternalizeRectangleL(writeStream, changedRect);
+                
+                CleanupStack::PopAndDestroy(); //workingBitmap
+ 
+                // update the previous frame to contain the new delay value
+                prevFrame.iDelay = TUint( (double) currentDelay / 10000 );
+                }
+
+            else
+                {
+                // frames are identical, we can just ignore this one
+                ignoreFrame = ETrue;     
+                }
+            
+            CleanupStack::PopAndDestroy(2); //curImgScanLineBuf,prevImgScanLineBuf
+
+            } // if (videoDimensionsHaveChanged)
+
+        } //if (iCurrentFrameNumber == 0)
+            
+    // close the stream
+    writeStream.CommitL();
+    writeStream.Close();
+    file.Close();
+    
+
+    if (ignoreFrame)
+        {
+        // delete the temp file since we don't need that
+            iFileSession.Delete(frame.iFileStorePath);
+        }
+    else
+        {
+        // remember for the next frame when this frame was taken
+        iPreviousFrameTaken = timeNow;
+
+        // take a copy of currentCapturedBitmap to iPreviouslyCapturedBitmap
+        User::LeaveIfError( iPreviouslyCapturedBitmap->Create(iVideoDimensions, EColor256) );
+
+        TPoint pt(0,0);
+        HBufC8* tempScanLineBuf = HBufC8::NewMaxLC(iVideoDimensions.iWidth);
+        TPtr8 tempScanLinePtr = tempScanLineBuf->Des();
+        
+        for (TInt i=0; i<iVideoDimensions.iHeight; i++)
+            {
+            pt.iY = i;
+            currentCapturedBitmap->GetScanLine(tempScanLinePtr, pt, iVideoDimensions.iWidth, EColor256);
+            iPreviouslyCapturedBitmap->SetScanLine(tempScanLinePtr, i);
+            }
+            
+        CleanupStack::PopAndDestroy(); //tempScanLineBuf
+        
+        // append frame information to the array
+        iVideoFrameArray->AppendL(frame);
+        
+        // remember screen size
+        iPreviousFrameScreenDimension = currentScreenSize;
+        }    
+
+    
+    CleanupStack::PopAndDestroy(); //currentCapturedBitmap
+    
+
+    // set the state of the active object
+    iState = ENextVideoFrame;
+    
+    // check time spent on the work above (probably this is not so important)
+    TTime timeNow2;
+    timeNow2.HomeTime();
+    TInt64 handlingDelay = timeNow2.MicroSecondsFrom(timeNow).Int64();
+    
+    // calculate delay till next frame
+    TUint idealDelay = VIDEO_CAPTURE_DELAY*1000;
+    TInt usedDelay; 
+    if (currentDelay > idealDelay)
+        usedDelay = idealDelay - (currentDelay - idealDelay) - handlingDelay;
+    else
+        usedDelay = idealDelay - handlingDelay;
+    
+    // check that the delay is atleast minimum delay anyway
+    if (usedDelay < VIDEO_CAPTURE_MINIMUM_DELAY*1000)
+        usedDelay = VIDEO_CAPTURE_MINIMUM_DELAY*1000;
+    
+    iTimer.After(iStatus, usedDelay);
+
+    // indicate an outstanding request
+    SetActive();
+    
+    SC_DEBUG(_L("SCREENGRABBER ------------------------------------------------------- Captureframeforvideo end"));
+	
+    }
+
+// ---------------------------------------------------------------------------
+
+void SGEngine::SaveVideoL(TInt aErr)
+    {
+
+    SC_DEBUG(_L("SCREENGRABBER ------------------------------------------------------- SaveVideo start"));
+    
+    if (aErr)
+        CapturingFinishedL(aErr);   
+   
+    else if (iGrabSettings.iVideoCaptureVideoFormat == EVideoFormatAnimatedGIF)
+        {
+        TInt err(KErrNone);
+
+        
+			iSaveFileName.Copy( PathInfo::PhoneMemoryRootPath() );
+            if (iGrabSettings.iVideoCaptureMemoryInUseMultiDrive != 0)//something different as PhoneMemory (memory card or mass memory)
+            	{
+        		if (PathInfo::GetRootPath(iSaveFileName,EDriveY) != KErrNone || !DriveOK(EDriveY))
+        			{
+        			//we need to find first available memory card in EDriveE - EDriveY range
+        			for (TInt i = EDriveY; i>=EDriveE; i--)
+        				{
+        				if ( DriveOK((TDriveNumber)(i)))
+        					{
+        					if (IsDriveMMC((TDriveNumber)(i)))
+        						{
+        						PathInfo::GetRootPath(iSaveFileName, (TDriveNumber)(i));
+        						break;
+        						}    
+        					}
+        				}
+        			}
+            	}
+
+        
+        iSaveFileName.Append( PathInfo::ImagesPath() );     // animated gif is actually an image, not a video
+        iSaveFileName.Append( KScreenShotsSubDirectory );
+        
+        // a quick check that filename is valid
+        if (iGrabSettings.iVideoCaptureFileName.Length() > 0 && iGrabSettings.iVideoCaptureFileName.Length() <= 255) 
+            iSaveFileName.Append( iGrabSettings.iVideoCaptureFileName );
+        else
+            iSaveFileName.Append( KDefaultVideoFileName );
+
+        iSaveFileName.Append( _L(".gif") );
+
+        CApaApplication::GenerateFileName(iFileSession, iSaveFileName );  // unique filename
+
+        // create and save the gif animation
+        err = CGifAnimator::CreateGifAnimation(iSaveFileName, iVideoDimensions, iVideoFrameArray, *iEngineWrapper);
+        
+        // remove the saved file in case of errors since it's likely corrupted
+        if (err != KErrNone)
+            iFileSession.Delete(iSaveFileName);
+        
+        CapturingFinishedL(err);   
+        }
+        
+    else
+        CapturingFinishedL(KErrNotSupported);
+    
+    SC_DEBUG(_L("SCREENGRABBER ------------------------------------------------------- SaveVideo end"));
+    }
+// ---------------------------------------------------------------------------
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysdef_1_5_1.dtd	Mon May 03 12:32:02 2010 +0300
@@ -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>